Beispiel #1
0
        /// <summary>
        /// 创建标签
        /// </summary>
        /// <param name="name"></param>
        /// <param name="sortNum"></param>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public int CreateTags(string name, int sortNum, int categoryId)
        {
            var pagesize = 0;

            CheckPageSize(this.PageSize, out pagesize);
            CheckManageId();
            CheckName(name);
            CheckSortNum(sortNum);
            CheckCategoryId(categoryId);
            Manage manage;

            CheckManageId(out manage);
            //CheckExistName(name);
            var tags = new Tags()
            {
                CreateUserId = manage.Id,
                CreateTime   = DateTime.Now,
                KeyWord      = PinyinHelper.PinyinString(name),
                Name         = name,
                SortNum      = sortNum,
                CategoryId   = categoryId
            };

            this._tagsRepository.CreateEntity(tags);
            return(tags.Id);
        }
        public int GetrOrAddUser(string userName)
        {
            using (ProofDataContext pdc = new ProofDataContext())
            {
                string pym = userName.ToLower();
                var    re  = pdc.xt_ryb.Where(p => p.xm == userName).FirstOrDefault();
                if (re == null)
                {
                    int ghid = int.Parse(pdc.xt_ryb.Max(p => p.gh));
                    pdc.xt_ryb.Add(new xt_ryb
                    {
                        id_dept = 3,
                        rylb    = "1",
                        gzlb    = "1",
                        xm      = userName,
                        pym     = PinyinHelper.PinyinString(userName),
                        mm      = "123",
                        xb      = "1",
                        gh      = (ghid + 1).ToString(),
                    });

                    pdc.SaveChanges();
                    re = pdc.xt_ryb.Where(p => p.xm == userName).FirstOrDefault();
                }
                return(re.id);
            }
        }
Beispiel #3
0
 public void SyncUsers(List <User> users)
 {
     using (SunginDataContext sc = new SunginDataContext())
     {
         var ulist = sc.Users.ToList();
         ulist.ForEach(p => p.IsDelete = true);
         users.ForEach(p =>
         {
             var u = ulist.SingleOrDefault(t => t.DdId == p.DdId);
             if (u == null)
             {
                 p.Pinyin = PinyinHelper.PinyinString(p.UserName);
                 sc.Users.Add(p);
             }
             else
             {
                 u.Pinyin     = PinyinHelper.PinyinString(u.UserName);
                 u.UserName   = p.UserName;
                 u.IsLeader   = p.IsLeader;
                 u.DeptId     = p.DeptId;
                 u.DepartName = p.DepartName;
                 u.Avatar     = p.Avatar;
                 u.IsDelete   = false;
             };
         });
         sc.SaveChanges();
     }
 }
