|
We have an application which is originally written in MFC. The entire business logic is in C++. Couple of years back we had a requirement of moving of the module to web, so we used Silverlight for that. We have added an interop over the existing MFC and then a wrote a WCF Web Service above the interop. Now we are planning to have the same module on mobile platforms as well. For this, instead of writing everything from scratch, I was thinking of utilizing the existing web service. I tried to consume the existing web service in a Windows Phone application but since the existing projects referred in the web service are regular DLLs it is not allowing me to use them. What is the best approach to tackle this? I also read about REST/ASP.NET Web Api, but I am guessing that this requires rewriting a new set of web services just for mobile platforms. I can do that if its the only option, but before going ahead I want to see if there is any solution to utilize the existing WCF Web Service. Any ideas on how to proceed.
|
|
|
|
|
Does this have something to do with C#? There are forums for WCF, Web development and Design, which are better suited to your question.
|
|
|
|
|
The web services have nothing to do with the phone side of the application. Ultimately, with a well written web service, the consumer should not care what it was written in or what runs at the back end. Think about it, you wouldn't worry about rewriting because Windows Phone didn't support Java would you?; What your phone application will need to do is import the service reference for the web service - you will code against this part and your phone application will run happily without caring one bit about what technology is running at the server side.
|
|
|
|
|
Thank you. Even I thought the same, but I was facing errors while importing the service. I'll try again and see if I can make it work. Thanks again!
|
|
|
|
|
Quote: How should i encrypt the data by using SHA1 Algorithm? Please elaborate it?
|
|
|
|
|
You don't.
SHA-1 is not an encryption algorithm. It is a hashing algorithm and the two are very, very different: encrypted data can be decrypted to get the original input back, hashed data cannot.
If you use SHA-1 to "encrypt" for files, you will not be able to get the original files back. Ever.
If you are trying to use SHA-1 to secure passwords, then that's fine: hashing is perfect for that. But do not describe it as "encrypting".
See here: Password Storage: How to do it.[^]
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 – ∞)
|
|
|
|
|
Hypothetically, how do you complete the code for a static method FileToArray, which reads text files of a special form, where the first line contains the digits of a positive number that we will call n, and there are at least n more lines in the file.
Assume that the string parameter filename refers to an existing text file. FileToArray 1) opens the file, 2) reads n as a string, 3) converts it to an int, and 4) creates a new array of length n. The method then 5) fills the array with n further lines from the file (using a loop, probably a for loop). Finally, the method must 6) close the file and 7) return the array.
For example, if the text file named "fruits.txt" contains these lines:
3
kiwi
mango
pineapple
ignore this
then FileToArray("fruits.txt") returns a new array containing elements {"kiwi", "mango", "pineapple"}, and the file ends up closed. Assume that the file passed to the function has at least one line in it, the number of remaining lines (if the file only has one line in it, that line must contain the number 0).
public static Main()
{
}
public static string[] FileToArray(string filename)
{
}
|
|
|
|
|
Oops you seem to have posted your homework into a forum question.
Try doing the work and when you have a specific coding problem wewould like to help, writing your entire homework for you is not going to happen.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Not my place to tell people how to answer questions, but why make any effort with stuff like this? The poster hasn't.
Regards,
Rob Philpott.
|
|
|
|
|
Well done. You've made so much effort there, you'll go far.
Regards,
Rob Philpott.
|
|
|
|
|
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
Try it yourself, you may find it is not as difficult as you think!
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 – ∞)
|
|
|
|
|
hi all,
i'm trying to retrieve some values in an outlook mail (.msg file extension).
i already get some fields using outlook object model, then writte result in csv file. (outputfile)
MailItem items = (MailItem)outlook.CreateItemFromTemplate(inputfile, Type.Missing);
...
Console.WriteLine(string.Format("Subject:{0}", items.Subject));
Console.WriteLine(string.Format("Sender Email Address:{0}", items.SenderEmailAddress));
...
Console.WriteLine(string.Format("Text Body:{0}", items.Body));
...
Now i'd like to get some fields values in the content of the body
items.Body . these values are splited with ":" .
My question: Can i use
MyString=Value.Split(:)[indexofvalue]; to retrieve custom values?
is it the right manner to do? some suggestions?
Thank you a lot for the answers.
Thim
|
|
|
|
|
Depends on the body. It might be HTML, or it might be plain text. It would be an odd email if it were just a set of fields separated by colons.
If that were the case, then yes, you're close.
string[] fields = value.Split(':');
string s1 = field[0];
string s2 = field[1];
etc. etc.
Regards,
Rob Philpott.
|
|
|
|
|
Hey Rob thanks for your answer.
ok so i'm using the right methode.
with :
System.Console.WriteLine(string.Format("Html Body:{0}", items.HTMLBody));
System.Console.WriteLine(string.Format("Text Body:{0}", items.Body));
i can even get .txt or html body, i chose txt body to avoid using Regular-Expressions !
my body look like:
---------
txtetxtet xt etxte txte txtetx tetxte txte txt etxtetx tetxtetxte
txtetxtetxtet xtetxtetxtetx tetxtetxtetxt etxtetx tetxtetxte
txtetxte : ............
txtetx tetxtetx tetxtet xtetxt etxtetxtet xtetxtet xtet xtetxte
txtetxte:....................
txtet xtetxtetx tetxtetxtet xtetxtetx tetxtetx tetxtet xtetxte
txtetxtetxtetxtetxtetxtetxtetxtetxtetxtetxtetxtetxtetxte
txte txtetxt etxtetxtetxtetx tetxte txtetxtet tetxt etxtetxte
txtetxtextetxte:....................
---------
i can use ?
....
string[] fields = value.Split(':');
...
thanks,
Thim
|
|
|
|
|
Need to explain the content a bit more. What are the field delimiters?
A colon appears to be one, is a new line (CRLF) another?
Regards,
Rob Philpott.
|
|
|
|
|
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.
|
|
|
|