Example #1
0
        void CWThread_TickAsyncPD()
        {
            bool DisplayFlag = true;

            while (true)
            {
                int length = MemoryManager.EndOfDownloadCount;//MemoryManager.TradeMemoryConDict.Count;

                if (length == initialStartPointCWAsync && DisplayFlag)
                {
                    DisplayFlag = false;
                    NetPositionMemory.UpdateClientNetPosition("", MemoryManager.NetPositionCWDemoDict.ToList());
                    //TODO call CWSW for pd
                    NetPositionMemory.UpdateCWSWDNetPosition("", MemoryManager.NetPositionCWDemoDict.ToList());
                    ProcessClientWiseTradeAsyncOnline();
                    thCWPersonalDownload.Abort();
                }

                if (MemoryManager.TradeMemoryConDict.Count > 0 && length > initialStartPointCWAsync)
                {
                    ParallelOptions oParallelOptions = new ParallelOptions();
                    oParallelOptions.MaxDegreeOfParallelism = 1;

                    Parallel.For(initialStartPointCWAsync, length, oParallelOptions, (index) =>
                    {
                        lock (newCWobjectAsync)
                        {
                            if (MemoryManager.TradeMemoryConDict.ContainsKey(index))
                            {
                                CommonFrontEnd.Processor.UMSProcessor.ProcessNetPositionCWDemo(MemoryManager.TradeMemoryConDict[index]);
                            }
                        }
                    });

                    initialStartPointCWAsync = length;
                }
                else
                {
                    Thread.Sleep(1000);
                }
            }
        }
Example #2
0
        void CWThread_TickAsyncOnline()
        {
            while (true)
            {
                int length = MemoryManager.TradeMemoryConDict.Count;

                //initialStartPointCWAsync = MemoryManager.EndOfDownloadCount;
                if (MemoryManager.TradeMemoryConDict.Count > 0 && length > initialStartPointCWAsync)
                {
                    ParallelOptions oParallelOptions = new ParallelOptions();
                    oParallelOptions.MaxDegreeOfParallelism = 1;

                    Parallel.For(initialStartPointCWAsync, length, oParallelOptions, (index) =>
                    {
                        lock (newCWobjectAsync)
                        {
                            if (MemoryManager.TradeMemoryConDict.ContainsKey(index))
                            {
                                CommonFrontEnd.Processor.UMSProcessor.ProcessNetPositionCWDemo(MemoryManager.TradeMemoryConDict[index]);
                                if (UtilityLoginDetails.GETInstance.Role.ToLower() == "trader")
                                {
                                    NetPositionMemory.UpdateClientNetPosition(((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).Client.Trim(), MemoryManager.NetPositionCWDemoDict.Where(x => ((CommonFrontEnd.Model.Trade.NetPosition)x.Value).ClientId == ((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).Client.Trim()).ToList());
                                    NetPositionMemory.UpdateCWSWDNetPosition(((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).Client.Trim(), MemoryManager.NetPositionCWDemoDict.ToList());
                                }
                                else if (UtilityLoginDetails.GETInstance.Role.ToLower() == "admin")
                                {
                                    NetPositionMemory.UpdateClientNetPosition(((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).TraderId.ToString(), MemoryManager.NetPositionCWDemoDict.Where(x => ((CommonFrontEnd.Model.Trade.NetPosition)x.Value).TraderId == ((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).TraderId.ToString()).ToList());
                                    NetPositionMemory.UpdateCWSWDNetPosition(((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).TraderId.ToString(), MemoryManager.NetPositionCWDemoDict.ToList());
                                }
                            }
                        }
                    });

                    initialStartPointCWAsync = length;
                }
                else
                {
                    Thread.Sleep(1000);
                }
            }
        }
        private void UpdateGridByClient(string TraderId)
        {
            var SettlementNo = string.Empty;

            NetPositionCWSWDataCollectionWindow = null;
            if (!string.IsNullOrEmpty(TraderId))
            {
                ClientIdCWSW = TraderId;

                if (UtilityLoginDetails.GETInstance.Role?.ToLower() == "admin")
                {
                    NetPositionMemory.UpdateCWSWDNetPosition(TraderId, MemoryManager.NetPositionCWDemoDict.Where(x => ((NetPosition)x.Value).TraderId == TraderId).ToList());
                    NetPositionCWSWDataCollectionWindow = new ObservableCollection <CWSWDetailPositionModel>(NetPositionMemory.NetPositionCWSWDataCollection.Where(x => x.TraderId == TraderId));
                }
                else if (UtilityLoginDetails.GETInstance.Role?.ToLower() == "trader")
                {
                    NetPositionMemory.UpdateCWSWDNetPosition(TraderId, MemoryManager.NetPositionCWDemoDict.Where(x => ((NetPosition)x.Value).ClientId == TraderId).ToList());
                    NetPositionCWSWDataCollectionWindow = new ObservableCollection <CWSWDetailPositionModel>(NetPositionMemory.NetPositionCWSWDataCollection.Where(x => x.ClientID == TraderId));
                }
            }
            if (!string.IsNullOrEmpty(UtilityLoginDetails.GETInstance.SettlementNo))
            {
                SettlementNo = UtilityLoginDetails.GETInstance.SettlementNo.Split('/')[1] + UtilityLoginDetails.GETInstance.SettlementNo.Split('/')[0];
            }
            if (UtilityLoginDetails.GETInstance.Role != null)
            {
                if (UtilityLoginDetails.GETInstance.Role?.ToLower() == "admin")
                {
                    NetPositionClientWiseScripWiseDetail = string.Format("Net Position Details - Trd Id- {0} - EQ Sett.No : {1}", TraderId, SettlementNo);
                }
                else if (UtilityLoginDetails.GETInstance.Role?.ToLower() == "trader")
                {
                    NetPositionClientWiseScripWiseDetail = string.Format("Net Position Details - {0} {1}- EQ Sett.No : {2}", TraderId, "CLIENT", SettlementNo);
                }
            }
        }