コード例 #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();
        }
コード例 #2
0
        public override void DeleteAccessProfile(string Token)
        {
            ConfStorageLoad();

            if (ConfStorage.AccessProfileList.ContainsKey(Token))
            {
                if (AccessProfileInUse(Token))
                {
                    string message = string.Format("Access Profile with token {0} is in use.", Token);
                    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "ReferenceInUse" });
                }
                else
                {
                    ConfStorage.AccessProfileList.Remove(Token);
                    EventServer.ConfigurationAccessProfileRemovedEvent(this, Token);
                    LoggingService.LogMessage(string.Format("Access Profile with token '{0}' was deleted.", Token), DUT.PACS.Simulator.ExternalLogging.MessageType.Message);
                }
            }
            else
            {
                string message = string.Format("Access Profile with token {0} does not exist", Token);
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" });
            }

            ConfStorageSave();
        }
コード例 #3
0
        public override System.DateTime PullMessages([System.Xml.Serialization.XmlElementAttribute(DataType = "duration")] string Timeout, int MessageLimit, [System.Xml.Serialization.XmlAnyElementAttribute()] System.Xml.XmlElement[] Any, out System.DateTime TerminationTime, [System.Xml.Serialization.XmlElementAttribute("NotificationMessage", Namespace = "http://docs.oasis-open.org/wsn/b-2")] out NotificationMessageHolderType[] NotificationMessage)
        {
            int subscriptionKey = SoapReferanceHeaderProcessing(unknownHeaders);

            ConfStorageLoad();
            EventServerLoad();

            DateTime timeout;

            try
            {
                TimeSpan timeSpan = System.Xml.XmlConvert.ToTimeSpan(Timeout);
                timeout = DateTime.UtcNow.Add(timeSpan.Subtract(new TimeSpan(0, 0, 1)));
            }
            catch (Exception)
            {
                throw FaultLib.GetSoapException(FaultType.General, "Wrong Timeout.");
            }


            NotificationMessage = EventServer.GetPullPointMessages(subscriptionKey, timeout, MessageLimit);

            TerminationTime = EventServer.EventSubsciptionList[subscriptionKey].TerminationTime;

            DateTime res = DateTime.UtcNow;


            EventServerSave();
            ConfStorageSave();

            actionHeader.actionValue = "http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/PullMessagesResponse";

            return(res);
        }
コード例 #4
0
        public override void AccessDoor(string Token, bool UseExtendedTime, [System.Xml.Serialization.XmlIgnoreAttribute()] bool UseExtendedTimeSpecified, [System.Xml.Serialization.XmlElementAttribute(DataType = "duration")] string AccessTime, [System.Xml.Serialization.XmlElementAttribute(DataType = "duration")] string OpenTooLongTime, [System.Xml.Serialization.XmlElementAttribute(DataType = "duration")] string PreAlarmTime, AccessDoorExtension Extension)
        {
            ConfStorageLoad();
            EventServerLoad();

            LoggingService.LogMessage(string.Format("AccessDoor operation requested for {0}", Token),
                                      ExternalLogging.MessageType.Details);

            if (ConfStorage.DoorStateList.ContainsKey(Token))
            {
                if (ConfStorage.DoorCapabilitiesList[Token].MomentaryAccess)
                {
                    if ((ConfStorage.DoorStateList[Token].DoorMode == DoorModeType.Blocked) || (ConfStorage.DoorStateList[Token].DoorMode == DoorModeType.LockedDown) || (ConfStorage.DoorStateList[Token].DoorMode == DoorModeType.LockedOpen))
                    {
                        string message = "Door " + Token + " is " + ConfStorage.DoorStateList[Token].DoorMode.ToString() +
                                         ". Operation denied.";

                        LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);

                        throw FaultLib.GetSoapException(FaultType.General, message);
                    }
                    else
                    {
                        try
                        {
                            TimeSpan timeSpan = System.Xml.XmlConvert.ToTimeSpan(AccessTime);

                            ConfStorage.DoorStateList[Token].DoorMode = DoorModeType.Accessed;

                            EventServer.DoorModeEvent(this, "Changed", Token, ConfStorage.DoorStateList[Token].DoorMode);

                            AccessToDoor func = new AccessToDoor(AccessToDoorImplementation);
                            ConfStorage.DoorAccessList[Token]++;
                            func.BeginInvoke(Token, timeSpan, ConfStorage.DoorAccessList[Token], null, null);
                        }
                        catch (Exception)
                        {
                            LoggingService.LogMessage(string.Format("Wrong duration ({0})", AccessTime), ExternalLogging.MessageType.Error);
                            throw FaultLib.GetSoapException(FaultType.General, "Wrong duration.");
                        }
                    }
                }
                else
                {
                    string message = string.Format("MomentaryAccess isn't supported for {0}.", Token);
                    LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);

                    throw FaultLib.GetSoapException(FaultType.General, message);
                }
            }
            else
            {
                string message = string.Format("Token {0} does not exist", Token);
                LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                throw FaultLib.GetSoapException(FaultType.General, message);
            }

            EventServerSave();
            ConfStorageSave();
        }
