Пример #1
0
        protected override void InnerExcute(IJobExecutionContext context)
        {
            try
            {
                SLogger.Info(string.Format("{0}: Starting Push question to QnA job", JobFriendlyName));

                var lastRunTime = SystemReader.GetLastPushQnAJobRunTime();

                var lstQuestion = _qnaService.GetQnAByDate(lastRunTime);

                // call stand alone to execute QnA
                var data = new PushLatestQnA {
                    ListQuestionAndAnswers = lstQuestion.ToList()
                };

                ApiHelper.PostAsyncNoEncrypt(WebApiConstant.XoomPushQuestionStandAloneEndPoint, data).GetAwaiter().GetResult();

                SLogger.Info(string.Format("{0} : - End Push question to QnA job", JobFriendlyName));

                SystemReader.SetLastPushQnAJobRunTime(DateTime.Now);
            }
            catch (Exception ex)
            {
                SLogger.Error(string.Format("{0}: InnerExcute. Push question to QnA job", JobFriendlyName), ex);
            }
        }
        public void Execute(IJobExecutionContext context)
        {
            JobFriendlyName = string.IsNullOrWhiteSpace(JobFriendlyName) ? Guid.NewGuid().ToString() : JobFriendlyName;

            ConfigurationManager.RefreshSection("appSettings");
            try
            {
                SLogger.Info(string.Format("Job {0} starts executing at {1}. Currently logged in as {2}.", JobFriendlyName, DateTime.Now, SystemReader.GetWindowsUsername()));

                //Check if the job is marked as disabled in the config
                if (!string.IsNullOrWhiteSpace(ConfigReader.DisableJobsByFriendlyName) && ConfigReader.DisableJobsByFriendlyName.Split(';').Any(j => j.Trim().Equals(JobFriendlyName, StringComparison.InvariantCultureIgnoreCase)))
                {
                    SLogger.Info(string.Format("Job {0} has been marked as disabled in the config file, therefore it does not execute this time.", JobFriendlyName));
                }
                else
                {
                    SLogger.Info(string.Format("Job {0} is executing...", JobFriendlyName));
                    InnerExcute(context);
                }
                SLogger.Info(string.Format("Job {0} finishes executing at {1}. Currently logged in as {2}.", JobFriendlyName, DateTime.Now, SystemReader.GetWindowsUsername()));
            }
            catch (Exception ex)
            {
                SLogger.Error(ex);
                SLogger.Info(string.Format("Job {0} stops executing at {1} due to internal errors. Currently logged in as {2}.", JobFriendlyName, DateTime.Now, SystemReader.GetWindowsUsername()));
            }
        }
Пример #3
0
        public void ClearTargetDirectory([NotNull] ScenarioSliceParameters slice)
        {
            var fullpath = FilenameHelpers.GetTargetDirectory(MyStage,
                                                              SequenceNumber, Name, slice, Services.RunningConfig);

            if (Directory.Exists(fullpath))
            {
                try {
                    DirectoryInfo di    = new DirectoryInfo(fullpath);
                    var           files = di.GetFiles("*.*", SearchOption.AllDirectories);
                    foreach (var fileInfo in files)
                    {
                        fileInfo.Delete();
                    }
                    di.Delete(true);
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e) {
#pragma warning restore CA1031 // Do not catch general exception types
                    SLogger.Error(e.Message);
                }
            }

            if (!Directory.Exists(fullpath))
            {
                Directory.CreateDirectory(fullpath);
                Thread.Sleep(250);
            }
        }
Пример #4
0
 static public string Translate(string content, string companyAdminUserID)
 {
     try {
         var sUsers = SDefines.ApplicationContainer.Resolve <SCompaniesAdminUsersService>();
         //LanguageCode languageCode = sUsers.GetLanguageCode(userID);
         //if (languageCode == LanguageCode.English) return content;
         //return TranslateToLanguageCode(content, languageCode);
     } catch (Exception ex) {
         SLogger.Error(ex);
     }
     return(content);
 }
