예제 #1
0
        /// <summary>
        /// 同步数据
        /// </summary>
        private void SynchronousData()
        {
            try
            {
                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 = "SynDataStart";

                model.CreateTime = DateTime.Now;
                bll.Add(model);
                int result = Rc.Common.DBUtility.DbHelperSQL.ExecuteSqlByTime("EXEC P_SynchronousData", 3600);
                model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                //model.FileSize = ls;
                // model.SyncUrl = strFilePath;
                model.MsgType = "SynDataEnd";

                model.CreateTime = DateTime.Now;
                bll.Add(model);
            }
            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    = "SynDataError";
                model.ErrorMark  = ex.Message.ToString();
                model.CreateTime = DateTime.Now;
                bll.Add(model);
            }
        }
예제 #2
0
        /// <summary>
        /// 得到请求内容
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            context.Server.ScriptTimeout = 36000;

            try
            {
                string strPath     = context.Request.QueryString["directory"].ToString();
                string strFileName = context.Request.QueryString["fname"].ToString();
                strPath = context.Server.MapPath("\\Upload\\Resource\\" + strPath);//.Replace("Upload", "newUpload");
                if (!Directory.Exists(strPath))
                {
                    Directory.CreateDirectory(strPath);
                }
                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.SyncUrl             = strPath + strFileName;
                model.MsgType             = "整体-开始接收";
                // model.ErrorMark = ex.Message;
                model.CreateTime = DateTime.Now;
                bll.Add(model);

                foreach (string f in context.Request.Files.AllKeys)
                {
                    HttpPostedFile file = context.Request.Files[f];

                    model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                    model.FileSize            = file.ContentLength;
                    model.SyncUrl             = strPath + strFileName;
                    model.MsgType             = "开始接收";
                    // model.ErrorMark = ex.Message;
                    model.CreateTime = DateTime.Now;
                    bll.Add(model);
                    file.SaveAs(strPath + strFileName);

                    model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                    model.FileSize            = file.ContentLength;
                    model.SyncUrl             = strPath + strFileName;
                    model.MsgType             = "接收完成";
                    // model.ErrorMark = ex.Message;
                    model.CreateTime = DateTime.Now;
                    bll.Add(model);
                }

                model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                model.SyncUrl             = strPath + strFileName;
                model.MsgType             = "整体-接收完成";
                // model.ErrorMark = ex.Message;
                model.CreateTime = DateTime.Now;
                bll.Add(model);

                context.Response.Write("1");
            }
            catch (Exception ex)
            {
                string strPath     = context.Request.QueryString["directory"].ToString();
                string strFileName = context.Request.QueryString["fname"].ToString();
                strPath = context.Server.MapPath("\\Upload\\Resource\\" + strPath);//.Replace("Upload", "newUpload");

                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.SyncUrl    = strPath + strFileName;
                model.MsgType    = "接收失败";
                model.ErrorMark  = ex.Message;
                model.CreateTime = DateTime.Now;
                bll.Add(model);
                context.Response.Write(ex.Message.ToString());
            }
        }
예제 #3
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);
            }
        }
예제 #4
0
        private string upLoadFile(string url, string strPath, string strFileName, string strFilePath)
        {
            FileInfo f       = new FileInfo(strFilePath);
            long     ls      = f.Length;
            string   strTemp = string.Empty;


            if (ls <= 1024 * 1024 * 2000)//小于2000兆的同步,大于2000兆的不同步了
            //if (1024 * 1024 * 8 <= ls && ls <= 1024 * 1024 * 20)//小于20兆的同步,大于20兆的不同步了
            {
                string strErryType = string.Empty;

                //sw.WriteLine("同步开始【" + ls.ToString() + "】:" + strFilePath + ";开始时间:" + DateTime.Now.ToLongDateString() + DateTime.Now.ToLongTimeString() + " \n");
                // Server.ScriptTimeout = 36000;
                System.Net.WebClient myWebClient = new System.Net.WebClient();

                // myWebClient.Headers.Add("Content-Type", ContentType);
                myWebClient.QueryString["directory"] = strPath;
                myWebClient.QueryString["fname"]     = strFileName;

                try
                {
                    Rc.Model.Resources.Model_SystemLogFileSync model = new Rc.Model.Resources.Model_SystemLogFileSync();
                    Rc.BLL.Resources.BLL_SystemLogFileSync     bll   = new Rc.BLL.Resources.BLL_SystemLogFileSync();
                    //myWebClient.UploadFileAsync(new Uri(url), "POST", strFilePath);
                    myWebClient.UploadFile(new Uri(url), "POST", strFilePath);

                    //myWebClient.
                    strTemp = "1";
                    model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                    model.FileSize            = ls;
                    model.SyncUrl             = strFilePath;
                    model.MsgType             = "OK";
                    //model.ErrorMark = ex.Message;
                    model.CreateTime = DateTime.Now;
                    bll.Add(model);
                    //if (strPath.IndexOf("microClassDocument") > -1) XHZ.Web.Payment.Core.LogHandler.WriteLogForPay(DateTime.Now.ToString("yyyy-MM-dd"), "同步microClassDocument", strFileName);
                }
                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;
                }

                // sw.WriteLine("结束时间:" + DateTime.Now.ToLongDateString() + DateTime.Now.ToLongTimeString() + " \n");
            }
            else
            {
                //if ((ls > 1024 * 1024 * 20))
                //{
                Rc.Model.Resources.Model_SystemLogFileSync model = new Rc.Model.Resources.Model_SystemLogFileSync();
                Rc.BLL.Resources.BLL_SystemLogFileSync     bll   = new Rc.BLL.Resources.BLL_SystemLogFileSync();
                // sw.WriteLine("太大【" + ls.ToString() + "】没同步:" + strFilePath + ";日期:" + DateTime.Now.ToLongDateString() + DateTime.Now.ToLongTimeString() + " \n");
                model.SystemLogFileSyncID = Guid.NewGuid().ToString();
                model.FileSize            = ls;
                model.SyncUrl             = strFilePath;
                model.MsgType             = "ErrorSize";
                model.ErrorMark           = "文件太大【" + ls.ToString() + "】没同步。:";
                model.CreateTime          = DateTime.Now;
                bll.Add(model);
                //}
            }
            return(strTemp);
        }
예제 #5
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);
            }
        }