コード例 #5
0
        public override void DisableAccessPoint(string Token)
        {
            ConfStorageLoad();

            if (ConfStorage.AccessPointInfoList.ContainsKey(Token))
            {
                if (ConfStorage.AccessPointInfoList[Token].Capabilities.DisableAccessPoint)
                {
                    ConfStorage.AccessPointState[Token].Enabled = false;
                    EventServer.AccessPointEnabledEvent(this, "Changed", Token, false, "Access point disabled");
                    LoggingService.LogMessage(string.Format("Access Point with token '{0}' disabled", Token), DUT.PACS.Simulator.ExternalLogging.MessageType.Message);
                }
                else
                {
                    LoggingService.LogMessage(string.Format("Access Point with token '{0}' cannot be disabled", Token), DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    string message = string.Format("AccessPoint with token {0} does not does not support DisableAccessPoint capability.", Token);
                    FaultLib.ReturnFault(message, new string[] { "Receiver", "ActionNotSupported", "NotSupported" });
                    //throw FaultLib.GetSoapException(FaultType.General, "AccessPoint " + Token + " does not does not support DisableAccessPoint capability.");
                }
            }
            else
            {
                string message = string.Format("AccessPoint with token {0} does not exist", Token);
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" });
                //throw FaultLib.GetSoapException(FaultType.General, "Token " + Token + " does not exist.");
            }

            ConfStorageSave();
        }
コード例 #6
0
        public override string GetDoorInfoList(int Limit, [System.Xml.Serialization.XmlIgnoreAttribute()] bool LimitSpecified, string StartReference, [System.Xml.Serialization.XmlElementAttribute("DoorInfo")] out DoorInfo[] DoorInfo)
        {
            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.DoorServiceCapabilities;

            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;
            }

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

            if (offset + DoorInfo.Length < ConfStorage.DoorInfoList.Count)
            {
                newStartReferense = Convert.ToString(offset + DoorInfo.Length);
            }
            return(newStartReferense);
        }
コード例 #7
0
        public override DoorInfo[] GetDoorInfoList([System.Xml.Serialization.XmlArrayItemAttribute("Token", IsNullable = false)] string[] TokenList, int Limit, [System.Xml.Serialization.XmlIgnoreAttribute()] bool LimitSpecified, int Offset, [System.Xml.Serialization.XmlIgnoreAttribute()] bool OffsetSpecified)
        {
            DoorInfo[] res;

            List <DoorInfo> tempRes    = new List <DoorInfo>();
            bool            tokenFaund = false;

            ConfStorageLoad();
            EventServerLoad();

            res = ConfStorage.DoorInfoList;

            if ((TokenList == null) || (TokenList.Count() == 0))
            {
                res = ConfStorage.DoorInfoList;

                if (OffsetSpecified)
                {
                    res = res.Skip(Offset).ToArray();
                }

                if (LimitSpecified)
                {
                    res = res.Take(Limit).ToArray();
                }
            }
            else
            {
                foreach (string token in TokenList)
                {
                    tokenFaund = false;
                    foreach (DoorInfo doorInfo in ConfStorage.DoorInfoList)
                    {
                        if (doorInfo.token == token)
                        {
                            if (!tempRes.Contains(doorInfo))
                            {
                                tempRes.Add(doorInfo);
                            }
                            tokenFaund = true;
                            break;
                        }
                    }

                    if (!tokenFaund)
                    {
                        string message = string.Format("Token {0} does not exist", token);
                        LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                        throw FaultLib.GetSoapException(FaultType.General, "Token " + token + " does not exist.");
                    }
                }
                res = tempRes.ToArray();
            }

            EventServerSave();
            ConfStorageSave();

            return(res);
        }
コード例 #8
0
        public override SpecialDayGroup[] GetSpecialDayGroups([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 <SpecialDayGroup>(Token, C => C.SpecialDayGroupList));
        }
