Beispiel #1
0
        public void SendDexportLog(DataAdminMessageFactory.LogMessage msg)
        {
            switch(msg.OperationStatus)
            {
                case DataAdminMessageFactory.LogMessage.Status.Started:
                    if (OnDexportStartedOperation != null)
                        OnDexportStartedOperation(msg);
                    break;

                case DataAdminMessageFactory.LogMessage.Status.Finished :
                    if (OnDexportFinishedOperation != null)
                        OnDexportFinishedOperation(msg);
                    break;

                case DataAdminMessageFactory.LogMessage.Status.Aborted :
                    if (OnDexportAbortedOperation != null)
                        OnDexportAbortedOperation(msg);
                    break;
            }
        }
Beispiel #2
0
 public void ChangePrivilege(string user, DataAdminMessageFactory.ChangePrivilage newprivilege)
 {
     if (changePrivilages != null)
         {
             changePrivilages(this, newprivilege);
         }
 }
Beispiel #3
0
        public void SendLog(List<string> symbols, DataAdminMessageFactory.LogMessage.Log logtype, string groupName,
            string timeFrame, bool started, bool finished, bool failed = false, string comments = "")
        {
            var status = started
                ? DataAdminMessageFactory.LogMessage.Status.Started
                : DataAdminMessageFactory.LogMessage.Status.Finished;

            if (symbols.Count > 0)
            {
                var logMsg = new DataAdminMessageFactory.LogMessage(_client.UserID, DateTime.Now, "",
                    logtype, groupName, status)
                {
                    IsByDataNetBusy = true,
                    IsDataNetClient = true,
                    IsTickNetClient = false,
                    TimeFrame = timeFrame,
                    Comments = comments

                };
                if (failed) logMsg.OperationStatus = DataAdminMessageFactory.LogMessage.Status.Aborted;

                var symb = symbols.Aggregate("", (current, symbol) => current + (symbol + ","));
                var index = symb.Count() - 1;
                symb = symb.Remove(index);
                logMsg.Symbol = symb;
                if (started)
                {
                    var tries = 0;
                    var errorHappened = false;
                    do
                    {
                        errorHappened = false;

                        try
                        {
                            Task.Factory.StartNew(() => _logClientService.ServiceProxy.SendStartedOperationLog(
                                logMsg)).Wait();

                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            errorHappened = true;
                            tries++;
                        }

                    } while (tries < 3 && errorHappened);

                }
                else if (finished)
                {
                    logMsg.IsByDataNetBusy = false;
                    Task.Factory.StartNew(() => _logClientService.ServiceProxy.SendFinishedOperationLog(logMsg)).Wait();
                }

            }
            else
            {
                var logMsg = new DataAdminMessageFactory.LogMessage(_client.UserID, DateTime.Now, "", logtype, groupName,
                    status);
                if (started)
                {
                    logMsg.IsByDataNetBusy = true;
                    logMsg.IsDataNetClient = true;
                    logMsg.TimeFrame = timeFrame;
                    Task.Factory.StartNew(() => _logClientService.ServiceProxy.SendStartedOperationLog(logMsg)).Wait();

                }
                else if (finished)
                {
                    logMsg.IsByDataNetBusy = false;
                    logMsg.IsDataNetClient = true;
                    logMsg.TimeFrame = timeFrame;
                    _logClientService.ServiceProxy.SendFinishedOperationLog(logMsg);
                }
            }
        }
Beispiel #4
0
 private void LoginFailed(object sender, DataAdminMessageFactory.LoginMessage msg)
 {
     _startControl.Invoke((Action) (() =>
     {
         ToastNotification.Show(_startControl, msg.ServerMessage);
         _startControl.ui_buttonX_logon.Enabled = true;
     }));
 }
