|
I need some help and I hope I have placed this is the correct forum.
I was asked by my employer to write an application to integrate a call recording system with a CSR issue tracking system. A customer calls in and the CSR handles the issue in the issue tracking software while at the same time a call recorder server is recording the call. My application tags the call database record with a unique id and passes it to the issue tracking software to allow administrators to later review the call recordings by clicking a link in the issue tracking software. When the link is clicked the unique call tag is passed back to my software by means of TCP sockets as in the code below to retrieve the call recording and play it to the user. I have wired an event in my code to the MessageRead event in this class. Everything works as planned EXCEPT: My problem is that when I include this class in my application I get random and frequent abends of the application with absolutely no indication of what the exception may be which caused it. I have turned on all exceptions in the debugger and tried to handle all exceptions outside of this class. This code was supplied to me by the company who wrote the issue tracking software so I have been reluctant to do anything inside their code, but at this point I am willing to try any suggestions. Their support has been to wait for us to resolve this (although I do hope and believe they are working on this on their side as well).
Any and all help is appreciated.
JLP
using System;
using System.ComponentModel;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Xml;
using System.Windows.Forms;
namespace CallRecordingServer
{
public class MessageReceiver
{
int tcpPort;
private BackgroundWorker tcpThread = new BackgroundWorker();
public delegate void ReadHandler(string MessageType, string MessageText);
public event ReadHandler MessageRead;
public MessageReceiver()
{
tcpPort = Convert.ToInt32(TaskTrayApplication.Properties.Settings.Default.tcpPort);
tcpThread.WorkerReportsProgress = true;
tcpThread.WorkerSupportsCancellation = true;
tcpThread.DoWork += Thread_DoWork;
tcpThread.ProgressChanged += tcpThread_ProgressChanged;
}
public void StartListening()
{
try
{
if (!tcpThread.IsBusy)
{
tcpThread.RunWorkerAsync();
}
}
catch (Exception ex)
{
MessageBox.Show("MessageReceiver", ex.Message);
}
}
public void StopListening()
{
tcpThread.CancelAsync();
Thread.Sleep(200);
}
void Thread_DoWork(Object sender, System.ComponentModel.DoWorkEventArgs e)
{
IPAddress ipLocalhost = IPAddress.Any;
TcpListener tcpListener = new TcpListener(ipLocalhost, tcpPort);
try
{
tcpListener.Start(100);
while (!tcpThread.CancellationPending)
{
while (!tcpListener.Pending() && !tcpThread.CancellationPending)
{
System.Windows.Forms.Application.DoEvents();
Thread.Sleep(10);
}
if (tcpThread.CancellationPending)
{
break;
}
TcpClient tcpClient = tcpListener.AcceptTcpClient();
NetworkStream netStream = tcpClient.GetStream();
StreamReader netStreamReader = new StreamReader(netStream);
StreamWriter netStreamWriter = new StreamWriter(netStream);
netStreamWriter.AutoFlush = true;
string stringData;
stringData = netStreamReader.ReadToEnd();
tcpThread.ReportProgress(0, stringData);
netStreamReader.Close();
netStream.Close();
tcpClient.Close();
}
}
catch (Exception ex)
{
MessageBox.Show("MessageReceiver",ex.Message);
tcpThread.ReportProgress(100, e);
}
finally
{
tcpListener.Stop();
}
}
void tcpThread_ProgressChanged(Object sender, System.ComponentModel.ProgressChangedEventArgs e)
{
if (e.ProgressPercentage == 0)
{
try
{
string xmlData = e.UserState.ToString();
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlData);
XmlNode root = doc.FirstChild;
string messageType = root.ChildNodes[0].InnerText;
string messageText = root.ChildNodes[1].InnerText;
MessageRead(messageType, messageText);
}
catch (Exception ex)
{
string er = ex.Message;
MessageBox.Show(ex.Message);
}
}
else
{
if (e.ProgressPercentage == 100)
{
tcpThread.CancelAsync();
Thread.Sleep(200);
}
}
}
}
}
|
|
|
|
|
I am sending mails using an SMTPClient object and later I recover the results of the delivery by the statusCode of the instance of the SmtpException using the values of the SmtpStatusCode enumeration, but needing to generate exceptions all the system go really slow, do anybody know other way of recover the results of the delivery faster.
Best Regards
|
|
|
|
|
Hi, I want to let the user to insert a string that will create a function.
I know how to create a class or method at runtime.
I have a delegate and I want the function that the user been created will be stored in the delegate event that i use.
How can I do it?
Specification
The user can select the sorted function that he want's(Sort of some system class).
He gets a list with this functions for example:
1. Area
2. Length
3. Custom
If the user choose Area/length then the list of item that I have (very complex system) will be sorted by Area/Length but if the user choose 'Custom' then I want to show him a new Textbox and then he can write 'Area*Length +COS(Length)'.
This is my delegate:
delegate double GetGrade(SystemD SD);
GetGrade MyGrade;
1. Area:
MyGrade = new GetGrade(AreaGrade);
public double AreaGrade(SystemD SD)
{
return SD.Area;
}
2. Length:
MyGrade = new GetGrade(LengthGrade);
public double LengthGrade(SystemD SD)
{
return SD.Length;
}
3. Custom:
MyGrade = new GetGrade(CustomGrade);
public double CustomGrade(SystemD SD)
{
string str= CustomTextBox.Text;
double Grade= CompileAndGetDoubleNumber(str,SD);
return Grade;
}
I want to get the string from the user and create at runtime a function that can be overload to this event but I need this function before to compilation because then I can not choose the function for the event because the function does not exists.
What can I do to resolve this problem?
|
|
|
|
|
Perhaps Action[^] or Func[^] is what you need
only two letters away from being an asset
|
|
|
|
|
Hi Experts,
I have developed a winApp in C# 2.0. I have created Setup of the application that creates required registry keys into the registry. I want these keys should not be deleted when application is uninstalled. I have set DeleteOnUninstall Property to false in the setup project. Still if application is uninstalled the keys are getting deleted.
I dont know how to overcome these problem
Please help me out!!!!!!!!!!111
Thanks And Regards,
Paramhans Dubey
|
|
|
|
|
Did you read this on MSDN [^]?
If a registry key has values, the key will be removed when all values are removed regardless of the DeleteAtUninstall property setting.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi Manas,
Thanks for your reply. I tried the link given by you but unable to connect to MSDN site. Anyways Can you guide me further? Can you please tell me how can I avoid these keys beeing deleted? Actually I want to keep track of the application installation on tha machine, like how many times this application has been installed to the machine, etc. Its part of licensing of the application.
Please help me
Thakns And Regards.
Paramhans Dubey.
|
|
|
|
|
Hi,
I am new to report control. i have just started to learn about it. i just started with a simple report. i just created a dataset and a table inside it containing few columns. i created a RDLC file and dragged and dropped the columns from the table onto the report.
I get textboxes and the value is automatically set to "Fields!<fieldname>.Value"..... when i preview i am getting only the last row in the data table. there are more than 50 rows in the table.
I am not able to find what is that i am missing.
can anyone pls help me.
|
|
|
|
|
Very basic question.
I think you are looking at the first record not the last one.
Place a List or Table element in the Report and place the database controls inside it.
List repeats as it finds more data elements. So you will see all the records.
In case of Table, Detail Section repeats.
|
|
|
|
|
ya thanks abishek it works
|
|
|
|
|
HI ALL
I create an appointment through c#.net,i save the entry id into my Database also.
Now i want to delete that appoinment.How can i delete?
Regards
Pradeep
|
|
|
|
|
I have a set of values based on which i have split the string
string[] seperator = new string[9];
seperator[0] = "*"; //is the client
seperator[1] = "/"; //is the name of company
seperator[2] = "("; //name of the market
seperator[5] = ":"; //ID
seperator[6] = "?"; //orderType
seperator[3] = "!@"; //realtive Time
seperator[4] = "!+"; //
seperator[7] = "+"; //quantity
seperator[8] = "@";//price
string[] result = values.Split(seperator, StringSplitOptions.None);
For example: The input string is
*A/AB(M!@12:6?SIMPLE!+5+2
OUTPUT
[0]: ""
[1]: "A"
[2]: "AB"
[3]: "M"
[4]: "12"
[5]: "6"
[6]: "SIMPLE"
[7]: "5"
[8]: "2"
For example: The input string is
*A(M!@12?SIMPLE!+5+2/AB:6
OUTPUT:
[0]: ""
[1]: "A"
[2]: "M"
[3]: "12"
[4]: "SIMPLE"
[5]: "5"
[6]: "2"
[7]: "AB"
[8]: "6"
The problem I am facing is : how can I relate that A is the client, AB is the company..etc etc
as the order in which the user can enter this information RANDOM...
If he doesnot enter any one of these values, it changes the result length ?
Thanks in advance
|
|
|
|
|
Not sure I completely understand your problem. If you have a string and know that the characters before the * is the client, why not just parse until you reach the *? Maybe the way with values.Split isn't the best approach here.
Edit: Just like OriginalGriff suggests (though in a more understandable way I guess..)
modified on Monday, September 21, 2009 8:57 AM
|
|
|
|
|
Is this data format somethng you have come up with, and thus can change? If so, then do. You are potentially giving yourself problems (Google "SQL Injection attack" to see what I mean).
If you can't change it, then I wouldn't bother with Split - iterate over each character in the string looking for your field prefixes in a switch block and handle them that way.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
|
His idea scared me so much that I dared not comment
So thanks
|
|
|
|
|
I don't see how that applies.
|
|
|
|
|
if you insist on having such a compact (and error-prone) representation, it would be easier to have the separator after the data instead of in front. That way, you can iterate the characters, and collect them until you hit an "separator" at which point you can handle the data you just collected.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
 Mightn't a Regular Expression help?
Edit:
As long as no delimiters are repeated, you can use a Regex to determine the order of the delimiters, then build another Regex to extract the data.
namespace Template
{
public static class Template
{
private static readonly System.Text.RegularExpressions.Regex reg ;
private static readonly System.Collections.Generic.Dictionary<string,string> dic ;
static Template
(
)
{
reg = new System.Text.RegularExpressions.Regex
(
"(\\*|/|\\(|:|\\?|!@|!\\+|\\+|@)"
) ;
dic = new System.Collections.Generic.Dictionary<string,string>() ;
dic [ "*" ] = "(?:\\*(?'Asterisk'.+?))" ;
dic [ "/" ] = "(?:/(?'Slash'.+?))" ;
dic [ "(" ] = "(?:\\((?'LeftParenthesis'.+?))" ;
dic [ ":" ] = "(?::(?'Colon'.+?))" ;
dic [ "?" ] = "(?:\\?(?'QuestionMark'.+?))" ;
dic [ "!@" ] = "(?:!@(?'ExclamationAt'.+?))" ;
dic [ "!+" ] = "(?:!\\+(?'ExclamationPlus'.+?))" ;
dic [ "+" ] = "(?:\\+(?'Plus'.+?))" ;
dic [ "@" ] = "(?:@(?'At'.+?))" ;
return ;
}
[System.STAThreadAttribute()]
public static int
Main
(
string[] args
)
{
int result = 0 ;
try
{
System.Text.StringBuilder sb =
new System.Text.StringBuilder ( "^" ) ;
foreach
(
System.Text.RegularExpressions.Match mat
in
reg.Matches ( args [ 0 ] )
)
{
sb.Append ( dic [ mat.Value ] ) ;
}
sb.Append ( "$" ) ;
System.Text.RegularExpressions.Regex temp =
new System.Text.RegularExpressions.Regex
(
sb.ToString()
) ;
foreach
(
System.Text.RegularExpressions.Match mat
in
temp.Matches ( args [ 0 ] )
)
{
foreach ( string gro in temp.GetGroupNames() )
{
System.Console.WriteLine ( "{0} = {1}" , gro , mat.Groups [ gro ].Value ) ;
}
}
}
catch ( System.Exception err )
{
while ( err != null )
{
System.Console.WriteLine ( err ) ;
err = err.InnerException ;
}
}
return ( result ) ;
}
}
}
|
|
|
|
|
if it works. Will you show one that isolates pieces of data in between two arbitrary delimiters?
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
modified on Monday, September 21, 2009 12:03 PM
|
|
|
|
|
If you insist: "(\*([\w\s]*)|\/([\w/s]*))" works with the first two of the OP prefixes, and even includes the prefix in the grouped item. Horrible isn't it? I will admit it could be used with named groups etc, etc, but it would still be hard to understand, maintain, etc. That's why I didn't suggest it! Yeuch. Regex has it's place: this is not it!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I said "help", not "do it all in one swell foop".
But I'll give it a shot; I have nothing else going on today. 
|
|
|
|
|
They're not exactly arbitrary. This one seems to work:
(?:(?'Delimiter'(\*|/|\(|:|\?|!@|!\+|\+|@))(?'Value'.+?))(?=(\*|/|\(|:|\?|!@|!\+|\+|@|))
(Whoops, no it doesn't... Working...)
Ah, here we go:
(?:(?'Delimiter'(\*|/|\(|:|\?|!@|!\+|\+|@))(?'Value'[^\*/\(\?!@\+:]*))
modified on Monday, September 21, 2009 1:33 PM
|
|
|
|
|
yep. it works:
public override void Test(int arg) {
Regex r=new Regex(@"(?:(?'Delimiter'(\*|/|\(|:|\?|!@|!\+|\+|@))(?'Value'[^\*/\(\?!@\+:]*))");
DoIt(r, @"*A(M!@12?SIMPLE!+5+2/AB:6");
DoIt(r, @"!+5+2/AB:6*A(M!@12?SIMPLE");
}
public void DoIt(Regex r, string s) {
log("");
log("input="+s);
foreach (Match m in r.Matches(s)) {
GroupCollection g=m.Groups;
log(" Delimiter=\""+g["Delimiter"]+"\" Value=\""+g["Value"]+"\"");
}
}
Looks terrible, works fine.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
I thought about recommending a regex, but decided that it would be more time and effort to create, test and debug the regex than the equivalant code! As a plus, the code is easier to understand, document and maintain.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|