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();
        }
Exemple #2
0
 public abstract 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);