Beispiel #4
0
        /// <summary>
        /// 添加多个标签和数量
        /// </summary>
        /// <param name="dicts">标签名称,排序数量</param>
        /// <returns></returns>
        public void CreateTags(IDictionary <string, int> dicts)
        {
            if (dicts == null || dicts.Count <= 0)
            {
                return;
            }
            if (UserId <= 0)
            {
                return;
            }
            IList <Condtion> condtions = new List <Condtion>()
            {
                ConditionEqualId(UserId),
                CondtionEqualState()
            };
            var user = this._userRepository.GetEntity(condtions);

            if (user == null)
            {
                return;
            }
            IList <Tags> updateTags = new List <Tags>();
            IList <Tags> insertTag  = new List <Tags>();

            foreach (var dict in dicts)
            {
                var tags = (from t in this._tagsRepository.GetEntityList()
                            where t.State == false &&
                            t.Name.Trim() == dict.Key
                            select t).FirstOrDefault();

                if (tags != null)
                {
                    tags.SortNum      = dict.Value;
                    tags.UpdateUserId = user.Id;
                    tags.UpdateTime   = DateTime.Now;
                    updateTags.Add(tags);
                }
                else
                {
                    var newTags = new Tags()
                    {
                        Name         = dict.Key,
                        KeyWord      = PinyinHelper.PinyinString(dict.Key),
                        CreateUserId = user.Id,
                        CreateTime   = DateTime.Now,
                        SortNum      = dict.Value
                    };
                    insertTag.Add(newTags);
                }
            }
            if (updateTags.Count > 0)
            {
                this._tagsRepository.UpdateEntitys(updateTags);
            }
            if (insertTag.Count > 0)
            {
                this._tagsRepository.CreateEntitys(insertTag);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 修改板块信息
        /// </summary>
        /// <param name="id">板块编号</param>
        /// <param name="categoryId">分类编号</param>
        /// <param name="name">板块名称</param>
        /// <param name="sortNum">排序数量</param>
        /// <param name="pageSize">显示行数</param>
        /// <returns></returns>
        public bool UpdatePlate(int id, int categoryId, string name, int sortNum, int pageSize)
        {
            CheckId(id);
            CheckName(name);
            CheckPageSize(pageSize);
            categoryId = categoryId <= 0 ? 0 : categoryId;
            Category category = null;

            if (categoryId > 0)
            {
                CheckCategoryId(categoryId);
                CheckCategoryId(categoryId, out category);
            }
            Plate plate;

            CheckId(id, out plate);
            CheckName(id, name, category);
            plate.CategoryId     = categoryId;
            plate.Name           = name;
            plate.KeyWord        = PinyinHelper.PinyinString(name);
            plate.UpdateManageId = 1;
            plate.UpdateTime     = DateTime.Now;
            plate.SortNum        = sortNum;
            plate.PageSize       = pageSize;
            return(this._plateRepository.UpdateEntity(plate));
        }
Beispiel #6
0
        /// <summary>
        /// 添加板块
        /// </summary>
        /// <param name="categoryId">分类编号</param>
        /// <param name="name">板块名称</param>
        /// <param name="sortNum">排序数量</param>
        /// <param name="pageSize">显示多少条</param>
        /// <returns></returns>
        public int CreatePlate(int categoryId, string name, int sortNum, int pageSize)
        {
            categoryId = categoryId <= 0 ? 0 : categoryId;
            CheckName(name);
            CheckPageSize(pageSize);
            Category category = null;

            if (categoryId > 0)
            {
                CheckCategoryId(categoryId);
                CheckCategoryId(categoryId, out category);
            }
            CheckName(name, category);
            var plate = new Plate()
            {
                CategoryId     = categoryId,
                CreateManageId = 1,
                CreateTime     = DateTime.Now,
                KeyWord        = PinyinHelper.PinyinString(name),
                PageSize       = pageSize,
                Name           = name,
                SortNum        = sortNum
            };

            this._plateRepository.CreateEntity(plate);
            return(plate.Id);
        }
Beispiel #7
0
        /// <summary>
        /// 添加分类
        /// </summary>
        /// <param name="name">分类名称</param>
        /// <param name="parentId">分类的上级编号</param>
        /// <returns></returns>
        public int CreateCategory(string name, int parentId)
        {
            CheckNameNotNull(name);
            CheckName(parentId, name);
            string locationpath = "";

            if (parentId > 0)
            {
                Category parentCategory;
                CheckId(parentId, out parentCategory);
                CheckLocalhostPathNotNull(parentCategory.LocationPath);
                CheckLocationPath(parentCategory.LocationPath);
                locationpath = parentCategory.LocationPath + ",";
            }
            var category = new Category()
            {
                Name           = name,
                ParentId       = parentId,
                CreateManageId = 1,
                CreateTime     = DateTime.Now,
                KeyWord        = PinyinHelper.PinyinString(name),
                LocationPath   = locationpath
            };

            this._categoryRepository.CreateEntity(category);
            category.LocationPath = category.LocationPath + GetLocalhostPath(category.Id);
            this._categoryRepository.UpdateEntity(category);
            return(category.Id);
        }
Beispiel #8
0
        /// <summary>
        /// 确认事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Accept_Click(object sender, EventArgs e)
        {
            bool IsOk = false;

            bpms_employee              = ControlBindHelper.GetWebControls <BPMS_Employee>(this.Page);
            bpms_employee.Enabled      = Enabled.Checked ? 1 : 0;
            bpms_employee.IsDimission  = IsDimission.Checked ? 1 : 0;
            bpms_employee.CompanyId    = hiddenCompanyId.Value;
            bpms_employee.DepartmentId = hiddenDepartmentId.Value;
            bpms_employee.WorkgroupId  = hiddenWorkgroupId.Value;
            bpms_employee.Spell        = PinyinHelper.PinyinString(bpms_employee.RealName);
            if (!string.IsNullOrEmpty(_key))//判断是否编辑
            {
                bpms_employee.EmployeeId     = _key;
                bpms_employee.ModifyDate     = DateTime.Now;
                bpms_employee.ModifyUserId   = RequestSession.GetSessionUser().UserId;
                bpms_employee.ModifyUserName = RequestSession.GetSessionUser().UserName;
                IsOk = bpms_employeeibll.Update(bpms_employee);
                if (IsOk)
                {
                    //保存成功后将数据同步到微信企业号
                    string[] tempDepart = new string[3] {
                        bpms_employee.CompanyId, bpms_employee.DepartmentId, bpms_employee.WorkgroupId
                    };
                    Extattr extattr = new Extattr();
                    extattr = null;
                    if (!myCommFun.UpdateMember(bpms_employee.Code, bpms_employee.RealName, toDepartmentId(tempDepart), toPosition(bpms_employee.DutyId), bpms_employee.Mobile, toGender(bpms_employee.Gender), bpms_employee.Email, bpms_employee.WeixinId, Convert.ToInt32(bpms_employee.Enabled), bpms_employee.headpic, extattr))
                    {
                        ShowMsgHelper.AlertCallback(MessageHelper.MSG0032);
                    }
                    ShowMsgHelper.AlertParmCallback(MessageHelper.MSG0006);
                }
            }
            else
            {
                bpms_employee.EmployeeId     = CommonHelper.GetGuid;
                bpms_employee.CreateUserId   = RequestSession.GetSessionUser().UserId;
                bpms_employee.CreateUserName = RequestSession.GetSessionUser().UserName;
                IsOk = bpms_employeeibll.Insert(bpms_employee);
                if (IsOk)
                {
                    //保存成功后将数据同步到微信企业号
                    string[] tempDepart = new string[3] {
                        bpms_employee.CompanyId, bpms_employee.DepartmentId, bpms_employee.WorkgroupId
                    };
                    Extattr extattr = new Extattr();
                    extattr = null;
                    if (!myCommFun.CreateMember(bpms_employee.Code, bpms_employee.RealName, toDepartmentId(tempDepart), toPosition(bpms_employee.DutyId), bpms_employee.Mobile, toGender(bpms_employee.Gender), bpms_employee.Email, bpms_employee.WeixinId, bpms_employee.headpic, extattr))
                    {
                        ShowMsgHelper.AlertCallback(MessageHelper.MSG0032);
                    }
                    ShowMsgHelper.AlertParmCallback(MessageHelper.MSG0005);
                }
            }
            if (!IsOk)
            {
                ShowMsgHelper.Alert_Error(MessageHelper.MSG0022);
            }
        }
Beispiel #9
0
        /// <summary>
        /// 添加多个标签
        /// </summary>
        /// <param name="names">标签名称</param>
        /// <returns></returns>
        public bool CreateTags(IList <string> names)
        {
            if (names == null || names.Count <= 0)
            {
                return(false);
            }
            if (UserId < 0)
            {
                return(false);
            }
            IList <Condtion> condtions = new List <Condtion>()
            {
                ConditionEqualId(UserId),
                CondtionEqualState()
            };
            var user = this._userRepository.GetEntity(condtions);

            if (user == null)
            {
                return(false);
            }
            IList <Tags> updateTags = new List <Tags>();
            IList <Tags> insertTags = new List <Tags>();

            foreach (var name in names)
            {
                var tag = (from t in this._tagsRepository.GetEntityList()
                           join u in this._userRepository.GetEntityList() on t.CreateUserId equals u.Id
                           where t.State == false &&
                           u.State == false
                           select t).FirstOrDefault();
                if (tag != null)
                {
                    tag.SortNum     += 1;
                    tag.UpdateTime   = DateTime.Now;
                    tag.UpdateUserId = user.Id;
                    updateTags.Add(tag);
                }
                else
                {
                    var newTag = new Tags()
                    {
                        Name         = name,
                        KeyWord      = PinyinHelper.PinyinString(name),
                        CreateUserId = user.Id,
                        CreateTime   = DateTime.Now
                    };
                    insertTags.Add(newTag);
                }
            }
            this._tagsRepository.UpdateEntitys(updateTags);
            this._tagsRepository.CreateEntitys(insertTags);
            return(true);
        }
Beispiel #10
0
 public void AddUser(User user)
 {
     using (SunginDataContext sc = new SunginDataContext())
     {
         SetLoginInfo(ref user);
         user.SetCreateUser("system");
         user.Pinyin = PinyinHelper.PinyinString(user.UserName);
         sc.Users.Add(user);
         sc.SaveChanges();
     }
 }
Beispiel #11
0
        /// <summary>
        /// 修改字典名称
        /// </summary>
        /// <param name="name">字典名称</param>
        /// <param name="id">分类编号</param>
        /// <returns></returns>
        public bool UpdateDictionary(string name, int id)
        {
            CheckNameNotNull(name);
            CheckIdBiggerZero(id);
            Dictionary dictionary;

            CheckDictionaryId(id, out dictionary);
            dictionary.Name           = name;
            dictionary.KeyWord        = PinyinHelper.PinyinString(name);
            dictionary.UpdateManageId = 1;
            dictionary.UpdateTime     = DateTime.Now;
            return(this._dictionaryRepository.UpdateEntity(dictionary));
        }
Beispiel #12
0
        /// <summary>
        /// 修改分类名称
        /// </summary>
        /// <param name="name">分类名称</param>
        /// <param name="id">分类编号</param>
        /// <returns></returns>
        public bool UpdateCategory(string name, int id)
        {
            CheckNameNotNull(name);
            CheckIdBiggerZero(id);
            Category category;

            CheckId(id, out category);
            CheckName(category.ParentId, name);
            category.Name           = name;
            category.KeyWord        = PinyinHelper.PinyinString(name);
            category.UpdateManageId = 1;
            category.UpdateTime     = DateTime.Now;
            return(this._categoryRepository.UpdateEntity(category));
        }
Beispiel #13
0
        public EmpCheckMonth(USERINFO emp, AttControlClass attControl, GetDeptNameDelgate GetDeptName)
        {
            Emp        = emp;
            DeptName   = GetDeptName((short)emp.DEFAULTDEPTID);
            AttControl = attControl;
            GetDayType = AttControl.GetDayType;
            EmpNote    = AttControl.GetEmpNoteInfoByByte(emp.Notes);

            if (EmpNote == null)
            {
                EmpNote            = new EmpNoteInfo();
                EmpNote.EmpPyName  = PinyinHelper.PinyinString(emp.Name);
                EmpNote.IsHaveNote = true;
                AttControl.UpDateEmpNoteInfo(emp.USERID, EmpNote);
            }
        }
Beispiel #14
0
        /// <summary>
        /// 确认事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Accept_Click(object sender, EventArgs e)
        {
            bool IsOk = false;

            bpms_user              = ControlBindHelper.GetWebControls <BPMS_User>(this.Page);
            bpms_user.Enabled      = Enabled.Checked ? 1 : 0;
            bpms_user.CompanyId    = hiddenCompanyId.Value;
            bpms_user.DepartmentId = hiddenDepartmentId.Value;
            bpms_user.WorkgroupId  = hiddenWorkgroupId.Value;
            bpms_user.RoleId       = hiddenRoleId.Value;
            bpms_user.Spell        = PinyinHelper.PinyinString(bpms_user.RealName);
            if (!string.IsNullOrEmpty(_key))//判断是否编辑
            {
                bpms_user.UserId         = _key;
                bpms_user.ModifyDate     = DateTime.Now;
                bpms_user.ModifyUserId   = RequestSession.GetSessionUser().UserId;
                bpms_user.ModifyUserName = RequestSession.GetSessionUser().UserName;
                bpms_user.Password       = null;
                IsOk = bpms_useribll.Update(bpms_user);
                if (IsOk)
                {
                    ShowMsgHelper.AlertCallback(MessageHelper.MSG0006);
                }
            }
            else
            {
                bpms_user.UserId    = CommonHelper.GetGuid;
                bpms_user.Secretkey = Md5Helper.MD5(CommonHelper.CreateNo(), 16);
                string Password = DESEncrypt.Encrypt(bpms_user.Password, bpms_user.Secretkey);
                bpms_user.Password       = Md5Helper.MD5(Password, 32);
                bpms_user.CreateUserId   = RequestSession.GetSessionUser().UserId;
                bpms_user.CreateUserName = RequestSession.GetSessionUser().UserName;
                IsOk = bpms_useribll.Insert(bpms_user);
                if (IsOk)
                {
                    ShowMsgHelper.AlertCallback(MessageHelper.MSG0005);
                }
            }
            if (!IsOk)
            {
                ShowMsgHelper.Alert_Error(MessageHelper.MSG0022);
            }
        }
Beispiel #15
0
        public int CreateDictionaryItem(string name, int parentId)
        {
            CheckNameNotNull(name);
            if (parentId > 0)
            {
                Dictionary parentDictionary;
                CheckDictionaryId(parentId, out parentDictionary);
            }
            var dictionaryItem = new DictionaryItem()
            {
                Name           = name,
                DictionaryId   = parentId,
                CreateManageId = 1,
                CreateTime     = DateTime.Now,
                KeyWord        = PinyinHelper.PinyinString(name),
            };

            this._dictionaryItemRepository.CreateEntity(dictionaryItem);
            return(dictionaryItem.Id);
        }
Beispiel #16
0
        /// <summary>
        /// 添加字典
        /// </summary>
        /// <param name="name">字典名称</param>
        /// <param name="parentId">字典上级分类编号</param>
        /// <returns></returns>
        public int CreateDictionary(string name, int parentId)
        {
            CheckNameNotNull(name);
            if (parentId > 0)
            {
                Category parentCategory;
                CheckCategoryId(parentId, out parentCategory);
                CheckLocalhostPathNotNull(parentCategory.LocationPath);
                CheckLocationPath(parentCategory.LocationPath);
            }
            var dictionary = new Dictionary()
            {
                Name           = name,
                CategoryId     = parentId,
                CreateManageId = 1,
                CreateTime     = DateTime.Now,
                KeyWord        = PinyinHelper.PinyinString(name),
            };

            this._dictionaryRepository.CreateEntity(dictionary);
            return(dictionary.Id);
        }
Beispiel #17
0
        /// <summary>
        /// 修改标签
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="sortNum"></param>
        /// <returns></returns>
        public int UpdateTags(int id, string name, int sortNum)
        {
            var pagesize = 0;

            CheckId(id);
            CheckPageSize(this.PageSize, out pagesize);
            CheckManageId();
            CheckName(name);
            CheckSortNum(sortNum);
            Manage manage;

            CheckManageId(out manage);
            Tags tags;

            CheckId(id, out tags);
            CheckExistName(tags.Id, name);
            tags.Name         = name;
            tags.KeyWord      = PinyinHelper.PinyinString(name);
            tags.SortNum      = sortNum;
            tags.UpdateTime   = DateTime.Now;
            tags.UpdateUserId = manage.Id;
            this._tagsRepository.UpdateEntity(tags);
            return(tags.Id);
        }
Beispiel #18
0
        /// <summary>
        /// 添加标签
        /// </summary>
        /// <param name="name">标签名称</param>
        /// <returns></returns>
        public bool CreateTags(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(false);
            }
            CheckUserId();
            User user;

            CheckUserId(out user);
            var tags = (from t in this._tagsRepository.GetEntityList()
                        where t.State == false &&
                        t.Name == name.Trim()
                        select t).FirstOrDefault();
            var success = false;

            if (tags != null)
            {
                tags.SortNum     += 1;
                tags.UpdateTime   = DateTime.Now;
                tags.UpdateUserId = user.Id;
                success           = this._tagsRepository.UpdateEntity(tags);
            }
            else
            {
                var newTags = new Tags()
                {
                    Name         = name,
                    KeyWord      = PinyinHelper.PinyinString(name),
                    CreateUserId = user.Id,
                    CreateTime   = DateTime.Now
                };
                success = this._tagsRepository.CreateEntity(newTags);
            }
            return(success);
        }
Beispiel #19
0
 public int GetOrAddClient(string clientName)
 {
     using (ProofDataContext pdc = new ProofDataContext())
     {
         string c   = clientName.ToLower();
         string pym = PinyinHelper.PinyinString(clientName).ToLower();
         var    re  = pdc.xt_khb.Where(p => p.khmc.ToLower() == c).FirstOrDefault();
         if (re == null)
         {
             pdc.xt_khb.Add(new xt_khb
             {
                 khmc    = clientName,
                 khqc    = clientName,
                 rq      = DateTime.Now,
                 bz_dd   = 1,
                 address = "内部同步客户",
                 pym     = pym == "" ? clientName : pym,
             });
             pdc.SaveChanges();
             re = pdc.xt_khb.Where(p => p.khmc.ToLower() == c).FirstOrDefault();
         }
         return(re.id);
     }
 }
Beispiel #20
0
 public void TestPinyinHelper()
 {
     var aa = PinyinHelper.PinyinString("ffff");
 }