Exemple #1
0
        private void DataNetFinishedCollect(DataAdminMessageFactory.LogMessage msg)
        {
            var logmodel = new LogModel();
            var groupFlag = false;
            IEnumerable<SymbolModel> symbolList = null;
            switch (msg.LogType)
            {
                case DataAdminMessageFactory.LogMessage.Log.CollectGroup:
                    {
                        groupFlag = true;
                        var idGr = _groups.Find(a => a.GroupName == msg.Group).GroupId;
                        symbolList = DataManager.GetSymbolsInGroup(idGr).AsEnumerable();

                             logmodel = new LogModel
                            {
                                Date = msg.Time,
                                Group = msg.Group,
                                UserId = msg.UserID,
                                MsgType = Convert.ToInt32(msg.LogType),
                                Status = Convert.ToInt32(msg.OperationStatus),
                                Symbol = msg.Symbol,
                                Timeframe = msg.TimeFrame
                            };

                       }
                    break;
                case DataAdminMessageFactory.LogMessage.Log.CollectSymbol:
                    {
                        var smList = msg.Symbol.Split(',').ToList();
                        symbolList = from items in _symbols
                                     where smList.Exists(o => o == items.SymbolName)
                                     select items;
                    }

                    break;
            }

            if (symbolList != null)
                foreach (var smb in symbolList)
                {
                    var bsmb = new DataAdminService.BusySymbol
                    {
                        ID = smb.SymbolId
                    };

                    if (_adminService.BusySymbols.Exists(a => a.ID == bsmb.ID))
                    {
                        var tempbsm = _adminService.BusySymbols.Find(a => a.ID == bsmb.ID);
                        if (!tempbsm.IsTickNet && tempbsm.TimeFrames.Count == 1)
                        {
                            _adminService.BusySymbols.Remove(tempbsm);
                            bsmb.IsDataNet = false;

                        }
                        else

                            if (tempbsm.IsTickNet && tempbsm.TimeFrames.Count == 1)
                            {
                                bsmb.IsTickNet = tempbsm.IsTickNet;
                                bsmb.IsDataNet = false;
                                tempbsm.IsDataNet = false;
                                var tf = tempbsm.TimeFrames.Find(oo => oo.TimeFrame == msg.TimeFrame);
                                tempbsm.TimeFrames.Remove(tf);
                            }
                            else
                                if (tempbsm.TimeFrames.Count > 1)
                                {
                                    bsmb.IsTickNet = tempbsm.IsTickNet;
                                    bsmb.IsDataNet = true;
                                    var tf = tempbsm.TimeFrames.Find(oo => oo.TimeFrame == msg.TimeFrame);
                                    tempbsm.TimeFrames.Remove(tf);
                                }
                    }

                    var tickNetStatus = bsmb.IsTickNet ? "Busy" : "Enabled";
                    var dataNetStatus = bsmb.IsDataNet ? "Busy" : "Enabled";
                    foreach (DataGridViewRow row in ui_symbols_dGrid_Symbols.Rows)
                    {
                        if (row.Cells[0].Value.ToString() != smb.SymbolName) continue;
                        row.Cells[1].Value = dataNetStatus;
                        row.Cells[2].Value = tickNetStatus;
                    }

                    lock (_lockFinishedCollect)
                    {
                        var logmodelLow = new LogModel
                        {
                            Date = msg.Time,
                            Group = msg.Group,
                            UserId = msg.UserID,
                            MsgType = Convert.ToInt32(msg.LogType),
                            Status = Convert.ToInt32(msg.OperationStatus),
                            Symbol = msg.Symbol,
                            Timeframe = msg.TimeFrame
                        };
                     DataManager.AddNewLog(logmodelLow);
                    }

                }

            if(groupFlag)
                DataManager.AddNewLog(logmodel);

            _adminService.SendBusySymbolList(msg.UserID);
            Task.Factory.StartNew(UpdateLogsTable).Wait();
        }