Пример #5
0
        /// <summary>
        /// Update db when we cant execute to add contacts
        /// </summary>
        /// <param name="contacts"></param>
        /// <summary>
        /// Get rolling list from  Web API of Xoom
        /// </summary>
        /// <returns></returns>
        protected virtual int TestJob()
        {
            var guid = Guid.NewGuid().ToString();

            try
            {
                //////Debug.WriteLine(string.Format("{0} : {1} - Start check and create if any new contacts found.WebApiCreateNewRollOutForEndPoint: {2}", guid, GetJobFriendlyName(), WebApiCreateNewRollOutForEndPoint));
                ////SLogger.Info(string.Format("{0} : {1} - Start check and create if any new contacts found.WebApiCreateNewRollOutForEndPoint: {2}", guid, GetJobFriendlyName(), WebApiCreateNewRollOutForEndPoint));
                ////Debug.WriteLine(string.Format("{0} : {1} - Start check and create if any new contacts found.WebApiCreateNewRollOutForEndPoint: {2}", guid, GetJobFriendlyName(), WebApiCreateNewRollOutForEndPoint));
                //var rollOutReqParam = new RolloutEmailModel
                //{
                //    LimitAttempts = ConfigReader.RollOutMaxRetry,
                //    SelectTop = ConfigReader.RollOutMaxEmailPerRun,
                //    MaxEmailAllowAutoSend = ConfigReader.MaxAllowAutoSendEmail,
                //    MigrateStatus = MigrateStatus,
                //    SelectGroupOnly = SelectGroupOnly
                //};

                //var result = _rolloutEmailHelper.RolloutEmailsVision6(rollOutReqParam);

                //SLogger.Info(string.Format("{0} : {1} - End check and create if any new contacts found", guid, GetJobFriendlyName()));
                ////Debug.WriteLine(string.Format("{0} : {1} - End check and create if any new contacts found", guid, GetJobFriendlyName()));
                //if (result!= null && result.RolloutId> 0)
                //{
                //    SLogger.Info(string.Format("{0} : {1} -  New rollout emails found. Total emails: {2}. Allow auto send: {3}", guid, GetJobFriendlyName(), result.TotalRolloutContacts, result.AllowAutoSend));
                //    //Debug.WriteLine(string.Format("{0} : {1} -  New rollout emails found. Total emails: {2}. Allow auto send: {3}", guid, GetJobFriendlyName(), result.TotalRolloutContacts, result.AllowAutoSend));
                //}
                //else
                //{
                //    SLogger.Info(string.Format("{0} : {1} -  No new rollout emails found", guid, GetJobFriendlyName()));
                //    //Debug.WriteLine(string.Format("{0} : {1} -  No new rollout emails found", guid, GetJobFriendlyName()));
                //}
                //////Debug.WriteLine(string.Format("{0} : {1} - End check and create if any new contacts found.WebApiCreateNewRollOutForEndPoint: {2}", guid, GetJobFriendlyName(), WebApiCreateNewRollOutForEndPoint));
                //return result;
            }
            catch (Exception ex)
            {
                SLogger.Error(string.Format("{0} : {1} - EXCEPTION check and create if any new contacts found", guid, GetJobFriendlyName()), ex);
                //Debug.WriteLine(string.Format("{0} : {1} - EXCEPTION check and create if any new contacts found", guid, GetJobFriendlyName()));
            }
            return(default(int));
        }
        private static DirectoryInfo PrepareArchiveDir([NotNull] string resultArchiveDirectory)
        {
            DirectoryInfo archiveDir = new DirectoryInfo(resultArchiveDirectory);

            var dstFiles = archiveDir.GetFiles("*.*", SearchOption.AllDirectories);

            foreach (var info in dstFiles)
            {
                try {
                    info.Delete();
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception ex) {
#pragma warning restore CA1031 // Do not catch general exception types
                    SLogger.Error(ex.Message);
                }
            }

            return(archiveDir);
        }