Ok quite simply I have a selenium script in C# and you choose a name from the dropdown box, choose the dates and counts the number of results page by page. Now can someone help me speed this process because it almost takes 5 seconds for the next button to be clicked to go on the next page.
Here is my code:
int entityCount = 0;
int totalCount = 0;
try
{
System.Threading.Thread.Sleep(5000);
while (_AuditRep.nextButton.Enabled && _AuditRep.nextButton.Displayed)
{
System.Threading.Thread.Sleep(5000);
_AuditRep.nextButton.Click();
entityCount += _AuditRep.AuditResultsByEntity("Users").Count;
totalCount += _AuditRep.AuditTotalResults.Count;
}
if (entityCount != totalCount)
{
Assert.Fail("The count of Drivers is " + entityCount + " whereas "
+ "the total count is " + totalCount);
}
else
{
Console.WriteLine("The count of entity Drivers is " + entityCount + " and "
+ "the total count is " + totalCount);
}
}
catch
{
if (_AuditRep.AuditResultsByEntity("Users").Count != _AuditRep.AuditTotalResults.Count)
{
Assert.Fail("The count of Drivers is " + _AuditRep.AuditResultsByEntity("Users").Count + " whereas "
+ "the total count is " + _AuditRep.AuditTotalResults.Count);
}
else
{
Console.WriteLine("The count of entity Drivers is " + _AuditRep.AuditResultsByEntity("Users").Count + " and "
+ "the total count is " + _AuditRep.AuditTotalResults.Count);
}
}
Related
At the moment i can just get the SPOT balance with this lines:
var subAccountBalances = await binanceClient.SpotApi.Account.GetBalancesAsync();
decimal total = 0;
if(subAccountBalances.Success)
{
foreach (var item in subAccountBalances.Data)
{
Debug.WriteLine(item.Asset + " : " + item.Total + " BTC: " + item.BtcValuation);
total += item.BtcValuation;
}
}
else
{
Debug.WriteLine(subAccountBalances.Error);
}
Debug.WriteLine("Total in BTC: " + total);
And this gives me my SPOT balance.
Is there a way to get all the balances togeather (futures, margin, earn, etc...)
and get each item individualy?
Im using:
using Binance.Net;
using Binance.Net.Clients;
using Binance.Net.Objects;
Thanks for the help!
I have tried this functions, but non of them gives me the full global balance:
await binanceClient.SpotApi.Account.GetBalancesAsync();
await binanceClient.SpotApi.CommonSpotClient.GetBalancesAsync();
await binanceClient.SpotApi.Account.GetAccountInfoAsync();
I try to use jQuery slide for price, as in this picture
So the user can filter the result as he want,
the jQuery code that i used is as follows:
<script>
var min = parseInt($('#<%=lbmin.ClientID%>').html());
var max = parseInt($('#<%=lbMax.ClientID%>').html());
var Smin = parseInt($('#<%=lbrangeMin.ClientID%>').html());
var Smax = parseInt($('#<%=lbrangeMax.ClientID%>').html());
if (Smin = isNaN )
{
Smin = min;
}
if (Smax = isNaN) {
Smax = max;
}
$(function () {
$("#slider-range").slider({
range: true,
min: min,
max: max,
values: [Smin, Smax],
slide: function (event, ui) {
var start = parseInt(ui.values[0]);
var end = parseInt(ui.values[1]);
$("#amount").val($('#<%=hfCur.ClientID%>').val() + " " + ui.values[0] + " - " + $('#<%=hfCur.ClientID%>').val() + " " + ui.values[1]);
$('#<%=lbrange.ClientID%>').html(ui.values[0] + " - " + ui.values[1]);
$('#<%=lbrangeMin.ClientID%>').html(ui.values[0] );
$('#<%=lbrangeMax.ClientID%>').html(ui.values[1]);
$('#<%=hfrange.ClientID%>').val(ui.values[1]);
}
});
$("#amount").val($('#<%=hfCur.ClientID%>').val() + " " + $("#slider-range").slider("values", 0) +
" - " + $('#<%=hfCur.ClientID%>').val() + " " + $("#slider-range").slider("values", 1));
});
So when page loads the first time min and max value will set on the label lbmin and lbmax, and when the user pulls the tape the range will change as pulling. and the value will set in other label lbrangeMin and lbrangeMax.
and until now everything works fine,
my request is: I need to run C# method like
protected void ttt()
{ some code }
I found several solutions, but all of it using a static method with a return value, and another thing when page post-back the ring should not reset.
My code it quite long but this is the part that I am stuck on. I have my try statement at the beginning before my for loops. But now I want to take my information that is in the ListBox and send it to a text file which I already have in my debug folder. I would like to just take my outputs from the list box and write them to the population.txt file.
//variable user input, store in userInput
try
{
if (double.TryParse(startTextbox.Text, out start))
{
if (double.TryParse(averageTextbox.Text, out average))
{
if (double.TryParse(daysTextbox.Text, out days))
{
//process
int count = 1;
while (count <= days)
{
//calculation
double output;
output = start * Math.Pow((1 + average / 100), count - 1);
//display the results in the listbox
populationListBox.Items.Add("The approximate population for " +
count + " day(s) is " + output.ToString("n2"));
//count the days
count = count + 1;
}
//used to text statement
//populationListBox.Items.Add("End of while loop");
count = 1;
do
{
//calculation
double output;
output = start * Math.Pow((1 + average / 100), count - 1);
//display the results in the listbox
populationListBox.Items.Add("The approximate population for " +
count + " day(s) is " + output.ToString("n2"));
//count the days
count = count + 1;
} while (count <= days);
//used to text statement
//populationListBox.Items.Add("End of do-while loop");
//int count;
for (count = 1; count <= days; )
{
//calculation
double output;
output = start * Math.Pow((1 + average / 100), count - 1);
//display the results in the listbox
populationListBox.Items.Add("The approximate population for " +
count + " day(s) is " + output.ToString("n2"));
//count the days
count = count + 1;
}
//used to text statement
//populationListBox.Items.Add("End of for loop");
}
else
{
//error message for input
MessageBox.Show("Invalid input for number of days to multiply.");
}
}
else
{
//error message for input
MessageBox.Show("Invalid input for average daily increase.");
}
}
else
{
//error message for input
MessageBox.Show("Invalid input for starting days");
}
StreamWriter outputFile;
outputFile = File.CreateText("population.txt");
outputFile.WriteLine("Approximate population: ");
outputFile.WriteLine(populationListBox.Items);
outputFile.ToString();
outputFile.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
You can use library like FileHelper to perform your job. It is open source and free. If you want to use just FileIO from .NET framework you can do that also
using (StreamWriter sr = File.CreateText("population.txt"))
{
foreach (string s in listBox.Items)
{
sr.WriteLine(s);
}
}
I am making the game minesweeper and I am trying to implement a highScores feature. I am trying to load 3 different files (each one holds the high scores for each of the 3 difficulty settings) into 3 different richTextBox's. When I run the app and click the 'high scores' tab from the menu strip it works the first time. However if I play a game and then try to access the high scores form I get an Exception error -
An unhandled exception of type 'System.IO.IOException' occurred in
mscorlib.dll
Additional information: The process cannot access the file
'C:\Users\jzcon_000\Copy\Visual
Studio\Projects\Assignment1\Assignment1\bin\Debug\highScoresMed.txt'
because it is being used by another process
This is where the call is made
private void highScoresToolStripMenuItem_Click(object sender, EventArgs e)
{
Minesweeper.HighSc highScore = new Minesweeper.HighSc();
highScore.read();
highScore.Show();
}
This is the method in my HighSc class
public void read()
{
StreamReader readerE = File.OpenText("highScoresEasy.txt");
StreamReader readerM = File.OpenText("highScoresMed.txt");
StreamReader readerH = File.OpenText("highScoresHard.txt");
if (readerE != null)
{
string readEasy = File.ReadAllText("highScoresEasy.txt");
richTextBox1.Text = readEasy;
}
readerE.Close();
if (readerM != null)
{
string readMed = File.ReadAllText("highScoresMed.txt");
richTextBox2.Text = readMed;
}
readerM.Close();
if (readerH != null)
{
string readHard = File.ReadAllText("highScoresHard.txt");
richTextBox3.Text = readHard;
}
readerH.Close();
}
Heres the save high scores class
namespace Minesweeper
{
class Save
{
int diff, hr, min, sec;
string player;
public Save(int difficulty, int hour, int minute, int second, string playerN)
{
diff = difficulty;
hr = hour;
min = minute;
sec = second;
player = playerN;
}
public void save()
{
StreamWriter writerEasy = new StreamWriter("highScoresEasy.txt", true);
StreamWriter writerMed = new StreamWriter("highScoresMed.txt", true);
StreamWriter writerHard = new StreamWriter("highScoresHard.txt", true);
if (diff == 1)
{
writerEasy.WriteLine("Time: " + hr + ":" + min + ":" + sec + " " + "Name: " + player);
writerEasy.Close();
}
else if (diff == 2)
{
writerMed.WriteLine("Time: " + hr + ":" + min + ":" + sec + " " + "Name: " + player);
writerMed.Close();
}
else if (diff == 3)
{
writerHard.WriteLine("Time: " + hr + ":" + min + ":" + sec + " " + "Name: " + player);
writerHard.Close();
}
}
}
}
So when you have the difficulty level set to 1 and then save, you open the StreamWriters for both the level2 and level3 but never close them.
This could only mean that when you try to load the highscore for these two levels you will find your files locked by your previous save.
You should change your Save method to open only the required file
public void save()
{
if (diff == 1)
{
using(StreamWriter writerEasy = new StreamWriter("highScoresEasy.txt", true))
{
writerEasy.WriteLine("Time: " + hr + ":" + min + ":" + sec + " " + "Name: " + player);
}
}
else if (diff == 2)
....
else if (diff == 3)
....
I suggest also to use the using statement in your reading method to be sure that also in case of exceptions the stream are correctly disposed
This question already has answers here:
What is a NullReferenceException, and how do I fix it?
(27 answers)
Closed 8 years ago.
So I have my memory class which looks like this:
namespace GeminiCore
{
public class Memory
{
public static int[] memory = new int[256];
public string nextInstruction;
public static int cacheSize = 8;
public CPU myCPU;
public struct frame
{
public bool dirtyBit;
public int isEmpty;
public int value;
public int tag;
public frame(int cacheSize)
{
dirtyBit = false;
isEmpty = 1;
value = 0;
tag = 0;
}
}
public int solveMemory(int value, int instr, frame[] myCache)
{
Console.WriteLine("I reached the solveMemory!!!");
int block = value % cacheSize;
if(instr == 127 || instr == 125 || instr == 124 || instr == 123
|| instr == 122 || instr == 121|| instr == 120)
{
Console.WriteLine("I reached the read section!!!");
if(myCache[block].isEmpty == 0) //Read hit
if(myCache[block].tag == value)
return myCache[block].value;
else
{
myCache[block].value = memory[value]; //Read Miss
myCache[block].tag = value;
myCache[block].isEmpty = 0;
Console.WriteLine("Read Miss --- The Cache is as follows: block = " + block + " the value at this block is: " + myCache[block].value + " the tag at this block is: " + myCache[block].tag);
return myCache[block].value;
}
}
else
{
Console.WriteLine("I reached the write section!!!");
if (myCache[block].isEmpty == 1) //Write Miss
{
Console.WriteLine("Write Miss --- The Cache is as follows: block = " + block + " the value at this block is: " + myCache[block].value + " the tag at this block is: " + myCache[block].tag);
memory[value] = myCPU.ACC;
}
else
{
if (myCache[block].dirtyBit == false)
{
if (myCache[block].tag != value)
{
myCache[block].value = myCPU.ACC; //Write Hit
myCache[block].dirtyBit = true;
myCache[block].tag = value;
Console.WriteLine("Write Hit --- The Cache is as follows: block = " + block + " the value at this block is: " + myCache[block].value + " the tag at this block is: " + myCache[block].tag);
}
}
else
{
memory[myCache[block].tag] = myCache[block].value;
myCache[block].value = myCPU.ACC;
myCache[block].tag = value;
myCache[block].dirtyBit = false;
Console.WriteLine("Write Hit --- The Cache is as follows: block = " + block + " the value at this block is: " + myCache[block].value + " the tag at this block is: " + myCache[block].tag);
}
}
}
return value;
}
}
}
and then I have my CPU class, and I will just post a small snippet of where the error is occurring:
public Memory myMemory;
public static Memory.frame[] myCache = new Memory.frame[Memory.cacheSize];
public void doInstruction()
{
var instr = (finalCodes[i] >> 9) & 127; //Parses op code to find instruction
var immed = (finalCodes[i] >> 8) & 1; //Parses op code to find immediate value
var value = (finalCodes[i] & 255); //Parse op code to find value
foreach (Memory.frame x in myCache)
{
Console.WriteLine("Dirtybit: " + x.dirtyBit + " isEmpty: " + x.isEmpty + " tag: " + x.tag + " value: " + x.value);
}
switch (instr)
{
case (127): //LDA instruction
if (immed == 1)
ACC = value;
else if (immed == 0)
//ACC = Memory.memory[value];
ACC = myMemory.solveMemory(value, instr, myCache);
break;
case (126): //STA instruction
if (immed == 0)
{
Console.WriteLine("The value is: " + value + " The instruction is: " + instr);
foreach (Memory.frame x in myCache)
{
Console.WriteLine("Dirtybit: " + x.dirtyBit + " isEmpty: " + x.isEmpty + " tag: " + x.tag + " value: " + x.value);
}
//Memory.memory[value] = ACC;
myMemory.solveMemory(value, instr, myCache);
}
So here is my problem, when I run my test which takes in assembly code and translates it to binary then runs through the code, when I get to the second command "sta" it should go to the line:
myMemory.solveMemory(value, instr, myCache);
It then gives me a Null Reference Exception when it reaches that point. As you can see I have some command line output to try and see where it is going. It prints out the contents of myCache right before that line. It does not reach any of the debug statements in the solveMemory function however, not even the first one that says:
Console.WriteLine("I reached the solveMemory!!!");
I'm not really sure what is causing this error and I've been looking at it for quite some time. Hopefully one of you will be able to find where exactly I am messing up. Thanks for the time.
public Memory myMemory;
should be:
public Memory myMemory = new Memory();