示例#1
0
 private void Close(CloseInfo closeInfo)
 {
     this.OnClosing(EventArgs.Empty);
     foreach (var item in this.services.Reverse <ICremaService>())
     {
         item.Close(closeInfo);
     }
     this.services.Clear();
     this.domainContext = null;
     this.dataBases     = null;
     this.userContext   = null;
     foreach (var item in this.plugins)
     {
         item.Release();
     }
     foreach (var item in this.authentications)
     {
         item.InvokeExpiredEvent(Authentication.SystemID);
     }
     this.dispatcher.InvokeAsync(() =>
     {
         this.log?.Dispose();
         this.log = null;
     });
     this.address     = null;
     this.userID      = null;
     this.isConnected = false;
     this.OnClosed(new ClosedEventArgs(closeInfo.Reason, closeInfo.Message));
     CremaLog.Info("Crema closed.");
 }
示例#2
0
文件: User.cs 项目: MutesK/Crema
        public Authentication Login(SecureString password)
        {
            this.Dispatcher.VerifyAccess();
            this.CremaHost.DebugMethod(Authentication.System, this, nameof(Login), this);
            this.ValidateLogin(password);

            var users          = new User[] { this };
            var authentication = new Authentication(new UserAuthenticationProvider(this), Guid.NewGuid());

            this.Sign(authentication);

            if (this.Authentication != null)
            {
                var message   = "다른 기기에서 동일한 아이디로 접속하였습니다.";
                var closeInfo = new CloseInfo()
                {
                    Reason = CloseReason.Reconnected, Message = message
                };
                this.Authentication.InvokeExpiredEvent(this.ID, message);
                this.Container.InvokeUsersLoggedOutEvent(this.Authentication, users, closeInfo);
            }

            this.Authentication = authentication;
            this.IsOnline       = true;
            this.Container.InvokeUsersStateChangedEvent(this.Authentication, users);
            this.Container.InvokeUsersLoggedInEvent(this.Authentication, users);
            return(this.Authentication);
        }
示例#3
0
 void IDomainServiceCallback.OnServiceClosed(SignatureDate signatureDate, CloseInfo closeInfo)
 {
     this.service.Abort();
     this.service = null;
     this.timer?.Dispose();
     this.timer = null;
     this.serviceDispatcher.Dispose();
     this.serviceDispatcher = null;
     this.InvokeAsync(() =>
     {
         this.cremaHost.RemoveService(this);
     }, nameof(IDomainServiceCallback.OnServiceClosed));
 }
示例#4
0
 public void Close(CloseInfo closeInfo)
 {
     this.serviceDispatcher?.Invoke(() =>
     {
         this.timer?.Dispose();
         this.timer = null;
         if (this.service != null)
         {
             try
             {
                 if (closeInfo.Reason != CloseReason.NoResponding)
                 {
                     this.service.Unsubscribe();
                     if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                     {
                         this.service.Close();
                     }
                     else
                     {
                         this.service.Abort();
                     }
                 }
                 else
                 {
                     this.service.Abort();
                 }
             }
             catch
             {
                 this.service.Abort();
             }
             this.service = null;
         }
         this.serviceDispatcher.Dispose();
         this.serviceDispatcher = null;
     });
 }
示例#5
0
 protected override void OnServiceClosed(SignatureDate signatureDate, CloseInfo closeInfo)
 {
     this.Callback.OnServiceClosed(signatureDate, closeInfo);
 }
示例#6
0
        public void InvokeUsersLoggedOutEvent(Authentication authentication, User[] users, CloseInfo closeInfo)
        {
            var eventLog = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeUsersLoggedOutEvent), users, closeInfo.Reason, closeInfo.Message);
            var comment  = EventMessageBuilder.LogoutUser(authentication, users);

            this.CremaHost.Debug(eventLog);
            this.CremaHost.Info(comment);
            this.OnUsersLoggedOut(new ItemsEventArgs <IUser>(authentication, users));
        }
示例#7
0
 protected override void OnServiceClosed(SignatureDate signatureDate, CloseInfo closeInfo)
 {
 }
