Exemplo n.º 1
0
        public static string GetSchoolUrl(string schoolId)
        {
            string temp = string.Empty;

            try
            {
                Model_ConfigSchool modelCS = new Model_ConfigSchool();
                BLL_ConfigSchool   bllCS   = new BLL_ConfigSchool();
                modelCS = bllCS.GetModelBySchoolId(schoolId.Filter());
                if (modelCS == null)
                {
                    temp = JsonConvert.SerializeObject(new
                    {
                        err = "学校配置信息不存在"
                    });
                }
                else
                {
                    if (string.IsNullOrEmpty(modelCS.D_PublicValue))
                    {
                        temp = JsonConvert.SerializeObject(new
                        {
                            err = "请配置学校外网地址"
                        });
                    }
                    else
                    {
                        temp = JsonConvert.SerializeObject(new
                        {
                            err            = "null",
                            SchoolIP_Local = modelCS.D_Value,
                            SchoolIP       = modelCS.D_PublicValue
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                temp = JsonConvert.SerializeObject(new
                {
                    err = ex.Message.ToString()
                });
            }
            return(temp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 文件同步
        /// </summary>
        protected void btnDataAnalysis_Click(object sender, EventArgs e)
        {
            try
            {
                string strDate           = txtBeginTime.Text.Trim();
                string strSchool         = hidtxtSchool.Value.Trim();
                string strSchoolExtranet = string.Empty;
                if (string.IsNullOrEmpty(strDate))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('请选择日期',{icon: 2, time: 2000 });", true);
                    return;
                }
                if (string.IsNullOrEmpty(strSchool))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('请选择学校',{icon: 2, time: 2000 });", true);
                    return;
                }
                Model_ConfigSchool modelCS = new Model_ConfigSchool();
                BLL_ConfigSchool   bllCS   = new BLL_ConfigSchool();
                modelCS = bllCS.GetModelBySchoolId(hidtxtSchool.Value);
                if (modelCS == null)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('学校配置信息不存在',{icon: 2, time: 2000 });", true);
                    return;
                }
                else
                {
                    if (string.IsNullOrEmpty(modelCS.D_PublicValue))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.closeAll();layer.msg('请配置学校外网IP',{icon: 2, time: 2000 });", true);
                        return;
                    }
                    else
                    {
                        strSchoolExtranet = modelCS.D_PublicValue;
                    }
                }

                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  步

                    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(strSchoolExtranet, strDate, strSchool);
                        ResSynchroTeachingPlanView(strSchoolExtranet, strDate, strSchool);
                    }
                    else if (ddlType.SelectedValue == "2")//习题集
                    {
                        ResSynchroTest(strSchoolExtranet, strDate, strSchool);
                    }
                    else
                    {
                        ResSynchroTeachingPlan(strSchoolExtranet, strDate, strSchool);
                        ResSynchroTeachingPlanView(strSchoolExtranet, strDate, strSchool);
                        ResSynchroTest(strSchoolExtranet, strDate, strSchool);
                    }

                    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.SyncSchool.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);
            }
        }