ok got it ronen
Ronenb
Posts
-
Linq - Conditions for two categories in parallel -
Linq - Conditions for two categories in parallelhi I’ve implement your idea and it work great, thank u! I have another question and hope you can assist The use will choose from UI several filter criteria, so the running filter should be dynamic and not hard coded Such as sometimes it could be collection.Filter(name1, value1) Or collection.Filter(name1, value1).Filter(name2, value2) collection.Filter(name1, value1).Filter(name2, value2). Filter(name3, value3) and so on how can I define by code the dynamic filter? Should I use recursive ? int interaction = #UserFilter.count; DoFilter(string name, string value) { While (interaction--) { collection.Filter(UserFilter[interaction].name, UserFilter[interaction].value) DoFilter(UserFilter[interaction].name, UserFilter[interaction].value); } } thanks ronen
-
Linq - Conditions for two categories in parallelthank u all, it is a good start to begin with
-
Linq - Conditions for two categories in parallelHi
I’ve a question regarding linq,
I’ve a DB contains main items (Product) and internal item(properties)Class Product
{
String name
List<properties> propList { get; set; }
}Class properties
{
String name
String value
}I would like to know if it possible to create a query that apply on two or more categories on the same internal item at one time
Such as, if the product is “car” and if the car year is 2012 and color is “Red” I would like to get this recordList< Product > DB;
I know the syntax below is wrong, but this is the idea I wish to do
Enumerable< Product > itemQuery = from item in DB where item.name=="car"
where
(
from prop in item.propList
where (prop.name.Equals("Color") && prop.value == "Red") && (prop.name.Equals("Year") && prop.value == "2012")
select field
).Any()
select item; -
how to clear memoryGot it :) thanks all Ronen
-
how to clear memoryok that this is Basically what i did srLog is type of StreamReader so my problem was that i didint need to read all file content to memory and then process it :)
I was thinking it is more efficient to read all file content (with one stroke) and work on it then to access file system for each line(ReadLine) and process it
Isn’t more expensive?while (!srLog.EndOfStream) { line = srLog.ReadLine(); fileLines.Add(line); } fileLinesContent = fileLines.ToArray();
-
how to clear memorythanks
-
how to clear memoryThank u all for the replay i think it is better to use the stream option as you suggested can you send me example how to stream a file for each line? should i use StreamFile, StreamRead or MemoryStream service? thanks ronen
-
how to clear memoryhi the array (string []fileLinesContent) is a member of the class, not local member in func, so my question is how to clean it in order free memory and read next lines in files i'm reading the lines because i need to know when the line end and parse the element in each line ronen
-
how to clear memoryHi I’ve extremely log file that I need to parse, 700M I need to read the file content and parse each line, The problem is that I get exception System.outofmemory In order to solved the memory issue, I think of reading the file in pages I think of defile pageSize to be 100,000 lines In order clean memory of array such as fileLinesContent, I think of defining it as null or to call Array.Clean(fileLinesContent) Is it correct approach to clean memory of array? string []fileLinesContent; internal void ReadFile(int pageSize) { //To clean memory for garbage collector fileLinesContent=null; List fileLines = new List(); int linesNumRead=0; string line; while (linesNumRead < pageSize && !srLog.EndOfStream ) { line = srLog.ReadLine(); linesNumRead ++; } fileLinesContent = fileLines.ToArray(); } }
-
close winforms childs and maini'm trying to closing the app by the mainform X :), not the child form X the status is when i press the mainform X, a child win is closed, each click close child form till all childs are closed, last click on X close the app once no child exist any advice?
-
close winforms childs and mainin case i will remove closing the child manully, once i click close "X", each time child window will be closed i need to press X button accurding the number of child windows that are opend what am i'm missing? what is the correct process to close MDI application? thanks ronen
-
close winforms childs and mainHi I have application that is define as MDI, there are several form child once the user press X button, i wish the application to be close and all other windows. at the FromClosing event i add the following code //handle and close the logic layer... foreach (Form frm in this.MdiChildren) { frm.Close(); frm.Dispose(); } Application.Exit(); All childs are closed but the the event FromClosing happen agian, why? i would expect the event of the main form FromClosing will happen only one time. this cause my problems at the logic layer ronen
-
handle data in GUI (datagridview) and databasethank you very much for your input
-
handle data in GUI (datagridview) and databasethanks for the tips the apps should be run localy, can i stll run web service, the service should collect the data and insert to db? i'm think of using several threads in te App (one handling the data recieving, one for processing and store in DB, and one for displaying thanks ronen
-
handle data in GUI (datagridview) and databaseI'm develop a online logger monitor, i know the user could be able to read the db in the grid The grid will be update each second with amount of data that I will define (such as 200 events) i'm asking about the Implementation ronen
-
handle data in GUI (datagridview) and databaseHi All I need your advice what is the best solution to handle data I’m developing online logger application at windows that will be connected to hardware. The application should handle heavy traffic data( could be up to hundreds of events per second) The datagridview is active as viewer only (readonly). I need to develop mechanism of insert the events to DB and display them in the datagridview. I need your advice if this is correct approach? I’m thinking of using the flow below Init() { SqlConnection connection = new SqlConnection(connectionstring); connection.open() SqlDataAdapter adapter = new SqlDataAdapter("select * from TableName", connection); DataSet ds = new DataSet(); dataGridView1.DataSource = ds; ); } AddRow(data) { //Add to database string insertString = "insert into TableName (Field1, Field2) values (‘Value1’,’Value2’)"; // 1. Instantiate a new command with a query and connection SqlCommand cmd = new SqlCommand(insertString, connection); // 2. Call ExecuteNonQuery to send command cmd.ExecuteNonQuery(); } //each second the timer event occurs Timer () { adapter.Fill(ds,idxLastUpdatedRow,100/* update 100 records each time*/ ,tableName); dataGridView1.refresh() } Thanks Ronen
-
how to waiti for specific events that occursI’ve using a Queue to store data and I do polling in order to know if the Queue contain data ( that I understand is not the correct approach) For Example private void PopDataFromQueue() { bool isRspOK; byte [] data; while (true) { //If so then stop the thread if (m_isStopReadingQueueThread == true) break; if (m_queue.Count > 0) { lock (m_queue) { if (m_queue.Count > 0) { data = (byte [])m_queue.Dequeue(); isRspOK = m_scenario.Parse(sockBuf.SocketData); if (isRspOK == true) { ; } } } } } I need to implement approach that wait for event occur and not always check the Queue status The function PopDataFromQueue is define as a thread Something like this private void PopDataFromQueue() { //create timer event that indicate in case the event that I waiting for not reach after some time , need to handle it Timer timer = new timer(1000); while (true) { //If so then stop the thread if (m_isStopReadingQueueThread == true) break; Event = WaitForEvent(Queue.Add,Timer. expire); // need to wait for two type of events Switch(Event) { case Queue.Dataexist: data = (byte [])m_queue.Dequeue(); isRspOK = m_scenario.Parse(sockBuf.SocketData); if (isRspOK == true) { ; } Break; Case timer.expire: isStopReadingQueueThread =true; break; } } } I try to look in the net and I didn’t
-
sizeof struct with arrayI see OK Thanks Ronen
-
sizeof struct with arrayHi But I define the size of the array size in the constructor Should the size of the member of the struct include array definitions? Ronen