Beispiel #5
0
        private void LoggedIn(object sender, DataAdminMessageFactory.ChangePrivilage msg)
        {
            labelItemUserName.Text = "<" + _client.UserName + ">  " + Settings.Default.connectionHost;

            _logined = true;
            _serverStatus = true;
            var xml = new XmlDocument();
            xml.LoadXml(msg.ServerMessage);

            string host = "";
            string dbName = "";
            string usName = "";
            string passw = "";
            string dbNameLive = "";

            var connString = xml.GetElementsByTagName("ConnectionString");
            var attr = connString[0].Attributes;
            if (attr != null)
            {
                host = (attr["Host"].Value);
                dbName = attr["dbName"].Value;
                usName = attr["userName"].Value;
                passw = attr["password"].Value;
                dbNameLive = attr["dbNameLive"].Value;
            }
            _connectionToSharedDb = "SERVER=" + host + "; Port=3306; DATABASE=" + dbName + "; UID=" + usName + "; PASSWORD="******"SERVER=" + host + "; Port=3306; DATABASE=" + dbNameLive + "; UID=" + usName + "; PASSWORD=" + passw;
            SetPrivilages(msg);
        }
Beispiel #6
0
 public void SendDexportPermission(DataAdminMessageFactory.ChangePrivilage msg)
 {
 }
Beispiel #7
0
 public void Login(DataAdminMessageFactory.LoginMessage loginParams)
 {
     if(loginFailed != null)
        {
            loginFailed(this, loginParams);
        }
 }
Beispiel #8
0
 private void FinishedOperationLog(object sender, DataAdminMessageFactory.LogMessage msg)
 {
     if (msg.IsTickNetClient)
     {
         Task.Factory.StartNew(() => TicknetCollectFinished(msg));
     }
     else
         Task.Factory.StartNew(() => DataNetFinishedCollect(msg));
 }
Beispiel #9
0
        private void DataNetCollectingGroupStarted(DataAdminMessageFactory.LogMessage msg)
        {
            lock (_thisLock)
            {
                var logmodel = new LogModel
                {
                    Date = msg.Time,
                    Group = msg.Group,
                    UserId = msg.UserID,
                    MsgType = Convert.ToInt32(msg.LogType),
                    Status = Convert.ToInt32(msg.OperationStatus),
                    Symbol = "",//todo empty msg.Symbol,
                    Timeframe = msg.TimeFrame,
                    Application = ApplicationType.DataNet.ToString()
                };

                AdminDatabaseManager.AddNewLog(logmodel);

                UpdateLogsTable();
            }
        }
Beispiel #10
0
        private void AbortedOperationLog(object sender, DataAdminMessageFactory.LogMessage msg)
        {
            if (msg.IsDataNetClient&& msg.LogType == DataAdminMessageFactory.LogMessage.Log.CollectSymbol)
            {
                Task.Factory.StartNew(() => DataNetCollectingSymbolFinished(msg));
                return;
            }

            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,
                Comments = msg.Comments
            };

            AdminDatabaseManager.AddNewLog(logmodel);
            UpdateLogsTable();
        }
Beispiel #11
0
        private void SimpleMessageLog(object sender, DataAdminMessageFactory.LogMessage msg)
        {
            var logmodel = new LogModel
            {
                Date = msg.Time,
                Group = "",

                UserId = msg.UserID,
                MsgType = Convert.ToInt32(msg.LogType),
                Status = Convert.ToInt32(msg.OperationStatus),
                Symbol = msg.Symbol,
                Timeframe = msg.TimeFrame
            };

            AdminDatabaseManager.AddNewLog(logmodel);
        }
Beispiel #12
0
 public void SendStartedOperationLog(DataAdminMessageFactory.LogMessage msg)
 {
 }
Beispiel #13
0
 public void SendSimpleLog(DataAdminMessageFactory.LogMessage msg)
 {
 }
Beispiel #14
0
 public void SendFinishedOperationLog(DataAdminMessageFactory.LogMessage msg)
 {
 }
Beispiel #15
0
 public void SendDexportLog(DataAdminMessageFactory.LogMessage msg)
 {
 }
Beispiel #16
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();
            }
        }
Beispiel #17
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();
        }
Beispiel #18
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();
            }
        }
Beispiel #19
0
 public void ChangePrivilege(string user, DataAdminMessageFactory.ChangePrivilage newprivilege)
 {
     if (changePrivilages != null)
         {
             var sdf = newprivilege.LocalDBAllowed;
             changePrivilages(this, newprivilege);
         }
 }
