示例#1
0
        private void ProcessEmailJobStatus(string emailAddresses, AryaTask job, bool includeLogUrl, string customStatus = null)
        {
            var emailAddress = emailAddresses;
            var projectName  = string.Empty;

            try
            {
                using (var aryaDb = new AryaDbDataContext(job.ProjectID, job.SubmittedBy))
                {
                    if (string.IsNullOrWhiteSpace(emailAddress))
                    {
                        emailAddress = aryaDb.CurrentUser.EmailAddress;
                    }
                    projectName = aryaDb.CurrentProject.ProjectName;
                }
            }
            catch (UnauthorizedAccessException e)
            {
                CurrentLogWriter.Warn(e.Message);
            }

            try
            {
                AryaServices.SendEmail(job, includeLogUrl, customStatus, projectName, emailAddress, Settings.Default.PortalLocation);
            }
            catch (Exception ex)
            {
                CurrentLogWriter.Error(String.Format("Email sending has failed. {0} has occured. Details{1}",
                                                     ex.GetType(), ex.StackTrace));
            }
        }
示例#2
0
        public void SubmitJobs()
        {
            // get data context
            using (var db = new AryaServicesDbDataContext())
            {
                // get a list of jobs to be executed
                var now  = DateTime.Now;
                var jobs = db.AryaSchedules.Where(s => (s.NextExecution == null || s.NextExecution <= now));

                // add each job to the task queue
                foreach (var job in jobs)
                {
                    string newArgumentDirectoryPath = Path.Combine(job.ProjectID.ToString(), Guid.NewGuid().ToString());
                    DirectoryCopy(Path.Combine(Settings.Default.ArgumentFileBasePath, job.ArgumentDirectoryPath),
                                  Path.Combine(Settings.Default.ArgumentFileBasePath, newArgumentDirectoryPath), true);
                    //File.Copy();
                    var newJob = new AryaTask
                    {
                        ID                    = Guid.NewGuid(),
                        ScheduleID            = job.ID,
                        Description           = job.Description,
                        ArgumentDirectoryPath = newArgumentDirectoryPath,
                        Status                = "New",
                        SubmittedBy           = job.SubmittedBy,
                        SubmittedOn           = now,
                        ProjectID             = job.ProjectID,
                        LastUpdateOn          = now,
                        JobType               = job.JobType
                    };
                    db.AryaTasks.InsertOnSubmit(newJob);
                    Logger.GetLogWriter().Info("SchedueJobId:" + job.ID + "was submitted as regular job");
                    // update the date of execution of the selected job
                    job.NextExecution = now.AddMinutes(job.Interval);
                    job.LastExecution = now;

                    // update the database
                    db.SubmitChanges();
                }
            }
        }