コード例 #9
0
        public override DoorInfo[] GetDoorInfo([System.Xml.Serialization.XmlElementAttribute("Token")] string[] Token)
        {
            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.DoorServiceCapabilities;

            if (Token != null && Token.Length > capabilities.MaxLimit)
            {
                FaultLib.ReturnFault("Too many items was requested. ", new[] { "Sender", "InvalidArgVal", "TooManyItems" });
            }
            return(GetListByTokenList <DoorInfo>(Token, C => C.DoorInfoList));
        }
コード例 #10
0
        public override AccessProfile[] GetAccessProfiles([System.Xml.Serialization.XmlElementAttribute("Token")] string[] Token)
        {
            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.AccessRulesCapabilities;

            if (Token != null && Token.Length > capabilities.MaxLimit)
            {
                FaultLib.ReturnFault("Too many items was requested. ", new[] { "Sender", "InvalidArgs", "TooManyItems" });
            }
            return(GetListByTokenList <AccessProfile>(Token, C => C.AccessProfileList));
        }
コード例 #11
0
        /***************************************************************************************/

        #region Utils

        void DoorOperation(string Token,
                           string operationName,
                           Func <DoorCapabilities, bool> capabilitiesCheck,
                           Func <DoorMode, bool> operationForbiddenCheck,
                           string notAllowedSeverity,
                           Func <DoorMode, DoorMode> transition)
        {
            LoggingService.LogMessage(string.Format("{0} operation requested for {1}", operationName, Token), ExternalLogging.MessageType.Details);

            ConfStorageLoad();
            EventServerLoad();

            if (ConfStorage.DoorStateList.ContainsKey(Token))
            {
                if (capabilitiesCheck(ConfStorage.DoorInfoList[Token].Capabilities))
                {
                    DoorState doorState = ConfStorage.DoorStateList[Token];
                    if (operationForbiddenCheck(doorState.DoorMode))
                    {
                        string message = String.Format("Door {0} is {1}. Operation {2}", Token,
                                                       doorState.DoorMode.ToString(), notAllowedSeverity);

                        LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                        FaultLib.ReturnFault(message, new string[] { "Sender", "ActionNotSupported" });
                        //throw FaultLib.GetSoapException(FaultType.General, message);
                    }
                    else
                    {
                        DoorMode targetState = transition(doorState.DoorMode);
                        doorState.DoorMode = targetState;
                        DoorSensorService.ProcessModeChanging(Token, targetState, ConfStorage, EventServer, StateReporter);
                        StateReporter.ReportStateUpdate(Token, doorState);
                        EventServer.DoorModeEvent(this, "Changed", Token, doorState.DoorMode);
                    }
                }
                else
                {
                    string message = string.Format("{0} is not supported for {1}.", operationName, Token);
                    LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "ActionNotSupported" });
                    //throw FaultLib.GetSoapException(FaultType.General, message);
                }
            }
            else
            {
                string message = string.Format("Token {0} does not exist", Token);
                LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" });
                //throw FaultLib.GetSoapException(FaultType.General, message);
            }

            EventServerSave();
            ConfStorageSave();
        }
コード例 #12
0
        public override ScheduleInfo[] GetScheduleInfo([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 <Schedule>(Token, C => C.ScheduleList), item => ToScheduleInfo(item)));
        }
コード例 #13
0
        /***************************************************************************************/

        #region Utils

        void DoorOperation(string Token,
                           string operationName,
                           Func <DoorCapabilities, bool> capabilitiesCheck,
                           Func <DoorModeType, bool> operationForbiddenCheck,
                           string notAllowedSeverity,
                           Func <DoorModeType, DoorModeType> transition)
        {
            LoggingService.LogMessage(string.Format("{0} operation requested for {1}", operationName, Token), ExternalLogging.MessageType.Details);

            ConfStorageLoad();
            EventServerLoad();

            if (ConfStorage.DoorStateList.ContainsKey(Token))
            {
                if (capabilitiesCheck(ConfStorage.DoorCapabilitiesList[Token]))
                {
                    DoorState doorState = ConfStorage.DoorStateList[Token];
                    if (operationForbiddenCheck(doorState.DoorMode))
                    {
                        string message = String.Format("Door {0} is {1}. Operation {2}", Token,
                                                       doorState.DoorMode.ToString(), notAllowedSeverity);

                        LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                        throw FaultLib.GetSoapException(FaultType.General,
                                                        message);
                    }
                    else
                    {
                        DoorModeType targetState = transition(doorState.DoorMode);
                        doorState.DoorMode = targetState;
                        StateReporter.ReportStateUpdate(Token, doorState);
                        EventServer.DoorModeEvent(this, "Changed", Token, doorState.DoorMode);
                    }
                }
                else
                {
                    string message = string.Format("{0} is not suported for {1}.", operationName, Token);
                    LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);

                    throw FaultLib.GetSoapException(FaultType.General, message);
                }
            }
            else
            {
                string message = string.Format("Token {0} does not exist", Token);
                LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                throw FaultLib.GetSoapException(FaultType.General, message);
            }

            EventServerSave();
            ConfStorageSave();
        }
