|
The TextWriter don't care. The state of the underlying Stream is what matters -- it can be opened to append or overwrite.
|
|
|
|
|
Thanks all of you.
I used StreamWriter for this.
Kind regards,
|
|
|
|
|
Hi All,
I have created an asp.net c# website that is being used like a helpdesk, tickets are being logged and resolved etc.
I now want to add a pop up that should appear on the user that logged the tickets' pc when the IT personnel updates the ticket.
I am not sure how or if you can use notifyicon to do this?
|
|
|
|
|
You would need to install an application on their machine which talked to the ticket server. There's no way to do that simply through a web interface.
|
|
|
|
|
Thank you for the response!
How would the application know which tickets belong to which user? - I have a username linked to the ticket and a ticket number.
Sorry if I sound stupid!
I don't know much about c# applications, I have only worked with websites.
|
|
|
|
|
If the user name was linked to their Windows Identity, then you can use that. If, however, your site uses a custom login mechanism or something like OAuth, then the user is going to have to associate their identity with the notification application - this would typically require you to provide a settings page where they entered their user name and password details so that you could verify that they were a valid user.
To be honest, this opens a whole can of worms, including things such as verifying that web service requests haven't been intercepted and so on. A simpler method would just be to email them.
|
|
|
|
|
Thank you so much!
I would just use email, but my company wants the pop up. They want to move away from emails.
I think I found my solution!
|
|
|
|
|
NickyRamshaw wrote: I think I found my solution!
Only if the user has a Windows machine. What do you do if they only ever use an iPad? Or how about those few people using WinRT? Perhaps they only use Linux boxes.
|
|
|
|
|
how i can convert this code from java to c#
public static String Dcipher(String encryptedText1) {
try {
byte[] desKeyData = {(byte) 0x01, (byte) 0x02, (byte) 0x03,
(byte) 0x04, (byte) 0x05, (byte) 0x06,
(byte) 0x07, (byte) 0x08};
DESKeySpec desKeySpec = new DESKeySpec(desKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = null;
try {
key = keyFactory.generateSecret(desKeySpec);
} catch (InvalidKeySpecException ex1) {
}
byte[] initVector = new byte[] {0x10, 0x10, 0x01, 0x04, 0x01, 0x01,
0x01,
0x02};
AlgorithmParameterSpec algParamSpec = new IvParameterSpec(
initVector);
Cipher m_decrypter = Cipher.getInstance("DES/OFB32/NoPadding");
m_decrypter.init(Cipher.DECRYPT_MODE, key, algParamSpec);
byte[] encryptedText = encryptedText1.getBytes();
byte[] decryptedText = m_decrypter.doFinal(encryptedText);
return (new String(decryptedText));
} catch (BadPaddingException ex) {
ex.printStackTrace();
} catch (IllegalBlockSizeException ex) {
ex.printStackTrace();
} catch (InvalidAlgorithmParameterException ex) {
ex.printStackTrace();
} catch (InvalidKeyException ex) {
ex.printStackTrace();
} catch (NoSuchPaddingException ex) {
ex.printStackTrace();
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
return "";
}
|
|
|
|
|
|
I don't have a conversion for some of the Java types you're using, but the following syntax should be correct:
public static string Dcipher(string encryptedText1)
{
try
{
sbyte[] desKeyData = {(sbyte) 0x01, (sbyte) 0x02, (sbyte) 0x03, (sbyte) 0x04, (sbyte) 0x05, (sbyte) 0x06, (sbyte) 0x07, (sbyte) 0x08};
DESKeySpec desKeySpec = new DESKeySpec(desKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = null;
try
{
key = keyFactory.generateSecret(desKeySpec);
}
catch (InvalidKeySpecException ex1)
{
}
sbyte[] initVector = new sbyte[] {0x10, 0x10, 0x01, 0x04, 0x01, 0x01, 0x01, 0x02};
AlgorithmParameterSpec algParamSpec = new IvParameterSpec(initVector);
Cipher m_decrypter = Cipher.getInstance("DES/OFB32/NoPadding");
m_decrypter.init(Cipher.DECRYPT_MODE, key, algParamSpec);
sbyte[] encryptedText = encryptedText1.Bytes;
sbyte[] decryptedText = m_decrypter.doFinal(encryptedText);
return (new string(decryptedText));
}
catch (BadPaddingException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (IllegalBlockSizeException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (InvalidAlgorithmParameterException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (InvalidKeyException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (NoSuchPaddingException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (NoSuchAlgorithmException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
return "";
}
Dave Doknjas
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
Instant C# - VB to C# Converter
Instant VB - C# to VB Converter
|
|
|
|
|
I am getting a timeout message when accessing a linq to sql object in a C# 2010 application. This error message is occuring when I am doing a select in the linq to sql object. thus can you tell me how I can increase the timeout on the linq to sql data set object? The following os the error message I am getting:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
2013-01-24 16:40:03.3082|ERROR|Sample|************* Stack Trace *******************
2013-01-24 16:40:03.3238|ERROR|Sample| at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
|
|
|
|
|
You may be causing the exception yourself, if it happens after a period of time or after a number of connection attempts. Try reading this[^] for a brief discussion on the topic.
If it's the first connection attempt your code makes to the database, you've got a problem with your connection string or the database engine isn't responding for some reason or ...
|
|
|
|
|
How is this question different than the one that you posted 3 days ago?
|
|
|
|
|
1. You already posted a similar question a while back. I suggested logging. Did you implement that? Logging a stack trace is not enough.
2. Try setting a break point in the catch that generates this message and check your variables. In LINQ you should be able to retreive the SQL that is sent to the database, find it and try to execute in SQL Server directly. If necessary, type it over in the SQL manager by hand.
3. A timeout is there for a reason, you should only increase the timeout if you're absolutely certain that procedure is lengthy. Honestly, based on your questions I don't think that is the case here. increasing the timeout could at best, be a workaround, not a solution.
|
|
|
|
|
hi dears...
i want the activity-selection algorithm in c#.
thanks for u...
|
|
|
|
|
There are many ways to select an activity. If you have a problem with some code you have written, feel free to post a question on it. Good luck.
|
|
|
|
|
sorry, my meaning was activity-selection algorithm that is greedy algorithm in C#. i have a project for university, i thanks so much if u help me.
best regards...
|
|
|
|
|
So you're trying to get me to pass your course. If you can't solve this, how do you expect to do this as a career?
|
|
|
|
|
I'm assuming you're talking about this[^]. Start there and write your own code. It's what you're going to school for or getting paid to write isn't it?? Either way, we're not writing your code for you.
|
|
|
|
|
sorry, my meaning was activity-selection algorithm that is greedy algorithm in C#. i have a project for university, i thanks so much if u help me.
best regards...
|
|
|
|
|
The whole point behind you getting these assignments is for YOU to demonstrate that you can applied what you've learned. It's NOT for us to do the work for you.
|
|
|
|
|
Here's an activity selection algorithmm coded in C# - probably not what you want.
But you have not explained what you want.
static void Main(string[] args)
{
Random rndGen = new Random();
var activities = new List<string>() { "bake bread", "mow lawn", "read book", "sleep", "don batman costume", "sneeze",
"have a beer", "code furiously", "make excuse for late assignment", "plead for help"};
for (int i = 0; i < 3; i++)
{
int act = rndGen.Next(activities.Count);
Console.WriteLine((i+1).ToString() + ". " + activities[act]);
}
Console.ReadLine();
}
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
I think maybe a command line parser is in order.
|
|
|
|
|
mazizi0 wrote: hi dears... Hello luvver
mazizi0 wrote: i want the activity-selection algorithm in c#. Oooh, ooh I know this game. I want a Porsche.
mazizi0 wrote: thanks for u... No no. Thanks for YOU!
|
|
|
|
|