예제 #1
0
        public SchedulerDto SaveScheduling(ApplicationContext context, SchedulerDto schedule)
        {
            using (var db = new TenantDb(ConnectionString.ForDomain(context.TenantDomainName)))
            {
                var sch = new Schedule
                {
                    Name = schedule.Name,
                    SourceConnectionId = schedule.SourceConnectionId,
                    TargetConnectionId = schedule.TargetConnectionId,
                    RegardingEntityName = schedule.RegardingEntityName,
                    SourceViewId = schedule.SourceViewId,
                    NotificationEmails = schedule.Emails,
                    IsActive = schedule.IsActive,
                    CreatedBy = context.UserId,
                    CreatedOn = DateTime.Now,
                    ModifiedBy = context.UserId,
                    ModifiedOn = DateTime.Now
                };

                db.Schedules.Add(sch);
                db.SaveChanges();

                schedule.ScheduleId = sch.ScheduleId;
                var excecution = new ExecutionDto
                {
                    ScheduleId = schedule.ScheduleId,
                    IsOnDemenad = false,
                    CreatedBy = schedule.CreatedBy
                };
                SaveExecution(context.TenantDomainName, excecution);

                MailService.SendMail(schedule.Emails, MailMessageType.SchedulerCreated);
                return schedule;
            }
        }
예제 #2
0
        public void RunNow(ApplicationContext context, SchedulerDto schedule)
        {
            schedule.Name = "On Demand";
            schedule.IsActive = false;
            schedule = SaveScheduling(context, schedule);

            var crmConnection = GetConnectionById(context.TenantDomainName, schedule.SourceConnectionId);
            var sharepointConnection = GetConnectionById(context.TenantDomainName, schedule.TargetConnectionId);
            var scheduler = new ScheduleExecutionJobInformation
            {
                SourceViewId = schedule.SourceViewId,
                Source = new Connection
                {
                    Login = crmConnection.UserName,
                    Password = crmConnection.Password,
                    Url = crmConnection.Url
                },
                Target = new Connection
                {
                    Login = sharepointConnection.UserName,
                    Password = sharepointConnection.Password,
                    Url = sharepointConnection.Url
                }
            };
            var excecution = new ExecutionDto
            {
                ScheduleId = schedule.ScheduleId,
                IsOnDemenad = true,
                CreatedBy = schedule.CreatedBy
            };
            SaveExecution(context.TenantDomainName, excecution);
            AzureAdapterService.RunNow(scheduler, context.TenantDomainName);
            scheduler.ExecutionId = excecution.ExecutionId;
        }
예제 #3
0
 public void SaveExecution(string domainName, ExecutionDto excecution)
 {
     using (var db = new TenantDb(ConnectionString.ForDomain(domainName)))
     {
         var exec = new Excecution()
         {
             ScheduleId =  excecution.ScheduleId,
             IsOnDemand = excecution.IsOnDemenad,
             StartTime = DateTime.Now,
             Status = (int)ExcecutionStatusEnum.Created,
             IsActive = true,
             CreatedBy = excecution.CreatedBy,
             CreatedOn = DateTime.Now,
             ModifiedBy = excecution.CreatedBy,
             ModifiedOn = DateTime.Now
         };
         db.Excecutions.Add(exec);
         db.SaveChanges();
         excecution.ExecutionId = exec.ExecutionId;
     }
 }
예제 #4
0
 public HttpResponseMessage SaveExcecution(ExecutionDto excecution)
 {
     SchedulingService.SaveExecution(Context.TenantDomainName, excecution);
     return new HttpResponseMessage(HttpStatusCode.OK);
 }