Esempio n. 1
0
        public Layer(PPDSheet sheet, IDProvider idProvider, bool isSelected)
        {
            var marks         = sheet.GetSortedData().Select(m => new EditorMarkInfo(m, this)).ToArray();
            var selectedMarks = new HashSet <Mark>(sheet.GetAreaData());

            if (selectedMarks.Count == 0)
            {
                var selectedMark = sheet.SelectedMark;
                if (selectedMark == null)
                {
                    SelectedMark = null;
                }
                else
                {
                    SelectedMark = marks.FirstOrDefault(m => m.Mark == selectedMark);
                }
                SelectedMarks = new EditorMarkInfo[0];
            }
            else
            {
                SelectedMarks = marks.Where(m => selectedMarks.Contains(m.Mark)).ToArray();
            }
            Marks = marks;

            manager    = new ChangeMarkPropertyManager(sheet, this, idProvider);
            IsSelected = isSelected;
        }
Esempio n. 2
0
        /// <summary>
        /// 待写入消息历史的队列处理
        /// </summary>
        private void WriteToHistoryQueueWork()
        {
            while (true)
            {
                //出队
                var item = QueueWriteToHistory.DeQueue();

                if (null != item)
                {
                    var userNameDic = ServicesProvider.Items.UserService.GetUserName(new[] { item.SenderID, item.ReceiverID });

                    MessageHistory message = new MessageHistory
                    {
                        Content      = item.Content,
                        MessageID    = IDProvider.NewId(),
                        MessageType  = item.MessageType,
                        ReadTime     = item.SendTime.ToDateTime(),
                        ReceiverID   = item.ReceiverID,
                        ReceiverName = userNameDic.ContainsKey(item.ReceiverID) ? userNameDic[item.ReceiverID] : item.ReceiverName,
                        SenderID     = item.SenderID,
                        SenderName   = userNameDic.ContainsKey(item.SenderID) ? userNameDic[item.SenderID] : string.Empty,
                        SendTime     = item.SendTime.ToDateTime()
                    };

                    //写入数据库
                    ServicesProvider.Items.MessageHistoryService.AddMessage(message);
                }

                //避免无数据操作时CPU空转
                Thread.Sleep(100);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 文本消息包接收后处理
        /// </summary>
        /// <param name="e"></param>
        void RecieveForTextMessage(PackageReceiveArgs e)
        {
            var msg = e.Message as TextMessage;

            if (null == msg)
            {
                return;
            }

            msg.MessageID = IDProvider.NewId();
            msg.SendTime  = DateTime.Now.ToDateTimeString();

            //加入写入历史消息队列
            QueueWriteToHistory.EnQueue(msg);

            IChannel channel = GetUserChannel(msg.ReceiverID);

            //如果消息接收者已连接
            if (null != channel)
            {
                //发送消息给接收者
                Server.Send(msg, channel);

                //放入发送队列
                //QueueWaitSend.EnQueue(msg);
            }
            else
            {
                //加入未发送消息队列
                QueueUnSendToDB.EnQueue(msg);

                //记录未发送消息标识
                AddUnrecived(msg.ReceiverID, 1);
            }
        }
Esempio n. 4
0
 public ChangeMarkPropertyManager(PPDSheet sheet, Layer layer, IDProvider idProvider)
 {
     tasks      = new List <TaskBase>();
     Sheet      = sheet;
     Layer      = layer;
     IDProvider = idProvider;
 }
Esempio n. 5
0
        /// <summary>
        /// 添加用户系统消息
        /// </summary>
        /// <param name="userIDs">用户ID集合</param>
        /// <param name="option">消息类型,<see cref="MessageTemplateOption"/></param>
        /// <param name="relateDataID">消息关联的数据ID,如:某某订单ID</param>
        /// <param name="title">消息标题</param>
        /// <param name="content">消息内容</param>
        /// <param name="sign">消息发送方签名(如:XXX公司)</param>
        /// <returns></returns>
        public bool AddUserMessage(long[] userIDs, MessageTemplateOption option, string relateDataID, string title, string content, string sign)
        {
            using (var db = new DataContext())
            {
                if (userIDs == null || userIDs.Length < 1)
                {
                    return(false);
                }

                foreach (var userId in userIDs)
                {
                    var item = new User_Message
                    {
                        MessageID   = IDProvider.NewId(),
                        Content     = content ?? string.Empty,
                        CreateTime  = DateTime.Now,
                        IsDelete    = false,
                        IsRead      = false,
                        MessageType = (int)option,
                        RefDataID   = relateDataID,
                        Sign        = sign ?? string.Empty,
                        Title       = title,
                        UserID      = userId
                    };

                    db.User_Message.Add(item);
                }

                return(db.SaveChanges() > 0);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 登录操作队列处理
        /// </summary>
        private void LoginQueueWork()
        {
            while (true)
            {
                //出队
                var item = QueueLogin.DeQueue();

                if (null != item)
                {
                    UserLoginRecords records = new UserLoginRecords
                    {
                        AreaID         = item.AreaID,
                        AreaName       = item.AreaName,
                        Latitude       = item.Latitude,
                        LoginTime      = item.LoginTime.ToDateTime(),
                        Longitude      = item.Longitude,
                        RecordID       = IDProvider.NewId(),
                        TerminalDevice = item.TerminalDevice,
                        UserID         = item.UserID
                    };

                    //更新用户信息
                    ServicesProvider.Items.UserService.UpdateLastInfo(item.UserID, item.UserName, item.UserType, item.AreaName, item.LoginTime.ToDateTime());

                    //记录登录操作信息
                    ServicesProvider.Items.UserLoginRecordService.AddRecord(records);
                }

                //避免无数据操作时CPU空转
                Thread.Sleep(100);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 未发送出去消息队列处理
        /// </summary>
        private void UnsendQueueWork()
        {
            while (true)
            {
                //出队
                var item = QueueUnSendToDB.DeQueue();

                if (null != item)
                {
                    UnSendMessage message = new UnSendMessage
                    {
                        Content     = item.Content,
                        MessageID   = IDProvider.NewId(),
                        MessageType = item.MessageType,
                        ReceiverID  = item.ReceiverID,
                        SenderID    = item.SenderID,
                        SenderName  = item.SernderName,
                        SendTime    = item.SendTime.ToDateTime()
                    };

                    //写入数据库
                    ServicesProvider.Items.UnsendMessageService.AddMessage(message);
                }

                //避免无数据操作时CPU空转
                Thread.Sleep(100);
            }
        }
 public static IDProvider getInstance()
 {
     if ( _instance == null )
     {
         _instance = new IDProvider();
     }
     return _instance;
 }
Esempio n. 9
0
        private void CreateSAMLResponse()
        {
            IDProvider config = IDProvider.GetConfig();

            SAMLResponse.ID           = SAMLUtility.GenerateID();
            SAMLResponse.Version      = SAMLUtility.VERSION;
            SAMLResponse.IssueInstant = DateTime.UtcNow.AddMinutes(10);
            SAMLResponse.InResponseTo = SAMLRequest.ID;

            SAMLResponse.Issuer       = new NameIDType();
            SAMLResponse.Issuer.Value = config.id;

            SAMLResponse.Status            = new StatusType();
            SAMLResponse.Status.StatusCode = new StatusCodeType();

            // Atualiza Cookie de sistemas autenticados e configura Status
            HttpCookie cookie = this.Context.Request.Cookies["SistemasLogged"];

            if (cookie != null)
            {
                // Carrega a Entidade SYS_Sistema apartir do caminho de logout
                SYS_Sistema entitySistema = new SYS_Sistema {
                    sis_caminhoLogout = ((NameIDType)SAMLRequest.Item).Value
                };
                if (SYS_SistemaBO.GetSelectBy_sis_caminho(entitySistema, SYS_SistemaBO.TypePath.logout))
                {
                    // Remove o sistema do Cookie
                    cookie.Values.Remove(entitySistema.sis_id.ToString());
                    // Atualiza dados do Cookie
                    this.Context.Response.Cookies.Set(cookie);

                    if (!cookie.Values.AllKeys.Contains(entitySistema.sis_id.ToString()))
                    {
                        SAMLResponse.Status.StatusCode.Value = SAMLUtility.StatusCodes.Success;
                        SAMLResponse.Status.StatusMessage    = "A solicitação foi realizada com sucesso.";
                    }
                    else
                    {
                        SAMLResponse.Status.StatusCode.Value = SAMLUtility.StatusCodes.RequestDenied;
                        SAMLResponse.Status.StatusMessage    = "Não foi possível atender a solicitação, o sistema emissor da requisição não está autenticado.";
                    }
                }
                else
                {
                    SAMLResponse.Status.StatusCode.Value = SAMLUtility.StatusCodes.RequestDenied;
                    SAMLResponse.Status.StatusMessage    = "Não foi possível atender a solicitação, sistema emissor da requisição não está cadastrado corretamente.";;
                }
            }
            else
            {
                SAMLResponse.Status.StatusCode.Value = SAMLUtility.StatusCodes.RequestDenied;
                SAMLResponse.Status.StatusMessage    = "Não foi possível atender a solicitação.";
            }

            HttpPostBinding binding = new HttpPostBinding(SAMLResponse, HttpUtility.UrlDecode(this.Context.Request[HttpBindingConstants.RelayState]));

            binding.SendResponse(this.Context, HttpUtility.UrlDecode(this.Context.Request[HttpBindingConstants.RelayState]), SAMLTypeSSO.logout);
        }
Esempio n. 10
0
 public WorkItem(string title, string description, IBoard board)
 {
     this.board              = board;
     this.id                 = IDProvider.GenerateUniqueID();
     this.Title              = title;
     this.Description        = description;
     this.listOfComments     = new List <IComment>();
     this.listOfHistoryItems = new List <IHistoryItem>();
 }
Esempio n. 11
0
        public IDProvider Clone()
        {
            var ret = new IDProvider(0)
            {
                nextID = nextID
            };

            return(ret);
        }
Esempio n. 12
0
 public string[] GetProperties() => new string[]
 {
     ID.ToString(),
         IDProvider.ToString(),
         IDProduct.ToString(),
         Count.ToString(),
         DataPurchase.ToShortDateString(),
         Cost.ToString()
 };
Esempio n. 13
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            IocProvider.Container = host.Services;
            IDProvider.InitIDWorker();
            SerilogProvider.StartWithMysql(IocProvider.GetService <IServiceConfigurationAgent>()?.LogConnectionString, "jpservice_log");
            host.Run();
        }
Esempio n. 14
0
        public MiniTask()
        {
            Notes    = new List <MiniTaskNote>();
            AllTasks = new List <MiniTask>();

            DateCreated = DateTime.Now;
            DateDue     = DateTime.Now;

            ID = IDProvider.GetNextID();
        }
Esempio n. 15
0
 static System_Level GetLevel(string name, int minScore)
 {
     return(new System_Level
     {
         CreateTime = DateTime.Now,
         Enable = true,
         Icon = string.Empty,
         LevelID = IDProvider.NewId(),
         Min = minScore,
         Name = name
     });
 }
Esempio n. 16
0
        public static Entity Create(EntityType type)
        {
            var entity = new Entity(IDProvider.Get());

            switch (type)
            {
            case EntityType.Player:
                entity.AddComponent(new Position(entity));
                entity.AddComponent(new Movement(entity));
                entity.AddComponent(new Property(entity));
                entity.AddComponent(new PlayerModel(entity));
                entity.AddComponent(new Ability(entity));
                entity.AddComponent(new Modifier(entity));
                entity.AddComponent(new Collider(entity));
                entity.AddComponent(new Clickable(entity));
                entity.AddComponent(new Camp(entity));
                break;

            case EntityType.Computer:
                entity.AddComponent(new Position(entity));
                entity.AddComponent(new Movement(entity));
                entity.AddComponent(new Property(entity));
                entity.AddComponent(new Brain(entity));
                entity.AddComponent(new PlayerModel(entity));
                entity.AddComponent(new Ability(entity));
                entity.AddComponent(new Modifier(entity));
                entity.AddComponent(new Collider(entity));
                entity.AddComponent(new Clickable(entity));
                entity.AddComponent(new Camp(entity));
                break;

            case EntityType.LinearProjectile:
                entity.AddComponent(new Position(entity));
                entity.AddComponent(new Movement(entity));
                entity.AddComponent(new Model(entity));
                entity.AddComponent(new Collider(entity));
                entity.AddComponent(new Camp(entity));
                break;

            case EntityType.TrackingProjectile:
                entity.AddComponent(new Position(entity));
                entity.AddComponent(new Movement(entity));
                entity.AddComponent(new Model(entity));
                entity.AddComponent(new Tracker(entity));
                entity.AddComponent(new Collider(entity));
                entity.AddComponent(new Camp(entity));
                break;
            }

            return(entity);
        }
Esempio n. 17
0
        /// <summary>
        /// 发送
        /// </summary>
        /// <param name="identityType"><seealso cref="IdentityType"/></param>
        /// <param name="senderId">发送者ID</param>
        /// <param name="mobiles">发送的目标手机号</param>
        /// <param name="uid">业务ID</param>
        /// <returns></returns>
        internal async Task <SmsSendResult> SendSms(IdentityType identityType, long senderId, IEnumerable <string> mobiles, object uid)
        {
            try
            {
                string strId = (uid ?? string.Empty).ToString();

                var result = await MiddlewareConfig.Options.SendProvider.SendSmsAsync(mobiles, Content, strId);

                //添加发送记录
                List <SmsSendRecords> records = new List <SmsSendRecords>();

                foreach (var m in realSendMobiles)
                {
                    SmsSendRecords record = new SmsSendRecords
                    {
                        IsSuccess  = result.IsSuccess,
                        Message    = Content,
                        Mobile     = m,
                        Remark     = result.Remark,
                        SenderId   = senderId,
                        SenderType = (int)identityType,
                        SmsType    = (int)Option,
                        SendID     = IDProvider.NewId(),
                        SendTime   = DateTime.Now
                    };

                    records.Add(record);
                }

                new SmsSendRecordsService().AddRecord(records);

                return(result);
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 添加商户系统消息
        /// </summary>
        /// <param name="merchantID">商家ID</param>
        /// <param name="option">消息类型,<see cref="MessageTemplateOption"/></param>
        /// <param name="relateDataID">消息关联的数据ID,如:某某订单ID</param>
        /// <param name="title">消息标题</param>
        /// <param name="content">消息内容</param>
        /// <param name="sign">消息发送方签名(如:XXX公司)</param>
        /// <returns></returns>
        public bool AddMerchantMessage(long merchantID, MessageTemplateOption option, string relateDataID, string title, string content, string sign)
        {
            using (var db = new DataContext())
            {
                var item = new Merchant_Message
                {
                    MessageID   = IDProvider.NewId(),
                    Content     = content,
                    CreateTime  = DateTime.Now,
                    IsDelete    = false,
                    IsRead      = false,
                    MessageType = (int)option,
                    MerchantID  = merchantID,
                    RefDataID   = relateDataID,
                    Sign        = sign,
                    Title       = title
                };

                db.Merchant_Message.Add(item);

                return(db.SaveChanges() > 0);
            }
        }
Esempio n. 19
0
        /// <summary>
        /// 初始化超级管理员
        /// </summary>
        /// <returns></returns>
        public static int InitSuperAdmin(string account, string pwd)
        {
            using (var db = new DataContext())
            {
                string password = Cryptography.MD5Encrypt(Cryptography.SHA1Encrypt(Cryptography.MD5Encrypt(pwd)));

                db.Admin_Account.Add(new Admin_Account
                {
                    AdminID    = IDProvider.NewId(),
                    CreateTime = DateTime.Now,
                    DataStatus = true,
                    LastIp     = "127.0.0.1",
                    LastTime   = DateTime.Now,
                    Logins     = 0,
                    Password   = password,
                    PowerLevel = (int)EnumPowerLevel.Super,
                    Realname   = "超级管理员",
                    Username   = account,
                    UserPic    = string.Empty
                });

                return(db.SaveChanges());
            }
        }
Esempio n. 20
0
 public MiniTopic()
 {
     ID = IDProvider.GetNextID();
 }
Esempio n. 21
0
    private void CreateSAMLResponse()
    {
        FormsIdentity id = null;

        if (HttpContext.Current.User != null)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (HttpContext.Current.User.Identity is FormsIdentity)
                {
                    id = (FormsIdentity)HttpContext.Current.User.Identity;
                }
            }
        }

        DateTime notBefore    = (id != null ? id.Ticket.IssueDate.ToUniversalTime() : DateTime.UtcNow);
        DateTime notOnOrAfter = (id != null ? id.Ticket.Expiration.ToUniversalTime() : DateTime.UtcNow.AddMinutes(30));

        IDProvider config = IDProvider.GetConfig();

        SAMLResponse.Status                  = new StatusType();
        SAMLResponse.Status.StatusCode       = new StatusCodeType();
        SAMLResponse.Status.StatusCode.Value = SAMLUtility.StatusCodes.Success;

        AssertionType assert = new AssertionType();

        assert.ID           = SAMLUtility.GenerateID();
        assert.IssueInstant = DateTime.UtcNow.AddMinutes(10);

        assert.Issuer       = new NameIDType();
        assert.Issuer.Value = config.id;

        SubjectConfirmationType subjectConfirmation = new SubjectConfirmationType();

        subjectConfirmation.Method = "urn:oasis:names:tc:SAML:2.0:cm:bearer";
        subjectConfirmation.SubjectConfirmationData              = new SubjectConfirmationDataType();
        subjectConfirmation.SubjectConfirmationData.Recipient    = SAMLRequest.Issuer;
        subjectConfirmation.SubjectConfirmationData.InResponseTo = SAMLRequest.Request.ID;
        subjectConfirmation.SubjectConfirmationData.NotOnOrAfter = notOnOrAfter;

        NameIDType nameID = new NameIDType();

        nameID.Format = SAMLUtility.NameIdentifierFormats.Transient;
        nameID.Value  = (id != null ? id.Name : UtilBO.FormatNameFormsAuthentication(this.__SessionWEB.__UsuarioWEB.Usuario));

        assert.Subject       = new SubjectType();
        assert.Subject.Items = new object[] { subjectConfirmation, nameID };

        assert.Conditions                       = new ConditionsType();
        assert.Conditions.NotBefore             = notBefore;
        assert.Conditions.NotOnOrAfter          = notOnOrAfter;
        assert.Conditions.NotBeforeSpecified    = true;
        assert.Conditions.NotOnOrAfterSpecified = true;

        AudienceRestrictionType audienceRestriction = new AudienceRestrictionType();

        audienceRestriction.Audience = new string[] { SAMLRequest.Issuer };
        assert.Conditions.Items      = new ConditionAbstractType[] { audienceRestriction };

        AuthnStatementType authnStatement = new AuthnStatementType();

        authnStatement.AuthnInstant = DateTime.UtcNow;
        authnStatement.SessionIndex = SAMLUtility.GenerateID();

        authnStatement.AuthnContext       = new AuthnContextType();
        authnStatement.AuthnContext.Items =
            new object[] { "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport" };

        authnStatement.AuthnContext.ItemsElementName =
            new ItemsChoiceType5[] { ItemsChoiceType5.AuthnContextClassRef };

        StatementAbstractType[] statementAbstract = new StatementAbstractType[] { authnStatement };
        assert.Items       = statementAbstract;
        SAMLResponse.Items = new object[] { assert };

        string xmlResponse = SAMLUtility.SerializeToXmlString(SAMLResponse);

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(xmlResponse);
        XmlSignatureUtils.SignDocument(doc, assert.ID);
        SAMLResponse = SAMLUtility.DeserializeFromXmlString <ResponseType>(doc.InnerXml);

        HttpPostBinding binding = new HttpPostBinding(SAMLResponse, HttpUtility.UrlDecode(Request[HttpBindingConstants.RelayState]));

        binding.SendResponse(this.Context, HttpUtility.UrlDecode(SAMLRequest.AssertionConsumerServiceURL), SAMLTypeSSO.signon);
    }
Esempio n. 22
0
        /// <summary>
        /// Retorna um XmlElement contendo informações do Saml
        /// </summary>
        /// <returns></returns>
        private XmlElement GetElementSAML(bool full)
        {
            // Cria elemento SAML
            XmlElement xmlElementSAML = xml.CreateElement("Saml");

            xmlElementSAML.SetAttribute("type", "Identity Provider");
            xmlElementSAML.SetAttribute("version", SAMLUtility.VERSION);

            // Cria elemento IDProvider
            string     statusIDProvider     = string.Empty;
            XmlElement xmlElementIDProvider = xml.CreateElement("IDProvider");

            xmlElementSAML.AppendChild(xmlElementIDProvider);
            try
            {
                IDProvider config = IDProvider.GetConfig();
                if (config != null)
                {
                    xmlElementIDProvider.SetAttribute("id", config.id);
                    statusIDProvider = StatusBO.Success;
                }
                else
                {
                    statusIDProvider = "Não foi possível encontrar as configurações.";
                }
            }
            catch (Exception ex)
            {
                statusIDProvider = ex.Message;
            }
            xmlElementIDProvider.SetAttribute("status", statusIDProvider);

            if (full)
            {
                // Cria elemento Logged
                string     statusLogged     = string.Empty;
                XmlElement xmlElementLogged = xml.CreateElement("Logged");
                xmlElementSAML.AppendChild(xmlElementLogged);
                try
                {
                    HttpCookie cookie = Context.Request.Cookies["SistemasLogged"];
                    xmlElementLogged.SetAttribute("count", (cookie == null ? "0" : cookie.Values.AllKeys.Count(p => p != null).ToString()));
                    if (cookie != null)
                    {
                        foreach (String str in cookie.Values.AllKeys.Where(p => p != null))
                        {
                            XmlElement xmlElement = xml.CreateElement("Application");
                            xmlElementLogged.AppendChild(xmlElement);
                            xmlElement.SetAttribute("name", cookie.Values[str]);
                        }
                    }
                    statusLogged = StatusBO.Success;
                }
                catch (Exception ex)
                {
                    statusLogged = ex.Message;
                }
                xmlElementLogged.SetAttribute("status", statusLogged);

                // Cria elemento Path
                XmlElement xmlElementPath = xml.CreateElement("Path");
                xmlElementSAML.AppendChild(xmlElementPath);
                try
                {
                    IList <Autenticador.Entities.SYS_Sistema> list          = SYS_SistemaBO.GetSelectBy_usu_id(__SessionWEB.__UsuarioWEB.Usuario.usu_id);
                    Autenticador.Entities.SYS_Sistema         entityCoreSSO = list.Where(p => p.sis_id == ApplicationWEB.SistemaID).First();
                    list.Remove(entityCoreSSO);

                    foreach (Autenticador.Entities.SYS_Sistema entitySistema in list)
                    {
                        string     status     = string.Empty;
                        XmlElement xmlElement = xml.CreateElement("Application");
                        xmlElementPath.AppendChild(xmlElement);
                        xmlElement.SetAttribute("name", entitySistema.sis_nome);
                        xmlElement.SetAttribute("login", entitySistema.sis_caminho);
                        xmlElement.SetAttribute("logout", entitySistema.sis_caminhoLogout);

                        // Validação url de login
                        if (string.IsNullOrEmpty(entitySistema.sis_caminho))
                        {
                            status += "Url de login inválida.";
                        }
                        else if (entitySistema.sis_caminho.Contains(entityCoreSSO.sis_caminho))
                        {
                            status += "A url de login contém um valor possivelmente inválido, que pode entrar em loop ao redirecionar.";
                        }
                        // Validação url de logout
                        if (string.IsNullOrEmpty(entitySistema.sis_caminhoLogout))
                        {
                            status += "Url de logout inválida.";
                        }
                        else if (entitySistema.sis_caminhoLogout.Contains(entityCoreSSO.sis_caminhoLogout))
                        {
                            status += "A url de logout contém um valor possivelmente inválido, que pode entrar em loop ao redirecionar.";
                        }

                        if (string.IsNullOrEmpty(status))
                        {
                            status = StatusBO.Success;
                        }
                        xmlElement.SetAttribute("status", status);
                    }
                }
                catch (Exception ex)
                {
                    xmlElementPath.SetAttribute("error", ex.Message);
                }
            }

            return(xmlElementSAML);
        }