コード例 #14
0
        public override AccessPointInfo[] GetAccessPointInfoList([System.Xml.Serialization.XmlArrayItemAttribute("Token", IsNullable = false)] string[] TokenList)
        {
            AccessPointInfo[] res;

            List <AccessPointInfo> tempRes = new List <AccessPointInfo>();
            bool tokenFaund = false;

            ConfStorageLoad();

            res = ConfStorage.AccessPointInfoList;

            if ((TokenList == null) || (TokenList.Count() == 0))
            {
                res = ConfStorage.AccessPointInfoList;
            }
            else
            {
                foreach (string token in TokenList)
                {
                    tokenFaund = false;
                    foreach (AccessPointInfo accessPointInfo in ConfStorage.AccessPointInfoList)
                    {
                        if (accessPointInfo.token == token)
                        {
                            if (!tempRes.Contains(accessPointInfo))
                            {
                                tempRes.Add(accessPointInfo);
                            }
                            tokenFaund = true;
                            break;
                        }
                    }

                    if (!tokenFaund)
                    {
                        throw FaultLib.GetSoapException(FaultType.General, "Token " + token + " does not exist.");
                    }
                }
                res = tempRes.ToArray();
            }

            ConfStorageSave();

            return(res);
        }
コード例 #15
0
        public override void DisableAccessPoint(string AccessPointToken)
        {
            ServiceAccessControl03.AccessPointInfo accessPointInfo;

            ConfStorageLoad();

            if (ConfStorage.AccessPointInfoList.Count(accessPoint => accessPoint.token == AccessPointToken) != 0)
            {
                accessPointInfo         = ConfStorage.AccessPointInfoList.Single(accessPoint => accessPoint.token == AccessPointToken);
                accessPointInfo.Enabled = false;
            }
            else
            {
                throw FaultLib.GetSoapException(FaultType.General, "Token " + AccessPointToken + " does not exist.");
            }

            ConfStorageSave();
        }
コード例 #16
0
        public override RenewResponse Renew([System.Xml.Serialization.XmlElementAttribute("Renew", Namespace = "http://docs.oasis-open.org/wsn/b-2")] Renew Renew1)
        {
            int subscriptionKey = SoapReferanceHeaderProcessing(unknownHeaders);

            ConfStorageLoad();
            EventServerLoad();

            DateTime terminationTime;

            try
            {
                TimeSpan timeSpan = System.Xml.XmlConvert.ToTimeSpan(Renew1.TerminationTime);
                terminationTime = DateTime.UtcNow.Add(timeSpan.Add(new TimeSpan(0, 0, 1)));
            }
            catch (Exception)
            {
                try
                {
                    terminationTime = System.Xml.XmlConvert.ToDateTime(Renew1.TerminationTime, XmlDateTimeSerializationMode.Utc);
                }
                catch (Exception)
                {
                    throw FaultLib.GetSoapException(FaultType.General, "Wrong Initial Termination Time.");
                }
            }

            EventServer.RenewSubscribtion(subscriptionKey, terminationTime);

            RenewResponse res = new RenewResponse();

            res.CurrentTimeSpecified = true;
            res.CurrentTime          = DateTime.UtcNow;
            res.TerminationTime      = terminationTime;

            EventServerSave();
            ConfStorageSave();

            actionHeader.actionValue = "http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/RenewResponse";

            return(res);
        }
コード例 #17
0
        public override DoorInfo GetDoorInfo(string Token)
        {
            DoorInfo res;

            ConfStorageLoad();

            if (ConfStorage.DoorInfoList.Count(doorInfo => doorInfo.token == Token) != 0)
            {
                res = ConfStorage.DoorInfoList.Single(doorInfo => doorInfo.token == Token);
            }
            else
            {
                string message = string.Format("Token {0} does not exist", Token);
                LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                throw FaultLib.GetSoapException(FaultType.General, "Token " + Token + " does not exist.");
            }

            ConfStorageSave();

            return(res);
        }
