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(); }
/***************************************************************************************/ public void SynchronizationPoint() { ConfStorageLoad(); EventServerLoad(); //foreach (AccessControllerInfo info in ConfStorage.AccessControllerInfoList) //{ // //EventServer.TamperingEvent(this, "Initialized", info.token, info.); //} //DoorState state = ConfStorage.DoorStateList[Token]; foreach (var accessPoint in ConfStorage.AccessPointInfoList.Values) { var capabilities = accessPoint.Capabilities; var token = accessPoint.token; if (capabilities.DisableAccessPoint) { EventServer.AccessPointEnabledEvent(this, "Initialized", token, ConfStorage.AccessPointState[token].Enabled, string.Empty); } if (capabilities.TamperSpecified && capabilities.Tamper) { EventServer.AccessPointTamperingEvent(this, "Initialized", token, ConfStorage.AccessPointTamperingState[token], string.Empty); } } EventServerSave(); ConfStorageSave(); }
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(); }
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); }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Do not execute this application!"); return; } EventRegistry.BuildDictionary(); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); _eventServer = new EventServer(Int32.Parse(args[0])); _eventServer.OnEventReceived += EventReceivedHandler; _eventServer.Start(); CefSettings settings = new CefSettings(); CefSharpSettings.ShutdownOnExit = true; settings.CefCommandLineArgs.Remove("mute-audio"); Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); while (true) { Thread.Sleep(1); } }
public static void InitEventServer() { var eventServer = new EventServer(GetIpAddress()); eventServer.Start(); var eventClient1 = new EventClient(GetIpAddress()); eventClient1.AddToGroup("Task", "Random"); eventClient1.Connect(); eventClient1.PublishEvent += (s, a) => { Console.WriteLine("CLIENT1: " + a.Arguments.ToString()); }; var eventClient2 = new EventClient(GetIpAddress()); eventClient2.Connect(); eventClient2.AddToGroup("Task"); eventClient2.PublishEvent += (s, a) => { Console.WriteLine("CLIENT2: " + a.Arguments.ToString()); }; var eventClient3 = new EventClient(GetIpAddress()); eventClient3.Connect(); eventClient3.AddToGroup("Task", "Random"); eventClient3.PublishEvent += (s, a) => { Console.WriteLine("CLIENT3: " + a.Arguments.ToString()); }; while (true) { eventClient1.SendEventToAll(new CustomEventData() { FirstName = "Event to All", LastName = "B" }); eventClient1.SendEventToOthers(new CustomEventData() { FirstName = "Event To Others", LastName = "D" }); eventClient1.SendEventToAllInGroup(new CustomEventData() { FirstName = "Event to all in Group Task", LastName = "D" }, "Task"); eventClient1.SendEventToRandomInGroup(new CustomEventData() { FirstName = "Event to random in Group Random", LastName = "D" }, "Random"); Console.WriteLine("Message sent"); Console.ReadLine(); } }
static void Main(string[] args) { EventServer s = new EventServer(); s.Start(); Console.ReadKey(); }
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(); }
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(); }
protected internal virtual void Initialize(XmlSerializer serializer, Service service) { if (serializer == null) { throw new ArgumentNullException("serializer"); } else if (service == null) { throw new ArgumentNullException("service"); } else if (service.ScpdUrl == null) { throw new ArgumentException("The service has no ScpdUrl.", "service"); } else if (service.ControlUrl == null) { throw new ArgumentException("The service has no ControlUrl.", "service"); } else if (service.EventUrl == null) { throw new ArgumentException("The service has no EventUrl.", "service"); } scpd_server = new DataServer(serializer.GetBytes(this), @"text/xml; charset=""utf-8""", service.ScpdUrl); control_server = new ControlServer(actions, service.Type.ToString(), service.ControlUrl, serializer); event_server = new EventServer(state_variables.Values, service.EventUrl); foreach (var state_variable in state_variables.Values) { state_variable.Initialize(this); } }
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); }
/***************************************************************************************/ #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(); }
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); } }
/***************************************************************************************/ #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(); }
public void SynchronizationPoint() { ConfStorageLoad(); EventServerLoad(); foreach (var schedule in ConfStorage.ScheduleList.Values) { EventServer.ScheduleStateActiveEvent(this, "Initialized", schedule.token, schedule.Name, ConfStorage.ScheduleStateList[schedule.token].Active, ConfStorage.ScheduleStateList[schedule.token].SpecialDay); } EventServerSave(); ConfStorageSave(); }
public override void SetSynchronizationPoint() { int subscriptionKey = SoapReferanceHeaderProcessing(unknownHeaders); ConfStorageLoad(); EventServerLoad(); EventServer.SynchronizationPoint(subscriptionKey); EventServerSave(); ConfStorageSave(); actionHeader.actionValue = "http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/SetSynchronizationPointResponse"; }
public void FireEvent(TopicInformation topicInfo, DateTime messageTime, string propertyOperation, List <SimpleItem> source, List <SimpleItem> data) { // find topic DUT.PACS.Simulator.Events.Topic topic = TopicsConverter.Find( DUT.PACS.Simulator.Events.PACSTopicSet.Instance, topicInfo); // create NotificationMessage NotificationMessageHolderType message = GenerateNotificationMessage(topicInfo, messageTime, propertyOperation, source, data); EventServer.TransmitMessage(message, topic); EventServer.TimeoutEvent(this, topic, source, data); }
public void EventServerLoad() { if (Application[AppVars.EVENTSERVER] != null) { m_EventServer = (EventServer)Application[AppVars.EVENTSERVER]; } else { m_EventServer = new EventServer(); Application[AppVars.EVENTSERVER] = m_EventServer; EventServer.DoorModePropertyEvent += EventServer.DoorModeEventHandler; EventServer.DoorPhysicalStatePropertyEvent += EventServer.DoorPhysicalStateEventHandler; EventServer.DoubleLockPhysicalStatePropertyEvent += EventServer.DoubleLockPhysicalStatePropertyEventHandler; EventServer.LockPhysicalStatePropertyEvent += EventServer.LockPhysicalStatePropertyEventHandler; EventServer.DoorAlarmPropertyEvent += EventServer.DoorAlarmPropertyEventHandler; EventServer.DoorTamperPropertyEvent += EventServer.DoorTamperPropertyEventHandler; EventServer.DoorFaultPropertyEvent += EventServer.DoorFaultPropertyEventHandler; EventServer.AccessPointEnabledPropertyEvent += EventServer.AccessPointEnabledPropertyEventHandler; EventServer.AccessPointTamperingPropertyEvent += EventServer.AccessPointTamperingPropertyEventHandler; EventServer.RequestTimeoutPropertyEvent += EventServer.RequestTimeoutEventHandler; EventServer.AccessControlExternalPropertyEvent += EventServer.AccessControlExternalEventHandler; EventServer.CredentialEnabledPropertyEvent += EventServer.CredentialEnabledPropertyEventHandler; EventServer.CredentialResetAntipassbackViolationPropertyEvent += EventServer.CredentialResetAntipassbackViolationPropertyEventHandler; EventServer.ConfigurationAccessProfileChangedPropertyEvent += EventServer.ConfigurationAccessProfileChangedEventHandler; EventServer.ConfigurationAccessProfileRemovedPropertyEvent += EventServer.ConfigurationAccessProfileRemovedEventHandler; EventServer.ConfigurationCredentialChangedPropertyEvent += EventServer.ConfigurationCredentialChangedEventHandler; EventServer.ConfigurationCredentialRemovedPropertyEvent += EventServer.ConfigurationCredentialRemovedEventHandler; EventServer.evConfigurationCredentialAntipassbackEvent += EventServer.ConfigurationCredentialAntipassbackEventHandler; EventServer.evConfigurationCredentialCredentialIdentifierEvent += EventServer.ConfigurationCredentialCredentialIdentifierEventHandler; //Schedule EventServer.eventConfigurationScheduleChangedEvent += EventServer.ConfigurationScheduleChangedEventHandler; EventServer.eventConfigurationScheduleRemovedEvent += EventServer.ConfigurationScheduleRemovedEventHandler; EventServer.eventConfigurationSpecialDayGroupChangedEvent += EventServer.ConfigurationSpecialDayGroupChangedEventHandler; EventServer.eventConfigurationSpecialDayGroupRemovedEvent += EventServer.ConfigurationSpecialDayGroupRemovedEventHandler; EventServer.eventScheduleStateActivePropertyEvent += EventServer.ScheduleStateActiveEventHandler; // Attach logger m_EventServer.ExternalLogger = LoggingService; } }
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); }
public UnsubscribeResponse Unsubscribe([System.Xml.Serialization.XmlElementAttribute("Unsubscribe", Namespace = "http://docs.oasis-open.org/wsn/b-2")] Unsubscribe Unsubscribe1) { int subscriptionKey = SoapReferanceHeaderProcessing(unknownHeaders); ConfStorageLoad(); EventServerLoad(); EventServer.RemoveSubscribtion(subscriptionKey); UnsubscribeResponse res = new UnsubscribeResponse(); EventServerSave(); ConfStorageSave(); actionHeader.actionValue = "http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/UnsubscribeResponse"; return(res); }
static void Main(string[] args) { Console.WriteLine($"테스트 전송할 파일 경로 : {PATH}"); Debug.MessageWritten += Debug_MessageWritten; //DatabaseManager.Initialize(); mServer = new EventServer(31006); mServer.ClientConnected += Server_ClientConnected; mServer.Start(); Console.WriteLine("서버가 시작되었습니다. 31006 포트"); Console.WriteLine("아무키나 누르면 클라이언트를 종료합니다..."); Console.ReadKey(false); mServer.Halt(); }
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); }
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(); }
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); } } }
private void OpenServer(object o) { try { Server = new EventServer(31006); Server.Start(); this.Dispatcher.Invoke(() => { SetState(true); Clients.BindCollection(); }); } catch (Exception e) { this.Dispatcher.Invoke(() => { SetState(false); MessageBox.Show(this, "서버를 시작할 수 없습니다. 인터넷 연결상태를 확인해주세요.\n\n자세한 오류 메세지 : " + e.Message, "오류", MessageBoxButton.OK, MessageBoxImage.Error); }); } }
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(); }
//public void AnswerButton() //{ // for (int i = 0; i < numbers.Length; i++) // { // if (i == findAnswer) // { // SocketEvent sendAnswerData = new SocketEvent(); // sendAnswerData.eventName = "SendAnswer"; // sendAnswerData.token = myToken; // sendAnswerData.answer = numbers[i].ToString(); // string stringAns = JsonUtility.ToJson(sendAnswerData); // ws.Send(stringAns); // Debug.Log(stringAns); // break; // } // } //} private void UpdateNotify() { if (string.IsNullOrEmpty(tempData) == false) { EventServer receiveMessageData = JsonUtility.FromJson <EventServer>(tempData); if (receiveMessageData.eventName == "RequestToken") { Debug.Log("My token :" + receiveMessageData.data); } if (receiveMessageData.eventName == "GetStudentData") { Debug.Log("My data :" + receiveMessageData.data); } if (receiveMessageData.eventName == "RequestExamInfo") { Debug.Log("Exam :" + receiveMessageData.data); } if (receiveMessageData.eventName == "SendAnswer") { Debug.Log("Answer :" + receiveMessageData.data); } } tempData = ""; }
protected internal virtual void Initialize(Uri serviceUrl) { description_server = new DescriptionServer (controller, new Uri (serviceUrl, "description/")); action_server = new ActionServer (controller, new Uri (serviceUrl, "control/")); event_server = new EventServer (controller, new Uri (serviceUrl, "event/")); }
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(); }
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); }
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); }