Esempio n. 1
0
        public override void ModifySpecialDayGroup(SpecialDayGroup SpecialDayGroup)
        {
            ConfStorageLoad();
            EventServerLoad();

            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.ScheduleCapabilities;

            //Check that Special Day Group exists
            if (!ConfStorage.SpecialDayGroupList.ContainsKey(SpecialDayGroup.token))
            {
                string message = string.Format("SpecialDayGroup with specified token {0} does not exists.", SpecialDayGroup.token);
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" });
            }

            //TODO: Check MaxSpecialDaysInSpecialDayGroup capability
            //if (ConfStorage.ScheduleList.Values.SelectMany(schedule => schedule.SpecialDays).Count() >= capabilities.MaxSpecialDaysInSpecialDayGroup)
            //{
            //    string message = string.Format("There is not enough space to create new SpecialDayGroup, see the MaxSpecialDaysInSpecialDayGroup capability.");
            //    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
            //    FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MaxSpecialDaysInSpecialDayGroup" });
            //}


            ConfStorage.SpecialDayGroupList.Remove(SpecialDayGroup.token);
            ConfStorage.SpecialDayGroupList.Add(SpecialDayGroup.token, SpecialDayGroup);

            EventServer.ConfigurationSpecialDayGroupChangedEvent(this, SpecialDayGroup.token);

            EventServerSave();
            ConfStorageSave();
        }
Esempio n. 2
0
        public override string GetSpecialDayGroupList(int Limit, [System.Xml.Serialization.XmlIgnoreAttribute()] bool LimitSpecified, string StartReference, [System.Xml.Serialization.XmlElementAttribute("SpecialDayGroup")] out SpecialDayGroup[] SpecialDayGroup)
        {
            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.ScheduleCapabilities;

            int offset = 0;

            if (!string.IsNullOrEmpty(StartReference))
            {
                if (!Int32.TryParse(StartReference, out offset))
                {
                    FaultLib.ReturnFault("Invalid StartReferense value. ", new[] { "Sender", "InvalidArgVal", "InvalidArgVal" });
                }
            }

            if (!LimitSpecified)
            {
                Limit = capabilities.MaxLimit > int.MaxValue ?
                        int.MaxValue : (int)capabilities.MaxLimit;
            }

            SpecialDayGroup = GetList <SpecialDayGroup>(offset, true, Limit, true, C => C.SpecialDayGroupList);
            string newStartReferense = null;

            if (offset + SpecialDayGroup.Length < ConfStorage.SpecialDayGroupList.Count)
            {
                newStartReferense = Convert.ToString(offset + SpecialDayGroup.Length);
            }
            return(newStartReferense);
        }
Esempio n. 3
0
        public override Schedule[] GetSchedules([System.Xml.Serialization.XmlElementAttribute("Token")] string[] Token)
        {
            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.ScheduleCapabilities;

            if (Token != null && Token.Length > capabilities.MaxLimit)
            {
                FaultLib.ReturnFault("Too many items was requested. ", new[] { "Sender", "InvalidArgs", "TooManyItems" });
            }
            return(GetListByTokenList <Schedule>(Token, C => C.ScheduleList));
        }
Esempio n. 4
0
        public override SpecialDayGroupInfo[] GetSpecialDayGroupInfo([System.Xml.Serialization.XmlElementAttribute("Token")] string[] Token)
        {
            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.ScheduleCapabilities;

            if (Token != null && Token.Length > capabilities.MaxLimit)
            {
                FaultLib.ReturnFault("Too many items was requested. ", new[] { "Sender", "InvalidArgs", "TooManyItems" });
            }


            return(Array.ConvertAll(GetListByTokenList <SpecialDayGroup>(Token, C => C.SpecialDayGroupList), item => ToSpecialDayGroupInfo(item)));
        }