Exemple #2
0
        private void TickNetCollectStarted(DataAdminMessageFactory.LogMessage msg)
        {
            lock (_thisNLock)
            {

                try
                {
                    var logmodel = new LogModel
                    {
                        Date = msg.Time,
                        Group = msg.Group,
                        UserId = msg.UserID,
                        MsgType = Convert.ToInt32(msg.LogType),
                        Status = Convert.ToInt32(msg.OperationStatus),
                        Symbol = msg.Symbol,
                        Timeframe = msg.TimeFrame
                    };

                    #region group collecting

                    if (msg.LogType == DataAdminMessageFactory.LogMessage.Log.CollectGroup)
                    {
                        var idGr = _groups.Find(a => a.GroupName == msg.Group).GroupId;

                        var listSmb = DataManager.GetSymbolsInGroup(idGr);

                        foreach (var symbolModel in listSmb)
                        {
                            var rankList = _adminService.TickNetSymbolAccesRank[symbolModel.SymbolName];
                            //the list which consist the user list
                            if (!rankList.Exists(a => a.DBId == msg.UserID))
                            {
                                var user = _adminService.OnlineClients.GetAllItems().Find(o => o.DBId == msg.UserID);
                                user.DepthValue = msg.DepthValue;
                                _adminService.TickNetSymbolAccesRank[symbolModel.SymbolName].Add(user);
                            }
                        }
                        foreach (var smb in listSmb)
                        {
                            var busySmb = new DataAdminService.BusySymbol
                            {
                                ID = smb.SymbolId,
                                //IsDataNet = msg.IsByDataNetBusy,
                                IsTickNet = msg.IsByTickNetBusy
                            };

                            var tickNetStatus = busySmb.IsTickNet ? "Busy" : "Enabled";
                            var dataNetStatus = busySmb.IsDataNet ? "Busy" : "Enabled";
                            foreach (DataGridViewRow row in ui_symbols_dGrid_Symbols.Rows)
                            {
                                if (row.Cells[0].Value.ToString() != smb.SymbolName) continue;
                                row.Cells[1].Value = dataNetStatus;
                                row.Cells[2].Value = tickNetStatus;
                            }
                        }

                    }
                    #endregion

                    else if (msg.LogType == DataAdminMessageFactory.LogMessage.Log.CollectSymbol)
                    {

                        var smb = _symbols.Find(a => a.SymbolName == msg.Symbol);
                        if (_adminService.TickNetSymbolAccesRank.All(o => o.Key != smb.SymbolName))
                        {
                            _adminService.TickNetSymbolAccesRank.Add(smb.SymbolName, new List<DataClient>());
                            var user = _adminService.OnlineClients.GetAllItems().Find(o => o.DBId == msg.UserID);
                            user.DepthValue = msg.DepthValue;
                            _adminService.TickNetSymbolAccesRank[smb.SymbolName].Add(user);
                            try
                            {
                                user.TClientProxy.SendActivateMsgToClient(smb.SymbolName);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex);
                                ErrorReport(new ErrorInfo
                                {
                                    AdditionalInformation = "",
                                    InvokeTime = DateTime.Now,
                                    MethodName = "TicknetCollectStarted-SendActivateMsgToClient",
                                    ErrorText = ex.Message
                                });
                            }
                            //add symbol to busy symbol list

                            var bsm = new DataAdminService.BusySymbol
                            {
                                ID = smb.SymbolId,
                                IsDataNet = msg.IsByDataNetBusy,
                                IsTickNet = msg.IsByTickNetBusy
                            };
                            if (!_busySymbols.Exists(a => a.ID == bsm.ID)) _busySymbols.Add(bsm);
                            else
                            {
                                var fsmb = _busySymbols.Find(o => o.ID == bsm.ID);
                                fsmb.IsTickNet = true;
                            }

                        }
                        else if (_adminService.TickNetSymbolAccesRank[smb.SymbolName].Count == 0)
                        {
                            var user = _adminService.OnlineClients.GetAllItems().Find(o => o.DBId == msg.UserID);
                            user.DepthValue = msg.DepthValue;
                            _adminService.TickNetSymbolAccesRank[smb.SymbolName].Add(user);
                            try
                            {
                                user.TClientProxy.SendActivateMsgToClient(smb.SymbolName);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex);
                                ErrorReport(new ErrorInfo
                                {
                                    AdditionalInformation = "",
                                    InvokeTime = DateTime.Now,
                                    MethodName = "TicknetCollectStarted-SendActivateMsgToClient",
                                    ErrorText = ex.Message
                                });
                            }
                            var bsm = new DataAdminService.BusySymbol
                            {
                                ID = smb.SymbolId,
                                IsDataNet = msg.IsByDataNetBusy,
                                IsTickNet = msg.IsByTickNetBusy
                            };
                            if (!_busySymbols.Exists(a => a.ID == bsm.ID)) _busySymbols.Add(bsm);
                            else
                            {
                                var fsmb = _busySymbols.Find(o => o.ID == bsm.ID);
                                fsmb.IsTickNet = true;
                            }
                        }
                        else
                        {
                            var rankList =
                                _adminService.TickNetSymbolAccesRank[smb.SymbolName].OrderByDescending(o => o.DepthValue)
                                    .
                                    ToList(); //the list which consist the user list
                            if (!rankList.Exists(a => a.DBId == msg.UserID))
                            {
                                var user = _adminService.OnlineClients.GetAllItems().Find(o => o.DBId == msg.UserID);
                                user.DepthValue = msg.DepthValue;
                                string tempuser = rankList[0].UserName;
                                int depthValue = rankList[0].DepthValue;
                                if (depthValue < user.DepthValue)
                                {
                                    _adminService.TickNetSymbolAccesRank[smb.SymbolName].Add(user);
                                    try
                                    {
                                        _adminService.Clients.GetAllItems().Find(oo => oo.UserName == tempuser).TClientProxy.SendWaitToClients(smb.SymbolName);
                                        nextTNClient = user.UserName;
                                        nextTNSymbol = smb.SymbolName;

                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex);
                                        ErrorReport(new ErrorInfo
                                        {
                                            AdditionalInformation = "",
                                            InvokeTime = DateTime.Now,
                                            MethodName = "TicknetCollectStarted-SendActivateMsgToClient",
                                            ErrorText = ex.Message
                                        });
                                    }

                                }

                                else
                                    _adminService.TickNetSymbolAccesRank[smb.SymbolName].Add(user);
                            }
                        }
                        var tickNetStatus = msg.IsByTickNetBusy ? "Busy" : "Enabled";
                        var ids = _symbols.Find(o => o.SymbolName == msg.Symbol).SymbolId;
                        var dataNetStatus = _busySymbols.Find(o => o.ID == ids).IsDataNet ? "Busy" : "Enabled";

                        var absm = new DataAdminService.BusySymbol { ID = ids, IsDataNet = msg.IsByDataNetBusy };
                        if (!_busySymbols.Exists(a => a.ID == absm.ID)) _busySymbols.Add(absm);
                        else
                        {
                            var fsmb = _busySymbols.Find(o => o.ID == absm.ID);
                            fsmb.IsTickNet = true;
                        }

                        foreach (DataGridViewRow row in ui_symbols_dGrid_Symbols.Rows)
                        {
                            var name = row.Cells[0].Value.ToString();
                            if (name != smb.SymbolName) continue;
                            row.Cells[1].Value = dataNetStatus;
                            row.Cells[2].Value = tickNetStatus;
                        }
                    }
                    //         _adminService.SendBusySymbolList();
                    Task.Factory.StartNew(() => DataManager.AddNewLog(logmodel)).ContinueWith(delegate
                    {
                        UpdateLogsTable();
                    });
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    ErrorReport(new ErrorInfo
                    {
                        AdditionalInformation = "",
                        ErrorText = ex.Message

                    });
                }
            }
        }