コード例 #18
0
        public override void DeleteSpecialDayGroup(string Token)
        {
            ConfStorageLoad();
            EventServerLoad();

            if (ConfStorage.SpecialDayGroupList.ContainsKey(Token))
            {
                ConfStorage.SpecialDayGroupList.Remove(Token);
                EventServer.ConfigurationSpecialDayGroupRemovedEvent(this, Token);
                LoggingService.LogMessage(string.Format("SpecialDayGroup with token '{0}' was deleted.", Token), DUT.PACS.Simulator.ExternalLogging.MessageType.Message);
            }
            else
            {
                string message = string.Format("SpecialDayGroup with token {0} does not exist", Token);
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" });
            }

            EventServerSave();
            ConfStorageSave();
        }
コード例 #19
0
        public override DoorState GetDoorState(string Token)
        {
            DoorState res;

            ConfStorageLoad();
            EventServerLoad();

            if (ConfStorage.DoorStateList.ContainsKey(Token))
            {
                res = ConfStorage.DoorStateList[Token];
            }
            else
            {
                string message = string.Format("Token {0} does not exist", Token);
                LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                throw FaultLib.GetSoapException(FaultType.General, "Token " + Token + " does not exist.");
            }

            EventServerSave();
            ConfStorageSave();

            return(res);
        }
コード例 #20
0
        protected bool Exists <T>(string token, Func <ConfStorage, Dictionary <string, T> > listSelector)
        {
            bool res = false;

            ConfStorageLoad();

            Dictionary <string, T> list = listSelector(ConfStorage);

            if (list.ContainsKey(token))
            {
                res = true;
            }
            else
            {
                string message = string.Format("Token {0} does not exist", token);
                LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" });
            }

            ConfStorageSave();

            return(res);
        }
コード例 #21
0
        public override void DeleteSchedule(string Token)
        {
            ConfStorageLoad();
            EventServerLoad();

            if (ConfStorage.AwaitingTasks.ContainsKey(Token))
            {
                foreach (var task in ConfStorage.AwaitingTasks[Token])
                {
                    task.Cancel();
                }
            }
            ConfStorage.AwaitingTasks.Remove(Token);

            if (ConfStorage.ScheduleList.ContainsKey(Token))
            {
                EventServer.ScheduleStateActiveEvent(this, "Removed", Token, ConfStorage.ScheduleList[Token].Name, ConfStorage.ScheduleStateList[Token].Active, ConfStorage.ScheduleStateList[Token].SpecialDay);
                EventServer.ConfigurationScheduleRemovedEvent(this, Token);
                ConfStorage.ScheduleList.Remove(Token);
                ConfStorage.ScheduleStateList.Remove(Token);
                LoggingService.LogMessage(string.Format("Schedule with token '{0}' was deleted.", Token), DUT.PACS.Simulator.ExternalLogging.MessageType.Message);
            }
            else
            {
                string message = string.Format("Schedule with token {0} does not exist", Token);
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" });
            }

            if (ConfStorage.ScheduleStateList.ContainsKey(Token))
            {
                ConfStorage.ScheduleStateList.Remove(Token);
            }

            EventServerSave();
            ConfStorageSave();
        }
コード例 #22
0
        protected T GetInfo <T>(string token, Func <ConfStorage, Dictionary <string, T> > listSelector)
        {
            T res = default(T);

            ConfStorageLoad();

            Dictionary <string, T> list = listSelector(ConfStorage);

            if (list.ContainsKey(token))
            {
                res = list[token];
            }
            else
            {
                string message = string.Format("Token {0} does not exist", token);
                LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" });
                //throw FaultLib.GetSoapException(FaultType.General, message);
            }

            ConfStorageSave();

            return(res);
        }