Esempio n. 5
0
        private SystemCapabilities()
        {
            // don't change service capabilities in other places to maintain synchronization of
            // typed properties and XmlElement's

            //Device Management Service
            DeviceServiceCapabilities          = new DeviceServiceCapabilities();
            DeviceServiceCapabilities.Network  = new NetworkCapabilities();
            DeviceServiceCapabilities.Security = new SecurityCapabilities();
            DeviceServiceCapabilities.Security.HttpDigestSpecified = true;
            DeviceServiceCapabilities.Security.HttpDigest          = true;
            DeviceServiceCapabilities.System = new Device10.SystemCapabilities();
            DeviceServiceCapabilities.System.DiscoveryByeSpecified = true;
            DeviceServiceCapabilities.System.DiscoveryBye          = false;


            //Door Control Service
            DoorServiceCapabilities          = new ServiceDoorControl10.ServiceCapabilities();
            DoorServiceCapabilities.MaxLimit = 7;

            //Access Control Service
            AccessControlCapabilities = new ServiceAccessControl10.ServiceCapabilities();
            //AccessControlCapabilities.DisableAccessPointSpecified = true;
            //AccessControlCapabilities.DisableAccessPoint = true;
            AccessControlCapabilities.MaxLimit = 1;

            //Credential Service
            CredentialCapabilities                = new ServiceCredential10.ServiceCapabilities();
            CredentialCapabilities.MaxLimit       = 3;
            CredentialCapabilities.MaxCredentials = 10;
            CredentialCapabilities.CredentialAccessProfileValiditySupported = true;
            CredentialCapabilities.CredentialValiditySupported    = true;
            CredentialCapabilities.MaxAccessProfilesPerCredential = 5;
            CredentialCapabilities.ResetAntipassbackSupported     = true;
            CredentialCapabilities.ValiditySupportsTimeValue      = true;
            CredentialCapabilities.SupportedIdentifierType        = new string[] { "pt:Card", "pt:PIN" };

            //Supported Format Types (probably refactoring requiered to be flexible)
            List <ServiceCredential10.CredentialIdentifierFormatTypeInfo> formatTypes;

            ServiceCredential10.CredentialIdentifierFormatTypeInfo credentialIdentifierFormatTypeInfo;

            SupportedFormatTypes = new Dictionary <string, List <ServiceCredential10.CredentialIdentifierFormatTypeInfo> >();

            formatTypes = new List <ServiceCredential10.CredentialIdentifierFormatTypeInfo>();

            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "WIEGAND26";
            credentialIdentifierFormatTypeInfo.Description = "Standard 26 bit Wiegand format as defined by SIA standard (SIA AC-01).";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);
            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "WIEGAND37";
            credentialIdentifierFormatTypeInfo.Description = "Description";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);

            SupportedFormatTypes.Add("pt:Card", formatTypes);

            formatTypes = new List <ServiceCredential10.CredentialIdentifierFormatTypeInfo>();

            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "WIEGAND37";
            credentialIdentifierFormatTypeInfo.Description = "Description";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);
            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "WIEGAND37_FACILITY";
            credentialIdentifierFormatTypeInfo.Description = "Description";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);
            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "SIMPLE_NUMBER32";
            credentialIdentifierFormatTypeInfo.Description = "Description";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);

            SupportedFormatTypes.Add("pt:PIN", formatTypes);

            //Access Rules Service
            AccessRulesCapabilities          = new ServiceAccessRules10.ServiceCapabilities();
            AccessRulesCapabilities.MaxLimit = 2;
            AccessRulesCapabilities.MaxAccessPoliciesPerAccessProfile = 2;
            AccessRulesCapabilities.MaxAccessProfiles = 5;
            AccessRulesCapabilities.MultipleSchedulesPerAccessPointSupported = true;

            //Schedule Service
            ScheduleCapabilities                             = new ServiceSchedule10.ServiceCapabilities();
            ScheduleCapabilities.MaxLimit                    = 2;
            ScheduleCapabilities.MaxSchedules                = 4;
            ScheduleCapabilities.MaxSpecialDayGroups         = 6;
            ScheduleCapabilities.MaxDaysInSpecialDayGroup    = 2;
            ScheduleCapabilities.MaxSpecialDaysSchedules     = 4;
            ScheduleCapabilities.MaxTimePeriodsPerDay        = 8;
            ScheduleCapabilities.SpecialDaysSupported        = true;
            ScheduleCapabilities.StateReportingSupported     = true;
            ScheduleCapabilities.ExtendedRecurrenceSupported = true;

            //Events Service
            EventsCapabilities = new Events10.Capabilities();
            EventsCapabilities.MaxNotificationProducers      = 3;
            EventsCapabilities.MaxPullPoints                 = 3;
            EventsCapabilities.PersistentNotificationStorage = false;
            EventsCapabilities.WSPullPointSupport            = true;
            EventsCapabilities.WSSubscriptionPolicySupport   = true;
            EventsCapabilities.WSPausableSubscriptionManagerInterfaceSupport = false;

            InitializeXmlElements();
        }
