Exemplo n.º 1
0
        private void InitData(SqlSugarClient db)
        {
            db.ExecuteCommand("delete from  Subject");
            db.ExecuteCommand("delete from   student");
            db.ExecuteCommand("delete from   school");
            db.ExecuteCommand("delete from   area");

            db.SqlBulkCopy(SchoolList);
            db.SqlBulkCopy(StudentList);
            db.SqlBulkCopy(SubjectList);
            db.InsertRange(AreaList);
        }
Exemplo n.º 2
0
        private void InitData(SqlSugarClient db)
        {
            db.ExecuteCommand("truncate table Subject");
            db.ExecuteCommand("truncate table student");
            db.ExecuteCommand("truncate table school");
            db.ExecuteCommand("truncate table area");

            db.SqlBulkCopy(SchoolList);
            db.SqlBulkCopy(StudentList);
            db.SqlBulkCopy(SubjectList);
            db.InsertRange(AreaList);
        }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //设置序列,程序起动时设置一次便可
     OracleConfig.SequenceMapping = new List <PubModel.SequenceModel>()
     {
         new PubModel.SequenceModel()
         {
             ColumnName = "ID", TableName = "STUDENT", Value = "SEQ_D"
         }
     };
     using (SqlSugarClient db = SugarDao.GetInstance())//开启数据库连接
     {
         var list = new List <STUDENT>()
         {
             new STUDENT()
             {
                 ISOK = true, NAME = "张三", SCH_ID = 1, SEX = "男"
             },
             new STUDENT()
             {
                 ISOK = false, NAME = "sun", SCH_ID = 1, SEX = "女"
             },
             new STUDENT()
             {
                 ISOK = true, NAME = "mama", SCH_ID = 1, SEX = "gril"
             }
         };
         db.SqlBulkCopy <STUDENT>(list);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 更新用户部门
        /// </summary>
        /// <param name="vguid"></param>
        /// <param name="personVguid"></param>
        /// <param name="labelStr"></param>
        /// <returns></returns>
        public bool UpdateDepartment(string vguid, string personVguid, string labelStr)
        {
            using (SqlSugarClient dbMsSql = SugarDao_MsSql.GetInstance())
            {
                Guid departmentVguid = Guid.Parse(vguid);
                Guid personVGUID     = Guid.Parse(personVguid);
                bool result          = false;
                var  listLabel       = JsonHelper.JsonToModel <List <Business_PersonnelLabel_Information> >(labelStr);
                if (listLabel.Count > 0)
                {
                    //先删除标签,再重新添加
                    dbMsSql.Delete <Business_PersonnelLabel_Information>(i => i.PersonnelVVGUID == personVGUID);
                    foreach (var item in listLabel)
                    {
                        item.VGUID       = Guid.NewGuid();
                        item.CreatedDate = DateTime.Now;
                        item.CreatedUser = CurrentUser.GetCurrentUser().LoginName;
                        item.ChangeDate  = DateTime.Now;
                        item.ChangeUser  = CurrentUser.GetCurrentUser().LoginName;
                        //var rtn = dbMsSql.Insert(item);
                    }

                    result = dbMsSql.SqlBulkCopy(listLabel);
                    //删除空标签
                    dbMsSql.Delete <Business_PersonnelLabel_Information>(i => i.PersonnelVVGUID == personVGUID && i.LabelName == "");
                }
                result = dbMsSql.Update <Business_Personnel_Information>(new { OwnedFleet = departmentVguid }, i => i.Vguid == personVGUID);
                return(result);
            }
        }
 /// <summary>
 /// 插入企业付款信息
 /// </summary>
 /// <param name="paymentInfos"></param>
 /// <returns></returns>
 public bool InsertPaymentInfos(List <Business_Enterprisepayment_Information> paymentInfos)
 {
     using (SqlSugarClient db = SugarDao.SugarDao_MsSql.GetInstance())
     {
         bool result = false;
         result = db.SqlBulkCopy(paymentInfos);
         return(result);
     }
 }
 /// <summary>
 /// 插入红包信息
 /// </summary>
 /// <param name="redpacketPushInfos"></param>
 /// <returns></returns>
 public bool InsertRedPacketInfo(List <Business_Redpacket_Push_Information> redpacketPushInfos)
 {
     using (SqlSugarClient db = SugarDao.SugarDao_MsSql.GetInstance())
     {
         bool result = false;
         result = db.SqlBulkCopy(redpacketPushInfos);
         return(result);
     }
 }
Exemplo n.º 7
0
        private void InitData(SqlSugarClient db)
        {
            try
            {
                db.ExecuteCommand(" DROP  sequence SEQ");
            }
            catch (Exception)
            {
            }
            try
            {
                db.ExecuteCommand(" DROP  sequence SEQ2");
            }
            catch (Exception)
            {
            }
            try
            {
                db.ExecuteCommand(" DROP  sequence SEQ3");
            }
            catch (Exception)
            {
            }
            try
            {
                db.ExecuteCommand(" DROP  sequence SEQ4");
            }
            catch (Exception)
            {
            }
            db.ExecuteCommand("  create  sequence SEQ");
            db.ExecuteCommand("  create  sequence SEQ2");
            db.ExecuteCommand("  create  sequence SEQ3");
            db.ExecuteCommand("  create  sequence SEQ4");
            db.ExecuteCommand("truncate table Subject");
            db.ExecuteCommand("truncate table student");
            db.ExecuteCommand("truncate table school");
            db.ExecuteCommand("truncate table area");

            db.SqlBulkCopy(StudentList);
            db.SqlBulkCopy(SchoolList);
            db.SqlBulkCopy(SubjectList);
            db.InsertRange(AreaList);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 查询出刚插入的1000条数据
 /// </summary>
 /// <returns></returns>
 private static List <Test> GetDeleteList()
 {
     using (SqlSugarClient conn = new SqlSugarClient(PubConst.connectionString))
     {
         conn.Delete <Test>(it => it.F_String == "Test");
         //插入1000条
         conn.SqlBulkCopy(GetList);
         //查询出插入的1000条
         var list = conn.Queryable <Test>().Where(it => it.F_String == "Test").ToList();
         return(list);
     }
 }
Exemplo n.º 9
0
        private static void SqlSugar(int eachCount)
        {
            GC.Collect();                        //回收资源
            System.Threading.Thread.Sleep(2000); //休息2秒

            PerHelper.Execute(eachCount, "SqlSugar", () =>
            {
                using (SqlSugarClient conn = new SqlSugarClient(PubConst.connectionString))
                {
                    var list = conn.SqlBulkCopy(GetList);
                }
            });
        }
Exemplo n.º 10
0
        public void Init()
        {
            using (SqlSugarClient db = SugarDao.GetInstance())//开启数据库连接
            {
                Student s = new Student()
                {
                    name = "张" + new Random().Next(1, int.MaxValue)
                };

                db.Insert(s); //插入一条记录 (有主键也好,没主键也好,有自增列也好都可以插进去)


                List <Student> list = new List <Student>()
                {
                    new Student()
                    {
                        name = "张" + new Random().Next(1, int.MaxValue)
                    },
                    new Student()
                    {
                        name = "张" + new Random().Next(1, int.MaxValue)
                    }
                };

                db.InsertRange(list); //批量插入


                //高性能批量插入
                //注意:性能比InsertRange高,功能没有InsertRange全,不支持别名表和排除列
                using (SqlSugarClient db2 = SugarDao.GetInstance())//开启数据库连接
                {
                    var list2 = new List <Student>()
                    {
                        new Student()
                        {
                            isOk = true, name = "张三", sch_id = 1, sex = "男"
                        },
                        new Student()
                        {
                            isOk = true, name = "sun", sch_id = 1, sex = "女"
                        },
                        new Student()
                        {
                            isOk = true, name = "mama", sch_id = 1, sex = "gril"
                        }
                    };
                    db.SqlBulkCopy <Student>(list2);
                }
            }
        }
Exemplo n.º 11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (SqlSugarClient db = SugarDao.GetInstance())//开启数据库连接
     {
         var list = new List <Student>()
         {
             new Student()
             {
                 isOk = true, name = "张三", sch_id = 1, sex = "男"
             },
             new Student()
             {
                 isOk = true, name = "sun", sch_id = 1, sex = "女"
             },
             new Student()
             {
                 isOk = true, name = "mama", sch_id = 1, sex = "gril"
             }
         };
         db.SqlBulkCopy <Student>(list);
     }
 }
Exemplo n.º 12
0
        private static void SqlSugar(int eachCount)
        {
            GC.Collect();//回收资源
            System.Threading.Thread.Sleep(2000);//休息2秒

            PerHelper.Execute(eachCount, "SqlSugar", () =>
            {
                using (SqlSugarClient conn = new SqlSugarClient(PubConst.connectionString))
                {
                    var list = conn.SqlBulkCopy(GetList);
                }
            });
        }
Exemplo n.º 13
0
 /// <summary>
 /// 查询出刚插入的1000条数据
 /// </summary>
 /// <returns></returns>
 private static List<Test> GetDeleteList()
 {
     using (SqlSugarClient conn = new SqlSugarClient(PubConst.connectionString))
     {
         conn.Delete<Test>(it => it.F_String == "Test");
         //插入1000条
         conn.SqlBulkCopy(GetList);
         //查询出插入的1000条
         var list = conn.Queryable<Test>().Where(it => it.F_String == "Test").ToList();
         return list;
     }
 }
Exemplo n.º 14
0
        private void InitData(SqlSugarClient db)
        {
            db.ExecuteCommand("truncate table Subject");
            db.ExecuteCommand("truncate table student");
            db.ExecuteCommand("truncate table school");
            db.ExecuteCommand("truncate table area");

            db.SqlBulkCopy(SchoolList);
            db.SqlBulkCopy(StudentList);
            db.SqlBulkCopy(SubjectList);
            db.InsertRange(AreaList);
        }
Exemplo n.º 15
0
        //public Sqlable Sqlable()
        //{
        //    return _db.Sqlable();
        //}

        public bool SqlBulkCopy <T>(List <T> entities) where T : class
        {
            return(_db.SqlBulkCopy(entities));
        }
Exemplo n.º 16
0
        /// <summary>
        /// 保存推送信息(主信息,详细信息)
        /// </summary>
        /// <param name="weChatMain"></param>
        /// <param name="weChatDetailList"></param>
        /// <returns></returns>
        public bool SavePushMsg(Business_WeChatPush_Information weChatMain, List <Business_WeChatPushDetail_Information> weChatDetailList, bool isEdit)
        {
            using (SqlSugarClient _dbMsSql = SugarDao_MsSql.GetInstance())
            {
                bool result = false;
                try
                {
                    _dbMsSql.BeginTran();
                    if (isEdit) //编辑
                    {
                        var model = new
                        {
                            Title              = weChatMain.Title,
                            RevenueType        = weChatMain.RevenueType,
                            CountersignType    = weChatMain.CountersignType,
                            Status             = weChatMain.Status,
                            Timed              = weChatMain.Timed,
                            TimedSendTime      = weChatMain.TimedSendTime,
                            Important          = weChatMain.Important,
                            Message            = weChatMain.Message,
                            History            = weChatMain.History,
                            PeriodOfValidity   = weChatMain.PeriodOfValidity,
                            ChangeDate         = weChatMain.ChangeDate,
                            ChangeUser         = weChatMain.ChangeUser,
                            CoverImg           = weChatMain.CoverImg,
                            CoverDescption     = weChatMain.CoverDescption,
                            ExercisesVGUID     = weChatMain.ExercisesVGUID, //推送习题Vguid
                            KnowledgeVGUID     = weChatMain.KnowledgeVGUID, //推送知识库Vguid
                            RedpacketMoney     = weChatMain.RedpacketMoney,
                            RedpacketMoneyFrom = weChatMain.RedpacketMoneyFrom,
                            RedpacketMoneyTo   = weChatMain.RedpacketMoneyTo
                        };
                        if (model.PeriodOfValidity == null) //说明是永久有效,则加入知识库
                        {
                            //先查询改知识是否存在
                            bool isExist = _dbMsSql.Queryable <Business_KnowledgeBase_Information>().Any(i => i.Title == model.Title);
                            if (!isExist)
                            {
                                //不存在则插入
                                var knowledge = new Business_KnowledgeBase_Information()
                                {
                                    Title       = model.Title,
                                    Content     = weChatMain.MessageType == 4 ? model.Message + " " + "4" : model.Message,
                                    Type        = "1",
                                    Status      = "1",
                                    Remark      = "",
                                    CreatedDate = DateTime.Now,
                                    CreatedUser = CurrentUser.GetCurrentUser().LoginName,
                                    Vguid       = Guid.NewGuid()
                                };
                                _dbMsSql.Insert(knowledge, false);
                            }
                            else
                            {
                                //存在则更新
                                _dbMsSql.Update <Business_KnowledgeBase_Information>(new
                                {
                                    //Title = model.Title,
                                    Content    = model.Message,
                                    ChangeUser = CurrentUser.GetCurrentUser().LoginName,
                                    ChangeDate = DateTime.Now,
                                }, i => i.Title == model.Title);
                            }
                        }
                        result = _dbMsSql.Update <Business_WeChatPush_Information>(model, i => i.VGUID == weChatMain.VGUID);

                        //存入操作日志表
                        string logData = JsonHelper.ModelToJson <Business_WeChatPush_Information>(weChatMain);
                        _ll.SaveLog(4, 14, Common.CurrentUser.GetCurrentUser().LoginName, weChatMain.Title, logData);
                    }
                    else //新增
                    {
                        if (weChatMain.PeriodOfValidity == null)
                        {
                            var knowledge = new Business_KnowledgeBase_Information()
                            {
                                Title       = weChatMain.Title,
                                Content     = weChatMain.Message,
                                Type        = "1",
                                Status      = "1",
                                Remark      = "",
                                CreatedDate = weChatMain.CreatedDate,
                                CreatedUser = weChatMain.CreatedUser,
                                Vguid       = Guid.NewGuid()
                            };
                            _dbMsSql.Insert(knowledge, false);
                        }
                        result = _dbMsSql.Insert(weChatMain, false) != DBNull.Value;

                        //存入操作日志表
                        string logData = JsonHelper.ModelToJson(weChatMain);
                        _ll.SaveLog(1, 13, weChatMain.CreatedUser, weChatMain.Title, logData);
                    }
                    _dbMsSql.Delete <Business_WeChatPushDetail_Information>(i => i.Business_WeChatPushVguid == weChatMain.VGUID);
                    //存入操作日志表
                    string log = JsonHelper.ModelToJson(weChatDetailList);
                    _ll.SaveLog(1, 15, weChatMain.CreatedUser, weChatMain.Title, log);
                    _dbMsSql.SqlBulkCopy(weChatDetailList);
                    _dbMsSql.CommitTran();
                }
                catch (Exception ex)
                {
                    _dbMsSql.RollbackTran();
                    LogHelper.WriteLog(ex.Message + "/n" + ex.ToString() + "/n" + ex.StackTrace);
                }

                return(result);
            }
        }