Ejemplo n.º 1
0
        public List <InfoTypeInfo> GetListByCorpid(int corpid, bool fromCache = false)
        {
            List <InfoTypeInfo> list     = GetList(fromCache);
            List <InfoTypeInfo> listcorp = list.FindAll(l => l.CorporationID == corpid);

            if (corpid == 0)
            {
                return(listcorp);
            }
            List <InfoTypeInfo> listsys = list.FindAll(l => l.CorporationID == 0);

            if (listsys.Exists(l => !listcorp.Exists(c => c.ParentID == l.ID)))
            {
                foreach (InfoTypeInfo info in listsys.FindAll(l => !listcorp.Exists(c => c.ParentID == l.ID)))
                {
                    InfoTypeInfo newentity = new InfoTypeInfo()
                    {
                        CorporationID = corpid,
                        DataLevel     = 0,
                        Lockday       = 0,
                        Locked        = 0,
                        Locklevel     = string.Empty,
                        LocklevelName = string.Empty,
                        Name          = info.Name,
                        ParentID      = info.ID
                    };
                    Add(newentity);
                }
                ReloadInfoTypeListCache();
                list     = GetList(fromCache);
                listcorp = list.FindAll(l => l.CorporationID == corpid);
            }

            return(listcorp.OrderBy(l => l.DataLevel).ThenBy(l => l.Sort).ToList());
        }
Ejemplo n.º 2
0
        public string GetName(int id)
        {
            InfoTypeInfo entity = GetModel(id, true);

            if (entity == null)
            {
                return(string.Empty);
            }
            return(entity.Name);
        }
Ejemplo n.º 3
0
        public InfoTypeInfo GetModel(int id, bool fromCache = false)
        {
            InfoTypeInfo entity = null;

            List <InfoTypeInfo> list = GetList(fromCache);

            entity = list.Find(c => c.ID == id);

            return(entity);
        }
Ejemplo n.º 4
0
        public static InfoTypeInfo PopulateInfoTypeInfo(IDataReader reader)
        {
            InfoTypeInfo entity = new InfoTypeInfo()
            {
                ID            = (int)reader["ID"],
                Name          = reader["Name"] as string,
                ParentID      = (int)reader["ParentID"],
                ParentName    = reader["ParentName"] as string,
                Locked        = (int)reader["Locked"],
                Lockday       = (int)reader["Lockday"],
                Locklevel     = reader["Locklevel"] as string,
                LocklevelName = reader["LocklevelName"] as string,
                DataLevel     = (int)reader["DataLevel"],
                CorporationID = (int)reader["CorporationID"],
                Sort          = DataConvert.SafeInt(reader["Sort"])
            };

            return(entity);
        }
Ejemplo n.º 5
0
 private void FillData(InfoTypeInfo entity)
 {
     entity.Name = txtName.Value;
     entity.Locked = DataConvert.SafeInt(rblLocked.SelectedValue);
     entity.Lockday = DataConvert.SafeInt(txtLockday.Value);
     entity.CorporationID = GetInt("corpid");
     List<string> locklevel = new List<string>();
     List<string> locklevelname = new List<string>();
     foreach (ListItem item in cblLocklevel.Items)
     {
         if (item.Selected)
         {
             locklevel.Add(item.Value);
             locklevelname.Add(item.Text);
         }
     }
     entity.Locklevel = string.Join("|", locklevel);
     entity.LocklevelName = string.Join(",", locklevelname);
 }
Ejemplo n.º 6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            InfoTypeInfo entity = new InfoTypeInfo();
            int id = GetInt("id");

            if (id > 0)
            {
                entity = InfoTypes.Instance.GetModel(id, true);
                FillData(entity);
                InfoTypes.Instance.Update(entity);
            }
            else
            {
                FillData(entity);
                entity.DataLevel = GetInt("corpid") == 0 ? 0 : 1;
                InfoTypes.Instance.Add(entity);
            }

            InfoTypes.Instance.ReloadInfoTypeListCache();

            Response.Redirect(string.IsNullOrEmpty(FromUrl) ? "infotypemg.aspx" : FromUrl);
        }
