Click here to Skip to main content
15,886,362 members
Home / Discussions / C#
   

C#

 
GeneralRe: Linq2Sql cannot add an entity Pin
Pete O'Hanlon4-Sep-12 22:52
mvePete O'Hanlon4-Sep-12 22:52 
GeneralRe: Linq2Sql cannot add an entity Pin
kenajelencres4-Sep-12 23:49
kenajelencres4-Sep-12 23:49 
GeneralRe: Linq2Sql cannot add an entity Pin
Pete O'Hanlon4-Sep-12 23:53
mvePete O'Hanlon4-Sep-12 23:53 
GeneralRe: Linq2Sql cannot add an entity Pin
kenajelencres5-Sep-12 12:47
kenajelencres5-Sep-12 12:47 
GeneralRe: Linq2Sql cannot add an entity Pin
Pete O'Hanlon5-Sep-12 20:13
mvePete O'Hanlon5-Sep-12 20:13 
QuestionStart pages for beginners Pin
mauricemcse4-Sep-12 8:59
mauricemcse4-Sep-12 8:59 
AnswerRe: Start pages for beginners Pin
Eddy Vluggen4-Sep-12 9:03
professionalEddy Vluggen4-Sep-12 9:03 
QuestionRTD help at C# Pin
yatici4-Sep-12 7:39
yatici4-Sep-12 7:39 
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
C#
class Program
    {
//Client mapping for Server, TCP communication
        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>();

// Security manager manages the security activity. Also generates a IDictionary SecurityMasterDictionary <string,Security>
        static SecurityManager Sec = new SecurityManager();
// Orderbook generator will be used to generate orderbook information for securities
        static Orderbook_Generator OGen = new Orderbook_Generator();

//SecGen randomly generates Securities which returns the list of generated securities.
        static List<Security> A = Sec.SecGen();

// RTD STARTS HERE
[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>();

// SecDic is the Security Dictionary Created by the Generator above
        public IDictionary<string, Security> SecDic = Sec.SecurityMasterDictionary;

// Going to take in Topic_1 and Topic_2 to a List <string>
        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)
        {
           //Convert Strings to List<string> and store
            Data = Strings.OfType<string>().ToList();
            GetNewValues = true;

// get the initial values stored in the history lists.
            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

//I THINK THE PROBLEM IS HERE

        #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();
            }
        }

//What data actually needs to be obtained for refreshing data

        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
AnswerRe: RTD help at C# Pin
Karl Sanford4-Sep-12 9:28
professionalKarl Sanford4-Sep-12 9:28 
GeneralRe: RTD help at C# Pin
yatici4-Sep-12 10:08
yatici4-Sep-12 10:08 
AnswerRe: RTD help at C# Pin
Eddy Vluggen4-Sep-12 22:00
professionalEddy Vluggen4-Sep-12 22:00 
QuestionC# proxy class Pin
sc steinhayse4-Sep-12 6:52
sc steinhayse4-Sep-12 6:52 
AnswerRe: C# proxy class Pin
Pete O'Hanlon4-Sep-12 7:03
mvePete O'Hanlon4-Sep-12 7:03 
GeneralRe: C# proxy class Pin
sc steinhayse4-Sep-12 12:29
sc steinhayse4-Sep-12 12:29 
GeneralRe: C# proxy class Pin
Pete O'Hanlon4-Sep-12 22:06
mvePete O'Hanlon4-Sep-12 22:06 
QuestionHow to do architecture design? Pin
yu-jian4-Sep-12 5:56
yu-jian4-Sep-12 5:56 
AnswerRe: How to do architecture design? Pin
Pete O'Hanlon4-Sep-12 5:59
mvePete O'Hanlon4-Sep-12 5:59 
AnswerRe: How to do architecture design? Pin
Eddy Vluggen4-Sep-12 6:04
professionalEddy Vluggen4-Sep-12 6:04 
GeneralRe: How to do architecture design? Pin
yu-jian4-Sep-12 6:30
yu-jian4-Sep-12 6:30 
GeneralRe: How to do architecture design? Pin
Eddy Vluggen4-Sep-12 6:47
professionalEddy Vluggen4-Sep-12 6:47 
AnswerRe: How to do architecture design? Pin
jschell4-Sep-12 11:51
jschell4-Sep-12 11:51 
QuestionC# windows service Pin
sc steinhayse4-Sep-12 4:56
sc steinhayse4-Sep-12 4:56 
AnswerRe: C# windows service Pin
Pete O'Hanlon4-Sep-12 5:11
mvePete O'Hanlon4-Sep-12 5:11 
GeneralRe: C# windows service Pin
sc steinhayse4-Sep-12 12:25
sc steinhayse4-Sep-12 12:25 
GeneralRe: C# windows service Pin
Dave Kreskowiak4-Sep-12 17:30
mveDave Kreskowiak4-Sep-12 17:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.