Example #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();
        }
Example #2
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);
        }