Ejemplo n.º 7
0
        public List<InfoTypeInfo> GetListByCorpid(int corpid, bool fromCache = false)
        {
            List<InfoTypeInfo> list = GetList(fromCache);
            List<InfoTypeInfo> listcorp = list.FindAll(l => l.CorporationID == corpid);
            if (corpid == 0) return listcorp;
            List<InfoTypeInfo> listsys = list.FindAll(l => l.CorporationID == 0);

            if (listsys.Exists(l => !listcorp.Exists(c => c.ParentID == l.ID)))
            {
                foreach (InfoTypeInfo info in listsys.FindAll(l => !listcorp.Exists(c => c.ParentID == l.ID)))
                {
                    InfoTypeInfo newentity = new InfoTypeInfo()
                    {
                        CorporationID = corpid,
                        DataLevel = 0,
                        Lockday = 0,
                        Locked = 0,
                        Locklevel = string.Empty,
                        LocklevelName = string.Empty,
                        Name = info.Name,
                        ParentID = info.ID
                    };
                    Add(newentity);
                }
                ReloadInfoTypeListCache();
                list = GetList(fromCache);
                listcorp = list.FindAll(l => l.CorporationID == corpid);
            }

            return listcorp.OrderBy(l => l.DataLevel).ThenBy(l => l.Sort).ToList();
        }
Ejemplo n.º 8
0
 public void Add(InfoTypeInfo entity)
 {
     CommonDataProvider.Instance().AddInfoType(entity);
 }
Ejemplo n.º 9
0
 public void Update(InfoTypeInfo entity)
 {
     CommonDataProvider.Instance().UpdateInfoType(entity);
 }
Ejemplo n.º 10
0
 public void Update(InfoTypeInfo entity)
 {
     CommonDataProvider.Instance().UpdateInfoType(entity);
 }
Ejemplo n.º 11
0
 public abstract void AddInfoType(InfoTypeInfo entity);
Ejemplo n.º 12
0
 public override void AddInfoType(InfoTypeInfo entity)
 {
     string sql = @"INSERT INTO ComOpp_InfoType(
         [Name]
         ,[CorporationID]
         ,[Locked]
         ,[Lockday]
         ,[Locklevel]
         ,[LocklevelName]
         ,[DataLevel]
         ,[ParentID]
         ,[Sort]
     )VALUES(
         @Name
         ,@CorporationID
         ,@Locked
         ,@Lockday
         ,@Locklevel
         ,@LocklevelName
         ,@DataLevel
         ,@ParentID
         ,(SELECT ISNULL(MAX([Sort]),0) + 1 FROM ComOpp_InfoType WHERE [CorporationID] = @CorporationID)
     )";
     SqlParameter[] p =
     {
         new SqlParameter("@Name",entity.Name),
         new SqlParameter("@CorporationID",entity.CorporationID),
         new SqlParameter("@Locked",entity.Locked),
         new SqlParameter("@Lockday",entity.Lockday),
         new SqlParameter("@Locklevel",entity.Locklevel),
         new SqlParameter("@LocklevelName",entity.LocklevelName),
         new SqlParameter("@DataLevel",entity.DataLevel),
         new SqlParameter("@ParentID",entity.ParentID)
     };
     SqlHelper.ExecuteNonQuery(_con, CommandType.Text, sql, p);
 }
Ejemplo n.º 13
0
 public override void UpdateInfoType(InfoTypeInfo entity)
 {
     string sql = @"
     UPDATE ComOpp_InfoType set
         Name = @Name
         ,Locked = @Locked
         ,Lockday = @Lockday
         ,Locklevel = @Locklevel
         ,LocklevelName = @LocklevelName
     WHERE ID=@ID";
     SqlParameter[] parameters =
     {
         new SqlParameter("@ID", entity.ID),
         new SqlParameter("@Name", entity.Name),
         new SqlParameter("@Locked", entity.Locked),
         new SqlParameter("@Lockday", entity.Lockday),
         new SqlParameter("@Locklevel", entity.Locklevel),
         new SqlParameter("@LocklevelName", entity.LocklevelName)
     };
     SqlHelper.ExecuteNonQuery(_con, CommandType.Text, sql, parameters);
 }
Ejemplo n.º 14
0
        private void LoadData()
        {
            int id = GetInt("id");
            if (id > 0)
            {
                CurrentInfoType = InfoTypes.Instance.GetModel(id);
                if (CurrentInfoType == null)
                    WriteMessage("/message.aspx", "系统提示", "无效信息类型!", "", "/index.aspx");
                else
                {
                    if (!Admin.Administrator && Admin.CorporationID != CurrentInfoType.CorporationID)
                        WriteMessage("/message.aspx", "系统提示", "没有权限!", "", "/index.aspx");
                    List<CustomerLevelInfo> cllist = CustomerLevels.Instance.GetListByCorpid(CurrentInfoType.CorporationID, true);
                    cblLocklevel.DataSource = cllist;
                    cblLocklevel.DataTextField = "Name";
                    cblLocklevel.DataValueField = "ID";
                    cblLocklevel.DataBind();
                    foreach (ListItem item in cblLocklevel.Items)
                    {
                        if (CurrentInfoType.Locklevel.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Contains(item.Value))
                            item.Selected = true;
                    }

                    txtName.Value = CurrentInfoType.Name;
                    SetSelectedByValue(rblLocked, CurrentInfoType.Locked.ToString());
                    txtLockday.Value = CurrentInfoType.Lockday.ToString();
                    if (!Admin.Administrator && CurrentInfoType.DataLevel == 0)
                        txtName.Attributes["readonly"] = "true";
                }
            }
            else
            {
                int corpid = GetInt("corpid");

                if (corpid > 0)
                {
                    List<CustomerLevelInfo> cllist = CustomerLevels.Instance.GetListByCorpid(corpid, true);
                    cblLocklevel.DataSource = cllist;
                    cblLocklevel.DataTextField = "Name";
                    cblLocklevel.DataValueField = "ID";
                    cblLocklevel.DataBind();
                }
            }
        }
