예제 #1
0
        /// <summary>
        /// 插入一条数据,并返回插入的实体
        /// </summary>
        /// <param name="model">实体类</param>
        /// <returns>插入后的实体</returns>
        public ReminderHistoryModel CreateAndReturn(ReminderHistoryModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("INSERT ReminderHistory(RunStartTime, RunEndTime, RunDate, DataStartTime, DataEndTime, TotalCount, SuccessCount, FailCount, ErrorCount, State, CreateTime) ");
            strSql.Append("OUTPUT Inserted.Id, Inserted.RunStartTime, Inserted.RunEndTime, Inserted.RunDate, Inserted.DataStartTime, Inserted.DataEndTime, Inserted.TotalCount, Inserted.SuccessCount, Inserted.FailCount, Inserted.ErrorCount, Inserted.State, Inserted.CreateTime ");
            strSql.Append("VALUES(@RunStartTime, @RunEndTime, @RunDate, @DataStartTime, @DataEndTime, @TotalCount, @SuccessCount, @FailCount, @ErrorCount, @State, @CreateTime) ");

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                db.AddInParameter(dbCommand, "RunStartTime", DbType.DateTime, model.RunStartTime);
                db.AddInParameter(dbCommand, "RunEndTime", DbType.DateTime, model.RunEndTime);
                db.AddInParameter(dbCommand, "RunDate", DbType.Date, model.RunDate);
                db.AddInParameter(dbCommand, "DataStartTime", DbType.DateTime, model.DataStartTime);
                db.AddInParameter(dbCommand, "DataEndTime", DbType.DateTime, model.DataEndTime);
                db.AddInParameter(dbCommand, "TotalCount", DbType.Int32, model.TotalCount);
                db.AddInParameter(dbCommand, "SuccessCount", DbType.Int32, model.SuccessCount);
                db.AddInParameter(dbCommand, "FailCount", DbType.Int32, model.FailCount);
                db.AddInParameter(dbCommand, "ErrorCount", DbType.Int32, model.ErrorCount);
                db.AddInParameter(dbCommand, "State", DbType.Int32, model.State);
                db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, model.CreateTime);

                DataSet dataSet = db.ExecuteDataSet(dbCommand);

                if (dataSet != null && dataSet.Tables[0].Rows.Count > 0)
                {
                    model.Id = dataSet.Tables[0].Rows[0]["Id"].ToInt32();
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 更新
        /// </summary>
        public int UpdateModel(ReminderHistoryModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE ReminderHistory SET RunStartTime = @RunStartTime, RunEndTime = @RunEndTime, RunDate = @RunDate, DataStartTime = @DataStartTime, DataEndTime = @DataEndTime, TotalCount = @TotalCount, SuccessCount = @SuccessCount, FailCount = @FailCount, ErrorCount = @ErrorCount, State = @State ");
            strSql.Append("WHERE Id = @Id ");

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                db.AddInParameter(dbCommand, "Id", DbType.Int32, model.Id);
                db.AddInParameter(dbCommand, "RunStartTime", DbType.DateTime, model.RunStartTime);
                db.AddInParameter(dbCommand, "RunEndTime", DbType.DateTime, model.RunEndTime);
                db.AddInParameter(dbCommand, "RunDate", DbType.Date, model.RunDate);
                db.AddInParameter(dbCommand, "DataStartTime", DbType.DateTime, model.DataStartTime);
                db.AddInParameter(dbCommand, "DataEndTime", DbType.DateTime, model.DataEndTime);
                db.AddInParameter(dbCommand, "TotalCount", DbType.Int32, model.TotalCount);
                db.AddInParameter(dbCommand, "SuccessCount", DbType.Int32, model.SuccessCount);
                db.AddInParameter(dbCommand, "FailCount", DbType.Int32, model.FailCount);
                db.AddInParameter(dbCommand, "ErrorCount", DbType.Int32, model.ErrorCount);
                db.AddInParameter(dbCommand, "State", DbType.Int32, model.State);
                db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, model.CreateTime);


                int effectCount = db.ExecuteNonQuery(dbCommand);;

                return(effectCount);
            }
        }
