|
Try these[^] for size
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I need with this project as =RTD at excel can't trace back what the problem is at my C# code. I am fairly new at C# and working on a trading game application.
At excel I would like to use
1) =RTD("ProgramID",,"SecurityName","price")
2) =RTD("ProgramID",,"SecurityName","volume")
So at my program.cs file
class Program
{
static IDictionary<int, string>; ClientMappingDictionary = new Dictionary<int, string>();
static IList<string> ClientList = new List<string>();
static IDictionary<string, double> AUMDictionary = new Dictionary<string, double>();
static SecurityManager Sec = new SecurityManager();
static Orderbook_Generator OGen = new Orderbook_Generator();
static List<Security> A = Sec.SecGen();
[Guid("E128D214-56EF-4AA5-B5D6-7B2283CE2F79"), ProgId("TradeRTD.OrderRTD"), ComVisible(true)]
public class TradeRTD : MSExcel.IRtdServer
{
#region Data Members
private MSExcel.IRTDUpdateEvent m_callback = null;
private Timer m_timer = null;
private IDictionary<int, double> m_topics = new Dictionary<int, double>();
public IDictionary<string, Security> SecDic = Sec.SecurityMasterDictionary;
public List<string> Data = new List<string>();
#endregion
#region IRtdServer Interface
#region ServerStart
public int ServerStart(MSExcel.IRTDUpdateEvent CallbackObject)
{
m_callback = CallbackObject;
m_timer = new Timer(1000);
m_timer.Elapsed += new ElapsedEventHandler(m_timer_Elapsed);
m_timer.Start();
return 1;
}
#endregion
#region ServerTerminate
public void ServerTerminate()
{
if (null != m_timer)
{
m_timer.Stop();
m_timer.Dispose();
m_timer = null;
}
}
#endregion
#region ConnectData
public object ConnectData(int TopicID, ref Array Strings, ref bool GetNewValues)
{
Data = Strings.OfType<string>().ToList();
GetNewValues = true;
double price = SecDic[Data[0]].Price_History.Last();
double volume = SecDic[Data[0]].Volume_History.Last();
if (Data[1] == "price")
{
if (!m_topics.Keys.Contains(TopicID))
{ m_topics.Add(TopicID, price); }
else { m_topics.Add(TopicID, volume); }
}
return GetData(Data);
}
#endregion
#region DisconnectData
public void DisconnectData(int TopicID)
{
if (m_topics.Keys.Contains(TopicID))
{ m_topics.Remove(TopicID); }
}
#endregion
#region HealthCheck
public int Heartbeat() { return 1; }
#endregion
#region RefreshData
public Array RefreshData(ref int TopicCount)
{
object[,] data = new object[2, m_topics.Count];
int idx = 0;
foreach (string A in SecDic.Keys)
{
data[0, idx] = A;
data[1, idx] = SecDic[Data[0]].Price_History.Last();
++idx;
data[0, idx] = A;
data[1, idx] = SecDic[Data[0]].Volume_History.Last();
}
TopicCount = m_topics.Count;
m_timer.Start();
return data;
}
#endregion
#endregion
#region Supporting Methods
void m_timer_Elapsed(object sender, ElapsedEventArgs e)
{
if (null != m_callback)
{
m_timer.Stop();
m_callback.UpdateNotify();
}
}
private double GetData(List<string> junk)
{
if(junk[1] == "price")
return SecDic[junk[0]].Price_History.Last();
if (junk[1] == "volume")
return SecDic[junk[0]].Volume_History.Last();
else { return 0; }
}
#endregion
}
static void Main(string[] args)
{ .... orderbook generation and Server starting
I would really appreciate some help here as my =RTD is returning N/A all the time
Thanks
|
|
|
|
|
|
Kind of. Microsoft.Office.Interop.Excel provides a built in method for =RTD function of excel.
Where you can =RTD("ProgramID",servername,Topic_1,Topic_2,...) to access data
I was trying to use this. your link explains for static data. My data will be dynamic so I need to update constantly
modified 4-Sep-12 17:25pm.
|
|
|
|
|
yatici wrote: I was trying to use this. your link explains for static data. My data will be dynamic so I need to update constantly
That's quite an advanced topic for someone who "is new". Try the example here[^].
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
In a C# 2008 proxy class for a console application, I am thinking that I want to add code to the production application. I obtained some code from a contract shop that I want to work with. I want to be able to update the sql server 2008 database and change some directory path locations.
Am I allowing to do this in a proxy class? If so, are there certain rules I need to follow to be allowed to change the code?
If I am not allowed to change the code, can you tell me what my alternatitves are and how to code for these alternatives?
|
|
|
|
|
Are you and this[^] person one and the same or do you both work together?
|
|
|
|
|
I asked the other few programmers and one said the post was from them. Thus we work at the same company.
|
|
|
|
|
You two need to coordinate then. It's getting very confusing answering similar questions from different people.
|
|
|
|
|
There is a system needs to support 3 different protocol. Two protocols uses CGI to communicating, the other one uses self-define protocol base on the TCP protocol. The devices base on different protocols have different properties. So how to do the abstract architecture for this system. I find that it is difficult to design an abstract class to support these two protocol. Because there have a little similar. Does anyone meet the same problem? Or suggest other open source system support different network device?
|
|
|
|
|
First of all, you should ask this in the design forum instead. Secondly, if there's little similarity then don't try and shoe horn it into an abstract design.
|
|
|
|
|
I'm usually sticking to generalizing what they have in common into an interface (altough an abstract class might be preferred under some conditions), with a strategy-pattern to switch between actual implementations.
No, they needn't be 100% equal; sometimes one of the implementations has an extra property, or lacks one. If it lacks the property, we implement a dummy. The "extras" are usually put in a separate class that's embedded in the object, comparable to the composition-pattern.
Can you describe the three items roughly with it's most important members?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Two type device use the some CGI interface to control the device, so these two types have much similar, but the other should use the self-define protocol base on the TCP protocol. I consider one way to define a muster to include these three types command, and defines a muster of pages to show different pages to user by device type.. But I found that this way was too completed.
|
|
|
|
|
yu-jian wrote: so these two types have much similar, but the other should use the self-define protocol base on the TCP protocol.
I see.. two classes, who look very similar. And I see a third class, following the same design, implementing all the members that the other two classes have, but somehow ignoring their calls.
class MallardDuck: Duck
{
public void Quack()
{
System.Diagnostics.Debugger.WriteLine("Ku-wack");
}
}
class RubberDuck: Duck
{
public void Quack()
{
Console.WriteLine("Squeek");
}
}
class SomeDog: Politician
{
public void Quack()
{
}
}
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
yu-jian wrote: So how to do the abstract architecture for this system
Simple - you don't, because you haven't posted anything that suggests that there is any need to do that.
For something to be be abstracted (for the need to exist) there must be a specified need to use several things in a common way.
You do have two protocols that use a base protocol the same so those two together might use a helper class to facilitate processing. But that doesn't mean they implementating for each is represented as common entity.
|
|
|
|
|
I need to write a C# 2010 windows service that calls a console application at different times. Since I have not written a windows service before, can you tell me the following:
1. How do you setup a windows service initally? Is it a windows service a desktop application, console application, or what kind of an application is it?
2. How to you include a timer in the application so it executes at specified time periods?
Can you tell me and/or point me to references that will answer these questions listed above for me
|
|
|
|
|
sc steinhayse wrote: 1. How do you setup a windows service initally? Is it a windows service a
desktop application, console application, or what kind of an application is
it?
File > New > Project > Visual C# > Windows > Windows Service
sc steinhayse wrote: 2. How to you include a timer in the application so it executes at specified
time periods?
Create a new class and instantiate it from the OnStart method (you'll find this created by default, just search for it). The new class will contain whatever logic you need.
|
|
|
|
|
Do I need to setup a deployment package at the same time I setup the code proejct intitally?
|
|
|
|
|
No, you can add it later. Don't get too used to the Setup and Deployment project in Visual Studio. It no longer exists in VS2012 as it's been replaced by InstallShield LE.
Typically, setup projects are built and designed right along side the project it's going to be installing.
|
|
|
|
|
sc steinhayse wrote: I need to write a C# 2010 windows service
Why? Explain me what you need to do that cannot be done from a console-app.
sc steinhayse wrote: 1. How do you setup a windows service initally? Is it a windows service a desktop application, console application, or what kind of an application is it?
There's my argumentation that you do not need a service
A Windows-service is an application that runs without any user-interaction, and which runs before any users logs in. They usually run under a limited user-profile, and not the users' profile.
sc steinhayse wrote: 2. How to you include a timer in the application so it executes at specified time periods?
Yes, but you don't want to. Use the Windows Task Scheduler[^]; it's there to run a specific task at a specific time/interval.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
i posted today my first question, but how can if find the answer or look if i got an answer?
thanks ..
|
|
|
|
|
You'll receive a mail, just as you receive a mail for each reply on the forum. This is the C#-forum BTW, meant for C#-related questions.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Rule 1: Be patient, the people who provide answers are all volunteers who do this in their own time at no cost to you.
Rule 2: See rule 1.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
If you don't know how to the answers to the other question, how do you expect to get the answers to this one? 
|
|
|
|
|
Klaus, I appreciate that you are new to asking/answering questions here on Code Project, and that you aren't aware of the forum etiquette so I'll try and point you in the right direction.
First of all, if you have a question about the way the site operates, you need to post in the Site Bugs/Suggestions[^] forum.
When you ask a question in the forums, as long as you have "E-mail me if someone replies to this message" checked, you will be sent a reply whenever anyone actually posts a response.
When I checked your profile, it showed that you had only allowed 12 minutes from posting your question to posting this question. Be patient.
Speaking of profile[^], that's where you find links to your activity; so if you want to get back to your question, just follow the appropriate[^] link.
I hope that this is enough to get you started with Code Project.
|
|
|
|