|
I am using Crystal reports in my .NET project.
Do i need to buy any user/developer copy of
Crystal Reports when I am distributing the software?
(do I have to pay or not?)
I have legal copy of .NET, and I did not register with Crystal Reports (they let you use it when you are in development I guess)
PS.And their licensing aggreement is just so confusing.
Thanks
~Mithat
|
|
|
|
|
I have been trying to develop a connection gateway which opens a fixed number of connections to a database using OLEDB in c#. This gateway keeps those XX connections opens and the idea is to have a thread/Session request a connection, use it, then return back to the queue. The request and return operations utilize a unique string called a SessionID to determine which connection to put back on the queue. Since this object will be accessed from several threads I have been trying to make it thread safe, but I have not developed far enough in thread programming to utilize this successfully. I am going to paste the code here and see if any of you can determine what is wrong with the code. Any help would be greatly appreciated.
Thank you.
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Threading;
namespace FritoLay.Data.Gateway
{
///
/// Summary description for ConnectionGateway.
///
public class ConnectionGateway : System.ComponentModel.Component
{
// Maximum Number of Database Connections
const int MAX_CONNECTIONS = 50;
// Maximum Number of Iterations in Sleep thread.
const int MAX_LOOPS = 60;
// Database Connection String
protected string connectionString = "";
// List of assigned connections with unique SessionID as Key
private System.Collections.SortedList connections = new System.Collections.SortedList(50);
// Queue of ready to use connections
private System.Collections.Queue connectionQueue = new System.Collections.Queue(50);
// Thread safe version of the assigned connections
private System.Collections.SortedList synchConnections = null;
// Thread safe version of the ready to use connections
private System.Collections.Queue synchQueue = null;
// Mutex to control threaded access to the ready to use connection queue
private System.Threading.Mutex mutex;
System.TimeSpan tSpan = new System.TimeSpan(0, 0, 0, 0, 100);
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public ConnectionGateway(System.ComponentModel.IContainer container)
{
///
/// Required for Windows.Forms Class Composition Designer support
///
container.Add(this);
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
this.synchConnections = System.Collections.SortedList.Synchronized(this.connections);
this.synchQueue = System.Collections.Queue.Synchronized(this.connectionQueue);
this.mutex = new System.Threading.Mutex();
}
public ConnectionGateway()
{
///
/// Required for Windows.Forms Class Composition Designer support
///
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
this.synchConnections = System.Collections.SortedList.Synchronized(this.connections);
this.synchQueue = System.Collections.Queue.Synchronized(this.connectionQueue);
this.mutex = new System.Threading.Mutex();
}
#region Component Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
public string ConnectionString
{
get { return this.connectionString; }
set { this.connectionString = value; }
}
public void Initialize()
{
if(this.connectionString != "")
{
for(int i = 0; i < ConnectionGateway.MAX_CONNECTIONS; i++)
{
System.Data.OleDb.OleDbConnection cnn = new System.Data.OleDb.OleDbConnection(this.connectionString);
cnn.Open();
this.connectionQueue.Enqueue(cnn);
}
}
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.Synchronized)]
public System.Data.OleDb.OleDbConnection GetConnection(string SessionID)
{
lock(this.connections)
{
try
{
//if(this.connectionQueue.Count == 0)
//{
//System.Threading.ThreadStart ts = new System.Threading.ThreadStart(this.Sleep);
//System.Threading.Thread thread = new System.Threading.Thread(ts);
//thread.Name = "Sleeper";
//thread.Start();
//thread.Join();
//}
int counter = 0;
while(this.connections.Count == ConnectionGateway.MAX_CONNECTIONS)
{
Monitor.Wait(this.connections, tSpan);
Monitor.Pulse(this.connections);
if(counter > ConnectionGateway.MAX_LOOPS)
break;
counter++;
}
if(this.connectionQueue.Count == 0)
{
//this.mutex.ReleaseMutex();
throw new FritoLay.Data.Gateway.TimeOutException("No Available Connections");
}
System.Data.OleDb.OleDbConnection conn = (System.Data.OleDb.OleDbConnection)this.synchQueue.Dequeue();
this.synchConnections.Add(SessionID, conn);
return conn;
}
catch(System.Exception ex)
{
throw ex;
}
finally
{
}
}
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.Synchronized)]
public void ReturnConnection(string SessionID)
{
lock(this.connections)
{
try
{
System.Data.OleDb.OleDbConnection conn = (System.Data.OleDb.OleDbConnection)this.synchConnections.GetByIndex(this.connections.IndexOfKey(SessionID));
if(conn.State == System.Data.ConnectionState.Closed)
{
conn.ConnectionString = this.connectionString;
conn.Open();
}
if(conn.ConnectionString != this.connectionString)
{
conn.Close();
conn.ConnectionString = this.connectionString;
conn.Open();
}
this.synchQueue.Enqueue(conn);
this.synchConnections.Remove(SessionID);
}
catch(System.Exception ex)
{
throw ex;
}
finally
{
}
}
}
private void Sleep()
{
try
{
this.mutex.WaitOne();
int counter = 0;
while(counter <= ConnectionGateway.MAX_LOOPS)
{
Thread.Sleep(this.tSpan);
//Monitor.Wait(this.connectionQueue, tSpan);
if(this.connectionQueue.Count > 0)
{
Thread.CurrentThread.Abort();
break;
}
counter++;
}
}
catch(System.Exception ex)
{
}
finally
{
this.mutex.ReleaseMutex();
}
}
public void Terminate()
{
if(this.connectionQueue.Count > 0)
{
for(int i = 0; i < this.connectionQueue.Count; i++)
{
System.Data.OleDb.OleDbConnection conn = (System.Data.OleDb.OleDbConnection)this.connectionQueue.Dequeue();
conn.Close();
conn = null;
}
}
this.connectionQueue.Clear();
if(this.connections.Count > 0)
{
System.Collections.IEnumerator ie = this.connections.GetEnumerator();
while(ie.MoveNext())
{
System.Collections.DictionaryEntry de = (System.Collections.DictionaryEntry)ie.Current;
System.Data.OleDb.OleDbConnection conn = (System.Data.OleDb.OleDbConnection)de.Value;
conn.Close();
conn = null;
}
}
}
}
}
|
|
|
|
|
I have added a context menu to my TreeView, but when i use TreeView.SelectedNode it doesnt return the node that the user right clicked on only the node that was last left clicked.
Is there anyway to get a TreeView to select the node the mouse is over on right click?
Thanks
Tim
|
|
|
|
|
Use the "GetNodeAt" Function on the MouseDown event of the TreeView and then Set the SelectedNode to that one.
|
|
|
|
|
Use the MouseUp Event for the TreeView and get the current mouse position.
Then you can Use the TreeView.GetNodeAt(X,Y), here follows the code.
The TreeView was called FolderTreeView!
private void FolderTreeView_MouseUp
(object sender ,System.Windows.Forms.MouseEventArgs e)
{//MouseButton Released
try
{
//Select the Node Under the Mouse Cursor as Current Node
FolderTreeView.SelectedNode = FolderTreeView.GetNodeAt(e.X,e.Y);
}
}
Leon v Wyk
|
|
|
|
|
I want to prompt the user with a alert message before they continue to delete a record from the database. Can anyone point me in the right direction.
Thanks,
Steve Nelson
|
|
|
|
|
gekoscan wrote:
I want to prompt the user with a alert message before they continue to delete a record from the database. Can anyone point me in the right direction.
DialgogResult confirm = MessageBox.Show("You sure you wanna do that?);
if(confirm == DialogResult.Ok)//Do stuff here
[edit]Actually, what you want is to go to the ASP.NET forum. This only works for a Windows Forms application.[/edit]
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
Hi All,
1). I created a Crystal Report and made it as web service.
2). The client-end is a Windows application, and I added the web service of the Crystal report into the windows application.
The windows application can work and show the crystal report that from Web.
But I dont know how to program to operate the crystal report, because I added the crystal report as web service,
Code like following:
// 1). Create the web service of the crystal report.
localhost.CrystalReport1WebService cyws = new localhost.CrystalReport1WebService();
// 2). Add it to the CrystalReportView.
crystalReportView1.ReportSource = cyws;
But now, I want to access a TextObject that added in the crystal report, I can not find any way to do that.
Because, now I only can get the CrystalReport1WebService, I can not find any method to get CrystalReport1.
Anybody can help?
Thanks!
|
|
|
|
|
Hi all,
I am working on a project that requires to convert MS Office docs (.doc and .xls) to XML. I have to write a component to handle such functionality. The component has to be in C# but even VB or VB.net would do.
The problem!
Where can I learn about the .doc and .xls formats? I nead to somehow scan the docs and convert them in XML.
Is anyone aware of any components that do such thing?
Is anyone aware of any information that might help me?
NOTE: I don't want an application that converts .doc to XML.
I need a component to inegrate it with my ASP.NET application.
|---------------|
| theJazzyBrain |
|---------------|
|
|
|
|
|
From my known, the format of doc is not public, otherwise many other Office products would be compliant with MS Office documents well and then rob its market.
I'm amumu, and you?
|
|
|
|
|
Hi there,
I don't think that MS is making money from the file format. I have seen applications that convert .doc and .xls to XML. The problem is that I don't want an application, I need a component to integrate it with my ASP.NET application. I want to write the component myselfe but I have no idea where to start from...
I tried to read a .doc file with the StreamReader object but I get a lot of wierd stuf. I need some information on how to do this...
Thanx for your reply though!
|---------------|
| theJazzyBrain |
|---------------|
|
|
|
|
|
Hi,
I guess the application you mentioned is using MSOffice Automation Object, it means the doc format analysis is done by MS. That's just my personal point. On the other hand, maybe you could also use this way.
I'm amumu, and you?
|
|
|
|
|
In commenting on my C# Design By Contract article someone wrote:
Hi,<br />
<br />
Have you tried to implement this using attributes and MessageSinks? I think something like the following would be a lot easier. <br />
<br />
class Example<br />
{<br />
public Example(){}<br />
<br />
[Precondition(y != 0)]<br />
public int Divide(int x, int y)<br />
{<br />
return x / y;<br />
}<br />
}
Any idea how to implement this? can it be done? the idea is that Precondition(y != 0) should translate to Assert(y != 0).
All the custom attribute examples I ever see seem to be to do with annotating classes or methods in some way, e.g., [CodeReview("Eric", "01-12-2000", Comment="Bitchin' Code")]
Kevin
|
|
|
|
|
Like this[^]?
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
Interesting. Although I want to know how to write such attributes myself.
Kevin
|
|
|
|
|
The source is included with the XC# download. All you have to do is look in $InstallDir$\Source\XCSharp.Attributes\
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
Hello,
I have an XmlNodeList with attributes and and text values. I am looking for a way to create a function that can return a value from reading a nodelist by specifiying the attribute name. For example, string a = FieldByName("acct") would result in 12345 being returned.
<fields>
<field name="acct">12345
<field name="company">ACME Inc
<field name="city">Dallas
<field name="state">TX
Any help would be greatly appreciated.
Thank you.
|
|
|
|
|
<br />
private string GetAttributeByName( XmlNode node, string name )<br />
{<br />
if( node != null && node.Attributes != null )<br />
{<br />
XmlAttribute attr = ( XmlAttribute )node.Attributes.GetNamedItem( name );<br />
<br />
if( attr != null ) return attr.Value;<br />
}<br />
<br />
return string.Empty;<br />
}<br />
Solutions:
1. Create method which make cycle and check each item in XmlNodeList (value can be taken by method written upper)
2. use XPath, like: //*[@*[local-name()='select123']] - such xpath return to you node(s) with contains attribute select123. After that use method written upper to get atribute value
Good Luck
Alex Kucherenko
|
|
|
|
|
Alex,
I am new to XML and not that familiar with the nodes and attributes. I have started with this by using xmlDocument.
Would you have an example of loading an XML doc similar to below and cycling thru the nodes and using your function of GetAttributeByName to return the value of the company from the below nodelist? I am having difficulties in getting the nodes setup from the nodelist.
<fields>
<field name="acct">12345</field>
<field name="company">ACME Inc</field>
<field name="city">Dallas</field>
<field name="state">TX</field>
</fields>
|
|
|
|
|
First of all, I am new to C# and .NET programming, however initial impression is very favourable, despite my brain complaining that it is already full up.
Anyway, I am trying to get a client system running a web browser, to exchange text with an application, running on a remote server. I have looked at .NET Remoting and it looks like overkill for what I want to do
So does the panel think the following will work ?
Client
- Web browser running the DHTML Webservice Behaviour
Server
- C# WebService talking to
- C# Windows Forms Application
Seems a simple solution to me however I can't work out the best way to get a C# WebService to talk to a C# application.
Appreciation for any help given will be shown with virtual beers (I am sure someone around here uses a beer icon, but I can't see it in the list of smilies)
Cheers
Steve
|
|
|
|
|
For your WebService to talk to your C# application you would again need something like .NET remoting, which brings you back to the first scenario anyways. You are crossing app domains, so communication has to be dealt with anyways.
My suggestion would be use .NET remoting. It's really not an overkill at all. The server (which would be you C# application) simply needs add a couple of lines of code. And your client app can add a couple of lines of code and voila!!! You're done!!!
The good thing here is that with .NET remoting you have all the flexibilty you want and it's very extensible. You can communicate TCP/IP or Http (through IIS or not) etc...
If you need some samples respond back.
Steve
|
|
|
|
|
Many thanks for that, if remoting only needs a few lines of code, then as you say it is not overkill !
I guess the answer then is to connect from the Webservice to the App via TCP/IP. If you have any samples of 'simple' remoting on the same system then that would be great.
Cheers
Steve M
|
|
|
|
|
This example exists within the examples of on your computer.
<frameworksdk>\Samples\Technologies\Remoting\Basic\RemotingHello
Take 15-30 minutes to look at it. It's worth it.
|
|
|
|
|
Hmmm...
Took a little while to make the stuff work. My system has 2 network connections. One for the cable set top box for broadband and one for my local network. Add in ZoneAlarm as the firewall and mix until thoroughly confused.
IIS on this machine is bound to the local network, BUT it is not resolved to LOCALHOST (i may need to switch network connections over). So I had to edit the .config files to use the actual IP address. The web client implementation wants me to log in as I am not authorized to view the page even though IIS is configured for anonymous acess and so refuses my administrator password
However, running the service using DirectHost service works when using the consoleclient. I have loads of questions but I will carry on playing for while...
Cheers
Steve
|
|
|
|
|
hey guys and girls,
im trying to get the ability to embed a hastable value of the password im going to encrypt a file with, in the file its self (but not embedding the password its self though just the hastable it generates). After encrypting it like above, i want the decryptor to beable to compare the incoming password to the hashtable on the encrypted file, if the 2 match, then continue, my problem is i need the incoming stream, to seek passed the hashtable and start there (SeekOrigin.Begin), so the original data is intact,the problem is when i use the FileStream.Seek = Seek(hashtablelength,SeekOrigin.Begin) when it gets to the actualy decryption part, it freezes and doesnt do anything, Ill include the code below, Am i just not doing it right ? If i was unable to make my question clear enough please let me know,
Jesse M
(i clipped the code so it will not be 100% correct, but the bulk of it is there)
///
///Decryption Method
///
<br />
FileStream fin = new FileStream(inName, FileMode.Open, FileAccess.Read);<br />
FileStream fout = new FileStream(outName, FileMode.OpenOrCreate, FileAccess.Write);<br />
fout.SetLength(0);<br />
byte[] bin = new byte[buffersize];
long rdlen = 0;
long totlen = fin.Length;
int len;
RC2CryptoServiceProvider RC2 = new RC2CryptoServiceProvider(); <br />
PasswordDeriveBytes db = new PasswordDeriveBytes(KeySecretString,SaltByte);<br />
byte[] f= db.GetBytes(RC2.LegalKeySizes[0].MaxSize /16);<br />
RC2.IV = f; <br />
RC2.Key =f;<br />
CryptoStream encStream = new CryptoStream(fout, RC2.CreateDecryptor(RC2.Key, RC2.IV), CryptoStreamMode.Write); <br />
Console.WriteLine("Encrypting...");<br />
while(rdlen < totlen)<br />
{<br />
len = fin.Read(bin, 0, buffersize);<br />
encStream.Write(bin, 0, len);<br />
rdlen = rdlen + len;<br />
PD.PerformStep();<br />
Console.WriteLine("{0} bytes processed", rdlen);<br />
} <br />
The Code Project Is Your Friend...
|
|
|
|