|
Hi Rob ,
The field delimiters are ' : ' (colon)
so i'm working on
string mybody =item.body and use Methode
Split() To look over my custom Fiels(Text Qualifier), but unfortunately i have some issues.
my text body look like:
Titel : MYPROJECT
Subject: NEWPROJECT
---------------
---------------
Manager:MYMANGER1
-------------------
---------------
with :
string title=bodyContent.split(':')[1]
I can already read 'title'. but when looking at the content of 'string title', it contain the next texte value!.
I get : title=MYPROJECT Subject:
instead of just:
title=MYPROJECT
and the same for the others fields.
How can i stop reading when found and read the value of the first colon ':' , I thought about using Readline(), but i know, i'll miss some line to read.
an others suggestion ?!
thanks a lot.
thim
Thim.
modified 22-Jul-14 9:02am.
|
|
|
|
|
Hello I have a problem with update of binding of a label.
I have this simple class:
public partial class frTest : INotifyPropertyChanged
{
private string _message;
public string Message
{
private set
{
_message = value;
OnPropertyChanged("Message");
}
get
{
return _message;
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName = null)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
public frTest()
{
InitializeComponent();
DataContext = this;
}
private void WindowLoaded(object sender, RoutedEventArgs e)
{
Message = "test";
txtDevQty.Text = "1000";
txtDevQty.TextAlignment = TextAlignment.Center;
txtDevQty.IsEnabled = false;
}
private void BtnNextClick(object sender, RoutedEventArgs e)
{
for (int i = 0; i < 1000; i++)
{
Message = string.Format("Tested {0} of {1}", i, 1000);
Thread.Sleep(10);
}
}
}
I have in the xaml code a label with content binded to Message value
<Label Name="lblHint" Content="{Binding Message}" HorizontalAlignment="Center" FontFamily="verdana" FontSize="11" FontWeight="Bold" Foreground="Black" Grid.ColumnSpan="2"></Label>
The problem is that when i launch the BtnNextClick function,i see the label updated only at the end of procedure,and what i would like is to see updated in every cycle the content of the label....
How can I do?
I think it's a problem between my form and the ui thread?
Thanks in advance
Best regards
|
|
|
|
|
The reason you're not seeing anything is because your Thread.Sleeps are locking the UI thread. If you want to see the labels, simply wrap the loop up like this:
Task.Factory.StartNew(() =>
{
for (int i = 0; i < 1000; i++)
{
Message = string.Format("Tested {0} of {1}", i, 1000);
Thread.Sleep(10);
}
});
|
|
|
|
|
|
Only if you want to pause your thread long enough to actually see the update. If you remove it, you'll flood the UI with notifications.
|
|
|
|
|
I have tried but unfortunately using task don't solve my problem...
Because my code is a little bit different of what i wrote...
With this code the update of the label start only when all the iterations of the for (for (int j = 0; j < 10; j++)) are completed
public partial class frTest : INotifyPropertyChanged
{
private string _message;
public string Message
{
private set
{
_message = value;
OnPropertyChanged("Message");
}
get
{
return _message;
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName = null)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
public frTest()
{
InitializeComponent();
DataContext = this;
}
private void WindowLoaded(object sender, RoutedEventArgs e)
{
Message = "test";
txtDevQty.Text = "1000";
txtDevQty.TextAlignment = TextAlignment.Center;
txtDevQty.IsEnabled = false;
}
public void DoSomething()
{
var a = 0;
for (int i = 0; i < 2000000; i++)
{
a++;
}
}
private void BtnNextClick(object sender, RoutedEventArgs e)
{
for (int j = 0; j < 10; j++)
{
DoSomething();
Task.Factory.StartNew(() =>
{
try
{
for (int i = 0; i < 1000; i++)
{
Message = string.Format("Tested {0} of {1}", i, 1000);
Thread.Sleep(10);
}
}
catch (Exception ex)
{
}
});
}
}
}
|
|
|
|
|
And what else would you expect it to do? You aren't actually starting to update Message until you have completed the other loop. Just drop your outer loop into the task factory.
|
|
|
|
|
I cannot do it because in reality my DoSomething function do some work and start a thread that do some long operations.
For this reason i need to update the label for have a feedback of where is my routine arrived
|
|
|
|
|
Look, I cannot read your mind about what you are trying to do. You cannot keep drip feeding things through. It's simple enough, you need to update your label text from a none UI thread, so you can simply spawn that off in its own TaskFactory. In your example, you aren't starting off the update of the label until you have completed DoSomething. Step away from the keyboard right now, and actually design the interactions you need rather than throwing things on here that don't actually match what you're trying to do.
|
|
|
|
|
Hello there,
I have a C# application and with in a thread am popping open another form using the ShowDialog() function. For some reason the form is not displayed as MODAL. I tried passing "this" and obviously that causes a problem as it cannot be used within a thread.
The main C# application is a MDI and has multiple forms embedded in it.
How can i make this form MODAL?
Thanks!
|
|
|
|
|
Don Guy wrote: I tried passing "this" and obviously that causes a problem as it cannot be used within a thread. The dialog should be created (and would then be owned) by the main-thread. You could pass the entire mainform to the thread as an argument, and when the dialog needs be shown, use the mainform to invoke[^] the code on the mainthread.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi. I`m starting programmer in C #. I have a task to automate OpenOffice. I need to create reports OO Calc on fly. Anyone can help me?
Win 7 x32, VS2010 C#
|
|
|
|
|
You haven't given much to go on really. So I would suggest that you have a read of this TblProc: OpenOffice Calc and Excel[^]
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
You need to include some component (COM, LibOpeOffice).
From my expirience I can't advise you COM for OpenOpeffice automation. I'm using LibOpenOffice. Look here http://4k.com.ua/products/others/libopenoffice
|
|
|
|
|
Hi,
I would like to ask about the magnetic strips on the cards?
How can I read the data?
is it just a raw data just like the bard code and I have to split it? or it's encrypted and needs special way to read?
Technology News @ www.JassimRahma.com
|
|
|
|
|
Depends on the card, depends on the reader.
What are you trying to do?
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I am trying to do a loyalty card. I don't have anything yet
I will purchase zebra printer with its encoder but I want to develop the application which will read the magnetic stripe and do the required task accordingly.
Technology News @ www.JassimRahma.com
|
|
|
|
|
Then talk to the manufacturers and see what they can provide!
They may do several versions...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
you mean there is no standard way of storing the data on magnetic stripes?!
Technology News @ www.JassimRahma.com
|
|
|
|
|
It's not the data side you need to worry about, it's the API for the reader. You aren't actually be reading the card, the reader does - what you need to do is interpret the output from the reader.
|
|
|
|
|
One interfaces with the "card reader"; which could be a USB device; which is opened and read (when armed) as a file stream.
The card's strip would contain some fields and "tracks" of data at particular offsets in the card reader "file".
You need to extract the required fields (using offsets and lengths), wrap them as strings in a "transaction", and typically send them to a "payment processor" (or whatever) via a web service.
The data is encrypted; the client does not decrypt it; it is sent "as is" (with say a $ amount) to the credit card data processor who decrypts the credit data; verifies it; approves the transaction; or declines it; by sending a web service response back to the client.
|
|
|
|
|
HI,
I am facing an issue , from my client side (HTTPS browser) I am trying to connect a HttpTaskAsyncHandler in the project
Eg:
var webSockets = new WebSocket("wss://xxx.com//Racer.HTML5/WSHandlerCall));
if (webSockets != null) {
webSockets.onopen = function () {
alert('Connection open');
}
webconfig:
<system.webServer>
<handlers>
<add name="WebSocketHandler" verb="*" path="WSHandlerCall" type="Racer.HTML5.WebSocketHandler,Racer.HTML5" resourceType="Unspecified" />
</handlers>
</system.webServer>
<appSettings>
<add key ="wsURL" value="/Racer.HTML5/WSHandlerCall"/>
1.The sockets send a request.
2. OnOpen Listener is triggered but not called the handler.
Plz Help !!
modified 15-Jul-14 14:42pm.
|
|
|
|
|
That looks amazingly like JavaScript to me.
|
|
|
|
|
It does seem to be like a JS issue , since the Wireshark did not respond with RESPONSE: 101 switching protocol
Also added the webconfig in the above thread...
Plz help..
modified 15-Jul-14 14:43pm.
|
|
|
|
|
I am working on a project where I have to integrate with an intelligent network using MML commands in C#. I have managed to connect to the target server using sockets. Now I want to transmit the appropriately formatted data to the server. That is to Encode the message then decode the response. I have code examples in C++ which I am finding quite cryptic.
Can anyone show me how I can implement this in C#
#define MAX_LEN_VERSION 4
#define MAX_LEN_TERMINAL 8
#define MAX_LEN_SERVNAME 8
#define MAX_LEN_DLGCTRL 6
#define MAX_LEN_TXID 8
#define MAX_LEN_TXCTRL 6
#define MAX_LEN_TXRSVD 4
#define MAX_MSG_LEN 65536
#define MAX_HEAD_LEN 56
#define MSG_STARTTAG_LEN 4
#define MSG_INFOLEN_LEN 4
#define MSG_CHKSUM_LEN 4
#define MSG_COMM_LEN 12
#define MAX_HB_MSG_LEN 4
#define MAX_HB_CONTENT_LEN 4
#define MAX_HB_CHCKSUM 4
#define HB_MSG_LEN 16
#define MAX_LEN_DLGID 8
#define MAX_LEN_DLGRSVD 4
#define MSG_STARTTAG "\x1C\x1D\x1E\x1F"
#define MSG_VERSION "1.00"
#define MSG_TERMINAL "internal"
#define MSG_TXRSVD " "
#define MSG_DLGRSVD " "
#define HB_CONTENT "HBHB"
EnRet Encode(MsgInfo & sendMsg, char * sendBuff, int & sendLen, int send_type)
{
if (TYPE_OF_HB_MSG == send_type)
{
int temp_len;
char * p_num, hb_checksum[MAX_HB_CHCKSUM];
temp_len = 0;
strncpy(sendBuff + temp_len, MSG_STARTTAG, MSG_STARTTAG_LEN);
temp_len += MSG_STARTTAG_LEN;
p_num = Int2ToHex(HB_MSG_LEN);
strncpy(sendBuff + temp_len, p_num, MAX_HB_MSG_LEN);
temp_len += MAX_HB_MSG_LEN;
strncpy(sendBuff + temp_len, HB_CONTENT, MAX_HB_CONTENT_LEN);
temp_len = MSG_STARTTAG_LEN + MAX_HB_MSG_LEN;
GetChkSum(MAX_HB_MSG_LEN, sendBuff + temp_len, hb_checksum);
temp_len = HB_MSG_LEN - MAX_HB_CHCKSUM;
strncpy(sendBuff + temp_len, hb_checksum, MAX_HB_CHCKSUM);
printf("\ncode HB secceed!\n%s", sendBuff);
return Success;
}
Int msglen, cmdlen, len;
char *p, chksum[MSG_CHKSUM_LEN];
char *pTx[] = { "TXBEG", "TXCON", "TXCAN", "TXEND" };
char *pDlg[] = { "DLGLGN", "DLGBEG", "DLGCON", "DLGEND" };
PrintMsg(sendMsg);
cmdlen = strlen(sendMsg.cmd);
msglen = MAX_HEAD_LEN + cmdlen;
len = (4 - msglen % 4);
msglen += len;
sendLen = msglen + MSG_COMM_LEN;
memset(sendBuff, ' ', MAX_MSG_LEN);
len = 0;
strncpy(sendBuff + len, MSG_STARTTAG, MSG_STARTTAG_LEN);
len += MSG_STARTTAG_LEN;
p = Int2ToHex(msglen);
strncpy(sendBuff + len, p, MSG_INFOLEN_LEN);
len += MSG_INFOLEN_LEN;
strncpy(sendBuff + len, MSG_VERSION, MAX_LEN_VERSION);
len += MAX_LEN_VERSION;
strncpy(sendBuff + len, MSG_TERMINAL, MAX_LEN_TERMINAL);
len += MAX_LEN_TERMINAL;
strncpy(sendBuff + len, sendMsg.service, strlen(sendMsg.service));
len += MAX_LEN_SERVNAME;
p = Int4ToHex(sendMsg.snLogin);
strncpy(sendBuff + len, p, MAX_LEN_DLGID);
len += MAX_LEN_DLGID;
strncpy(sendBuff + len, pDlg[sendMsg.dlgCtrl], strlen(pDlg[sendMsg.dlgCtrl]));
len += MAX_LEN_DLGCTRL;
strncpy(sendBuff + len, MSG_DLGRSVD, MAX_LEN_DLGRSVD);
len += MAX_LEN_DLGRSVD;
p = Int4ToHex(sendMsg.sequence);
strncpy(sendBuff + len, p, MAX_LEN_TXID);
len += MAX_LEN_TXID;
strncpy(sendBuff + len, pTx[sendMsg.txCtrl], strlen(pTx[sendMsg
.txCtrl]));
len += MAX_LEN_TXCTRL;
strncpy(sendBuff + len, MSG_TXRSVD, MAX_LEN_TXRSVD);
len += MAX_LEN_TXRSVD;
strncpy(sendBuff + len, sendMsg.cmd, cmdlen);
len = MSG_STARTTAG_LEN + MSG_INFOLEN_LEN;
GetChkSum(msglen, sendBuff + len, chksum);
len = sendLen - MSG_CHKSUM_LEN;
strncpy(sendBuff + len, chksum, MSG_CHKSUM_LEN);
return Success;
}
|
|
|
|
|