Beispiel #1
0
 /// <summary>
 /// 编辑用户
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public bool EditUser(User_U user)
 {
     using (var factory = new BaseAccess(base._DBConfigPath))
     {
         try
         {
             var model = factory.Single <UserEntity>(user.ID);
             model = user.Adapter <UserEntity>(model);//将页面对象user的属性转换到数据库对象modle中
             factory.Update <UserEntity>(model, false);
             //处理用户分组
             var userDep = factory.Single <UserOrganizationEntity>(Specification <UserOrganizationEntity>
                                                                   .Create(c => c.UserID == user.ID && c.IsDefault == 1));
             if (userDep.OrganizationID != user.UserDeptID)
             {
                 userDep.OrganizationID = user.UserDeptID;
                 factory.Update <UserOrganizationEntity>(userDep, false);
             }
             factory.Commit();
             //清理缓存
             Manage.Open.CacheshipFactory.Instance.ClearSSOUserCache(user.ID);
             return(true);
         }
         catch (Exception ex)
         {
             factory.Rollback();
             return(false);
         }
     }
 }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity"></param>
        public void Edit(Dictionary_U model)
        {
            using (var factory = new BaseAccess())
            {
                try
                {
                    if (!string.IsNullOrEmpty(model.ID))
                    {
                        var model_old = factory.GetSingle <Sys_DictionaryEntity>(model.ID);
                        model_old = model.Adapter <Sys_DictionaryEntity>(model_old);//将页面对象的属性转换到数据库对象modle中
                        factory.Update <Sys_DictionaryEntity>(model_old, false);
                        if ((model.IsCache ?? 0) != (model.IsCache_Old ?? 0))
                        {
                            //更新其他所有DictType的IsCache
                            string type = model_old.DictType;
                            factory.Update <Sys_DictionaryEntity>(model_old, new string[] { "IsCache" }, Specification <Sys_DictionaryEntity> .Create(c => c.DictType == model_old.DictType && c.ParDictID != Define._TOPPARENTID), false);
                        }
                        factory.Commit();

                        //清除缓存
                        if ((model_old.IsCache ?? 0) == 1)
                        {
                            Manage.Open.CacheshipFactory.Instance.ClearDictionaryCache(model_old.DictType);
                        }
                    }
                }
                catch (Exception ex)
                {
                    factory.Rollback();
                    throw ex;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 设置为主分组
        /// </summary>
        /// <param name="OrganID"></param>
        /// <param name="UserID"></param>
        public void SetDefaultOrgan(string OrganID, string UserID)
        {
            using (var factory = new BaseAccess())
            {
                try
                {
                    //获取用户的所有分组
                    var UserAllOrgan = factory.GetAll <UserOrganizationEntity>(Specification <UserOrganizationEntity> .Create(c => c.UserID == UserID));
                    var defaultOrgan = UserAllOrgan.Where(c => c.IsDefault == (int)YesNo.Yes).ToList() ?? new List <UserOrganizationEntity>();
                    var setOrgan     = UserAllOrgan.Where(w => w.OrganizationID == OrganID).FirstOrDefault();
                    if (setOrgan != null)
                    {
                        //取消所有原主分组(做荣誉操作,正常情况下不会有多个主分组)
                        foreach (var m in defaultOrgan)
                        {
                            m.IsDefault = (int)YesNo.No;
                            factory.Update <UserOrganizationEntity>(m, false);
                        }
                        //设置需要设置的分组为主分组
                        setOrgan.IsDefault = (int)YesNo.Yes;
                        factory.Update <UserOrganizationEntity>(setOrgan, false);

                        factory.Commit();
                    }
                }
                catch (Exception e)
                {
                    factory.Rollback();
                    throw e;
                }
            }
        }
Beispiel #4
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if ((listView2.SelectedItems != null) && (listView2.SelectedItems.Count == 0))
            {
                MessageBox.Show("请选择要取消的任务");
            }
            else
            {
                BaseAccess dbhelper = BaseAccess.CreateDataBase();
                var        entity   = listView2.SelectedItems[0].Tag as WMS_IO_Task;
                entity.Status   = "5";
                entity.EditUser = "******";
                entity.Remark   = "程序取消";
                entity.EditTime = System.DateTime.Now.ToString(CommFinal.TimeFormat);
                if (dbhelper.Update(entity) > 0)
                {
                    //DataTable dt = dbhelper.GetDataTable("".AsSQLQuery() + "update wms_B_loc set status=2 where locnum="+entity.""

                    MessageBox.Show("取消成功");

                    listView2.Items.Clear();
                }
                else
                {
                    MessageBox.Show("请确认任务状态");
                }
            }
        }
Beispiel #5
0
        //更新
        public Boolean UpdateConfiguration(Configuration_U model)
        {
            using (var factory = new BaseAccess())
            {
                if (!string.IsNullOrEmpty(model.USERID))
                {
                    var spec = Specification <SYS_ConfigurationEntity> .Create(c => c.USERID == model.USERID);

                    try
                    {
                        var    model_old = factory.GetSingle <SYS_ConfigurationEntity>(spec);
                        string id        = model_old.ID;
                        model_old    = model.Adapter <SYS_ConfigurationEntity>(model_old);//将页面对象的属性转换到数据库对象modle中
                        model_old.ID = id;
                        factory.Update <SYS_ConfigurationEntity>(model_old, false);
                        factory.Commit();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        factory.Rollback();
                        return(false);
                    }
                }
                return(false);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 点击||点赞
        /// </summary>
        /// <param name="ArticleID">文章ID</param>
        /// <param name="HitType">点击类型0点击量1点赞数</param>
        /// <returns></returns>
        public bool Hit(string ArticleID, string HitType, string IpAddress)
        {
            using (var factory = new BaseAccess())
            {
                try
                {
                    var spec = Specification <HitRecordEntity> .Create(c => c.VC_IP_ADDRESS == IpAddress);

                    spec = Specification <HitRecordEntity> .Create(c => c.N_ARTICLE_ID == ArticleID);

                    if (HitType == "3" || HitType == "4" || HitType == "5")//3满意 4一般 5不满意
                    {
                        spec &= Specification <HitRecordEntity> .Create(c => (",3,4,5,").Contains("," + c.C_HIT_TYPE + ","));
                    }
                    else
                    {
                        spec &= Specification <HitRecordEntity> .Create(c => c.C_HIT_TYPE == HitType);
                    }
                    spec &= Specification <HitRecordEntity> .Create(c => c.DT_HIT_TIME >= DateTime.Now.AddDays(-1));

                    var hitrecord = factory.GetSingle <HitRecordEntity>(spec);
                    if (hitrecord != null)
                    {
                        return(false);
                    }
                    else
                    {
                        if (HitType == "0" || HitType == "1")//2网站访问量 0点击量 1点赞量 3满意 4一般 5不满意
                        {
                            var article = factory.GetSingle <ArticleEntity>(ArticleID);
                            if (HitType == ((int)EMHITTYPE.点击量).ToString())
                            {
                                article.N_HITS += 1;
                            }
                            else
                            {
                                article.N_LIKES += 1;
                            }
                            factory.Update <ArticleEntity>(article);
                        }
                        hitrecord               = new HitRecordEntity();
                        hitrecord.ID            = Guid.NewGuid().ToString();
                        hitrecord.N_ARTICLE_ID  = ArticleID;
                        hitrecord.VC_IP_ADDRESS = IpAddress;
                        hitrecord.C_HIT_TYPE    = HitType;
                        hitrecord.DT_HIT_TIME   = DateTime.Now;
                        factory.Insert <HitRecordEntity>(hitrecord);
                        return(true);
                    }
                }
                catch
                {
                    return(false);
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        public void Edit(Organization_U model)
        {
            using (var factory = new BaseAccess())
            {
                if (!string.IsNullOrEmpty(model.ID))
                {
                    var model_old = factory.GetSingle <OrganizationEntity>(model.ID);
                    model_old = model.Adapter <OrganizationEntity>(model_old);//将页面对象的属性转换到数据库对象modle中
                    factory.Update <OrganizationEntity>(model_old);

                    //清理缓存
                    CacheshipFactory.Instance.ClearOrganCache();
                }
            }
        }
Beispiel #8
0
 /// <summary>
 /// 修改用户密码
 /// </summary>
 /// <param name="UserID"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public bool ChangePwd(string UserID, string password)
 {
     using (var factory = new BaseAccess())
     {
         var    user        = factory.GetSingle <UserEntity>(Specification <UserEntity> .Create(c => c.ID == UserID));
         string newPassword = (user.UserLoginName + Define._PASSWORDSPLIT + password).ToMD5();
         if (user != null)
         {
             user.UserPassword = newPassword;
             factory.Update <UserEntity>(user);
             return(true);
         }
         return(false);
     }
 }
Beispiel #9
0
 /// <summary>
 /// 修改专题明细
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool EditArticleApply(ArticleApply_S model)
 {
     using (var factory = new BaseAccess())
     {
         try
         {
             var entity = model.Adapter <ArticleApplyEntity>(new ArticleApplyEntity());
             factory.Update <ArticleApplyEntity>(entity);
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Beispiel #10
0
 /// <summary>
 /// 修改专题明细
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool EditFloatWindow(FloatWindow_S model)
 {
     using (var factory = new BaseAccess())
     {
         try
         {
             var entity = model.Adapter <FloatWindowEntity>(new FloatWindowEntity());
             factory.Update <FloatWindowEntity>(entity);
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Beispiel #11
0
 /// <summary>
 /// 修改专题
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool EditEvent(Event_S model)
 {
     using (var factory = new BaseAccess())
     {
         try
         {
             var entity = model.Adapter <EventEntity>(new EventEntity());
             factory.Update <EventEntity>(entity);
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Beispiel #12
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        public void Edit(Menu_U model)
        {
            using (var factory = new BaseAccess())
            {
                if (!string.IsNullOrEmpty(model.ID))
                {
                    var model_old = factory.GetSingle <MenuEntity>(model.ID);
                    model_old = model.Adapter <MenuEntity>(model_old);//将页面对象的属性转换到数据库对象modle中
                    factory.Update <MenuEntity>(model_old);

                    //清理缓存
                    if (model_old.MenuType == (int)MenuType.Function)
                    {
                        CacheshipFactory.Instance.ClearFunMenuCache();
                    }
                }
            }
        }
Beispiel #13
0
 public static int Update(TEntity model)
 {
     return(BaseAccess <TEntity, TFileFields> .Update(model));
 }