Exemple #3
0
        private void DataNetCollectStarted(DataAdminMessageFactory.LogMessage msg)
        {
            var logmodel = new LogModel
            {
                Date = msg.Time,
                Group = msg.Group,
                UserId = msg.UserID,
                MsgType = Convert.ToInt32(msg.LogType),
                Status = Convert.ToInt32(msg.OperationStatus),
                Symbol = msg.Symbol,
                Timeframe = msg.TimeFrame
            };

            IEnumerable<string> symbolList = null;

            if (msg.LogType == DataAdminMessageFactory.LogMessage.Log.CollectGroup)
            {
                var idGr = DataManager.GetGroups().Find(a => a.GroupName == msg.Group).GroupId;

                symbolList = from symbols in DataManager.GetSymbolsInGroup(idGr) select symbols.SymbolName;
                DataManager.AddNewLog(logmodel);
            }
            else
                if (msg.LogType == DataAdminMessageFactory.LogMessage.Log.CollectSymbol)
            {
                symbolList = msg.Symbol.Split(',').ToList().AsEnumerable();
            }

            if (symbolList != null)
                foreach (var smbcollect in symbolList)
                {

                    var smb = _symbols.Find(a => a.SymbolName == smbcollect);
                    var bsmb = new DataAdminService.BusySymbol
                    {
                        ID = smb.SymbolId,
                        IsDataNet = msg.IsByDataNetBusy,
                        UserName =
                            (from items in _users where items.Id == msg.UserID select items.Name).
                            First(),
                        TimeFrames = new List<DataAdminService.TimeFrameModel>
                                                            {
                                                                new DataAdminService.TimeFrameModel
                                                                    {TimeFrame =  msg.TimeFrame,
                                                                UserId =  msg.UserID}
                                                            }

                    };

                    if (!_adminService.BusySymbols.Exists(a => a.ID == bsmb.ID))
                        _adminService.BusySymbols.Add(bsmb);
                    else
                    {
                        bsmb.IsTickNet = _adminService.BusySymbols.Find(a => a.ID == bsmb.ID).IsTickNet;
                        _adminService.BusySymbols.Find(a => a.ID == bsmb.ID).IsDataNet = true;
                        if (!_adminService.BusySymbols.Find(a => a.ID == bsmb.ID).TimeFrames.Exists(oo => oo.TimeFrame == msg.TimeFrame))
                            _adminService.BusySymbols.Find(a => a.ID == bsmb.ID).TimeFrames.Add(
                                new DataAdminService.TimeFrameModel { TimeFrame = msg.TimeFrame, UserId = msg.UserID });

                    }

                    var tickNetStatus = bsmb.IsTickNet ? "Busy" : "Enabled";
                    var dataNetStatus = bsmb.IsDataNet ? "Busy" : "Enabled";
                    foreach (DataGridViewRow row in ui_symbols_dGrid_Symbols.Rows)
                    {
                        var name = row.Cells[0].Value.ToString();
                        if (name != smb.SymbolName) continue;
                        row.Cells[1].Value = dataNetStatus;
                        row.Cells[2].Value = tickNetStatus;
                    }

                    var logmodellow = new LogModel
                    {
                        Date = msg.Time,
                        Group = "",
                        UserId = msg.UserID,
                        MsgType = Convert.ToInt32(DataAdminMessageFactory.LogMessage.Log.CollectSymbol),
                        Status = Convert.ToInt32(msg.OperationStatus),
                        Symbol = smbcollect,
                        Timeframe = msg.TimeFrame
                    };

                    lock (_thisLock)
                    {
                        DataManager.AddNewLog(logmodellow);
                    }

                }

            _adminService.SendBusySymbolList(msg.UserID);

            lock (_thisLock)
            {
                UpdateLogsTable();
            }
        }
