Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 3
0
 public HttpResponseMessage SaveSchedule(SchedulerDto schedule)
 {
     SchedulingService.SaveScheduling(Context, schedule);
     return new HttpResponseMessage(HttpStatusCode.OK);
 }