Beispiel #20
0
 private void FinishedOperationLog(object sender, DataAdminMessageFactory.LogMessage msg)
 {
     if (msg.IsTickNetClient)
         Task.Factory.StartNew(() => TicknetCollectFinished(msg));
     else
     {
         if (msg.LogType == DataAdminMessageFactory.LogMessage.Log.CollectGroup)
             Task.Factory.StartNew(() => DataNetCollectingGroupFinished(msg));
         else
             Task.Factory.StartNew(() => DataNetCollectingSymbolFinished(msg));
     }
 }
Beispiel #21
0
 public void onLogon(bool logged, DataAdminMessageFactory.ChangePrivilage getprivilages)
 {
     if (login != null)
         {
          login(this, getprivilages);
         }
 }
Beispiel #22
0
 private void StartedOperationLog(object sender, DataAdminMessageFactory.LogMessage msg)
 {
     if(msg.IsTickNetClient)
       Task.Factory.StartNew( () => TickNetCollectStarted(msg));
        else
      Task.Factory.StartNew( () =>  DataNetCollectStarted(msg));
 }
Beispiel #23
0
 public void SendSymbolCollectRequest(DataAdminMessageFactory.TickNetCollectMsg msg)
 {
 }
Beispiel #24
0
        private void TicknetCollectFinished(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
            };

            var smb = _symbols.Find(a => a.SymbolName == msg.Symbol);
            if (_adminService.TickNetSymbolAccesRank.Any(o => o.Key == smb.SymbolName))
            {
                if (_adminService.TickNetSymbolAccesRank[smb.SymbolName].Count == 0) return;

                var usr = _adminService.TickNetSymbolAccesRank[smb.SymbolName].OrderByDescending(o => o.DepthValue).ToList()[0];

                if (usr.DBId != msg.UserID)
                {
                    var delusr =
                        _adminService.TickNetSymbolAccesRank[smb.SymbolName].Find(
                            o => o.DBId == msg.UserID);
                    _adminService.TickNetSymbolAccesRank[smb.SymbolName].Remove(delusr);
                    DataManager.AddNewLog(logmodel);

                    return;
                }
            }

            Task.Factory.StartNew(() => ActivateNextClient(msg.Symbol)).Wait();

            DataManager.AddNewLog(logmodel);
            UpdateLogsTable();
        }
Beispiel #25
0
        private void LoggedIn(object sender, DataAdminMessageFactory.ChangePrivilage msg)
        {
            labelItemUserName.Text = "<" + _client.UserName + ">  " + Settings.Default.scHost;

            _missingBarManager.AllowCollectingAndMissingBar();
            _logined = true;
            _shouldStop = true;

            var xml = new XmlDocument();
            xml.LoadXml(msg.ServerMessage);

            string host = "";
            string dbName = "";
            string dbNameBar = "";

            string dbNameHist = "";

            string usName = "";
            string passw = "";

            var connString = xml.GetElementsByTagName("ConnectionString");
            var attr = connString[0].Attributes;
            if (attr != null)
            {
                host = (attr["Host"].Value);
                dbName = attr["dbName"].Value;
                dbNameBar = attr["dbNameBar"].Value;
                dbNameHist = attr["dbNameHist"].Value;

                usName = attr["userName"].Value;
                passw = attr["password"].Value;
            }
            _connectionToSharedDb = "SERVER=" + host + "; DATABASE=" + dbName + "; UID=" + usName + "; PASSWORD="******"SERVER=" + host + "; DATABASE=" + dbNameBar + "; UID=" + usName + "; PASSWORD="******"SERVER=" + host + "; DATABASE=" + dbNameHist + "; UID=" + usName +
                                              "; PASSWORD=" + passw;

            SetPrivilages(msg);

            CQGDataCollectorManager.Init(_client.UserName);

            //#Crashing
            Invoke((Action) (() =>
            {
                if (Settings.Default.IsCrashed && Settings.Default.WasConnected)
                {
                    if (Settings.Default.WasConnectedToShared)
                        ConnectToShared();
                    else
                        ConnectToLocal();

                    ContinueCollectingData();

                }

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

                    });
                }
            }
        }
