示例#1
0
        /// <summary> 执行数据自动上传任务
        /// </summary>
        private static void _ExcuteTask()
        {
            //用户登录
            LoginFlag = LoginCloud();

            if (LoginFlag)
            {
                ServiceAgent.ReceiveComplated += new ServiceAgent.ReceiveComplate(WriteDataLog);
            }

            //服务传输服务
            ServiceAgent.StartSendAndReceiveThread();

            while (true)
            {
                if (LoginFlag)
                {
                    long     time        = long.Parse(GlobalStaticObj_Server.Instance.LastUploadTime);
                    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 dbList)
                        {
                            //上传本地数据
                            UploadDataHandler.UpLoadData(dbName, time.ToString());

                            //备份上传时间
                            GlobalStaticObj_Server.Instance.LastUploadTime = time.ToString();
                            //写入
                            ConfigManager.SaveConfig(ConfigConst.UploadTime,
                                                     GlobalStaticObj_Server.Instance.LastUploadTime, ConfigConst.ConfigPath);
                        }
                    }
                    Thread.Sleep(60 * 60 * 1000);
                    dbList = GetDbList();
                }
                else
                {
                    Thread.Sleep(waitSecond * 1000);
                }
            }
        }
示例#2
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();
            }
        }
示例#3
0
 /// <summary>
 /// 继续任务
 /// </summary>
 public static void Continue()
 {
     if (status == DataSources.EnumTaskStatus.Suspend)
     {
         ServiceAgent.ResumeSendThread();
         if (thread.ThreadState == ThreadState.Suspended)
         {
             thread.Resume();
         }
         if (fileThread.ThreadState == ThreadState.Suspended)
         {
             fileThread.Resume();
         }
         if (threadHeartBeat.ThreadState == ThreadState.Suspended)
         {
             threadHeartBeat.Resume();
         }
         status = DataSources.EnumTaskStatus.Runing;
     }
 }
示例#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;
     }
 }