Esempio n. 1
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool AddUser(User_I user)
        {
            using (var factory = new BaseAccess(base._DBConfigPath))
            {
                try
                {
                    //user.UserPassword = (user.UserLoginName + Define._PASSWORDSPLIT + appConfig.DefaultPassword).ToMD5();
                    user.UserPassword = appConfig.DefaultPassword.ToMD5();
                    user.ID           = Guid.NewGuid().ToString();
                    var userDep = new UserOrganizationEntity()
                    {
                        ID             = Guid.NewGuid().ToString(),
                        UserID         = user.ID,
                        OrganizationID = user.UserDeptID,
                        IsDefault      = 1
                    };
                    var model = user.Adapter <UserEntity>(new UserEntity());
                    factory.Insert <UserEntity>(model, false);
                    factory.Insert <UserOrganizationEntity>(userDep, false);
                    factory.Commit();

                    return(true);
                }
                catch (Exception ex)
                {
                    factory.Rollback();
                    return(false);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 设置角色系统
 /// </summary>
 /// <param name="UserID"></param>
 /// <param name="RoleID"></param>
 /// <param name="IsHas">ture设置 false移除</param>
 public void SetAppRole(string AppID, string RoleID, bool IsHas)
 {
     using (var factory = new BaseAccess(base._DBConfigPath))
     {
         var appRole = factory.GetSingle <SYS_AppRoleEntity>(Specification <SYS_AppRoleEntity> .Create(c => c.AppID == AppID && c.RoleID == RoleID));
         if (IsHas)
         {
             //增加
             if (appRole == null || string.IsNullOrEmpty(appRole.ID))
             {
                 appRole = new SYS_AppRoleEntity()
                 {
                     RoleID = RoleID, AppID = AppID
                 };
                 factory.Insert <SYS_AppRoleEntity>(appRole);
             }
         }
         else
         {
             //移除
             if (appRole != null && !string.IsNullOrEmpty(appRole.ID))
             {
                 factory.Delete <SYS_AppRoleEntity>(appRole);
             }
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 设置角色菜单
 /// </summary>
 /// <param name="RoleID"></param>
 /// <param name="MenuIDs"></param>
 public void SetRoleMenus(string RoleID, List <string> MenuIDs)
 {
     using (var factory = new BaseAccess())
     {
         try
         {
             if (!string.IsNullOrEmpty(RoleID))
             {
                 var menus_old = factory.GetAll <MenuRoleEntity>(Specification <MenuRoleEntity> .Create(c => c.RoleID == RoleID));
                 factory.Delete <MenuRoleEntity>(menus_old, false);
                 if (MenuIDs != null)
                 {
                     foreach (string id in MenuIDs)
                     {
                         var entity = new MenuRoleEntity()
                         {
                             ID     = Guid.NewGuid().ToString(),
                             RoleID = RoleID,
                             MenuID = id
                         };
                         factory.Insert <MenuRoleEntity>(entity, false);
                     }
                 }
                 factory.Commit();
             }
         }
         catch (Exception ex)
         {
             factory.Rollback();
             throw ex;
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 设置分组用户
 /// </summary>
 /// <param name="OrganID"></param>
 /// <param name="UserID"></param>
 /// <param name="IsHas">ture设置 false移除</param>
 public void SetUserOrgan(string OrganID, string UserID, bool IsHas)
 {
     using (var factory = new BaseAccess())
     {
         //获取用户的所有分组
         var UserAllOrgan = factory.GetAll <UserOrganizationEntity>(Specification <UserOrganizationEntity> .Create(c => c.UserID == UserID));
         if (IsHas)
         {
             //增加
             if (UserAllOrgan == null || UserAllOrgan.Count == 0 || UserAllOrgan.Count(c => c.OrganizationID == OrganID) == 0)
             {
                 var organUser = new UserOrganizationEntity()
                 {
                     OrganizationID = OrganID,
                     UserID         = UserID,
                     IsDefault      = UserAllOrgan.Count(c => c.IsDefault == (int)YesNo.Yes) == 0 ? (int)YesNo.Yes : (int)YesNo.No
                 };
                 factory.Insert <UserOrganizationEntity>(organUser);
             }
         }
         else
         {
             //移除
             if (UserAllOrgan != null && UserAllOrgan.Count(c => c.OrganizationID == OrganID) > 0)
             {
                 factory.Delete <UserOrganizationEntity>(UserAllOrgan.Where(c => c.OrganizationID == OrganID).First());
             }
         }
     }
 }
Esempio n. 5
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Test t = new Test()
            {
                I32Value         = 1,
                I64Value         = 1,
                StringValue      = "测试",
                DateValue        = DateTime.Now,
                DateTimeValue    = DateTime.Now.ToUniversalTime(),
                Float64Value     = 1.1,
                PartitionByValue = new DateTime(2000, 1, 1),
                PKI64            = 1,
                PKString         = "分类1",
            };
            List <Test> list = new List <Test>();

            list.Add(t);
            try
            {
                var result = baseAccess.Insert(t, "test");
                rtbLogs.Text += $"{result}\n";
            }
            catch (Exception ex)
            {
                rtbLogs.Text += $"{ex}\n";
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 设置用户角色
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="RoleID"></param>
        /// <param name="IsHas">ture设置 false移除</param>
        public void SetUserRole(string UserID, string RoleID)
        {
            using (var factory = new BaseAccess())
            {
                //如果传入的roleid为空的话移除改用户对对应的所有角色
                if (string.IsNullOrWhiteSpace(RoleID))
                {
                    var entity = factory.GetAll <UserRoleEntity>(Specification <UserRoleEntity> .Create(c => c.UserID == UserID));
                    factory.Delete <UserRoleEntity>(entity);
                }
                else
                {
                    var entity = factory.GetAll <UserRoleEntity>(Specification <UserRoleEntity> .Create(c => c.UserID == UserID));
                    factory.Delete <UserRoleEntity>(entity);
                    var Rids = RoleID.Split(',');
                    foreach (var item in Rids)
                    {
                        var spec = Specification <UserRoleEntity> .Create(c => c.UserID == UserID && c.RoleID == item);

                        bool bl = factory.IsExists <UserRoleEntity>(spec);
                        if (!bl)
                        {
                            var userRole = new UserRoleEntity()
                            {
                                RoleID = item, UserID = UserID
                            };
                            factory.Insert <UserRoleEntity>(userRole);
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 根据当前登陆用户获取用户配置信息
        /// 如果没有配置信息则 创建一天空的配置信息
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public Configuration_S GetConfigurationByUserId(string UserId)
        {
            using (var factory = new BaseAccess())
            {
                var spec = Specification <SYS_ConfigurationEntity> .Create(c => c.USERID == UserId);

                try
                {
                    if (factory.IsExists <SYS_ConfigurationEntity>(spec))
                    {
                        var entity = factory.GetSingle <SYS_ConfigurationEntity>(spec);
                        return(entity.Adapter <Configuration_S>(new Configuration_S()));
                    }
                    else
                    {
                        var entity = new SYS_ConfigurationEntity();
                        entity.ID     = Guid.NewGuid().ToString();
                        entity.USERID = UserId;
                        factory.Insert <SYS_ConfigurationEntity>(entity, false);
                        factory.Commit();
                        return(null);
                    }
                }
                catch (Exception ex)
                {
                    factory.Rollback();
                    return(null);
                }
            }
        }
Esempio n. 8
0
 /// <summary>
 /// 增加日志
 /// </summary>
 /// <param name="logType">日志类型</param>
 /// <param name="source">日志来源</param>
 /// <param name="message">日志内容</param>
 /// <param name="createTime">创建时间</param>
 /// <param name="createUserId">创建用户编号</param>
 /// <param name="createUserName">创建用户名称</param>
 public void Insert(LogItemModel log)
 {
     using (var factory = new BaseAccess())
     {
         var entity = log.Adapter <SYS_Log>(new SYS_Log());
         factory.Insert <SYS_Log>(entity);
     }
 }
Esempio n. 9
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);
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        public void Add(Organization_I model)
        {
            using (var factory = new BaseAccess())
            {
                if (string.IsNullOrEmpty(model.ID))
                {
                    model.ID = Guid.NewGuid().ToString();
                }
                factory.Insert <OrganizationEntity>(model.Adapter <OrganizationEntity>(new OrganizationEntity()));

                //清理缓存
                CacheshipFactory.Instance.ClearOrganCache();
            }
        }
Esempio n. 11
0
 private void Do(string message)
 {
     try
     {
         var result = baseAccess.Insert(new User {
             Id = 1, Name = "测试", RegDate = DateTime.Now
         }, "test");
         //Console.WriteLine(result);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Esempio n. 12
0
 /// <summary>
 /// 新增专题明细
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddArticleApply(ArticleApply_S model)
 {
     using (var factory = new BaseAccess())
     {
         try
         {
             var entity = model.Adapter <ArticleApplyEntity>(new ArticleApplyEntity());
             factory.Insert(entity);
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Esempio n. 13
0
 /// <summary>
 /// 新增专题
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddEvent(Event_S model)
 {
     using (var factory = new BaseAccess())
     {
         try
         {
             var entity = model.Adapter <EventEntity>(new EventEntity());
             factory.Insert(entity);
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Esempio n. 14
0
 /// <summary>
 /// 获取所有站点
 /// </summary>
 /// <param name="searchContent"></param>
 /// <returns></returns>
 public bool Add(EmailRecord_S model)
 {
     using (var factory = new BaseAccess())
     {
         try
         {
             var entity = model.Adapter <EmailRecordEntity>(new EmailRecordEntity());
             factory.Insert <EmailRecordEntity>(entity);
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Esempio n. 15
0
 /// <summary>
 /// 新增专题明细
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddFloatWindow(FloatWindow_S model)
 {
     using (var factory = new BaseAccess())
     {
         try
         {
             var entity = model.Adapter <FloatWindowEntity>(new FloatWindowEntity());
             factory.Insert(entity);
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Esempio n. 16
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        public void Add(Dictionary_I model)
        {
            using (var factory = new BaseAccess())
            {
                if (string.IsNullOrEmpty(model.ID))
                {
                    model.ID = Guid.NewGuid().ToString();
                }
                factory.Insert <Sys_DictionaryEntity>(model.Adapter <Sys_DictionaryEntity>(new Sys_DictionaryEntity()));

                //清理缓存
                if ((model.IsCache ?? 0) == 1)
                {
                    Manage.Open.CacheshipFactory.Instance.ClearDictionaryCache(model.DictType);
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        public void Add(Menu_I model)
        {
            using (var factory = new BaseAccess())
            {
                if (string.IsNullOrEmpty(model.ID))
                {
                    model.ID = Guid.NewGuid().ToString();
                }
                factory.Insert <MenuEntity>(model.Adapter <MenuEntity>(new MenuEntity()));

                //清理缓存
                if (model.MenuType == (int)MenuType.Function)
                {
                    CacheshipFactory.Instance.ClearFunMenuCache();
                }
            }
        }
Esempio n. 18
0
 public static int Insert(TEntity model)
 {
     return(BaseAccess <TEntity, TFileFields> .Insert(model));
 }
Esempio n. 19
0
        private void button1_Click(object sender, EventArgs e)
        {
            PageCondition.Visible = true;

            BaseAccess dbhelper = BaseAccess.CreateDataBase();

            dbhelper.ExecuteNonQuerySQL("".AsSQLQuery() + "delete ZBO");


            if (dbhelper.Insert <Excel>(excels) > 0)
            {
                lvw.Clear();
                lvw.Items.Clear();
                lvw.Columns.AddRange(new ColumnHeader[] {
                    new ColumnHeader {
                        Text = "物料编码", Width = 100, TextAlign = HorizontalAlignment.Center
                    },
                    new ColumnHeader {
                        Text = "物料名称", Width = 100, TextAlign = HorizontalAlignment.Center
                    },
                    new ColumnHeader {
                        Text = "在库数量", Width = 100, TextAlign = HorizontalAlignment.Center
                    },
                    new ColumnHeader {
                        Text = "待验收数量", Width = 100, TextAlign = HorizontalAlignment.Center
                    },
                    new ColumnHeader {
                        Text = "一次验收完成数量", Width = 110, TextAlign = HorizontalAlignment.Center
                    },
                    new ColumnHeader {
                        Text = "二次验收完成数量", Width = 110, TextAlign = HorizontalAlignment.Center
                    },
                    new ColumnHeader {
                        Text = "入库待处理数量", Width = 110, TextAlign = HorizontalAlignment.Center
                    },
                });

                PageCondition.PageSize = 50;
                PageCondition.SqlSort  = "order by MaterialId";

                listTask = dbhelper.GetList <MaterialStatus>("".AsSQLQuery() + "select * from  View_ZBO", PageCondition.PageCondition);
                page     = listTask.rows.Count();
                PageCondition.DataQuery(new Func <int>(() =>
                {
                    if (listTask != null && listTask.rows != null &&
                        listTask.rows.Count > 0)
                    {
                        Invoke(new Action(() =>
                        {
                            lvw.Items.Clear();
                            for (int i = 0; i < listTask.rows.Count; i++)
                            {
                                ListViewItem item = new ListViewItem();
                                item.Tag          = listTask.rows[i];
                                item.Text         = listTask.rows[i].MaterialId;

                                item.SubItems.Add(listTask.rows[i].MaterialName);
                                item.SubItems.Add(listTask.rows[i].AllQuantity);
                                item.SubItems.Add(listTask.rows[i].Checkquantity);
                                item.SubItems.Add(listTask.rows[i].FCheckquantity);
                                item.SubItems.Add(listTask.rows[i].SCheckquantity);
                                item.SubItems.Add(listTask.rows[i].Inquantity);
                                lvw.Items.Add(item);
                            }
                        }));
                    }
                    return(listTask == null ? 0 : listTask.total);
                }), true);
            }
            else
            {
                MessageBox.Show("请重试", "提示");
            }

            buttonoutport.Visible = true;
        }