Beispiel #27
0
        private void SetPrivilages(DataAdminMessageFactory.ChangePrivilage msg)
        {
            if (msg == null) return;

            var privileges = msg;

            _client.Privileges.AnyIPAllowed = privileges.AnyIPAllowed;
            _client.Privileges.CollectSQGAllowed = privileges.CollectSQGAllowed;
            _client.Privileges.DatanetEnabled = privileges.DatanetEnabled;
            _client.Privileges.LocalDBAllowed = privileges.LocalDBAllowed;
            _client.Privileges.MissingBarFAllowed = privileges.MissingBarFAllowed;
            _client.Privileges.SharedDBAllowed = privileges.SharedDBAllowed;
            _client.Privileges.TicknetEnabled = privileges.TicknetEnabled;

            string sharedDbstring;
            Color sharedDbColor;

            string localDbstring;
            Color localDbColor;

            if (_client.Privileges.SharedDBAllowed)
            {
                sharedDbstring = "AVAILABLE";
                sharedDbColor = Color.Green;
            }
            else
            {
                sharedDbstring = "UNAVAILABLE";
                sharedDbColor = Color.OrangeRed;
            }

            if (_client.Privileges.LocalDBAllowed)
            {
                localDbstring = "AVAILABLE";
                localDbColor = Color.Green;
            }
            else
            {
                localDbstring = "UNAVAILABLE";
                localDbColor = Color.OrangeRed;
            }

            Task.Factory.StartNew(delegate
            {
                ui_buttonX_localConnect.Invoke(
                    (Action) delegate { ui_buttonX_localConnect.Enabled = _client.Privileges.LocalDBAllowed; });

                ui_buttonX_shareConnect.Invoke((Action) delegate
                {
                    ui_buttonX_shareConnect.Enabled = _client.Privileges.SharedDBAllowed;
                });
                ui_LabelX_localAvaliable.Invoke((MethodInvoker) delegate
                {
                    ui_LabelX_localAvaliable.Text = localDbstring;
                    ui_LabelX_localAvaliable.ForeColor = localDbColor;
                });
                ui_LabelX_sharedAvaliable.Invoke((MethodInvoker) delegate
                {
                    ui_LabelX_sharedAvaliable.Text = sharedDbstring;
                    ui_LabelX_sharedAvaliable.ForeColor = sharedDbColor;
                });

                _startControl.Invoke((Action) (() => _startControl.Hide()));
            });
        }
Beispiel #28
0
        private void AbortedOperationLog(object sender, 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
            };

            DataManager.AddNewLog(logmodel);
            UpdateLogsTable();
        }
Beispiel #29
0
 private void ChangedPrivileges(object sender, DataAdminMessageFactory.ChangePrivilage msg)
 {
     SetPrivilages(msg);
 }
Beispiel #30
0
        private void ClientLoggedOutLog(DataAdminMessageFactory.LogMessage msg, string msgMain, string userName)
        {
            _onlineUsers = _adminService.OnlineClients.GetAllItems();
            foreach (DataGridViewRow row in ui_users_dgridX_users.Rows)
            {
                if (_onlineUsers.Exists(a => a.UserName == userName))
                {
                    var tickNet = _onlineUsers.Find(a => a.UserName == userName).IsTickNetConnected;
                    var dNet = _onlineUsers.Find(a => a.UserName == userName).IsDatanetConnected;

                    if (row.Cells[0].Value.ToString() == userName && dNet)
                    {
                        row.Cells[2].Value = "online";
                    }
                    else
                    {
                        row.Cells[2].Value = "offline";
                    }

                    if (row.Cells[0].Value.ToString() == userName && tickNet)
                    {
                        row.Cells[3].Value = "online";
                    }
                    else
                    {
                        row.Cells[3].Value = "offline";
                    }
                }
                else
                {
                    if (row.Cells[0].Value.ToString() == userName)
                    {
                        row.Cells[2].Value = "offline";
                        row.Cells[3].Value = "offline";
                    }
                }
            }
            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,
                Application = (msg.IsDataNetClient ? "DataNet" : msg.IsTickNetClient ? "TickNet" : "DataExport")
            };
            DataManager.AddNewLog(logmodel);
            UpdateLogsTable();
        }