/// <summary>
 /// 上传记录
 /// </summary>
 /// <returns></returns>
 public void LogUpload()
 {
     try
     {
         DateTime uploadTime = DateTime.Parse(string.Format("{0} {1}", DateTime.Now.ToShortDateString(), ServiceSet.LogUploadTime));
         //同步时间小于当前时间,并大于
         if (uploadTime.CompareTo(DateTime.Now) < 0 && isUpload)
         {
             //进出记录上传
             //EnterOutLogUpload.Upload();
             //SlipCustomer.UploadSlipPrintInfo();
             if (!UpLoadLog.Upload())
             {
                 WriteLog.Write("添加记录遇到错误!");
             }
             if (!UpLoadAdvertUsage.SendUsage())
             {
                 WriteLog.Write("添加媒体使用记录遇到错误!");
             }
             if (!UploadSeatUsage.GetUsage())
             {
                 WriteLog.Write("添加使用记录遇到错误!");
             }
             isUpload = false;
         }
         else if (uploadTime.CompareTo(DateTime.Now) > 0)
         {
             isUpload = true;
         }
     }
     catch (Exception ex)
     {
         WriteLog.Write(string.Format("上传刷卡记录失败:{0}", ex.Message));
         //执行完成删除一个月以前的日志文件
         WriteLog.DeleteLog(DateTime.Now.AddMonths(-2));
     }
 }
        /// <summary>
        /// 新的命令获取
        /// </summary>
        public void GetCommand()
        {
            try
            {
                //UploadReaderInfo.Upload();
                bool handleResult = false;
                List <AMS_IssureList> modelList = new List <AMS_IssureList>();
                modelList = IssuredCommandService.GetSchoolCommand(ServiceSet.SchoolNums);
                foreach (AMS_IssureList command in modelList)
                {
                    command.Flag = (int)CommandHandleResult.Getting;
                    IssuredCommandService.UpdateCommand(command);
                    switch (command.CommandType)
                    {
                    case IsureCommandType.Advertisement:
                        try
                        {
                            //获取广告操作
                            handleResult = GetAdvertisement.Get(command.CommandID);
                        }
                        catch (Exception ex)
                        {
                            WriteLog.Write(string.Format("执行获取广告遇到错误,异常来自{0},异常信息:", ex.Source, ex.Message));
                            handleResult = false;
                        }
                        break;

                    case IsureCommandType.AdvertUsage:
                        try
                        {
                            handleResult = UpLoadAdvertUsage.SendUsage();
                        }
                        catch (Exception ex)
                        {
                            WriteLog.Write(string.Format("执行获取广告情况遇到错误,异常来自{0},异常信息:", ex.Source, ex.Message));
                            handleResult = false;
                        }
                        break;

                    case IsureCommandType.EnterOutLog:
                        try
                        {
                            handleResult = UploadSeatUsage.GetUsage();
                        }
                        catch (Exception ex)
                        {
                            WriteLog.Write(string.Format("执行获取使用记录状态遇到错误,异常来自{0},异常信息:", ex.Source, ex.Message));
                            handleResult = false;
                        }
                        break;

                    case IsureCommandType.State:
                        try
                        {
                        }
                        catch (Exception ex)
                        {
                            WriteLog.Write(string.Format("执行获取使用状态遇到错误,异常来自{0},异常信息:", ex.Source, ex.Message));
                            handleResult = false;
                        }
                        break;

                    case IsureCommandType.ReaderInfo:
                        try
                        {
                            handleResult = UploadReaderInfo.Upload();
                        }
                        catch (Exception ex)
                        {
                            WriteLog.Write(string.Format("执行获取信息遇到错误,异常来自{0},异常信息:", ex.Source, ex.Message));
                            handleResult = false;
                        }
                        break;
                    }
                    if (handleResult)
                    {
                        command.Flag = (int)CommandHandleResult.Success;
                        IssuredCommandService.UpdateCommand(command);
                    }
                    else
                    {
                        command.Flag = (int)CommandHandleResult.Failed;
                        IssuredCommandService.UpdateCommand(command);
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog.Write(string.Format("获取命令遇到错误,异常来自{0},异常信息:", ex.Source, ex.Message));
            }
        }