Esempio n. 6
0
        public override string CreateSpecialDayGroup(SpecialDayGroup SpecialDayGroup)
        {
            ConfStorageLoad();

            EventServerLoad();

            if (SpecialDayGroup.token == "")
            {
                int i = 1;

                SpecialDayGroup.token = "specialdaygroup" + i.ToString();

                while (ConfStorage.SpecialDayGroupList.Keys.Contains(SpecialDayGroup.token))
                {
                    SpecialDayGroup.token = "specialdaygroup" + i.ToString();
                    i++;
                }
            }
            else
            {
                string message = string.Format("Not empty token.");
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgs" });
            }

            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.ScheduleCapabilities;
            string res = SpecialDayGroup.token;

            //Check that there is no schedule with the same token exists
            if (ConfStorage.SpecialDayGroupList.ContainsKey(SpecialDayGroup.token))
            {
                string message = string.Format("SpecialDayGroup with token {0} aleady exist.", SpecialDayGroup.token);
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal" });
            }

            //Check MaxSpecialDayGroups capability
            if (ConfStorage.SpecialDayGroupList.Count() >= capabilities.MaxSpecialDayGroups)
            {
                string message = string.Format("There is not enough space to create new SpecialDayGroup, see the MaxSpecialDayGroups capability.");
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Receiver", "CapabilityViolated", "MaxSpecialDayGroups" });
            }

            //TODO: Check MaxSpecialDaysInSpecialDayGroup capability
            //if (ConfStorage.ScheduleList.Values.SelectMany(schedule => schedule.SpecialDays).Count() >= capabilities.MaxSpecialDaysInSpecialDayGroup)
            //{
            //    string message = string.Format("There is not enough space to create new SpecialDayGroup, see the MaxSpecialDaysInSpecialDayGroup capability.");
            //    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
            //    FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MaxSpecialDaysInSpecialDayGroup" });
            //}

            ConfStorage.SpecialDayGroupList.Add(SpecialDayGroup.token, SpecialDayGroup);

            EventServer.ConfigurationSpecialDayGroupChangedEvent(this, SpecialDayGroup.token);

            EventServerSave();
            ConfStorageSave();


            return(res);
        }
Esempio n. 7
0
        public override void ModifySchedule(Schedule Schedule)
        {
            ConfStorageLoad();
            EventServerLoad();

            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.ScheduleCapabilities;

            ICalendar standardICalendar        = new ICalendar(Schedule.Standard);
            var       standardICalendarVEvents = standardICalendar.GetVEvents();

            if (standardICalendarVEvents != null && standardICalendarVEvents.Count > capabilities.MaxTimePeriodsPerDay)
            {
                string message = string.Format("There are too many TimePeriods in a day schedule, see MaxTimePeriodsPerDay capability.");
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MaxTimePeriodsPerDay" });
            }

            //Check that schedule exists
            if (!ConfStorage.ScheduleList.ContainsKey(Schedule.token))
            {
                string message = string.Format("Schedule with specified token {0} does not exists.", Schedule.token);
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" });
            }

            if (Schedule.SpecialDays != null)
            {
                if (Schedule.SpecialDays.Count() >= capabilities.MaxSpecialDaysSchedules)
                {
                    string message = string.Format("There are too many SpecialDaysSchedule entities referred in this schedule, see MaxSpecialDays-Schedules capability.");
                    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MaxSpecialDaysSchedules" });
                }

                foreach (var specialDays in Schedule.SpecialDays)
                {
                    if (specialDays.TimeRange.Count() >= capabilities.MaxTimePeriodsPerDay)
                    {
                        string message = string.Format("There are too many TimePeriods in a day schedule, see MaxTimePeriodsPerDay capability.");
                        LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                        FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MaxTimePeriodsPerDay" });
                    }
                    if (specialDays.TimeRange != null)
                    {
                        foreach (var timeRange in specialDays.TimeRange)
                        {
                            if (timeRange.Until < timeRange.From)
                            {
                                string message = string.Format("Schedule SpecialDayGroupToken.TimeRange.Until value is less that From value.");
                                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "ReferenceNotFound" });
                            }
                        }
                    }
                }

                //Check that all Schedules special days exists
                if (Schedule.SpecialDays.Any(C => !(ConfStorage.SpecialDayGroupList.Keys.Contains(C.GroupToken))))
                {
                    string message = string.Format("Schedule special day group token does not exist.");
                    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal" });
                }
            }

            ConfStorage.ScheduleList.Remove(Schedule.token);
            ConfStorage.ScheduleList.Add(Schedule.token, Schedule);

            EventServer.ConfigurationScheduleChangedEvent(this, Schedule.token);

            EventServerSave();
            ConfStorageSave();
        }