예제 #3
0
        /// <summary>
        /// 插入一条数据
        /// </summary>
        /// <param name="model">实体类</param>
        /// <returns>是否成功</returns>
        public bool Create(ReminderHistoryModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("INSERT ReminderHistory(RunStartTime, RunEndTime, RunDate, DataStartTime, DataEndTime, TotalCount, SuccessCount, FailCount, ErrorCount, State, CreateTime) ");
            strSql.Append("OUTPUT Inserted.Id, Inserted.RunStartTime, Inserted.RunEndTime, Inserted.RunDate, Inserted.DataStartTime, Inserted.DataEndTime, Inserted.TotalCount, Inserted.SuccessCount, Inserted.FailCount, Inserted.ErrorCount, Inserted.State, Inserted.CreateTime ");
            strSql.Append("VALUES(@RunStartTime, @RunEndTime, @RunDate, @DataStartTime, @DataEndTime, @TotalCount, @SuccessCount, @FailCount, @ErrorCount, @State, @CreateTime) ");

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                db.AddInParameter(dbCommand, "RunStartTime", DbType.DateTime, model.RunStartTime);
                db.AddInParameter(dbCommand, "RunEndTime", DbType.DateTime, model.RunEndTime);
                db.AddInParameter(dbCommand, "RunDate", DbType.Date, model.RunDate);
                db.AddInParameter(dbCommand, "DataStartTime", DbType.DateTime, model.DataStartTime);
                db.AddInParameter(dbCommand, "DataEndTime", DbType.DateTime, model.DataEndTime);
                db.AddInParameter(dbCommand, "TotalCount", DbType.Int32, model.TotalCount);
                db.AddInParameter(dbCommand, "SuccessCount", DbType.Int32, model.SuccessCount);
                db.AddInParameter(dbCommand, "FailCount", DbType.Int32, model.FailCount);
                db.AddInParameter(dbCommand, "ErrorCount", DbType.Int32, model.ErrorCount);
                db.AddInParameter(dbCommand, "State", DbType.Int32, model.State);
                db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, model.CreateTime);


                var effectCount = db.ExecuteNonQuery(dbCommand);
                if (effectCount > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 更新
        /// </summary>
        public bool UpdateModel(ReminderHistoryModel model)
        {
            int result = dal.UpdateModel(model);

            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        private ReminderHistoryModel IniReminderHistory()
        {
            ReminderHistoryModel historyModel = new ReminderHistoryModel();

            historyModel.Id            = 0;
            historyModel.RunStartTime  = DateTime.Now;
            historyModel.RunEndTime    = null;
            historyModel.RunDate       = DateTime.Now;
            historyModel.DataStartTime = new DateTime(1998, 1, 1);
            historyModel.DataEndTime   = DateTime.Now.Date.AddDays(-3);
            historyModel.State         = ReminderStateEnum.Reminding;
            historyModel.CreateTime    = DateTime.Now;

            return(_historyManager.CreateAndReturn(historyModel));
        }
예제 #6
0
        public bool ReminderAll()
        {
            if (IsCanRun())
            {
                //插入一条新同步记录
                ReminderHistoryModel historyModel = IniReminderHistory();


                //所有用户提醒
                var users = _usersApp.GetActiveUserList();
                foreach (var user in users)
                {
                    //每用户提醒
                    ReminderByUser(user);
                }

                //更新同步记录
                historyModel.RunEndTime = DateTime.Now;
                historyModel.State      = ReminderStateEnum.Succeed;
                _historyManager.UpdateModel(historyModel);
            }

            return(true);
        }
예제 #7
0
 /// <summary>
 /// 插入一条数据,并返回插入的实体
 /// </summary>
 /// <param name="model">实体类</param>
 /// <returns>插入后的实体</returns>
 public ReminderHistoryModel CreateAndReturn(ReminderHistoryModel model)
 {
     return(dal.CreateAndReturn(model));
 }
예제 #8
0
 /// <summary>
 /// 插入一条数据
 /// </summary>
 /// <param name="model">实体类</param>
 /// <returns>是否成功</returns>
 public bool Create(ReminderHistoryModel model)
 {
     return(dal.Create(model));
 }