示例#1
0
 private static async Task GetFileHpJobAsync()
 {
     using (var client = new CSMFileServiceClient())
     {
         Task <ImportHpTaskResponse> t      = client.GetFileHPAsync(WebConfig.GetWebUsername(), WebConfig.GetWebPassword());
         ImportHpTaskResponse        result = await t;
     }
 }
示例#2
0
 private static async Task ExportFileNCBJobAsync()
 {
     using (var client = new CSMFileServiceClient())
     {
         Task <ExportNCBTaskResponse> t      = client.ExportFileNCBAsync(WebConfig.GetWebUsername(), WebConfig.GetWebPassword());
         ExportNCBTaskResponse        result = await t;
     }
 }
示例#3
0
 private static async Task GetFileHpJobAsync()
 {
     using (var client = new CSMFileServiceClient())
     {
         Task <CSM.Service.Messages.SchedTask.ImportHpTaskResponse> t      = client.GetFileHPAsync(WebConfig.GetWebUsername(), WebConfig.GetWebPassword());
         CSM.Service.Messages.SchedTask.ImportHpTaskResponse        result = await t.ConfigureAwait(false);
     }
 }
示例#4
0
        public static void GetFileHpJobAsync()
        {
            try
            {
                Logger.Info("I:--START--");

                Task <ImportHpTaskResponse> task;
                using (var client = new CSMFileServiceClient())
                {
                    task = client.GetFileHPAsync(WebConfig.GetTaskUsername(), WebConfig.GetTaskPassword());
                }

                while (!task.IsCompleted)
                {
                    Thread.Sleep(1000);
                }

                if (task.Exception != null)
                {
                    Logger.InfoFormat("O:--FAILED--:Exception/{0}", task.Exception);
                    Logger.Error("Exception occur:\n", task.Exception);

                    // Send mail to system administrator
                    _mailSender = TaskMailSender.GetTaskMailSender();
                    _mailSender.NotifyImportHPFailed(WebConfig.GetTaskEmailToAddress(), DateTime.Now, task.Exception);
                    Thread.Sleep(5000);
                }
                //else
                //{
                //    var result = task.GetAwaiter().GetResult();
                //    Logger.InfoFormat("O:--SUCCESS--:Task Result/{0}", result);

                //    // Send mail to system administrator
                //    SendMailTask(result);
                //}
            }
            catch (Exception ex)
            {
                Logger.InfoFormat("O:--FAILED--:Exception/{0}", ex.Message);
                Logger.Error("Exception occur:\n", ex);

                // Send mail to system administrator
                _mailSender = TaskMailSender.GetTaskMailSender();
                _mailSender.NotifyImportHPFailed(WebConfig.GetTaskEmailToAddress(), DateTime.Now, new AggregateException(ex));
                Thread.Sleep(5000);
            }
        }