コード例 #1
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();
        }
コード例 #2
0
 void FireAllEvents(string Token, DoorState state)
 {
     EventServer.DoorModeEvent(this, "Initialized", Token, state.DoorMode);
     EventServer.DoorMonitorEvent(this, "Initialized", Token, state.DoorMonitor);
     EventServer.DoorDoubleLockMonitorEvent(this, "Initialized", Token, state.DoorDoubleLockMonitor);
     EventServer.DoorLockMonitorEvent(this, "Initialized", Token, state.DoorLockMonitor);
     EventServer.DoorAlarmMonitorEvent(this, "Initialized", Token, state.DoorAlarm);
     EventServer.DoorTamperMonitorEvent(this, "Initialized", Token, state.DoorTamper);
 }
コード例 #3
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();
        }
コード例 #4
0
 void FireAllEvents(string Token, DoorState state)
 {
     EventServer.DoorModeEvent(this, "Initialized", Token, state.DoorMode);
     EventServer.DoorPhysicalStateEvent(this, "Initialized", Token, state.DoorPhysicalState);
     EventServer.DoubleLockPhysicalStateEvent(this, "Initialized", Token, state.DoubleLockPhysicalState);
     EventServer.LockPhysicalStateEvent(this, "Initialized", Token, state.LockPhysicalState);
     EventServer.DoorAlarmMonitorEvent(this, "Initialized", Token, state.Alarm);
     if (state.Tamper != null)
     {
         EventServer.DoorTamperMonitorEvent(this, "Initialized", Token, state.Tamper.State);
     }
 }
コード例 #5
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();
        }
コード例 #6
0
        void FireAllEvents(DoorInfo door, DoorState state)
        {
            var capabilities = door.Capabilities;

            EventServer.DoorModeEvent(this, "Initialized", door.token, state.DoorMode);

            if (capabilities.DoorMonitorSpecified && capabilities.DoorMonitor)
            {
                EventServer.DoorPhysicalStateEvent(this, "Initialized", door.token, state.DoorPhysicalState);
            }

            if (capabilities.LockMonitorSpecified && capabilities.LockMonitor)
            {
                EventServer.LockPhysicalStateEvent(this, "Initialized", door.token, state.LockPhysicalState);
            }

            if (capabilities.DoubleLockMonitorSpecified && capabilities.DoubleLockMonitor)
            {
                EventServer.DoubleLockPhysicalStateEvent(this, "Initialized", door.token, state.DoubleLockPhysicalState);
            }

            if (capabilities.AlarmSpecified && capabilities.Alarm)
            {
                EventServer.DoorAlarmMonitorEvent(this, "Initialized", door.token, state.Alarm);
            }

            if (capabilities.TamperSpecified && capabilities.Tamper)
            {
                if (state.Tamper != null)
                {
                    EventServer.DoorTamperMonitorEvent(this, "Initialized", door.token, state.Tamper.State);
                }
            }

            if (capabilities.FaultSpecified && capabilities.Fault)
            {
                if (state.Fault != null)
                {
                    EventServer.DoorFaultEvent(this, "Initialized", door.token, state.Fault.State);
                }
            }

            //if (capabilities.FaultSpecified && capabilities.Fault)
            //    EventServer.DoorFaultMonitorEvent(this, "Initialized", door.token, state.Fault);
        }
コード例 #7
0
 private void AccessToDoorImplementation(string Token, TimeSpan AccessTime, int DoorAccessSesion)
 {
     if (AccessTime == TimeSpan.Zero)
     {
         System.Threading.Thread.Sleep(c_DefaultAccessTime);
     }
     else
     {
         System.Threading.Thread.Sleep((int)(AccessTime.TotalMilliseconds));
     }
     if (ConfStorage.DoorStateList[Token].DoorMode == DoorMode.Accessed)
     {
         if (DoorAccessSesion == ConfStorage.DoorAccessList[Token])
         {
             ConfStorage.DoorStateList[Token].DoorMode = ConfStorage.DoorAccessPreviousStateList[Token];
             DoorSensorService.ProcessModeChanging(Token, ConfStorage.DoorStateList[Token].DoorMode, ConfStorage, EventServer, StateReporter);
             StateReporter.ReportStateUpdate(Token, ConfStorage.DoorStateList[Token]);
             EventServer.DoorModeEvent(this, "Changed", Token, ConfStorage.DoorStateList[Token].DoorMode);
         }
     }
 }
コード例 #8
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();
        }