コード例 #23
0
        public override void ExternalAuthorization(string AccessPointToken, string CredentialToken, string Reason, Decision Decision)
        {
            Reason = "Other";
            AccessPointInfo accessPointInfo = null;

            try
            {
                accessPointInfo = GetInfo(AccessPointToken, C => C.AccessPointInfoList);
            }
            catch (SoapException ex)
            {
                FaultLib.ReturnFault(string.Format("Access point '{0}' not found. ", AccessPointToken),
                                     new[] { "Sender", "InvalidArgVal", "NotFound" });
            }

            AccessPointState accessPointState = GetInfo(AccessPointToken, C => C.AccessPointState);
            var       capabilities            = accessPointInfo.Capabilities;
            Requester requester = Requester.Anonymous;

            DUT.PACS.Simulator.ServiceCredential10.Credential credentials = new DUT.PACS.Simulator.ServiceCredential10.Credential();

            if (!string.IsNullOrEmpty(CredentialToken))
            {
                requester = Requester.Credential;

                try
                {
                    credentials = GetInfo(CredentialToken, C => C.CredentialList);
                }
                catch (SoapException)
                {
                    Reason = "Invalid credentials";
                    EventServer.AccessControlExternalEvent(this, "Access Response",
                                                           AccessPointToken, CredentialToken, null, Reason,
                                                           Decision.Denied, requester);
                    throw;
                }
            }
            if (!capabilities.AnonymousAccess && requester == Requester.Anonymous)
            {
                Reason = "AnonymousAccess is inaccessible";
                EventServer.AccessControlExternalEvent(this, "Access Response",
                                                       AccessPointToken, CredentialToken, credentials.CredentialHolderReference,
                                                       Reason, Decision.Denied, requester);
                FaultLib.ReturnFault(Reason, new string[] { "Sender", "ActionNotSupported", "NotSupported" });
            }

            if (accessPointState.Enabled)
            {
                if (capabilities.ExternalAuthorizationSpecified && capabilities.ExternalAuthorization)
                {
                    EventServer.AccessControlExternalEvent(this, "Access Response",
                                                           AccessPointToken, CredentialToken,
                                                           credentials.CredentialHolderReference,
                                                           Reason, Decision, requester);
                }
                else
                {
                    Reason = "External authorization is inaccessible";
                    EventServer.AccessControlExternalEvent(this, "Access Response",
                                                           AccessPointToken, CredentialToken, credentials.CredentialHolderReference,
                                                           Reason, Decision.Denied, requester);
                    FaultLib.ReturnFault(Reason, new string[] { "Sender", "ActionNotSupported", "NotSupported" });
                }
            }
            else
            {
                Reason = "Access point is disabled";
                EventServer.AccessControlExternalEvent(this, "Access Response",
                                                       AccessPointToken, CredentialToken, credentials.CredentialHolderReference, Reason,
                                                       Decision.Denied, requester);
                FaultLib.ReturnFault(Reason, new string[] { "Sender" });
            }
        }
コード例 #24
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);
        }
コード例 #25
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();
        }
コード例 #26
0
        public override void AccessDoor(string Token, bool UseExtendedTime, [System.Xml.Serialization.XmlIgnoreAttribute()] bool UseExtendedTimeSpecified, [System.Xml.Serialization.XmlElementAttribute(DataType = "duration")] string AccessTime, [System.Xml.Serialization.XmlElementAttribute(DataType = "duration")] string OpenTooLongTime, [System.Xml.Serialization.XmlElementAttribute(DataType = "duration")] string PreAlarmTime, AccessDoorExtension Extension)
        {
            ConfStorageLoad();
            EventServerLoad();

            LoggingService.LogMessage(string.Format("AccessDoor operation requested for {0}", Token),
                                      ExternalLogging.MessageType.Details);

            if (ConfStorage.DoorStateList.ContainsKey(Token))
            {
                if (ConfStorage.DoorInfoList[Token].Capabilities.AccessSpecified && ConfStorage.DoorInfoList[Token].Capabilities.Access)
                {
                    if ((ConfStorage.DoorStateList[Token].DoorMode == DoorMode.Blocked) || (ConfStorage.DoorStateList[Token].DoorMode == DoorMode.LockedDown) || (ConfStorage.DoorStateList[Token].DoorMode == DoorMode.LockedOpen))
                    {
                        string message = "Door " + Token + " is " + ConfStorage.DoorStateList[Token].DoorMode.ToString() +
                                         ". Operation denied.";

                        LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                        FaultLib.ReturnFault(message, new string[] { "Sender", "ActionNotSupported" });
                        //throw FaultLib.GetSoapException(FaultType.General, message);
                    }
                    else
                    {
                        try
                        {
                            TimeSpan timeSpan = TimeSpan.Zero;
                            if (!string.IsNullOrEmpty(AccessTime))
                            {
                                timeSpan = System.Xml.XmlConvert.ToTimeSpan(AccessTime);
                            }

                            if (ConfStorage.DoorStateList[Token].DoorMode != DoorMode.Accessed)
                            {
                                ConfStorage.DoorAccessPreviousStateList[Token] = ConfStorage.DoorStateList[Token].DoorMode;
                            }

                            ConfStorage.DoorStateList[Token].DoorMode = DoorMode.Accessed;
                            StateReporter.ReportStateUpdate(Token, ConfStorage.DoorStateList[Token]);
                            DoorSensorService.ProcessModeChanging(Token, DoorMode.Accessed, ConfStorage, EventServer, StateReporter);

                            EventServer.DoorModeEvent(this, "Changed", Token, ConfStorage.DoorStateList[Token].DoorMode);

                            AccessToDoor func = new AccessToDoor(AccessToDoorImplementation);
                            ConfStorage.DoorAccessList[Token]++;

                            func.BeginInvoke(Token, timeSpan, ConfStorage.DoorAccessList[Token], null, null);
                        }
                        catch (Exception)
                        {
                            string message = string.Format("Wrong duration ({0})", AccessTime);
                            LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                            FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal" });
                            //throw FaultLib.GetSoapException(FaultType.General, "Wrong duration.");
                        }
                    }
                }
                else
                {
                    string message = string.Format("MomentaryAccess isn't supported for {0}.", Token);
                    LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "ActionNotSupported" });
                    //throw FaultLib.GetSoapException(FaultType.General, message);
                }
            }
            else
            {
                string message = string.Format("Token {0} does not exist", Token);
                LoggingService.LogMessage(message, ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" });
                //throw FaultLib.GetSoapException(FaultType.General, message);
            }

            EventServerSave();
            ConfStorageSave();
        }
