public static SchedulingRule FromLegacyRule(Legacy.SchedulingRuleElement legacyRule) { SchedulingRule rule = new SchedulingRule(); switch (legacyRule.CalendarUnit) { case Legacy.CalendarUnit.Day: rule.Scope = SchedulingScope.Day; break; case Legacy.CalendarUnit.Month: rule.Scope = SchedulingScope.Month; break; case Legacy.CalendarUnit.Week: rule.Scope = SchedulingScope.Week; break; } //subunits= weekday,monthdays rule.Days = legacyRule.SubUnits.ToList(); rule.Times = legacyRule.ExactTimes.ToList(); rule.MaxDeviationAfter = legacyRule.MaxDeviation; return(rule); }
public SchedulingRequest(ServiceConfiguration configuration, SchedulingRule rule, DateTime requestedTime) { this.Configuration = configuration; this.Rule = rule; this.RequestedTime = requestedTime; this.RequestID = Guid.NewGuid(); }
protected static T FromLegacyConfiguration <T>(NamedConfigurationElement legacyConfiguration, ServiceConfiguration baseConfiguration = null, Profile profile = null, Dictionary <string, string> options = null) where T : ServiceConfiguration, new() { if (legacyConfiguration is AccountServiceElement || legacyConfiguration is WorkflowStepElement || legacyConfiguration is ActiveServiceElement) { if (baseConfiguration == null) { throw new ArgumentNullException("baseConfiguration", "When creating a configuration from a Legacy.AccountServiceElement or Legacy.ActiveServiceElement, baseConfiguration must be supplied."); } if (profile == null) { throw new ArgumentNullException("profile", "When creating a configuration from a Legacy.AccountServiceElement or Legacy.ActiveServiceElement, profile must be supplied."); } } if (legacyConfiguration is ServiceElement && !(legacyConfiguration is ActiveServiceElement)) { if (baseConfiguration != null) { throw new ArgumentException("baseConfiguration", "When creating a configuration from a Legacy.ServiceInstance, baseConfiguration must be null."); } if (profile != null) { throw new ArgumentException("profile", "When creating a configuration from a Legacy.ServiceInstance, profile must be null."); } } ServiceElement legacy; if (legacyConfiguration is AccountServiceElement) { legacy = new ActiveServiceElement(legacyConfiguration as AccountServiceElement); } else if (legacyConfiguration is WorkflowStepElement) { legacy = new ActiveServiceElement(legacyConfiguration as WorkflowStepElement); } else { if (options != null) { legacy = new ActiveServiceElement((ServiceElement)legacyConfiguration); } else { legacy = (ServiceElement)legacyConfiguration; } } if (options != null) { legacy.Options.Merge(options); } T serviceConfiguration = new T() { _name = legacy.Name, MaxConcurrent = (legacy.MaxInstances == 0) ? 9999 : legacy.MaxInstances, MaxConcurrentPerProfile = (legacy.MaxInstancesPerAccount == 0) ? 9999 : legacy.MaxInstancesPerAccount, _legacyConfiguration = legacy, _baseConfiguration = baseConfiguration, _schedulingProfile = profile }; if (legacy.Options.ContainsKey("ServicePriority")) { serviceConfiguration._priority = int.Parse(legacy.Options["ServicePriority"]); } //scheduling rules foreach (SchedulingRuleElement schedulingRuleElement in legacy.SchedulingRules) { SchedulingRule rule = SchedulingRule.FromLegacyRule(schedulingRuleElement); if (serviceConfiguration.SchedulingRules == null) { serviceConfiguration.SchedulingRules = new List <SchedulingRule>(); } serviceConfiguration.SchedulingRules.Add(rule); } return(serviceConfiguration); }
public SchedulingRequest(ServiceInstance instance, SchedulingRule rule, DateTime requestedTime) : this(instance.Configuration, rule, requestedTime) { }