Esempio n. 8
0
        public void ScheduleTask(DateTime dateStart, DateTime dateEnd, Schedule schedule, ServiceCapabilities capabilities)
        {
            var startCancelSource         = new CancellationTokenSource();
            CancellationToken startCancel = startCancelSource.Token;
            var delayStart = (int)dateStart.Subtract(DateTime.Now).TotalMilliseconds;
            var delayEnd   = (int)dateEnd.Subtract(DateTime.Now).TotalMilliseconds;

            if (delayStart < 1000)
            {
                dateStart = dateStart.AddSeconds(1);
                dateEnd   = dateEnd.AddSeconds(1);
            }
            if (dateEnd.Subtract(dateStart).TotalMilliseconds < 1000)
            {
                dateEnd = dateEnd.AddSeconds(1);
            }

            Task taskStart = Task.Factory.StartNew(() => ScheduleAction(() =>
            {
                ConfStorageLoad();
                EventServerLoad();
                if (ConfStorage.ScheduleList.ContainsKey(schedule.token))
                {
                    var specialDay = IsSpecialDay(schedule);

                    EventServer.ScheduleStateActiveEvent(this, "Changed", schedule.token, schedule.Name, true, specialDay);
                    ScheduleState state = new ScheduleState()
                    {
                        Active = true, SpecialDaySpecified = capabilities.SpecialDaysSupported, SpecialDay = specialDay
                    };
                    if (!ConfStorage.ScheduleStateList.ContainsKey(schedule.token))
                    {
                        ConfStorage.ScheduleStateList.Add(schedule.token, state);
                    }
                    else
                    {
                        ConfStorage.ScheduleStateList[schedule.token] = state;
                    }
                }

                EventServerSave();
                ConfStorageSave();
            }, dateStart),
                                                   startCancel);

            if (!ConfStorage.AwaitingTasks.ContainsKey(schedule.token))
            {
                ConfStorage.AwaitingTasks[schedule.token] = new List <CancellationTokenSource>();
            }
            ConfStorage.AwaitingTasks[schedule.token].Add(startCancelSource);

            var endCancelSource         = new CancellationTokenSource();
            CancellationToken endCancel = endCancelSource.Token;

            Task taskEnd = Task.Factory.StartNew(() => ScheduleAction(() =>
            {
                ConfStorageLoad();
                EventServerLoad();

                var specialDay = IsSpecialDay(schedule);

                EventServer.ScheduleStateActiveEvent(this, "Changed", schedule.token, schedule.Name, false, specialDay);
                ScheduleState state = new ScheduleState()
                {
                    Active = false, SpecialDaySpecified = capabilities.SpecialDaysSupported, SpecialDay = specialDay
                };
                if (!ConfStorage.ScheduleStateList.ContainsKey(schedule.token))
                {
                    ConfStorage.ScheduleStateList.Add(schedule.token, state);
                }
                else
                {
                    ConfStorage.ScheduleStateList[schedule.token] = state;
                }

                EventServerSave();
                ConfStorageSave();
            }, dateEnd),
                                                 endCancel);

            ConfStorage.AwaitingTasks[schedule.token].Add(endCancelSource);
        }
Esempio n. 9
0
        public override ServiceCapabilities GetServiceCapabilities()
        {
            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.ScheduleCapabilities;

            return(capabilities);
        }
