コード例 #1
0
        /// <summary>
        /// send to currently logined client busy symbol list
        /// </summary>
        public void SendBusySymbolListToClient()
        {
            string ticknetstr  = "";
            var    dnetsmblist = new DNetBusySymbolList();

            foreach (var item in BusySymbols)
            {
                if (item.IsDataNet)
                //    datanetstr += item.ID.ToString(CultureInfo.InvariantCulture) + ",";
                {
                    dnetsmblist.BusySymbols.Add(item);
                }

                if (item.IsTickNet)
                {
                    ticknetstr += item.ID.ToString(CultureInfo.InvariantCulture) + ",";
                }
            }

            var xEle = new XElement("BusySymbols",
                                    from emp in dnetsmblist.BusySymbols
                                    select new XElement("BSymbol",
                                                        new XElement("ID", emp.ID),
                                                        from tframes in emp.TimeFrames
                                                        select new XElement("TimeFrame", tframes.TimeFrame)
                                                        ));

            var sw = new StringWriter();
            var tx = new XmlTextWriter(sw);

            xEle.WriteTo(tx);
            string datanetstr = sw.ToString();

            // if (client.IsDexportConnected) client.DexportProxy.SendAllowedSymbolList(str);

            //client.TClientProxy.SendAllowedSymbolGroups(str);
            try
            {
                if (CurrentLoginTypeDnet)
                {
                    CurrentClient.GetClientProxy <IDataAdminService>().SendAllowedSymbolList(datanetstr);
                }

                if (CurrentLoginTypeTnet)
                {
                    CurrentClient.GetClientProxy <IDataAdminService>().SendAllowedSymbolList(ticknetstr);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                ErrorReport(new ErrorInfo
                {
                    AdditionalInformation = "",
                    ErrorText             = ex.Message,
                    InvokeTime            = DateTime.Now,
                    MethodName            = "SendBusySymbolListToClient"
                });
            }
        }
コード例 #2
0
        public void DataExportClientLogin(DataAdminMessageFactory.LoginMessage loginParams, UserModel tempUser)
        {
            if (!(Clients.GetAllItems().Exists(a => a.UserName == loginParams.UsernameMD5)))
            //if client not in list and he/she want to connected with dnet
            {
                AddClient(CurrentClient, loginParams.NetType, tempUser); //add client
                return;
            }
            var clientInList = Clients.GetAllItems().Find(a => a.UserName == loginParams.UsernameMD5);

            if (clientInList.IsDexportConnected == false)
            {
                clientInList.IsDexportConnected = true;
                clientInList.DexportProxy       = CurrentClient.GetClientProxy <IDataAdminService>();
                clientInList.DexportClient      = CurrentClient;
                var usrModel = new UserModel();
                if (OnloggedInLog != null)
                {
                    var msg = new DataAdminMessageFactory.LogMessage
                    {
                        OperationStatus = DataAdminMessageFactory.LogMessage.Status.Finished,
                        LogType         = DataAdminMessageFactory.LogMessage.Log.Login,
                        Time            = DateTime.Now,
                        UserID          = tempUser.Id
                    };
                    var msgMain = "Client " + usrModel.Name + " connected from " + CurrentClient.RemoteEndPoint;
                    OnloggedInLog(msg, msgMain);
                }
                CurrentLoginTypeDexp = true;
                CurrentLoginTypeDnet = false;
                CurrentLoginTypeTnet = false;

                OnClientLogon(tempUser);
            }
        }
コード例 #3
0
        /// <summary>
        ///     Invoked by the client including the parameter.
        /// </summary>
        /// <param name="poco"></param>
        public void SomeRemoteMagic(SimplePoco poco)
        {
            ServerConsole.DebugLine("Recv poco obj from client! {0}: {1}", poco.Id, poco.Title);
            Debug.WriteLine(poco);

            // Get client proxy and invoke a answer to the poco
            var proxy = CurrentClient.GetClientProxy <ITestClient>();

            proxy.SomeClientMagic("Got your poco, ty client!");
        }
コード例 #4
0
        /// <summary>
        /// Pobiera reklame lobby
        /// </summary>
        public void GetAdsLobby()
        {
            using (ISession session = DatabaseSession.Open())
            {
                var    advList = session.QueryOver <AdvertisingModel>().List().ToList();
                Random r       = new Random();
                var    adv     = advList.ElementAt(r.Next(0, advList.Count() - 1));

                CurrentClient.GetClientProxy <IPokerClient>().OnGetAdvertising(adv);
            }
        }
コード例 #5
0
        /// <summary>
        /// Logowanie użytkownika
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        public void DoLogin(string username, string password)
        {
            Console.WriteLine("Logowanie -> " + username);

            if (!ServerOpened)
            {
                throw new ApplicationException("Serwer został chwilowo zamknięty");
            }

            //Sprawdzamy czy użytkownik jest już zalogowany
            var _userLogged = (from c in Clients
                               where c.User.Username == username
                               select c).FirstOrDefault();

            if (_userLogged != null)
            {
                throw new ApplicationException("Użytkownik jest już zalogowany");
            }

            using (var session = DatabaseSession.Open())
            {
                var user = session.QueryOver <UserModel>().
                           Where(u => u.Username == username).SingleOrDefault();

                if (user == null || (user != null && !Helper.CheckPassword(user.Password, password)))
                {
                    throw new ApplicationException("Złe dane do logowania, popraw dane i spróbuj ponownie.");
                }

                //Tworzenie modelu użytkownika
                ClientModel client = new ClientModel(
                    user
                    )
                {
                    Client      = CurrentClient,
                    ClientProxy = CurrentClient.GetClientProxy <IPokerClient>()
                };

                //Dodajemy uchwyt
                client.Client.Disconnected += ClientDisconnected;

                //Dodawanie do listy zalogowanych klientów
                Clients.Add(client);

                //Wysyłanie informacji do użytkownika o poprawnym zalogowaniu
                client.ClientProxy.OnLoginSuccessfull(CurrentClient.ClientId, (UserModel)user);

                Console.WriteLine("Aktualnie zalogowanych -> " + Clients.Count());

                DailyVirtualBonus(user);
            }
        }
コード例 #6
0
 public int RegisterDriver(int driverId, int positionId)
 {
     if (!mDrivers.ContainsKey(driverId))
     {
         Console.WriteLine("Driver registred, driverId = " + driverId);
         mDrivers.Add(driverId, new Driver(driverId, CurrentClient.GetClientProxy <IDriverClient>(), positionId, true, null));
         freeDrivers++;
         SendOrders();
         return(0);
     }
     Console.WriteLine("Driver doesn't registred, driverId = " + driverId);
     return(1);
 }
コード例 #7
0
        // ReSharper restore FunctionNeverReturns

        public void Auth(string key)
        {
            if (!key.Equals(SecurityKey))
            {
                CurrentClient.Disconnect();
                return;
            }

            Authed[CurrentClient.ClientId] = new InformerClient(CurrentClient, CurrentClient.GetClientProxy <IInformerClient>());

            CurrentClient.Disconnected += ClientDisconnected;
            Log.Info("InformerService: Client connected...");

            Authed[CurrentClient.ClientId].Proxy.Authed();
            Authed[CurrentClient.ClientId].Proxy.Message("Test message!");
        }
コード例 #8
0
        public void Login(DataNormalizatorMessageFactory.LoginMessage msg)
        {
            // var users = DataManager.GetUsers();
            var clientProxy     = CurrentClient.GetClientProxy <IDataNormalizatorService>();
            var client          = CurrentClient;
            var collectorClient = new CollectorClient(msg.Username, 1, CurrentClient, clientProxy)
            {
                IndexInAdminList = (int)client.ClientId
            };

            Clients[client.ClientId] = collectorClient;

            //Register to Disconnected event to know when user connection is closed
            client.Disconnected += ClientDisconnected;
            //Start a new task to send user list to mainform
        }
コード例 #9
0
        public void AddClient(IScsServiceClient newClient, char listflag, UserModel usrModel)
        {
            var client = CurrentClient;

            //Get a proxy object to call methods of client when needed
            var clientProxy = CurrentClient.GetClientProxy <IDataAdminService>();
            //Create a DataClient and store it in a collection
            bool dnet       = listflag == 'd';
            bool tnet       = listflag == 't';
            bool dexp       = listflag == 'e';
            var  dataClient = new DataClient(usrModel.Name, usrModel.Id, dnet, tnet)
            {
                IsDexportConnected = dexp
            };

            if (dnet)
            {
                dataClient.DClientProxy = clientProxy;
                dataClient.DnetClient   = CurrentClient;
                CurrentLoginTypeDnet    = true;
                CurrentLoginTypeTnet    = false;
                CurrentLoginTypeDexp    = false;
                dataClient.DexportProxy = null;
                dataClient.TnetClient   = null;
            }
            if (tnet)
            {
                dataClient.TClientProxy = clientProxy;
                dataClient.TnetClient   = CurrentClient;
                CurrentLoginTypeTnet    = true;
                CurrentLoginTypeDnet    = false;
                CurrentLoginTypeDexp    = false;
                dataClient.DnetClient   = null;
                dataClient.DexportProxy = null;
            }
            if (dexp)
            {
                dataClient.DexportProxy  = clientProxy;
                dataClient.DexportClient = CurrentClient;
                CurrentLoginTypeDexp     = true;
                CurrentLoginTypeTnet     = false;
                CurrentLoginTypeDnet     = false;
                dataClient.DnetClient    = null;
                dataClient.TnetClient    = null;
            }

            dataClient.IndexInAdminList = (int)client.ClientId;
            Clients[client.ClientId]    = dataClient;

            //Register to Disconnected event to know when user connection is closed
            client.Disconnected += Client_Disconnected;
            //Start a new task to send user list to mainform

            if (OnloggedInLog != null)
            {
                var msg = new DataAdminMessageFactory.LogMessage
                {
                    OperationStatus = DataAdminMessageFactory.LogMessage.Status.Finished,
                    LogType         = DataAdminMessageFactory.LogMessage.Log.Login,
                    Time            = DateTime.Now,
                    UserID          = usrModel.Id,
                    IsDataNetClient = CurrentLoginTypeDnet,
                    IsTickNetClient = CurrentLoginTypeTnet,
                };
                var msgMain = "Client " + usrModel.Name + " connected from " + CurrentClient.RemoteEndPoint;
                OnloggedInLog(msg, msgMain);
            }
            OnClientLogon(usrModel);
            Task.Factory.StartNew(OnUserListChanged);
        }