コード例 #27
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);
        }
コード例 #28
0
        public override void ModifyAccessProfile(AccessProfile AccessProfile)
        {
            ConfStorageLoad();
            EventServerLoad();

            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.AccessRulesCapabilities;

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


            //Check MaxAccessPoliciesPerAccessProfile capability
            if (AccessProfile.AccessPolicy != null)
            {
                if (AccessProfile.AccessPolicy.Count() > capabilities.MaxAccessPoliciesPerAccessProfile)
                {
                    string message = string.Format("Max Access Polisies per AccessProfile exeeded.");
                    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MaxAccessPoliciesPerAccessProfile" });
                }

                //Check MultipleSchedulesPerAccessPointSupported capability
                if (!capabilities.MultipleSchedulesPerAccessPointSupported)
                {
                    foreach (var group in AccessProfile.AccessPolicy.GroupBy(C => C.Entity))
                    {
                        if (group.Count() > 1)
                        {
                            string message = string.Format("Multiple AccessPoints are not supported for the same schedule, see MultipleSchedulesPerAccessPointSupported capability.");
                            LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                            FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MultipleSchedulesPerAccessPointSupported" });
                        }
                    }
                }

                //Check that only access points are used
                if (AccessProfile.AccessPolicy.Any(C => (C.EntityType != null) && ((C.EntityType.Namespace != "http://www.onvif.org/ver10/accesscontrol/wsdl") || (C.EntityType.Name != "AccessPoint"))))
                {
                    string message = string.Format("Specified Entity is not supported.");
                    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal" });
                }

                //Check that all Access Pioints exists
                if (AccessProfile.AccessPolicy.Any(C => !(ConfStorage.AccessPointInfoList.Keys.Contains(C.Entity))))
                {
                    string message = string.Format("Access Profile does not exist.");
                    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal" });
                }
            }

            //TODO: Check that all Schedules exists

            ConfStorage.AccessProfileList.Remove(AccessProfile.token);
            ConfStorage.AccessProfileList.Add(AccessProfile.token, AccessProfile);

            EventServer.ConfigurationAccessProfileChangedEvent(this, AccessProfile.token);

            EventServerSave();
            ConfStorageSave();
        }