Exemple #4
0
        private void DataNetCollectingSymbolFinished(DataAdminMessageFactory.LogMessage msg)
        {
            lock (_thisLock)
            {
                IEnumerable<SymbolModel> symbolList = null;

                var smList = msg.Symbol.Split(',').ToList();
                symbolList = from items in _symbols
                                where smList.Exists(o => o == items.SymbolName)
                                select items;

                if (symbolList != null)
                    foreach (var smb in symbolList)
                    {
                        var bsmb = new DataAdminService.BusySymbol
                        {
                            ID = smb.SymbolId
                        };

                        if (_adminService.BusySymbols.Exists(a => a.ID == bsmb.ID))
                        {
                            var tempbsm = _adminService.BusySymbols.Find(a => a.ID == bsmb.ID);
                            if (!tempbsm.IsTickNet && tempbsm.TimeFrames.Count == 1)
                            {
                                _adminService.BusySymbols.Remove(tempbsm);
                                bsmb.IsDataNet = false;

                            }
                            else

                                if (tempbsm.IsTickNet && tempbsm.TimeFrames.Count == 1)
                                {
                                    bsmb.IsTickNet = tempbsm.IsTickNet;
                                    bsmb.IsDataNet = false;
                                    tempbsm.IsDataNet = false;
                                    var tf = tempbsm.TimeFrames.Find(oo => oo.TimeFrame == msg.TimeFrame);
                                    tempbsm.TimeFrames.Remove(tf);
                                }
                                else
                                    if (tempbsm.TimeFrames.Count > 1)
                                    {
                                        bsmb.IsTickNet = tempbsm.IsTickNet;
                                        bsmb.IsDataNet = true;
                                        var tf = tempbsm.TimeFrames.Find(oo => oo.TimeFrame == msg.TimeFrame);
                                        tempbsm.TimeFrames.Remove(tf);
                                    }
                        }

                        var tickNetStatus = bsmb.IsTickNet ? "Busy" : "Enabled";
                        var dataNetStatus = bsmb.IsDataNet ? "Busy" : "Enabled";
                        foreach (DataGridViewRow row in ui_symbols_dGrid_Symbols.Rows)
                        {
                            if (row.Cells[0].Value.ToString() != smb.SymbolName) continue;
                            row.Cells[1].Value = dataNetStatus;
                            row.Cells[2].Value = tickNetStatus;
                        }

                        lock (_lockFinishedCollect)
                        {
                            var logmodelLow = new LogModel
                            {
                                Date = msg.Time,
                                Group = msg.Group,
                                UserId = msg.UserID,
                                MsgType = Convert.ToInt32(msg.LogType),
                                Status = Convert.ToInt32(msg.OperationStatus),
                                Symbol = msg.Symbol,
                                Timeframe = msg.TimeFrame,
                                Application = ApplicationType.DataNet.ToString(),
                                Comments = msg.Comments
                            };
                            AdminDatabaseManager.AddNewLog(logmodelLow);
                        }
                    }

                _adminService.SendBusySymbolList(msg.UserID);

                UpdateLogsTable();
            }
        }