Ejemplo n.º 15
0
 public abstract void UpdateInfoType(InfoTypeInfo entity);
Ejemplo n.º 16
0
 public abstract void AddInfoType(InfoTypeInfo entity);
Ejemplo n.º 17
0
 public abstract void UpdateInfoType(InfoTypeInfo entity);
Ejemplo n.º 18
0
 public void Add(InfoTypeInfo entity)
 {
     CommonDataProvider.Instance().AddInfoType(entity);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 客户降级(每天凌晨1点5分开始执行)
        /// </summary>
        public void CustomerDegrade()
        {
            if (DateTime.Now.Hour == 1 && DateTime.Now.Minute == 5)
            {
                if (!hasruncustomerdegrade)
                {
                    hasruncustomerdegrade = true;
                    try
                    {
                        EventLogs.JobLog("开始作业-客户降级");
                        List <CorporationInfo> list = Corporations.Instance.GetList(true);
                        foreach (CorporationInfo corpinfo in list)
                        {
                            bool hasdeeldata = false;
                            List <CustomerInfo>      clist     = GetCustomerListByCorporation(corpinfo.ID, true);
                            List <CustomerLevelInfo> levellist = CustomerLevels.Instance.GetListByCorpid(corpinfo.ID, true);

                            foreach (CustomerInfo cinfo in clist)
                            {
                                if (cinfo.LastCustomerLevelID > 0)
                                {
                                    CustomerLevelInfo level    = CustomerLevels.Instance.GetModel(cinfo.LastCustomerLevelID, true);
                                    InfoTypeInfo      infotype = InfoTypes.Instance.GetModel(cinfo.InfoTypeID);

                                    //如果已经是最低一级则不处理
                                    if (levellist.FindIndex(l => l.ID == cinfo.LastCustomerLevelID) == levellist.Count - 1)
                                    {
                                        continue;
                                    }

                                    if (level != null && level.Drtday > 0)
                                    {
                                        DateTime lastconnecttime = DateTime.Now;
                                        if (DateTime.TryParse(cinfo.LastConnectTime, out lastconnecttime))
                                        {
                                            if (infotype != null && infotype.Locked == 1)
                                            {
                                                double days = DateTime.Now.Subtract(lastconnecttime).TotalDays;
                                                //锁定级别判断
                                                if (infotype.Locklevel.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Contains(level.ID.ToString()))
                                                {
                                                    if (days <= infotype.Lockday)
                                                    {
                                                        continue;
                                                    }
                                                }

                                                //做降级处理
                                                if (days > level.Drtday)
                                                {
                                                    SetCustomerLevel(cinfo.ID, levellist[levellist.FindIndex(l => l.ID == cinfo.LastCustomerLevelID) + 1].ID);

                                                    hasdeeldata = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            if (hasdeeldata)
                            {
                                ReloadCustomerListByCorporationCache(corpinfo.ID);
                            }
                        }
                        EventLogs.JobLog("完成作业-客户降级");
                    }
                    catch (Exception ex)
                    {
                        EventLogs.JobError("作业发生错误-客户降级", EventLogs.EVENTID_JOB_ERROR, 0, ex);
                        ExpLog.Write(ex);
                    }
                }
            }
            else
            {
                hasruncustomerdegrade = false;
            }
        }
Ejemplo n.º 20
0
        public static InfoTypeInfo PopulateInfoTypeInfo(IDataReader reader)
        {
            InfoTypeInfo entity = new InfoTypeInfo()
            {
                ID = (int)reader["ID"],
                Name = reader["Name"] as string,
                ParentID = (int)reader["ParentID"],
                ParentName = reader["ParentName"] as string,
                Locked = (int)reader["Locked"],
                Lockday = (int)reader["Lockday"],
                Locklevel = reader["Locklevel"] as string,
                LocklevelName = reader["LocklevelName"] as string,
                DataLevel = (int)reader["DataLevel"],
                CorporationID = (int)reader["CorporationID"],
                Sort = DataConvert.SafeInt(reader["Sort"])
            };

            return entity;
        }