示例#8
0
 public void InvokeClose(CloseInfo closeInfo)
 {
     this.Close(closeInfo);
 }
示例#9
0
 public void RemoveService(ICremaService service, CloseInfo closeInfo)
 {
     this.closeInfo = closeInfo;
     this.RemoveService(service);
 }
示例#10
0
 public async ValueTask SendChannelClose(CloseInfo info)
 {
     await _protocol.Writer.WriteAsync(new CloseWriter(), info);
 }
示例#11
0
 void IUserServiceCallback.OnServiceClosed(SignatureDate signatureDate, CloseInfo closeInfo)
 {
     throw new NotImplementedException();
 }
示例#12
0
 protected abstract void OnServiceClosed(SignatureDate signatureDate, CloseInfo closeInfo);
示例#13
0
 public ValueTask OnChannelCloseAsync(ushort channelId, CloseInfo info)
 {
     throw new NotImplementedException();
 }
示例#14
0
 ValueTask IConnectionHandler.OnCloseAsync(CloseInfo info)
 {
     Logger.LogDebug($"{nameof(RabbitMQSession)} {ConnectionId}: Close received");
     ConnectionClosedSrc.SetResult(info);
     return(default);
 public static ValueTask SendConnectionCloseAsync(this RabbitMQProtocolWriter protocol, CloseInfo info, CancellationToken token = default)
 {
     return(protocol.SendClose(0, 10, 50, info, token));
 }
示例#16
0
        //выборка из xml
        /// <summary>
        /// чтение хml файла Закрытых фирм
        /// </summary>
        public void ReadCloseXmil()
        {
            XmlDocument xDoc = new XmlDocument();

            DateTime temData = DateTime.Now;

            try
            {
                //загружаем хмл
                xDoc.Load(pathXmlCloseInfo);

                // получим корневой элемент
                XmlElement xRoot = xDoc.DocumentElement;

                // обход всех узлов в корневом элементе
                foreach (XmlNode xnode in xRoot)
                {
                    //обьект для заполнения данными из листа
                    CloseInfo сloseInfo = new CloseInfo();

                    // получаем атрибут name
                    if (xnode.Attributes.Count > 0)

                    {
                        XmlNode attr = xnode.Attributes.GetNamedItem("Name");
                        if (attr != null)
                        {
                            //заполняем обьект
                            //  сompany.Name = attr.Value;
                            //  Console.WriteLine(attr.Value);
                        }
                    }


                    // обходим все дочерние узлы элемента user
                    foreach (XmlNode childnode in xnode.ChildNodes)
                    {
                        // если узел Id
                        if (childnode.Name == "Id")
                        {
                            сloseInfo.Id = int.Parse(childnode.InnerText);
                            Console.WriteLine($"ID {childnode.InnerText}");
                        }

                        // если узел закрытия организации
                        if (childnode.Name == "CloseDate")
                        {
                            сloseInfo.CloseDate = DateTime.Parse(childnode.InnerText);
                            temData             = DateTime.Parse(childnode.InnerText);
                            Console.WriteLine($"дата закрытия  компании: {childnode.InnerText}");
                        }

                        сloseInfo.TimeDayClose = JobDateTTime(temData); //вычитаем даты
                        Console.WriteLine($"Дата закрытия организации: {сloseInfo.TimeDayClose}\t\n");
                    }
                    closeinfoList.Add(сloseInfo);           // при каждой итераци добавляем в список новый обьект
                    SaveDanni(сloseInfo, "CloseInfoItems"); // запись в json
                }

                Console.WriteLine();

                foreach (CloseInfo com in closeinfoList)
                {
                    Console.WriteLine($"Номер ID :{com.Id} - Дата закрытия:{com.CloseDate}  - Количество дней существования фирмы {com.TimeDayClose}");
                }

                //Console.WriteLine($"Количество действующих компаний = {companesTrue}");
            }

            catch (Exception ex)
            {
                Console.WriteLine($"Что то пошло не так...Надо разбиратся...\t\n{ex}");
            }

            Console.Read();
        }