예제 #1
0
        public List <Model_FileSyncRecord> DataTableToList(DataTable dt)
        {
            List <Model_FileSyncRecord> list = new List <Model_FileSyncRecord>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Model_FileSyncRecord item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
예제 #2
0
        public bool Add(Model_FileSyncRecord model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into FileSyncRecord(");
            builder.Append("FileSyncRecord_Id,SyncLong,Remark,SyncTime,SyncUserId,SyncUserName,SyncType)");
            builder.Append(" values (");
            builder.Append("@FileSyncRecord_Id,@SyncLong,@Remark,@SyncTime,@SyncUserId,@SyncUserName,@SyncType)");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@FileSyncRecord_Id", SqlDbType.Char, 0x24), new SqlParameter("@SyncLong", SqlDbType.VarChar, 50), new SqlParameter("@Remark", SqlDbType.NVarChar, 200), new SqlParameter("@SyncTime", SqlDbType.DateTime), new SqlParameter("@SyncUserId", SqlDbType.Char, 0x24), new SqlParameter("@SyncUserName", SqlDbType.NVarChar, 200), new SqlParameter("@SyncType", SqlDbType.VarChar, 50) };
            cmdParms[0].Value = model.FileSyncRecord_Id;
            cmdParms[1].Value = model.SyncLong;
            cmdParms[2].Value = model.Remark;
            cmdParms[3].Value = model.SyncTime;
            cmdParms[4].Value = model.SyncUserId;
            cmdParms[5].Value = model.SyncUserName;
            cmdParms[6].Value = model.SyncType;
            return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
예제 #3
0
        public bool Update(Model_FileSyncRecord model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update FileSyncRecord set ");
            builder.Append("SyncLong=@SyncLong,");
            builder.Append("Remark=@Remark,");
            builder.Append("SyncTime=@SyncTime,");
            builder.Append("SyncUserId=@SyncUserId,");
            builder.Append("SyncUserName=@SyncUserName,");
            builder.Append("SyncType=@SyncType");
            builder.Append(" where FileSyncRecord_Id=@FileSyncRecord_Id ");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@SyncLong", SqlDbType.VarChar, 50), new SqlParameter("@Remark", SqlDbType.NVarChar, 200), new SqlParameter("@SyncTime", SqlDbType.DateTime), new SqlParameter("@SyncUserId", SqlDbType.Char, 0x24), new SqlParameter("@SyncUserName", SqlDbType.NVarChar, 200), new SqlParameter("@SyncType", SqlDbType.VarChar, 50), new SqlParameter("@FileSyncRecord_Id", SqlDbType.Char, 0x24) };
            cmdParms[0].Value = model.SyncLong;
            cmdParms[1].Value = model.Remark;
            cmdParms[2].Value = model.SyncTime;
            cmdParms[3].Value = model.SyncUserId;
            cmdParms[4].Value = model.SyncUserName;
            cmdParms[5].Value = model.SyncType;
            cmdParms[6].Value = model.FileSyncRecord_Id;
            return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
예제 #4
0
        public Model_FileSyncRecord DataRowToModel(DataRow row)
        {
            Model_FileSyncRecord record = new Model_FileSyncRecord();

            if (row != null)
            {
                if (row["FileSyncRecord_Id"] != null)
                {
                    record.FileSyncRecord_Id = row["FileSyncRecord_Id"].ToString();
                }
                if (row["SyncLong"] != null)
                {
                    record.SyncLong = row["SyncLong"].ToString();
                }
                if (row["Remark"] != null)
                {
                    record.Remark = row["Remark"].ToString();
                }
                if ((row["SyncTime"] != null) && (row["SyncTime"].ToString() != ""))
                {
                    record.SyncTime = new DateTime?(DateTime.Parse(row["SyncTime"].ToString()));
                }
                if (row["SyncUserId"] != null)
                {
                    record.SyncUserId = row["SyncUserId"].ToString();
                }
                if (row["SyncUserName"] != null)
                {
                    record.SyncUserName = row["SyncUserName"].ToString();
                }
                if (row["SyncType"] != null)
                {
                    record.SyncType = row["SyncType"].ToString();
                }
            }
            return(record);
        }
예제 #5
0
 public bool Add(Model_FileSyncRecord model)
 {
     return(this.dal.Add(model));
 }
예제 #6
0
 public bool Update(Model_FileSyncRecord model)
 {
     return(this.dal.Update(model));
 }
예제 #7
0
        /// <summary>
        /// 文件同步
        /// </summary>
        protected void btnDataAnalysis_Click(object sender, EventArgs e)
        {
            try
            {
                string strDate = txtBeginTime.Text.Trim();
                if (string.IsNullOrEmpty(strDate))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('文件同步失败',{icon: 2, time: 2000 });", true);
                    return;
                }

                try
                {
                    Model_FileSyncRecord modelSync = new Model_FileSyncRecord();
                    modelSync.FileSyncRecord_Id = Guid.NewGuid().ToString();
                    modelSync.SyncTime          = DateTime.Now;

                    Stopwatch timer = new System.Diagnostics.Stopwatch();
                    timer.Start();

                    #region  步

                    //同步数据
                    SynchronousData();
                    //统计生数据情况 暂时去掉,有单独模块执行
                    //GenerateStatisticsData();
                    Rc.Model.Resources.Model_SystemLogFileSync model = new Rc.Model.Resources.Model_SystemLogFileSync();
                    Rc.BLL.Resources.BLL_SystemLogFileSync     bll   = new Rc.BLL.Resources.BLL_SystemLogFileSync();
                    model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                    //model.FileSize = ls;
                    // model.SyncUrl = strFilePath;
                    model.MsgType    = "Start";
                    model.ErrorMark  = DateTime.Now.ToString();
                    model.CreateTime = DateTime.Now;
                    bll.Add(model);

                    //for (int i = 0; i < 30; i++)
                    //{
                    //string strDate = DateTime.Now.ToString("yyyy-MM-dd");

                    // Date = DateTime.Now.ToString("yyyy-MM-dd");
                    //Rc.Model.Resources.Model_SystemLogFileSync model = new Rc.Model.Resources.Model_SystemLogFileSync();
                    // Rc.BLL.Resources.BLL_SystemLogFileSync bll = new Rc.BLL.Resources.BLL_SystemLogFileSync();
                    model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                    //model.FileSize = ls;
                    // model.SyncUrl = strFilePath;
                    model.MsgType    = "Start";
                    model.ErrorMark  = strDate;
                    model.CreateTime = DateTime.Now;
                    bll.Add(model);

                    strLog = new StringBuilder();

                    //同步文件
                    if (ddlType.SelectedValue == "1")//教案
                    {
                        ResSynchroTeachingPlan(strDate);
                        ResSynchroTeachingPlanView(strDate);
                    }
                    else if (ddlType.SelectedValue == "2")//习题集
                    {
                        ResSynchroTest(strDate);
                    }
                    else
                    {
                        ResSynchroTeachingPlan(strDate);
                        ResSynchroTeachingPlanView(strDate);
                        ResSynchroTest(strDate);
                    }

                    model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                    //model.FileSize = ls;
                    // model.SyncUrl = strFilePath;
                    model.MsgType = "End";
                    // model.ErrorMark = ex.Message;
                    model.CreateTime = DateTime.Now;
                    bll.Add(model);
                    //}
                    #endregion

                    timer.Stop();
                    string lenght = timer.Elapsed.ToString();
                    modelSync.SyncUserId   = loginUser.SysUser_ID;
                    modelSync.SyncUserName = loginUser.SysUser_Name == "" ? loginUser.SysUser_LoginName : loginUser.SysUser_Name;
                    modelSync.SyncLong     = lenght;
                    modelSync.SyncType     = FileSyncType.SyncOperate.ToString();

                    if (new BLL_FileSyncRecord().Add(modelSync))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('文件同步成功',{icon: 1, time: 1000 },function(){loadData();});", true);
                        return;
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('文件同步失败',{icon: 2, time: 2000 });", true);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Rc.Model.Resources.Model_SystemLogFileSync model = new Rc.Model.Resources.Model_SystemLogFileSync();
                    Rc.BLL.Resources.BLL_SystemLogFileSync     bll   = new Rc.BLL.Resources.BLL_SystemLogFileSync();
                    model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                    //model.FileSize = ls;
                    // model.SyncUrl = strFilePath;
                    model.MsgType    = "Error";
                    model.ErrorMark  = ex.Message;
                    model.CreateTime = DateTime.Now;
                    bll.Add(model);
                    throw;
                }
            }
            catch (Exception ex)
            {
                new BLL_clsAuth().AddLogErrorFromBS("文件同步失败:", string.Format("类:{0},方法{1},错误信息:{2}", ex.TargetSite.DeclaringType.ToString()
                                                                             , ex.TargetSite.Name.ToString(), ex.Message));
                ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('文件同步失败,出现异常',{icon: 2, time: 2000 });", true);
            }
        }
예제 #8
0
        /// <summary>
        /// 同步失败文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUsering_Click(object sender, EventArgs e)
        {
            try
            {
                //string strDate = txtBeginTime.Text.Trim();
                //if (string.IsNullOrEmpty(strDate))
                //{
                //    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('文件同步失败',{icon: 2, time: 2000 });", true);
                //    return;
                //}

                try
                {
                    Model_FileSyncRecord modelSync = new Model_FileSyncRecord();
                    modelSync.FileSyncRecord_Id = Guid.NewGuid().ToString();
                    modelSync.SyncTime          = DateTime.Now;

                    Stopwatch timer = new System.Diagnostics.Stopwatch();
                    timer.Start();

                    #region  步

                    //把运营平台的失败文件数据同步到生产平台
                    //SynchronousData();
                    Rc.Model.Resources.Model_SystemLogFileSync model = new Rc.Model.Resources.Model_SystemLogFileSync();
                    Rc.BLL.Resources.BLL_SystemLogFileSync     bll   = new Rc.BLL.Resources.BLL_SystemLogFileSync();
                    model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                    model.MsgType             = "Start";
                    model.ErrorMark           = DateTime.Now.ToString();
                    model.CreateTime          = DateTime.Now;
                    bll.Add(model);
                    model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                    model.MsgType             = "Start";
                    model.ErrorMark           = DateTime.Now.ToString();
                    model.CreateTime          = DateTime.Now;
                    bll.Add(model);

                    strLog = new StringBuilder();

                    //同步文件
                    ResSynchroTeachingPlan();
                    ResSynchroTeachingPlanView();
                    ResSynchroTest();

                    model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                    //model.FileSize = ls;
                    // model.SyncUrl = strFilePath;
                    model.MsgType = "End";
                    // model.ErrorMark = ex.Message;
                    model.CreateTime = DateTime.Now;
                    bll.Add(model);
                    //}
                    #endregion

                    timer.Stop();
                    string lenght = timer.Elapsed.ToString();
                    modelSync.SyncUserId   = loginUser.SysUser_ID;
                    modelSync.SyncUserName = loginUser.SysUser_Name == "" ? loginUser.SysUser_LoginName : loginUser.SysUser_Name;
                    modelSync.SyncLong     = lenght;


                    if (new BLL_FileSyncRecord().Add(modelSync))
                    {
                        string TempSql = "delete from FileSyncRecordFail";
                        Rc.Common.DBUtility.DbHelperSQL.ExecuteSql(TempSql);
                        ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('文件同步成功',{icon: 1, time: 1000 },function(){loadData();});", true);
                        return;
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('文件同步失败',{icon: 2, time: 2000 });", true);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Rc.Model.Resources.Model_SystemLogFileSync model = new Rc.Model.Resources.Model_SystemLogFileSync();
                    Rc.BLL.Resources.BLL_SystemLogFileSync     bll   = new Rc.BLL.Resources.BLL_SystemLogFileSync();
                    model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                    //model.FileSize = ls;
                    // model.SyncUrl = strFilePath;
                    model.MsgType    = "Error";
                    model.ErrorMark  = ex.Message;
                    model.CreateTime = DateTime.Now;
                    bll.Add(model);
                    throw;
                }
            }
            catch (Exception ex)
            {
                new BLL_clsAuth().AddLogErrorFromBS("文件同步失败:", string.Format("类:{0},方法{1},错误信息:{2}", ex.TargetSite.DeclaringType.ToString()
                                                                             , ex.TargetSite.Name.ToString(), ex.Message));
                ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('文件同步失败,出现异常',{icon: 2, time: 2000 });", true);
            }
        }