Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }