示例#1
0
        protected void Application_Start()
        {
            AutoMapperConf.MapperInit.Init();
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BConfig.RegisterBundles(BundleTable.Bundles);
            //BundleConfig.RegisterBundles(BundleTable.Bundles);



            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize;
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Include;
        }
示例#2
0
        /// <summary>
        /// 启动
        /// </summary>
        public static void Start()
        {
            IsRun = true;

            try
            {
                BLog.Write(BLog.LogLevel.INFO, "程序即将启动。");

                MaxExecuteNodeCount = BConfig.GetConfigToInt("MaxExecuteNodeCount");
                if (MaxExecuteNodeCount < 1)
                {
                    MaxExecuteNodeCount = 10;
                }

                MaxUploadCount = BConfig.GetConfigToInt("MaxUploadCount");

                EachUploadCount = BConfig.GetConfigToInt("EachUploadCount");

                EachSearchUploadCount = BConfig.GetConfigToInt("EachSearchUploadCount");

                MaxMonitCount = BConfig.GetConfigToInt("MaxMonitCount");

                NeedClearCount = BConfig.GetConfigToInt("NeedClearCount");


                //if (MaxExecuteNodeCount < 1)
                //{
                //    MaxExecuteNodeCount = 10;
                //}

                if (bool.TryParse(BConfig.GetConfigToString("KeyFieldIsAutoIncrement"), out KeyFieldIsAutoIncrement) == false)
                {
                    KeyFieldIsAutoIncrement = true;
                }

                if (bool.TryParse(BConfig.GetConfigToString("KeyFieldIsUseSequence"), out KeyFieldIsUseSequence) == false)
                {
                    BLog.Write(BLog.LogLevel.FATAL, "KeyFieldIsUseSequence配置不正确,请在.config中配置为true或false。");
                    IsRun = false;
                    return;
                }

                if (KeyFieldIsAutoIncrement && KeyFieldIsUseSequence)
                {
                    BLog.Write(BLog.LogLevel.FATAL, "KeyFieldIsAutoIncrement和KeyFieldIsUseSequence不可以同时配置为true,即:数据库已经可以自己实现自增长了,就不再需要另外配置序列,请在.config中修改配置。");
                    IsRun = false;
                    return;
                }

                if (KeyFieldIsAutoIncrement == false && KeyFieldIsUseSequence == false)
                {
                    BLog.Write(BLog.LogLevel.FATAL, "KeyFieldIsAutoIncrement和KeyFieldIsUseSequence不可以同时配置为false,即:数据库不能实现自增长,对于oracle和DB2来说,就需要使用序列,请在.config中修改配置。");
                    IsRun = false;
                    return;
                }

                //节点任务记录器
                _dicRunningNodeCaseID = new Dictionary <long, DateTime>();

                lock (_dicRunningNodeCaseID)
                {
                    _dicRunningNodeCaseID = new Dictionary <long, DateTime>();
                }
                _bw = new BackgroundWorker();
                _bw.WorkerSupportsCancellation = true;
                _bw.DoWork += bw_DoWork;
                _bw.RunWorkerAsync();

                #region 并行+非并行:停止遗留的(等待+执行中)任务组 (2018/12/13,与非并行的处理合并)
                var supCaseList = BLL.EM_SCRIPT_CASE.Instance.GetNotStopCaseList();
                if (supCaseList != null && supCaseList.Count > 0)
                {
                    foreach (var sc in supCaseList)
                    {
                        BLL.EM_SCRIPT_CASE.Instance.SetStop(sc.ID, Enums.ReturnCode.Warn);//标记停止的为警告状态
                    }
                }
                #endregion

                #region 作废: 非并行:停止等待中的任务组 (2018/12/13注释,与以上并行的处理合并)
                //var noSupCaseList = BLL.EM_SCRIPT_CASE.Instance.GetRunningNoSuperveneCaseList();
                //if (noSupCaseList != null && noSupCaseList.Count > 0)
                //{
                //    foreach (var sc in noSupCaseList)
                //    {
                //        BLL.EM_SCRIPT_CASE.Instance.SetStop(sc.ID, Enums.ReturnCode.Success);
                //    }
                //}
                #endregion

                #region 5回复为0
                using (BDBHelper dbop = new BDBHelper())
                {
                    dbop.ExecuteNonQuery(string.Format(@"update FM_MONIT_FILE set COPY_STATUS=0 where COPY_STATUS= 5"));
                    dbop.Close();//主动关闭
                }
                #endregion

                #region 重启时删除临时表FM_MONIT_FILE_TEMP_PRO FM_MONIT_FILE_TEMP
                using (BDBHelper dbop = new BDBHelper())
                {
                    dbop.ExecuteNonQuery(string.Format(@"truncate table  FM_MONIT_FILE_TEMP"));
                    dbop.ExecuteNonQuery(string.Format(@"truncate table  FM_MONIT_FILE_TEMP_PRO"));
                    dbop.Close();//主动关闭
                }
                #endregion

                //启动手动任务线程
                Task.Hand.Start();

                //启动节点扫描线程(含监控任务数量的限制处理,含添加的待拷贝文件列表)
                Task.Scanner.Start();

                BLog.Write(BLog.LogLevel.INFO, "程序已经启动。");
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.FATAL, "程序启动失败。" + ex.ToString());
            }
        }