|
miss YY wrote: where can i download the crystal report?
http://www.crystalreports.com/[^]
and this is the c# forum - thats a bit different to 'Crystal Reports' .. I suggest if you license the product you go back to the support service if you have other issues with the product itself - of course if you get the software from a dubious source, dont license it etc etc, you deserve everything you get IMNSHO ...
'g'
|
|
|
|
|
Hey,
I am running into a weird problem. I am using below method to extract country location based on IP address.
if (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
{
m_IPAddress = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else if (HttpContext.Current.Request.UserHostAddress.Length != 0)
{
m_IPAddress = HttpContext.Current.Request.UserHostAddress;
}
DataTable dt = GetLocation(m_IPAddress);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
m_IPCountry = dt.Rows[0]["City"].ToString() + "," + dt.Rows[0]["RegionName"].ToString() + "," + dt.Rows[0]["CountryName"].ToString() + "," + dt.Rows[0]["CountryCode"].ToString();
}
else
{
}
}
private DataTable GetLocation(string ipaddress)
{
WebRequest rssReq = WebRequest.Create("http://freegeoip.appspot.com/xml/" + ipaddress);
WebProxy px = new WebProxy("http://freegeoip.appspot.com/xml/" + ipaddress, true);
rssReq.Proxy = px;
rssReq.Timeout = 2000;
try
{
WebResponse rep = rssReq.GetResponse();
XmlTextReader xtr = new XmlTextReader(rep.GetResponseStream());
DataSet ds = new DataSet();
ds.ReadXml(xtr);
return ds.Tables[0];
}
catch
{
return null;
}
}
when i try to catch the exception i get error msg "The remote server returned an error: (503) Server Unavailable."
the website is hosted in australia. I am logging all the details in database. IP address is correct at all time just after midnight in australia i am able to get country information while during the day it becomes null. any idea what am i doing wrong. probably need to add something in web.config?
modified on Tuesday, January 5, 2010 8:47 PM
|
|
|
|
|
I cut and pasted your url [http://freegeoip.appspot.com] into a browser and received :-
"App Engine Error
Over Quota
This Google App Engine application is temporarily over its serving quota. Please try again later. "
so is there a possibility its being hammered at some stage of the day and when you want to access it its already 'over quota' ?
'g'
|
|
|
|
|
is there a work around to get a country details based on IP without using this service?
|
|
|
|
|
undoubtedly there are other services 'out there' or other databases - wether they are free or not, remains to be seen
'g'
|
|
|
|
|
|
I tried to implement this solution http://dotnetguts.blogspot.com/2008/06/finding-country-from-visitors-ip-in.html[^]
i didnt use the last step to import database as I only need a country code not flag but its not working. since in the example its using a aspx page to display but in my case I have a all the page which is derived from basepage.cs
in basepage.cs I am trying to get a countrycode and store in a database as a pageview record.
could you please help as to why its null. I am not missed any of the steps mentioned in the article.
Thank you
|
|
|
|
|
|
actually, all the free web services seems to reject request after it reaches certain daily hits. which in my case is true. if google crawls my site i am using the service to get the country code so i gave up on using free webservice to get a country code based on IP. I used this one http://dotnetguts.blogspot.com/2008/06/finding-country-from-visitors-ip-in.html[^]
but its getting a wrong country codes for example in below. I am using my iphone which is in sydney, australia, its logging country code as FR. could someone please help?
58.104.249.183 FR Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16
|
|
|
|
|
good question. 5!
some one has a solution here.
Another solution here.
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|
|
Hi everyone,
My name is Susan and I work for an outside vendor who was hired by SAP BusinessObjects to learn more about what people are saying about CrystalReports in the social media space. I was hoping you could give me some feedback on what your initial thoughts are about CrystalReports. Do you like the product? Do you have any issues with the product? What are your reasons for coming to this message board?
Any feedback would be much appreciated. Thank you!
- Susan
|
|
|
|
|
This would be better asked in The Lounge[^] IMO as it's not really a programming question directly related to C#
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks Dave, I'll post there!
- Susan
|
|
|
|
|
I am wondering how to create a key container on a machine that only my application can access. I have successfully created and used the container, but I think that other users and applications on the machine have access to the private key. Is there any way to protect this information? The code used to generate and utilize the CspParameters object is below:
CspParameters csp = new CspParameters();
csp.Flags = CspProviderFlags.UseMachineKeyStore |
CspProviderFlags.UseNonExportableKey;
csp.KeyContainerName = "Example Container Name";
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024, csp); Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Guys,
I`m working on a Windows application and running into a problem, can`t seem to figure it out. Let me first explain the app. Its a windows forms application with a Tab Controls. Each Tab Control is a single file and has other controls within it [tabcontrols, buttons, etc etc]. Based on the file extension only the First tab within the Tab Control changes everything else remains the same. Lets say like a Web browser with Tabs.
The problem I`m running into is - How do I stop duplicate tabcontrols [each tab control is a file] from opening. Lets say I load a file ABC.opt how do make sure ABC.opt is not loaded again..i.e, open by the software. I can load files now, but can`t seem to control the duplicates.
Also, when i Save a file..I want only the contents of the Tab Control open to be saved. Is there a Tab Control active property? What is the best way to do it. Something like a Web Browser..Lets say you open a website in a tab and click on Save on the Menu Strip, only the active Tab is saved.
Here is the code I`m working on.
//File Item Clicked from the MainMenuItem - This has File New, File Open, Save, Save As, etc
private void FileToolStripMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
FileToolStripMenuClicked(e.ClickedItem);
}
//FTSI - File Tool Strip Item Clicked
private void FileToolStripMenuClicked(ToolStripItem FTSI)
{
switch (FTSI.Name)
{
case "FileOpenTSMI":
// FileOpen.cs
FileOpen FO = new FileOpen();
FO.OpenFile();
break;
case "FileSave"
//See comments in ABCOpen
//Code here
break;
default:
break;
}
}
//Based on the Extention of the file the ABCOpen() or XYZOpen() functions are called
internal void OpenFile()
{
OpenFileDialog OFD = new OpenFileDialog();
OFD.InitialDirectory = @"C:\Cust";
OFD.Filter = "ABC Files|*.abc|XYZ Files|*.xyz";
OFD.CheckFileExists = true;
OFD.CheckPathExists = true;
OFD.RestoreDirectory = true;
if (OFD.ShowDialog() == DialogResult.OK)
{
switch (Path.GetExtension(OFD.FileName).Substring(1))
{
case "abc":
ABCOpen(OFD.FileName);
break;
case "xyz":
XYZOpen("OFD.FileName");
break;
default:
break;
}
}
}
private void ABCOpen(string FileName)
{
// Code here loads some User Controls
// Code here reads a File and then loads the data into Windows forms
// How do I save it in such a way that only the active tab control data is saved
// Lets say I loaded Sample.abc and Test.xyz. I edit Sample.abc and it is the active Tab, and when I hit save how can I make sure only Sample.abc data is written into the file?
}
Any ideas, help are greatly appreciated.
Thanks!
|
|
|
|
|
sharat567 wrote: how do make sure ABC.opt is not loaded again.
Maintain a collection that contains the opened files and check it before loading a file. It's not that difficult.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Determine which tab is active:
See TabControl.SelectedIndex[^] and TabControl.SelectedTab[^]
Determine if a file is already open:
Set the TabPage.Tag property on each TabPage that you open to the full path of the file, then iterate through each tab and compare the full path of the file attempting to be opened. This also gives an easy way to remember the path when you go to save the active tab.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I have a cryptography question that is puzzling me. Basically, I am attempting to create an encrypted file that includes a signed hashcode to ensure that it is not tampered with. The procedure to perform this is as follows:
1) Load an asymmetric algorithm (RSACryptoServiceProvider) stored using a CspParameters object
2) Create a symmetric algorithm object (AesCryptoServiceProvider)
3) Encrypt the concatenated key and initialization vector using the RSA encryptor
4) Create a new MemoryStream object (with associated BinaryWriter)
5) Write the following data to the output stream:
*The size of the encrypted key/IV vector
*The encrypted key/IV vector
6) Create new CryptoStream and BinaryWriter objects and write my data to the MemoryStream
7) Hash the MemoryStream, and sign the hash
8) Open a file for writing (FileStream)
9) Write the following data
*Length of the signed hash
*The signed hash
*COPY THE CONTENTS OF THE MEMORY STREAM TO THE OUTPUT
I put the last portion of step 9 in bold because this is where something is going terribly wrong. My entire encryption/decryption process works when I copy/paste the code that writes to the MemoryStream object. However, if I simply attempt to copy the contents of the MemoryStream to the FileStream, the decryption process begins, but I get to a point reading the data where I get the error, "Padding is invalid and cannot be removed". Everything up to this point is decrypted correctly, and my file is validated against the signed hash (in both cases... ie, when I rewrite the data to the FileStream, my file has the same signed hash as when I copy the contents of the MemoryStream to the FileStream). What am I missing here? Why is the file validated against the hash in both cases, but is only able to be decrypted when I rewrite the data? I have copied what I think is relevant below:
class ExampleForm : Form {
private readonly int m_SymmetricKeySize = s_KeySizeSym >> 3;
private readonly int m_SymmetricBlockSize;
private readonly RSACryptoServiceProvider m_AsymmetricAlg;
private readonly SymmetricAlgorithm m_SymmetricAlg = new AesCryptoServiceProvider();
private readonly HashAlgorithm m_HashAlg = new MD5CryptoServiceProvider();
private readonly string m_OutFile =
Path.Combine(Application.CommonAppDataPath, "Example.dat");
private static void CopyStream(Stream src, Stream dst) {
const int bufferSize = 256;
byte[] buffer = new byte[bufferSize];
int count;
do {
count = src.Read(buffer, 0, bufferSize);
dst.Write(buffer, 0, count);
} while (count == bufferSize);
}
public ExampleForm() {
m_SymmetricBlockSize = m_SymmetricAlg.BlockSize >> 3;
CspParameters csp = new CspParameters();
csp.KeyContainerName = "Example Container";
m_AsymmetricAlg = new RSACryptoServiceProvider(2048, csp);
bool isFileValid = File.Exists(m_OutFile);
if (isFileValid) {
Stream dataStream = new MemoryStream();
Stream fileStream = File.OpenRead(m_OutFile);
BinaryReader binaryReader = new BinaryReader(fileStream);
byte[] sign = new byte[binaryReader.ReadInt32()];
fileStream.Read(sign, 0, sign.Length);
ExampleForm.CopyStream(fileStream, dataStream);
binaryReader.Close();
fileStream .Close();
byte[] hash = m_HashAlg.ComputeHash(dataStream);
isFileValid = m_AsymmetricAlg.VerifyHash(hash,
CryptoConfig.MapNameToOID("MD5"), sign);
if (isFileValid) {
dataStream.Seek(0, SeekOrigin.Begin);
binaryReader = new BinaryReader(dataStream);
byte[] encKeyIV = new byte[binaryReader.ReadInt32()];
dataStream.Read(encKeyIV, 0, encKeyIV.Length);
byte[] keyAndIV = new byte[m_SymmetricBlockSize + m_SymmetricKeySize];
keyAndIV = m_AsymmetricAlg.Decrypt(encKeyIV, true);
byte[] key = new byte[m_SymmetricKeySize ];
byte[] iv = new byte[m_SymmetricBlockSize];
for (int idx = 0; idx < m_SymmetricKeySize; ++idx)
key[idx] = keyAndIV[idx];
for (int idx = 0; idx < m_SymmetricBlockSize; ++idx)
iv [idx] = keyAndIV[idx + m_SymmetricKeySize];
CryptoStream cryptoStream = new CryptoStream(dataStream,
m_SymmetricAlg.CreateDecryptor(key, iv), CryptoStreamMode.Read);
BinaryReader cryptoReader = new BinaryReader(cryptoStream);
binaryReader.Close();
cryptoReader.Close();
cryptoStream.Close();
} else {
}
dataStream.Close();
}
}
private void ExampleForm_FormClosing(object sender, FormClosingEventArgs e) {
byte[] keyAndIV = new byte[m_SymmetricBlockSize + m_SymmetricKeySize];
m_SymmetricAlg.Key.CopyTo(keyAndIV, 0);
m_SymmetricAlg.IV .CopyTo(keyAndIV, m_SymmetricKeySize);
Stream dataStream = new MemoryStream();
BinaryWriter binaryWriter = new BinaryWriter(dataStream);
BinaryWriter cryptoWriter = new BinaryWriter(new CryptoStream(
dataStream, m_SymmetricAlg.CreateEncryptor(), CryptoStreamMode.Write));
byte[] encKeyIV = m_AsymmetricAlg.Encrypt(keyAndIV, true);
binaryWriter.Write(encKeyIV.Length);
binaryWriter.Flush();
dataStream.Write(encKeyIV, 0, encKeyIV.Length);
cryptoWriter.Flush();
byte[] hash = m_HashAlg.ComputeHash(dataStream);
byte[] sign = m_AsymmetricAlg.SignHash(hash, CryptoConfig.MapNameToOID(s_HashName));
#region Option 1 (What I would like to do)
Stream fileStream = File.OpenWrite(m_OutFile);
binaryWriter = new BinaryWriter(fileStream);
binaryWriter.Write(sign.Length);
binaryWriter.Flush();
fileStream.Write(sign, 0, sign.Length);
dataStream.Seek(0, SeekOrigin.Begin);
ExampleForm.CopyStream(dataStream, fileStream);
cryptoWriter.Close();
binaryWriter.Close();
fileStream.Close();
dataStream.Close();
#endregion
#region Option 2 (The option that currently works)
cryptoWriter.Close();
binaryWriter.Close();
dataStream .Close();
Stream fileStream = File.OpenWrite(m_OutFile);
binaryWriter = new BinaryWriter(fileStream);
cryptoWriter = new BinaryWriter(new CryptoStream(
fileStream, m_SymmetricAlg.CreateEncryptor(), CryptoStreamMode.Write));
binaryWriter.Write(sign.Length);
binaryWriter.Flush();
fileStream.Write(sign, 0, sign.Length);
binaryWriter.Write(encKeyIV.Length);
binaryWriter.Flush();
fileStream.Write(encKeyIV, 0, encKeyIV.Length);
cryptoWriter.Close();
binaryWriter.Close();
fileStream .Close();
#endregion
}
} Again, I am wondering why "Option 1" from above doesn't work. I noticed that the last character written when copying the stream was an "11". Any ideas? Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I noticed that the size of the two files is different... The one created using "Option 1" is 1144 bytes and the one created using "Option 2" is 1160 bytes. Perhaps this will help someone explain to me what is happening? Thanks again,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I don't use the CryptoStream (I have an article about a SecureStream, but I think it will not work for you) but as I remember there is a FlushFinalBlock in the CryptoStream. I think you should use it because I think the "FinalBlock" will include additional information that is needed during decryption.
|
|
|
|
|
Thanks... the FlushFinalBlock() operation you suggested worked! Thank you very much!
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I use Microsoft.DirectX.AudioVideoPlayback for video player, and I don't know how to get frequencies and amplitude of the sound (when playing video) to draw a waveform. I can't find any-code about it. Somebode help me please!!
Thank you for your help.
|
|
|
|
|
This article[^] demonstrates how to resolve the frequencies and amplitudes of audio waveforms using a FFT algorithm, and even provides code for displaying it. As to accessing the actual audio sample stream, you'll have to look into the DirectX API yourself; I have no idea how it works. I'm sure it's encoded in some way to include synchronized audio and video packet streams for your multimedia hardware to display it correctly, and that will have to be converted to a stream of instantaneous audio samples at a uniform sample rate to make the FFT algorithm work. If the audio is time-compressed it will have to be expanded, and if amplitude compressed an inverse transform will have to be applied to restore the original dynamic range.
By the way, Google led me straight back here. There is an extensive collection of member articles about audio and video manipulation available at CodeProject, and if you haven't already done so, it would be very helpful to you to spend some time reading them. Some contain far more information than their titles would imply.
Good luck, and I look forward to your article appearing once you solve this one.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Hi All,
how find all used / connected COM PORT on the system??
Thanks.
|
|
|
|
|
First, include System.IO.Ports this snippet shout help you:
foreach (string portName in SerialPort.GetPortNames())
{
SerialPort port = new SerialPort(portName);
Console.WriteLine("{0} is open = {1}", port.PortName, port.IsOpen);
}
The important thing is the SerialPort object, it allows communication with the port and has plenty of useful properties and methods see http://msdn.microsoft.com/en-us/library/system.io.ports.serialport(VS.80).aspx[^] for more details.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|