Esempio n. 10
0
        public override string CreateSchedule(Schedule Schedule)
        {
            ConfStorageLoad();

            EventServerLoad();

            if (Schedule.token == "")
            {
                int i = 1;

                Schedule.token = "schedule" + i.ToString();

                while (ConfStorage.ScheduleList.Keys.Contains(Schedule.token))
                {
                    Schedule.token = "schedule" + i.ToString();
                    i++;
                }
            }
            else
            {
                string message = string.Format("Not empty token.");
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgs" });
            }

            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.ScheduleCapabilities;
            string res = Schedule.token;

            ICalendar standardICalendar        = new ICalendar(Schedule.Standard);
            var       standardICalendarVEvents = standardICalendar.GetVEvents();

            if (standardICalendarVEvents != null && standardICalendarVEvents.Count > capabilities.MaxTimePeriodsPerDay)
            {
                string message = string.Format("There are too many TimePeriods in a day schedule, see MaxTimePeriodsPerDay capability.");
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MaxTimePeriodsPerDay" });
            }

            //Check that there is no schedule with the same token exists
            if (ConfStorage.ScheduleList.ContainsKey(Schedule.token))
            {
                string message = string.Format("Schedule with token {0} aleady exist.", Schedule.token);
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal" });
            }


            //Check MaxSchedules capability
            if (ConfStorage.ScheduleList.Count() >= capabilities.MaxSchedules)
            {
                string message = string.Format("There is not enough space to create new schedule, see the MaxSchedules capability.");
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Receiver", "CapabilityViolated", "MaxSchedules" });
            }


            if (Schedule.SpecialDays != null)
            {
                if (Schedule.SpecialDays.Count() >= capabilities.MaxSpecialDaysSchedules)
                {
                    string message = string.Format("There are too many SpecialDaysSchedule entities referred in this schedule, see MaxSpecialDays-Schedules capability.");
                    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MaxSpecialDaysSchedules" });
                }

                foreach (var specialDays in Schedule.SpecialDays)
                {
                    if (specialDays.TimeRange.Count() > capabilities.MaxTimePeriodsPerDay)
                    {
                        string message = string.Format("There are too many TimePeriods in a day schedule, see MaxTimePeriodsPerDay capability.");
                        LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                        FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MaxTimePeriodsPerDay" });
                    }
                    if (specialDays.TimeRange != null)
                    {
                        foreach (var timeRange in specialDays.TimeRange)
                        {
                            if (timeRange.Until < timeRange.From)
                            {
                                string message = string.Format("Schedule SpecialDayGroupToken.TimeRange.Until value is less that From value.");
                                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "ReferenceNotFound" });
                            }
                        }
                    }
                }

                //Check that all Schedules exists
                if (Schedule.SpecialDays.Any(C => !(ConfStorage.SpecialDayGroupList.Keys.Contains(C.GroupToken))))
                {
                    string message = string.Format("Schedule special day group token does not exist.");
                    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal" });
                }
            }

            ConfStorage.ScheduleList.Add(Schedule.token, Schedule);
            ScheduleState scheduleState = new ScheduleState();

            DateTime dateStart = standardICalendarVEvents.First().DateStart;
            DateTime dateEnd   = standardICalendarVEvents.First().DateEnd;

            if (dateStart.ToFileTime() < DateTime.Now.ToFileTime() && dateEnd.ToFileTime() > DateTime.Now.ToFileTime())
            {
                scheduleState.Active = true;
            }
            else
            {
                scheduleState.Active = false;
            }

            scheduleState.SpecialDaySpecified = capabilities.SpecialDaysSupported;
            scheduleState.SpecialDay          = IsSpecialDay(Schedule);

            ConfStorage.ScheduleStateList.Add(Schedule.token, scheduleState);

            EventServer.ConfigurationScheduleChangedEvent(this, Schedule.token);
            EventServer.ScheduleStateActiveEvent(this, "Initialized", Schedule.token, Schedule.Name, scheduleState.Active, scheduleState.SpecialDay);



            if (dateStart.ToFileTime() > DateTime.Now.ToFileTime() && standardICalendarVEvents.First().Rrule.Contains("DAILY"))
            {
                ScheduleTask(dateStart, dateEnd, Schedule, capabilities);
            }
            else if (dateEnd.ToFileTime() > DateTime.Now.ToFileTime())
            {
                ScheduleTask(DateTime.Now, dateEnd, Schedule, capabilities);
            }

            var specialDayGroupToken = string.Empty;

            if (Schedule.SpecialDays != null)
            {
                specialDayGroupToken = Schedule.SpecialDays.First().GroupToken;
            }

            if (!string.IsNullOrEmpty(specialDayGroupToken))
            {
                if (ConfStorage.SpecialDayGroupList.ContainsKey(specialDayGroupToken))
                {
                    var specialDayGroup = ConfStorage.SpecialDayGroupList[specialDayGroupToken];

                    ICalendar specialDayGroupICalendar        = new ICalendar(specialDayGroup.Days);
                    var       specialDayGroupICalendarVEvents = specialDayGroupICalendar.GetVEvents();

                    DateTime dateSpecialDayStart = specialDayGroupICalendarVEvents.First().DateStart;
                    DateTime dateSpecialDayEnd   = specialDayGroupICalendarVEvents.First().DateEnd;

                    if (string.IsNullOrEmpty(specialDayGroupICalendarVEvents.First().Rrule) || specialDayGroupICalendarVEvents.First().Rrule.Contains("DAILY"))
                    {
                        if (dateSpecialDayStart.ToFileTime() > DateTime.Now.ToFileTime())
                        {
                            ScheduleTask(dateSpecialDayStart, dateSpecialDayEnd, Schedule, capabilities);
                        }
                        else if (dateSpecialDayEnd.ToFileTime() > DateTime.Now.ToFileTime())
                        {
                            ScheduleTask(DateTime.Now, dateSpecialDayEnd, Schedule, capabilities);
                        }
                    }
                }
            }

            EventServerSave();
            ConfStorageSave();

            return(res);
        }