Exemple #1
0
        /// <summary> 执行附件自动上传任务
        /// </summary>
        private static void _ExcuteFileTask()
        {
            try
            {
                //用户登录
                FileLoginFlag = LoginCloud_File();

                if (FileLoginFlag)
                {
                    FileAgent.ReceiveComplated += new FileAgent.ReceiveComplate(WriteFileLog);
                }
                FileAgent.SetParas(GlobalStaticObj_Server.Instance.CloundFileIp, GlobalStaticObj_Server.Instance.CloundFilePort);
                //附件传输服务
                FileAgent.StartSendAndReceiveThread();

                while (true)
                {
                    if (FileLoginFlag)
                    {
                        var time        = long.Parse(GlobalStaticObj_Server.Instance.FileLastUploadTime);
                        var currentTime = DateTime.Now;
                        if (currentTime.Hour > 22 && currentTime.Hour < 23 &&
                            time < currentTime.Ticks)
                        {
                            time = currentTime.Ticks;
                            foreach (var dbName in dbListFile)
                            {
                                //上传附件信息
                                FileHandler.UpLoadFile(dbName, time.ToString());

                                //备份上传时间
                                GlobalStaticObj_Server.Instance.FileLastUploadTime = time.ToString();
                                //写入
                                ConfigManager.SaveConfig(ConfigConst.FileUploadTime,
                                                         GlobalStaticObj_Server.Instance.FileLastUploadTime, ConfigConst.ConfigPath);
                            }
                        }
                        Thread.Sleep(60 * 60 * 1000);
                        dbListFile = GetDbList();
                    }
                    else
                    {
                        Thread.Sleep(waitSecond * 1000);
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalStaticObj_Server.CloudPadLogService.WriteLog("云平台", ex);
            }
        }
Exemple #2
0
        /// <summary> 执行附件自动上传任务
        /// </summary>
        private static void _ExcuteFileTask()
        {
            //用户登录
            FileLoginFlag = LoginCloud_File();

            if (FileLoginFlag)
            {
                FileAgent.ReceiveComplated += new FileAgent.ReceiveComplate(WriteFileLog);
            }

            //附件传输服务
            FileAgent.StartSendAndReceiveThread();

            while (true)
            {
                if (FileLoginFlag)
                {
                    long     time        = long.Parse(GlobalStaticObj_Server.Instance.FileLastUploadTime);
                    DateTime currentTime = GlobalStaticObj_Server.Instance.CurrentDateTime;
                    //currentTime = DateTime.Now;
                    if (currentTime.Hour > 22 && currentTime.Hour < 23 &&
                        time < currentTime.Ticks)
                    {
                        time = currentTime.Ticks;
                        foreach (string dbName in dbListFile)
                        {
                            //上传附件信息
                            FileHandler.UpLoadFile(dbName, time.ToString());

                            //备份上传时间
                            GlobalStaticObj_Server.Instance.FileLastUploadTime = time.ToString();
                            //写入
                            ConfigManager.SaveConfig(ConfigConst.FileUploadTime,
                                                     GlobalStaticObj_Server.Instance.FileLastUploadTime, ConfigConst.ConfigPath);
                        }
                    }
                    Thread.Sleep(60 * 60 * 1000);
                    dbListFile = GetDbList();;
                }
                else
                {
                    Thread.Sleep(waitSecond * 1000);
                }
            }
        }
Exemple #3
0
        /// <summary> 开始任务
        /// </summary>
        public static void StartTest(long time)
        {
            GlobalStaticObj_Server.Instance.LastUploadTime     = time.ToString();
            GlobalStaticObj_Server.Instance.FileLastUploadTime = time.ToString();
            if (thread == null)
            {
                status = DataSources.EnumTaskStatus.Not_Started;
                thread = new Thread(new ThreadStart(_ExcuteTaskTest));
                thread.IsBackground = true;
            }
            if (fileThread == null)
            {
                fileThread = new Thread(new ThreadStart(_ExcuteFileTaskTest));
                fileThread.IsBackground = true;
            }
            if (threadHeartBeat == null)
            {
                threadHeartBeat = new Thread(new ThreadStart(_HeartBeatThread));
                threadHeartBeat.IsBackground = true;
            }
            if (status == DataSources.EnumTaskStatus.Not_Started)
            {
                //服务传输服务
                ServiceAgent.StartSendAndReceiveThread();
                //附件传输服务
                FileAgent.StartSendAndReceiveThread();
                //获取帐套信息
                dbList = GetDbList();
                dbListFile.Clear();
                _dbList.Clear();
                foreach (string db in dbList)
                {
                    dbListFile.Add(db);
                    _dbList.Add(db);
                }
                status = DataSources.EnumTaskStatus.Runing;

                thread.Start();
                fileThread.Start();
                threadHeartBeat.Start();
            }
        }
Exemple #4
0
 /// <summary> 停止任务
 /// </summary>
 public static void Stop()
 {
     if (status == DataSources.EnumTaskStatus.Runing)
     {
         ServiceAgent.SupendSendThread();
         FileAgent.SupendSendThread();
         if (thread.ThreadState == ThreadState.Running)
         {
             thread.Suspend();
         }
         if (fileThread.ThreadState == ThreadState.Running)
         {
             fileThread.Suspend();
         }
         if (threadHeartBeat.ThreadState == ThreadState.Running)
         {
             threadHeartBeat.Suspend();
         }
         status = DataSources.EnumTaskStatus.Suspend;
     }
 }