コード例 #29
0
        public override EndpointReferenceType CreatePullPointSubscription(FilterType Filter, [System.Xml.Serialization.XmlElementAttribute(IsNullable = true)] string InitialTerminationTime, CreatePullPointSubscriptionSubscriptionPolicy SubscriptionPolicy, [System.Xml.Serialization.XmlAnyElementAttribute()] ref System.Xml.XmlElement[] Any, [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://docs.oasis-open.org/wsn/b-2")] out System.DateTime CurrentTime, [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://docs.oasis-open.org/wsn/b-2", IsNullable = true)] out System.Nullable <System.DateTime> TerminationTime)
        {
            SoapHeaderProcessing(unknownHeaders);

            ConfStorageLoad();
            EventServerLoad();

            EndpointReferenceType res = new EndpointReferenceType();

            DateTime terminationTime;
            bool     nullInitialTerminationTime = false;

            if (InitialTerminationTime == null)
            {
                InitialTerminationTime     = "PT10S";
                nullInitialTerminationTime = true;
            }

            try
            {
                TimeSpan timeSpan = System.Xml.XmlConvert.ToTimeSpan(InitialTerminationTime);
                terminationTime = DateTime.UtcNow.Add(timeSpan.Add(new TimeSpan(0, 0, 1)));
            }
            catch (Exception)
            {
                try
                {
                    terminationTime = System.Xml.XmlConvert.ToDateTime(InitialTerminationTime, XmlDateTimeSerializationMode.Utc);
                }
                catch (Exception)
                {
                    throw FaultLib.GetSoapException(FaultType.General, "Wrong Initial Termination Time.");
                }
            }

            string     rawRequest    = RequestListener.Take();
            XmlElement filterElement = Utils.GetFilterElements(rawRequest, true);

            int subscriptionKey = EventServer.AddSubscribtion(null, Filter, filterElement, terminationTime, nullInitialTerminationTime);

            CurrentTime     = DateTime.UtcNow;
            TerminationTime = terminationTime;

            res.ReferenceParameters = new ReferenceParametersType();
            res.Address             = new AttributedURIType();
            string hostAndPort = HttpContext.Current.Request.Url.Authority;

            res.Address.Value           = "http://" + hostAndPort + "/ServiceEvents10/PullpointSubscriptionService.asmx";
            res.ReferenceParameters.Any = new System.Xml.XmlElement[1];

            NameTable           nt    = new NameTable();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);

            nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
            nsmgr.AddNamespace("dut", "http://dut");
            nsmgr.AddNamespace("tdc", "http://www.onvif.org/ver10/doorcontrol/wsdl");

            XmlDocument referenceParameters = new XmlDocument(nt);

            res.ReferenceParameters.Any[0]          = referenceParameters.CreateElement("dut", "id", "http://dut");
            res.ReferenceParameters.Any[0].InnerXml = subscriptionKey.ToString();



            EventServerSave();
            ConfStorageSave();

            actionHeader.actionValue = "http://www.onvif.org/ver10/events/wsdl/EventPortType/CreatePullPointSubscriptionResponse";
            EventServer.SynchronizationPoint(subscriptionKey);
            return(res);
        }
コード例 #30
0
        public override SubscribeResponse Subscribe([System.Xml.Serialization.XmlElementAttribute("Subscribe", Namespace = "http://docs.oasis-open.org/wsn/b-2")] Subscribe Subscribe1)
        {
            SoapHeaderProcessing(unknownHeaders);

            ConfStorageLoad();
            EventServerLoad();

            SubscribeResponse res = new SubscribeResponse();

            DateTime terminationTime;

            try
            {
                TimeSpan timeSpan = System.Xml.XmlConvert.ToTimeSpan(Subscribe1.InitialTerminationTime);
                terminationTime = DateTime.UtcNow.Add(timeSpan.Add(new TimeSpan(0, 0, 1)));
            }
            catch (Exception)
            {
                try
                {
                    terminationTime = System.Xml.XmlConvert.ToDateTime(Subscribe1.InitialTerminationTime, XmlDateTimeSerializationMode.Utc);
                }
                catch (Exception)
                {
                    throw FaultLib.GetSoapException(FaultType.General, "Wrong Initial Termination Time.");
                }
            }

            string     rawRequest    = RequestListener.Take();
            XmlElement filterElement = Utils.GetFilterElements(rawRequest);

            int subscriptionKey = EventServer.AddSubscribtion(Subscribe1.ConsumerReference.Address.Value,
                                                              Subscribe1.Filter,
                                                              filterElement,
                                                              terminationTime, false);



            res.CurrentTimeSpecified          = true;
            res.CurrentTime                   = DateTime.UtcNow;
            res.TerminationTimeSpecified      = true;
            res.TerminationTime               = terminationTime;
            res.SubscriptionReference         = new EndpointReferenceType();
            res.SubscriptionReference.Address = new AttributedURIType();
            string hostAndPort = HttpContext.Current.Request.Url.Authority;

            res.SubscriptionReference.Address.Value           = "http://" + hostAndPort + "/ServiceEvents10/SubscriptionManagerService.asmx";
            res.SubscriptionReference.ReferenceParameters     = new ReferenceParametersType();
            res.SubscriptionReference.ReferenceParameters.Any = new System.Xml.XmlElement[1];

            NameTable           nt    = new NameTable();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);

            nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
            nsmgr.AddNamespace("dut", "http://dut");
            nsmgr.AddNamespace("tdc", "http://www.onvif.org/ver10/doorcontrol/wsdl");

            XmlDocument referenceParameters = new XmlDocument(nt);

            res.SubscriptionReference.ReferenceParameters.Any[0]          = referenceParameters.CreateElement("dut", "id", "http://dut");
            res.SubscriptionReference.ReferenceParameters.Any[0].InnerXml = subscriptionKey.ToString();



            EventServerSave();
            ConfStorageSave();

            actionHeader.actionValue = "http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeResponse";
            EventServer.SynchronizationPoint(subscriptionKey);
            return(res);
        }