public PutRequest(ResourceURI ResourceURI, Locale Locale, SelectorSet SelectorSet, System.Xml.XmlElement Body) { this.ResourceURI = ResourceURI; this.Locale = Locale; this.SelectorSet = SelectorSet; this.Body = Body; }
private static ResourceURI CreateResourceUri(Uri urn) { var resourceUri = new ResourceURI() { Value = urn.ToString() }; return(resourceUri); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (ApplicationName.Expression != null) { targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context)); } if (BasePropertiesOnly.Expression != null) { targetCommand.AddParameter("BasePropertiesOnly", BasePropertiesOnly.Get(context)); } if ((ComputerName.Expression != null) && (PSRemotingBehavior.Get(context) != RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", ComputerName.Get(context)); } if (ConnectionURI.Expression != null) { targetCommand.AddParameter("ConnectionURI", ConnectionURI.Get(context)); } if (Dialect.Expression != null) { targetCommand.AddParameter("Dialect", Dialect.Get(context)); } if (Enumerate.Expression != null) { targetCommand.AddParameter("Enumerate", Enumerate.Get(context)); } if (Filter.Expression != null) { targetCommand.AddParameter("Filter", Filter.Get(context)); } if (Fragment.Expression != null) { targetCommand.AddParameter("Fragment", Fragment.Get(context)); } if (OptionSet.Expression != null) { targetCommand.AddParameter("OptionSet", OptionSet.Get(context)); } if (Port.Expression != null) { targetCommand.AddParameter("Port", Port.Get(context)); } if (Associations.Expression != null) { targetCommand.AddParameter("Associations", Associations.Get(context)); } if (ResourceURI.Expression != null) { targetCommand.AddParameter("ResourceURI", ResourceURI.Get(context)); } if (ReturnType.Expression != null) { targetCommand.AddParameter("ReturnType", ReturnType.Get(context)); } if (SelectorSet.Expression != null) { targetCommand.AddParameter("SelectorSet", SelectorSet.Get(context)); } if (SessionOption.Expression != null) { targetCommand.AddParameter("SessionOption", SessionOption.Get(context)); } if (Shallow.Expression != null) { targetCommand.AddParameter("Shallow", Shallow.Get(context)); } if (UseSSL.Expression != null) { targetCommand.AddParameter("UseSSL", UseSSL.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (Authentication.Expression != null) { targetCommand.AddParameter("Authentication", Authentication.Get(context)); } if (CertificateThumbprint.Expression != null) { targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public override void GetFullState() { try { List <SIPAccount> sipAccounts = null; if (ResourceURI.User == m_wildcardUser) { //sipAccounts = m_sipAccountPersistor.Get(s => s.Owner == SubscriptionDialogue.Owner, "SIPUsername", 0, MAX_SIPACCOUNTS_TO_RETRIEVE); sipAccounts = GetSIPAccountsForOwner_External(SubscriptionDialogue.Owner, 0, MAX_SIPACCOUNTS_TO_RETRIEVE); } else { //sipAccounts = m_sipAccountPersistor.Get(s => s.SIPUsername == CanonicalResourceURI.User && s.SIPDomain == CanonicalResourceURI.Host, "SIPUsername", 0, MAX_SIPACCOUNTS_TO_RETRIEVE); sipAccounts = GetSIPAccountsForUser_External(CanonicalResourceURI.User, CanonicalResourceURI.Host, 0, MAX_SIPACCOUNTS_TO_RETRIEVE); } foreach (SIPAccount sipAccount in sipAccounts) { SIPURI aor = SIPURI.ParseSIPURIRelaxed(sipAccount.SIPUsername + "@" + sipAccount.SIPDomain); int bindingsCount = GetSIPRegistrarBindingsCount_External(sipAccount.Id); if (bindingsCount > 0) { string safeSIPAccountID = sipAccount.Id.ToString(); Presence.Tuples.Add(new SIPEventPresenceTuple(safeSIPAccountID, SIPEventPresenceStateEnum.open, aor, Decimal.Zero, sipAccount.AvatarURL)); //logger.Debug(" full presence " + aor.ToString() + " open."); } else { string safeSIPAccountID = sipAccount.Id.ToString(); Presence.Tuples.Add(new SIPEventPresenceTuple(safeSIPAccountID, SIPEventPresenceStateEnum.closed, null, Decimal.Zero, sipAccount.AvatarURL)); //logger.Debug(" full presence " + aor.ToString() + " closed."); } } MonitorLogEvent_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.Notifier, SIPMonitorEventTypesEnum.NotifySent, "Full state notification for presence and " + ResourceURI.ToString() + ".", SubscriptionDialogue.Owner)); } catch (Exception excp) { logger.Error("Exception SIPPresenceEventSubscription GetFullState. " + excp.Message); } }
/// <summary> /// Checks and where required adds a presence related monitor event to the list of pending notifications. /// </summary> /// <param name="machineEvent">The monitor event that has been received.</param> /// <returns>True if a notification needs to be sent as a result of this monitor event, false otherwise.</returns> public override bool AddMonitorEvent(SIPMonitorMachineEvent machineEvent) { try { MonitorLogEvent_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.Notifier, SIPMonitorEventTypesEnum.Monitor, "Monitor event " + machineEvent.MachineEventType + " presence " + machineEvent.ResourceURI.ToString() + " for subscription to " + ResourceURI.ToString() + ".", SubscriptionDialogue.Owner)); string safeSIPAccountID = machineEvent.ResourceID; SIPURI sipAccountURI = machineEvent.ResourceURI; bool sendNotificationForEvent = true; string avatarURL = null; if (m_switchboardSIPAccountsOnly) { // Need to check whether the SIP account is switchboard enabled before forwarding the notification. Guid sipAccountID = new Guid(machineEvent.ResourceID); //sendNotificationForEvent = Convert.ToBoolean(m_sipAccountPersistor.GetProperty(sipAccountID, "IsSwitchboardEnabled")); sendNotificationForEvent = Convert.ToBoolean(GetSipAccountProperty_External(sipAccountID, "IsSwitchboardEnabled")); if (sendNotificationForEvent) { //avatarURL = m_sipAccountPersistor.GetProperty(sipAccountID, "AvatarURL") as string; avatarURL = GetSipAccountProperty_External(sipAccountID, "AvatarURL") as string; } } if (sendNotificationForEvent) { if (machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPRegistrarBindingUpdate) { // A binding has been updated so there is at least one device online for the SIP account. Presence.Tuples.Add(new SIPEventPresenceTuple(safeSIPAccountID, SIPEventPresenceStateEnum.open, sipAccountURI, Decimal.Zero, avatarURL)); //logger.Debug(" single presence open."); } else { // A binding has been removed but there could still be others. Guid sipAccountID = new Guid(machineEvent.ResourceID); int bindingsCount = GetSIPRegistrarBindingsCount_External(sipAccountID); if (bindingsCount > 0) { Presence.Tuples.Add(new SIPEventPresenceTuple(safeSIPAccountID, SIPEventPresenceStateEnum.open, sipAccountURI, Decimal.Zero, avatarURL)); } else { Presence.Tuples.Add(new SIPEventPresenceTuple(safeSIPAccountID, SIPEventPresenceStateEnum.closed, sipAccountURI, Decimal.Zero, avatarURL)); } } return(true); } else { return(false); } } catch (Exception excp) { logger.Error("Exception SIPresenceEventSubscription AddMonitorEvent. " + excp.Message); throw; } }
public override bool AddMonitorEvent(SIPMonitorMachineEvent machineEvent) { try { lock (DialogInfo) { MonitorLogEvent_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.Notifier, SIPMonitorEventTypesEnum.Monitor, "Monitor event " + machineEvent.MachineEventType + " dialog " + ResourceURI.ToString() + " (ID " + machineEvent.ResourceID + ").", SubscriptionDialogue.Owner)); string state = GetStateForEventType(machineEvent.MachineEventType); if (machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPDialogueRemoved) { DialogInfo.DialogItems.Add(new SIPEventDialog(machineEvent.ResourceID, state, null)); return(true); } else { SIPDialogue sipDialogue = GetDialogue_External(new Guid(machineEvent.ResourceID)); if (sipDialogue == null) { // Couldn't find the dialogue in the database so it must be terminated. DialogInfo.DialogItems.Add(new SIPEventDialog(machineEvent.ResourceID, "terminated", null)); return(true); } else if (machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPDialogueTransfer) { // For dialog transfer events add both dialogs involved to the notification. DialogInfo.DialogItems.Add(new SIPEventDialog(sipDialogue.Id.ToString(), state, sipDialogue)); if (sipDialogue.BridgeId != Guid.Empty) { //SIPDialogue bridgedDialogue = GetDialogues_External(d => d.BridgeId == sipDialogue.BridgeId && d.Id != sipDialogue.Id, null, 0, 1).FirstOrDefault(); SIPDialogue bridgedDialogue = GetRemoteDialogueForBridge_External(sipDialogue.BridgeId, sipDialogue.Id); if (bridgedDialogue != null) { DialogInfo.DialogItems.Add(new SIPEventDialog(bridgedDialogue.Id.ToString(), state, bridgedDialogue)); } } return(true); } else { DialogInfo.DialogItems.Add(new SIPEventDialog(sipDialogue.Id.ToString(), state, sipDialogue)); return(true); } } } } catch (Exception excp) { MonitorLogEvent_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.Notifier, SIPMonitorEventTypesEnum.Monitor, "Exception AddMonitorEvent. " + excp.Message, null)); logger.Error("Exception SIPDialogEventSubscription AddMonitorEvent. " + excp.Message); throw; } }
public override void GetFullState() { try { DialogInfo.State = SIPEventDialogInfoStateEnum.full; List <SIPDialogue> dialogues = GetDialoguesForOwner_External(SubscriptionDialogue.Owner, 0, MAX_DIALOGUES_FOR_NOTIFY); foreach (SIPDialogue dialogue in dialogues) { DialogInfo.DialogItems.Add(new SIPEventDialog(dialogue.Id.ToString(), "confirmed", dialogue)); } MonitorLogEvent_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.Notifier, SIPMonitorEventTypesEnum.NotifySent, "Full state notification for dialog and " + ResourceURI.ToString() + ".", SubscriptionDialogue.Owner)); } catch (Exception excp) { logger.Error("Exception SIPDialogEventSubscription GetFullState. " + excp.Message); } }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (Action.Expression != null) { targetCommand.AddParameter("Action", Action.Get(context)); } if (ApplicationName.Expression != null) { targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context)); } if ((ComputerName.Expression != null) && (PSRemotingBehavior.Get(context) != RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", ComputerName.Get(context)); } if (ConnectionURI.Expression != null) { targetCommand.AddParameter("ConnectionURI", ConnectionURI.Get(context)); } if (FilePath.Expression != null) { targetCommand.AddParameter("FilePath", FilePath.Get(context)); } if (OptionSet.Expression != null) { targetCommand.AddParameter("OptionSet", OptionSet.Get(context)); } if (Port.Expression != null) { targetCommand.AddParameter("Port", Port.Get(context)); } if (SelectorSet.Expression != null) { targetCommand.AddParameter("SelectorSet", SelectorSet.Get(context)); } if (SessionOption.Expression != null) { targetCommand.AddParameter("SessionOption", SessionOption.Get(context)); } if (UseSSL.Expression != null) { targetCommand.AddParameter("UseSSL", UseSSL.Get(context)); } if (ValueSet.Expression != null) { targetCommand.AddParameter("ValueSet", ValueSet.Get(context)); } if (ResourceURI.Expression != null) { targetCommand.AddParameter("ResourceURI", ResourceURI.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (Authentication.Expression != null) { targetCommand.AddParameter("Authentication", Authentication.Get(context)); } if (CertificateThumbprint.Expression != null) { targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public GetRequest(ResourceURI ResourceURI, Locale Locale, SelectorSet SelectorSet) { this.ResourceURI = ResourceURI; this.Locale = Locale; this.SelectorSet = SelectorSet; }