|
Don't be so ridiculous.
This is NOT what the LiquidNitrogen class was designed for.
|
|
|
|
|
Well, I was originally going to recommend The InternallyAdjustableThrowoutPiston object, but it's not as widely used, not to mention that LiquidNitrogen object has the same properties because they share the same base class (SpanishInquisition , which nobody expected), and it consumes a lot less memory.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: LiquidNitrogen object has the same properties because they share the same base class (SpanishInquisition, which nobody expected), and it consumes a lot less memory.
I would never have expected that. I was going to recommend using the ILeftHandThread Interface with the StarboardMufflerBearing object, but your solution is clearly better.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Hi All,
I want to retrieve SSL Certification status in my C# application.
Can anybody help me?
Thanking You,
Sunil G.
|
|
|
|
|
|
|
Hello anyone..,
How we can differentiate between an encrypted and none encrypted txt???
i need a method for that, to using in my project...,
Please help me.........,,,
An encryption methode is below:
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.Configuration;
namespace SharpPcap.EnCryptDecrypt
{
public class CryptorEngine
{
public static string Encrypt(string toEncrypt, bool useHashing)
{
byte[] keyArray;
byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);
System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
if (useHashing)
{
MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
hashmd5.Clear();
}
else
keyArray = UTF8Encoding.UTF8.GetBytes(key);
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Key = keyArray;
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = tdes.CreateEncryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
tdes.Clear();
return Convert.ToBase64String(resultArray, 0, resultArray.Length);
}
}
}
Regards...
modified on Wednesday, January 27, 2010 6:56 AM
|
|
|
|
|
3bood.ghzawi wrote: How we can differentiate between an encrypted and none encrypted txt???
You can't, not without decrypting. It is possible to perform a preliminary check to see whether the decryption "string" is HEX (which encrypted strings are), but not all HEX strings are encrypted information. The only reliable way is to attempt to decrypt, even then it only checks for the decryption key.
Also this is worrying:
3bood.ghzawi wrote:
string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
The app config is by-and-large publicly available, and the key *MUST*
be kept secret for the cryptography to be worth anything.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Hi,
I've a service that push data from MSSQL db based on time frequency. Everything is fine, except while starting the system. At this time alone an error is coming "Operation not allowed when the object is closed."
I traced this error, this is because my service is start the prcoess before the SQL server is stared. I can handle this either delaying my service process to 2 or 5 mins or I can handle this exception in my catch block.
But I want to know any other way to handle this, like can I force my service once the SQL server is started or Is it possible to check a windows service (SQL Server) was started or not.
If any idea pls share with us.
Thanks & Regards,
Rishi
WinCrs
|
|
|
|
|
Hi,
there is a possibility to set on which services your service depends. Only if these services are running your service will start too. Since you are using C# guess you wrote an installer for your service, did you? During the install you can set the ServiceDependsOn-property.
Have a look here:
http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.servicesdependedon.aspx[^]
All you have to do is to set this propery during installation to the name of the sql server service name (check by open the properties of the service).
Regards
Sebastian
|
|
|
|
|
You should change the service config/start state by setting the "SeviceDependedOn" value with an array of services that needs to be started before your service can start.
ServiceInstaller example:
[RunInstallerAttribute(true)]
public class ControllerInstaller : Installer
{
public ControllerInstaller()
{
processInstaller=new ServiceProcessInstaller();
serviceInstaller=new ServiceInstaller();
processInstaller.Account=ServiceAccount.LocalSystem;
serviceInstaller.StartType=ServiceStartMode.Automatic;
serviceInstaller.DisplayName = "ServiceDisplyName";
serviceInstaller.ServiceName = "ServiceName";
serviceInstaller.ServicesDependedOn = new string[] { "MSSQL$SQLEXPRESS" };
Installers.Add(serviceInstaller);
Installers.Add(processInstaller);
}
private ServiceInstaller serviceInstaller;
private ServiceProcessInstaller processInstaller;
}
Now your service depends on a service called MSSQL$SQLEXPRESS (service name not display name) and
the system tries to start this service before yours. If it can't start this service your service can't start too.
Here some code to do this execution time:
(You need the permissions to access these registry keys!)
string[] szArrayDependsOn = (string[])Registry.GetValue("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\[YourServiceName]", "DependOnService", null);
if ((szArrayDependsOn == null) || (szArrayDependsOn.Length != 1) ||
(szArrayDependsOn[0] == null) || (szArrayDependsOn[0].ToUpper() != "MSSQL$SQLEXPRESS")
{
Registry.SetValue("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\[YourServiceName]", "DependOnService", new string[] { "MSSQL$SQLEXPRESS" }, RegistryValueKind.MultiString);
}
Greetings
Covean
|
|
|
|
|
And also handle it in a catch.
|
|
|
|
|
|
Dear folks,
I have many folders to compare but I don't know how I can make a comparison between them without lacking for memory usage.
I explain :
I have two servers with around 10TB of data each. I use "xcopy" command (on Windows-DOS) for making the copy incrementaly.
The first server have datas changing everytime but the other is just for mirroring. Sometimes I need to check if every folders between the two servers are the same (just the folder). I used IEnumerable/List<>... to do the work but consume CPU usage or memory usage.
The structure of the folders are the same so what I need is to compare each structure only.
If anybody have an idea (with a sample code or just the algorithm or pseudo-code) I should appreciate it.
Many thanks to you all.
|
|
|
|
|
Hi,
so could you post what you have already? First thought of me was to use threads, this will speed up the execution (maybe).
Regards
Sebastian
|
|
|
|
|
Thanks for your prompt reply but i think i found another idea. That's getting the list of the first server and try to find it into the second server. If the folder exist, do not care, otherwise log the foldername.fullpath.
for example, suppose i have this :
S1 : c:\rootfolder_S1\folder1\folder2\folder3
S2 : c:\rootfolder_S2\folder1\folder2\folder3
beginning from c:\rootfolder
- get list of folders for one level i got : folder1
- used Path.GetFileNameWithoutExtension(dir) and got : folder1
- use the Path.Combine(S2, foldername) and got : c:\rootfolder_S2\folder1
It's ok and very nice algorithm. But my problem, now, is how can i use this if recursing folders in S1. Using Path.GetFileNameWithoutExtension(dir) will get only the last name of the folder and if combining with S2, will got error or something else.
What i'm going to try is check the size of S1 (rootfolder only), and then use the substring(index) before combining with S2, but how can i get the size or lenght of S1. S1 : c:\rootfolder -> should have 13 characters.
This is my sample code :
static void Main(string[] args)
{
CombinePaths(args[0], args[1]);
}
private static void CombinePaths(string p1, string p2)
{
string[] dirs = Directory.GetDirectories(p1);
foreach (string dir in dirs)
{
try
{
int index = dir.LastIndexOf("\\") + 1;
string foldername = dir.Substring(index);
string combination = Path.Combine(p2, foldername);
if (!Directory.Exists(combination))
{
Console.WriteLine(dir);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine(Path.GetFileNameWithoutExtension(dir));
}
}
this is what i have for now. I'll reply back if found how to have the number of the character of the source string.
Maybe not yet very clear my code but think it is still a draft code.
See you later.
|
|
|
|
|
So finally here is my final code which is what i expect to have (no lack of memory usage nor cpu usage) :
static void Main(string[] args) {
CombinePaths(args[0], args[1]);
}
private static void CombinePaths(string S, string D) {
int indexRoot = S.Length + 1;
var stack = new Stack<string>();
stack.Push(S);
while (stack.Count > 0) {
string dir = stack.Pop();
try {
foreach (string sd in Directory.GetDirectories(dir)) {
stack.Push(sd);
string foldername = sd.Substring(indexRoot);
string combination = Path.Combine(D, foldername);
if (!Directory.Exists(combination))
{
Console.WriteLine(sd);
}
}
}
catch (UnauthorizedAccessException e)
{
Log.Add(e.Message);
}
}
}
The principle is this : the program iterate all directories inside the root folder, then parse the length to the subdirectories that it combine with the destination server, to finally check if the folder just listed from the source server exist in the destination server. (I think it some kind of "dir /s" in DOS Command). It is what i expect to have during 9 days but i still need help to optimize my apps.
As I've just count now, some of my root folder contains 2,000,000 - 3,000,000 folders inside. So I do not want to iterate all of this but i need to stop at level ten (10) or twenty (20), means i need to specify a deep level of iteration but i don't know how to make it by using this stack<> techniques.
Any suggestions are welcome. Thanks for all!
|
|
|
|
|
I am drawing a custom graph in c# openGL.
When I load the program the the Y axis lables draws (it is draw as txt) but everything else, the box representing the bars on the graph and the axis dont draw until you resize the window normally going from full screen down to a smaller window then the graph draws properly.
Does anyone have any ideas why this might be or have had a similar problem.
thanks.
|
|
|
|
|
I'm not an expert on OpenGL, but usually when something dosn't work untill the form/window is resized it might be a problem with initializing all the variables.
For starters you can try calling the OnSize event hendler manually when the window is first shown. If this makes things better you can have a look at what's happening inside the method and find the missing initialization.
|
|
|
|
|
Is it possible to make a explicit casting using a variable?
I'm passig a boxed object, and it's Type, as arguments. Inside the method I would like to unbox and use the content
private void myMethod ( Object boxedObject, Type dataType)
{
....
... = (dataType)boxedObject;
....
}
I know it doesn't compile this way. By the moment i'm using this kind of code:
switch (dataType.ToString())
{
case "int":
... = (int)boxedObject;
case "string"
... = (string)boxedObject;
...
}
But... is there a way to make something similar to "(dataType)boxedObjec)" that doesn't need using 'if' or 'case' for every dataType?
Thanks!
|
|
|
|
|
You can probably do it via reflection, but what are you going to do with it then?
If (for example) "as" worked that way, so you could do " = boxedObject as dataType;" what are you going to assign it to? Other than another object?
You can't pass it to another method, because any type you haven't covered will either no compile or will throw an exception.
You can't use it's properties, as you can't be sure it has those properties (other than ToString and the other really basic ones).
What are you trying to do, that you need this?
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
'as' works the same way than normal casting... Doesn't work...
What I want is compare the given value with data values from a dataset. So I first get the needed column DataType, and then I compare whith the properly unboxed value. The basic code would be:
public int SeekRow (string colName, object value)
{
Type dataType = myDataSet.MyTable.Columns[colName].DataType;
for (row=0; ...)
{
if (myDataSet.myTable[row][ColName]==(dataType)value)
{
return row;
}
}
return -1;
}
If I can't, I must use a lot of untidy 'if' ot 'case'...
|
|
|
|
|
I know "as" doesn't work - that's why I said 'If (for example) "as" worked that way' rather than 'Use "as" - it will do what you want'
I can't help thinking you are overdoing this a little, but...
Do you really need to know what the datatype is? Since your are returning only the row number rather than the value, either compare it directly
myDataSet.myTable[row][ColName] == value or use ToString and compare that way.
myDataSet.myTable[row][ColName].ToString() == value.ToString() Otherwise you have to be sure that all the objects you may pass the routine implement the == operator...
I would still think about why I was doing this in this (rather odd) way in the first place.
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
This is the temporal solution I have implemented, converting ToString. As you say, otherwise I should be sure to implement "==" operator for every object.
Thanks for your reply!
|
|
|
|
|
Assuming that you are not actually passing objects in, you might be able to use generics here:
public int SeekRow<T>(string colName, T value)
{
for (row = 0; ...)
{
if ((T)myDataSet.myTable[row][ColName] == value)
{
return row;
}
}
return -1;
}
int row1 = SeekRow("Age", 25);
int row2 = SeekRow("Name", "John Doe");
|
|
|
|