/// <summary> /// Fetch a role by objectId or name and fill the properties (if found) of the current class instance with what's found /// </summary> /// <param name="pObjectId"> /// GUID of the role to find. /// </param> /// <returns> /// WebCallResults instance. /// </returns> private WebCallResult GetPolicy(string pObjectId) { string strUrl = HomeServer.BaseUrl + "policies/" + pObjectId; //issue the command to the CUPI interface return(HomeServer.FillObjectWithRestGetResults(strUrl, this)); }
/// <summary> /// Fills the current instance with details of a routing rule fetched using the ObjectID or the name. /// </summary> /// <param name="pObjectId"> /// ObjectId to search for - can be empty if name provided. /// </param> /// <param name="pDisplayName"> /// display name to search for. /// </param> /// <returns> /// Instance of the webCallSearchResult class. /// </returns> private WebCallResult GetRoutingRule(string pObjectId, string pDisplayName) { string strObjectId = pObjectId; if (string.IsNullOrEmpty(pObjectId)) { strObjectId = GetObjectIdFromName(pDisplayName); if (string.IsNullOrEmpty(strObjectId)) { return(new WebCallResult { Success = false, ErrorText = "Could not find routing rule by display name:" + pDisplayName }); } } string strUrl = string.Format("{0}routingrules/{1}", HomeServer.BaseUrl, strObjectId); //issue the command to the CUPI interface var res = HomeServer.FillObjectWithRestGetResults(strUrl, this); ClearPendingChanges(); return(res); }
/// <summary> /// Fetch details for a single notification template by ObjectId and populate the local instance's properties with it /// </summary> /// <param name="pObjectId"> /// Unique identifier for notification template to fetch /// </param> /// <returns> /// Instance of the WebCallResults class with details of the fetch results. /// </returns> private WebCallResult GetNotificationTemplate(string pObjectId) { string strUrl = string.Format("{0}notificationtemplates/{1}", HomeServer.BaseUrl, pObjectId); //issue the command to the CUPI interface return(HomeServer.FillObjectWithRestGetResults(strUrl, this)); }
/// <summary> /// Returns the message count for a specific folder type (inbox, sent, deleted) /// </summary> /// <param name="pFolder"> /// Mailbox folder to fetch count for /// </param> /// <param name="pCount"> /// Message count for the folder type /// </param> /// <returns> /// Instance of the WebCallResult class with details of the fetch and results from the server /// </returns> public WebCallResult GetFolderCount(FolderTypes pFolder, out int pCount) { pCount = 0; string strUrl = string.Format("{0}mailbox/folders/{1}?userobjectid={2}", HomeServer.BaseUrl, pFolder.ToString(), UserObjectId); //issue the command to the CUPI interface WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return res; } Folder oFolder= HomeServer.GetObjectFromJson<Folder>(res.ResponseText, "Folder"); if (oFolder==null) { res.ErrorText = "Failure parsing JSON response into MailboxInfo class:" + res.ResponseText; res.Success = false; return res; } pCount = oFolder.MessageCount; return res; }
/// <summary> /// Builds an instance of an AlternateExtension object, filling it with the details of an alternate extension idenitified by the /// UserObjectID and the ObjectId of the alternate extension owned by that user. /// This AlternateExtension has already been created - you can use this to "re fill" an existing alternate extension with possibly /// updated information or if you created an "empty" AlternateExtension object and now want to populate it. /// </summary> /// <param name="pObjectId"> /// The GUID identifying the alternate extension to fetch /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> private WebCallResult GetAlternateExtension(string pObjectId) { string strUrl = string.Format("{0}users/{1}/alternateextensions/{2}", HomeServer.BaseUrl, UserObjectId, pObjectId); //issue the command to the CUPI interface WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } try { JsonConvert.PopulateObject(ConnectionServerRest.StripJsonOfObjectWrapper(res.ResponseText, "AlternateExtension"), this, RestTransportFunctions.JsonSerializerSettings); } catch (Exception ex) { res.ErrorText = "Failure populating class instance form JSON response:" + ex; res.Success = false; } //all the updates above will flip pending changes into the queue - clear that here. this.ClearPendingChanges(); return(res); }
/// <summary> /// Fill the current instance of a PrivateList in with properties fetched from the server. When getting a list of /// lists or searching by alias you get a "short" list of properties - unfortunatley this is short by 4 or 5 properties which /// is not worth a nested "FullList" and "BaseList" approach used with users (which have a much larger delta in properties). Further /// two of those properties missing are the extension and voice name path which are so commonly needed items that it's worth the /// extra fetch to get them here. /// </summary> /// <param name="pObjectId"> /// GUID identifier of the list to be fetched. Either this or the Alias needs to be provided. /// </param> /// <param name="pNumericId"> /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> private WebCallResult GetPrivateList(string pObjectId, int pNumericId) { WebCallResult res; if (string.IsNullOrEmpty(pObjectId)) { //get the list by ID - you can't do this via URL construction so just fetch the entire list of private lists and find the one //with the ID you want and copy it into the current instance List <PrivateList> oLists; res = GetPrivateLists(HomeServer, _userOwnerObjectId, out oLists); if (res.Success == false) { return(res); } foreach (PrivateList oList in oLists) { if (oList.NumericId == pNumericId) { //cheesy object copy this.DisplayName = oList.DisplayName; this.NumericId = oList.NumericId; this.ObjectId = oList.ObjectId; } } } else { //go fetch the private list by ObjectId string strUrl = string.Format("{0}users/{1}/privatelists/{2}", HomeServer.BaseUrl, _userOwnerObjectId, pObjectId); //issue the command to the CUPI interface res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } try { JsonConvert.PopulateObject(res.ResponseText, this, RestTransportFunctions.JsonSerializerSettings); } catch (Exception ex) { res.ErrorText = "Failure populating class instance form JSON response:" + ex; res.Success = false; } } //all the updates above will flip pending changes into the queue - clear that here. this.ClearPendingChanges(); if (string.IsNullOrEmpty(this.ObjectId)) { res.Success = false; } return(res); }
/// <summary> /// Helper function to fill in the Location instance with data from a Location by its objectID string or their hostaddress string. /// </summary> /// <param name="pObjectId"></param> /// <param name="pDisplayName"></param> /// <returns></returns> private WebCallResult GetLocation(string pObjectId, string pDisplayName = "") { string strObjectId = pObjectId; if (string.IsNullOrEmpty(pObjectId)) { int iCount; strObjectId = GetObjectIdFromName(pDisplayName, out iCount); if (string.IsNullOrEmpty(strObjectId)) { WebCallResult oRes = new WebCallResult(); oRes.Success = false; if (iCount > 1) { oRes.ErrorText = "More than one location found for host address=" + pDisplayName; } else { oRes.ErrorText = "No location found for host address=" + pDisplayName; } return(oRes); } } string strUrl = string.Format("{0}locations/connectionlocations/{1}", HomeServer.BaseUrl, strObjectId); //issue the command to the CUPI interface return(HomeServer.FillObjectWithRestGetResults(strUrl, this)); }
/// <summary> /// Fills the current instance with details of a call handler template fetched using the ObjectID or the name. /// </summary> /// <param name="pObjectId"> /// ObjectId to search for - can be empty if name provided. /// </param> /// <param name="pDisplayName"> /// display name to search for. /// </param> /// <returns> /// Instance of the webCallSearchResult class. /// </returns> private WebCallResult GetCallHandlerTemplate(string pObjectId, string pDisplayName) { string strObjectId = pObjectId; if (string.IsNullOrEmpty(pObjectId)) { int iCount; strObjectId = GetObjectIdFromName(pDisplayName, out iCount); if (string.IsNullOrEmpty(strObjectId)) { WebCallResult oRes = new WebCallResult(); oRes.Success = false; if (iCount > 1) { oRes.ErrorText = "More than one template found for display name=" + pDisplayName; } else { oRes.ErrorText = "No template found for display name=" + pDisplayName; } return(oRes); } } string strUrl = string.Format("{0}callhandlertemplates/{1}", HomeServer.BaseUrl, strObjectId); var res = HomeServer.FillObjectWithRestGetResults(strUrl, this); ClearPendingChanges(); return(res); }
private void btnCreateServer_Click(object sender, EventArgs e) { server = new HomeServer(txtAddress.Text, port); if (server.DataError) { DialogResult dr = MessageBox.Show("Error! Check your IP Address/Port.", "Data Error!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (dr == DialogResult.Retry) { btnCreateServer_Click(sender, e); return; } else { server = null; return; } } btnCreateServer.Enabled = false; txtAddress.Enabled = false; txtPort.Enabled = false; cmbMessegesSearch.Enabled = true; cmbUserSearch.Enabled = true; server.activeUser += UpdateActiveUser; }
/// <summary> /// Fills the current instance of InterviewHandlerQuestion in with properties fetched from the server. /// </summary> /// <param name="pInterviewHandlerObjectId"> /// Unique GUID of the interview handler this question is associatded with /// </param> /// <param name="pQuestionNumber"> /// 1-20 /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> private WebCallResult GetInterviewQuestion(string pInterviewHandlerObjectId, int pQuestionNumber) { if (string.IsNullOrEmpty(pInterviewHandlerObjectId)) { return(new WebCallResult { Success = false, ErrorText = "No value for ObjectId or display name passed to GetInterviewHandler." }); } string strUrl = string.Format("{0}handlers/interviewhandlers/{1}/interviewquestions/{2}", HomeServer.BaseUrl, pInterviewHandlerObjectId, pQuestionNumber); //issue the command to the CUPI interface WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } try { JsonConvert.PopulateObject(ConnectionServerRest.StripJsonOfObjectWrapper(res.ResponseText, "InterviewQuestion"), this, RestTransportFunctions.JsonSerializerSettings); } catch (Exception ex) { res.ErrorText = "Failure populating class instance form JSON response:" + ex; res.Success = false; } return(res); }
/// <summary> /// Fetch a COSes ObjectId by it's name - fetching a COS needs to happen via ObjectId so we get all the properties - searching by name returns only the display /// name and ObjectId but not all the rest of the properties. /// </summary> /// <param name="pCosName"> /// Display name of the COS to search for /// </param> /// <returns> /// ObjectId of the COS with the name if found, or blank string if not. /// </returns> private string GetObjectIdByCosName(string pCosName) { string strUrl = string.Format("{0}coses/?query=(DisplayName is {1})", HomeServer.BaseUrl, pCosName.UriSafe()); //issue the command to the CUPI interface WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(""); } List <ClassOfService> oCoses = HomeServer.GetObjectsFromJson <ClassOfService>(res.ResponseText, "Cos"); if (oCoses == null) { return(""); } foreach (var oCos in oCoses) { if (oCos.DisplayName.Equals(pCosName, StringComparison.InvariantCultureIgnoreCase)) { return(oCos.ObjectId); } } return(""); }
/// <summary> /// Lazy fetch for restriction table associated with COS - this needs to be implemented as a method instead of a /// property so that if a grid is bound to the generic list of objects it doesn't "lazy fetch" it for display purposes resulting /// in needless data fetching /// </summary> /// <param name="pForceRefetchOfData"> /// Pass as true to force the restriction table to be refetched even if its already be populated earlier. /// </param> /// <returns> /// Instance of the RestrictionTable class /// </returns> public RestrictionTable OutcallRestrictionTable(bool pForceRefetchOfData = false) { if (pForceRefetchOfData) { _restrictionTableOutcall = null; } if (string.IsNullOrEmpty(this.OutcallRestrictionObjectId)) { return(null); } if (_restrictionTableOutcall == null) { try { _restrictionTableOutcall = new RestrictionTable(HomeServer, this.OutcallRestrictionObjectId); } catch (Exception ex) { HomeServer.RaiseErrorEvent("Failed fetching OutcallRestrictionTable:" + ex); _restrictionTableOutcall = null; } } return(_restrictionTableOutcall); }
/// <summary> /// Fetch the ObjectId of a template by it's name. Empty string returned if not match is found. /// </summary> /// <param name="pName"> /// Name of the template to find /// </param> /// <param name="pCount"> /// Total number of templates found /// </param> /// <returns> /// ObjectId of template if found or empty string if not. /// </returns> private string GetObjectIdFromName(string pName, out int pCount) { pCount = 0; string strUrl = string.Format("{0}callhandlertemplates/?query=(DisplayName is {1})", HomeServer.BaseUrl, pName.UriSafe()); //issue the command to the CUPI interface WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false || res.TotalObjectCount != 1) { pCount = res.TotalObjectCount; return(""); } List <CallHandlerTemplate> oTemplates = HomeServer.GetObjectsFromJson <CallHandlerTemplate>(res.ResponseText); foreach (var oTemplate in oTemplates) { if (oTemplate.DisplayName.Equals(pName, StringComparison.InvariantCultureIgnoreCase)) { return(oTemplate.ObjectId); } } return(""); }
/// <summary> /// Fetches a greetingstreamfile option object filled with all the properties for a specific entry identified with the ObjectId /// of the call handler that owns it and the name of the greeting rule (Standard, Alternate, OffHours...) /// </summary> /// <param name="pCallHandlerObjectId"> /// The objectID of the call handler that owns the greeting stream to be fetched. /// </param> /// <param name="pGreetingType"> /// The name of the greeting option to fetch (Standard, Alternate, OffHours...) /// </param> /// <param name="pLanguageCode"> /// Language of the stream file to fetch /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public WebCallResult GetGreetingStreamFile(string pCallHandlerObjectId, GreetingTypes pGreetingType, int pLanguageCode) { string strUrl = string.Format("{0}handlers/callhandlers/{1}/greetings/{2}/greetingstreamfiles/{3}", HomeServer.BaseUrl, pCallHandlerObjectId, pGreetingType.Description(), pLanguageCode); //issue the command to the CUPI interface return(HomeServer.FillObjectWithRestGetResults(strUrl, this)); }
/// <summary> /// Fills the current instance of RestrictionTable in with properties fetched from the server. If both the display name and ObjectId /// parameters are provided, the ObjectId is used for the search. /// </summary> /// <param name="pObjectId"> /// Unique GUID of the RT to fetch - can be blank if the display name is passed in. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> private WebCallResult GetRestrictionTablePattern(string pObjectId) { //when fetching a RT use the query construct in both cases so the XML parsing is identical string strUrl = string.Format("{0}restrictiontables/{1}/restrictionpatterns/{2}", HomeServer.BaseUrl, RestrictionTableObjectId, pObjectId); //issue the command to the CUPI interface return(HomeServer.FillObjectWithRestGetResults(strUrl, this)); }
/// <summary> /// Fetches a greeting stream off a directory handler /// </summary> /// <param name="pDirectoryHandlerObjectId"> /// The objectID of the directory handler that owns the greeting to be fetched. /// </param> /// <param name="pLanguageCode"> /// Language of the stream file to fetch /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public WebCallResult GetGreetingStreamFile(string pDirectoryHandlerObjectId, int pLanguageCode) { string strUrl = string.Format("{0}handlers/directoryhandlers/{1}/directoryhandlerstreamfiles/{2}", HomeServer.BaseUrl, pDirectoryHandlerObjectId, pLanguageCode); //issue the command to the CUPI interface return(HomeServer.FillObjectWithRestGetResults(strUrl, this)); }
/// <summary> /// Fetches a greeting stream off a post greeting recording /// </summary> /// <param name="pPostRecordingGreetingObjectId"> /// The objectID of the post greeting recording that owns the greeting to be fetched. /// </param> /// <param name="pLanguageCode"> /// Language of the stream file to fetch /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public WebCallResult GetGreetingStreamFile(string pPostRecordingGreetingObjectId, int pLanguageCode) { string strUrl = string.Format("{0}postgreetingrecordings/{1}/postgreetingrecordingstreamfiles/{2}", HomeServer.BaseUrl, pPostRecordingGreetingObjectId, pLanguageCode); //issue the command to the CUPI interface return(HomeServer.FillObjectWithRestGetResults(strUrl, this)); }
/// <summary> /// Fills the current instance of Mwi in with properties fetched from the server. /// </summary> /// <param name="pObjectId"> /// GUID that identifies the user that owns the device /// </param> /// <param name="pUserObjectId"> /// GUID that identifies the device itself. /// </param> /// <returns></returns> private WebCallResult GetMwi(string pUserObjectId, string pObjectId) { string strUrl = string.Format("{0}users/{1}/mwis/{2}", HomeServer.BaseUrl, pUserObjectId, pObjectId); //issue the command to the CUPI interface var res = HomeServer.FillObjectWithRestGetResults(strUrl, this); ClearPendingChanges(); return(res); }
/// <summary> /// Fetches a transfer option object filled with all the properties for a specific entry identified with the ObjectId /// of the call handler that owns it and the name of the transfer rule (Standard, Alternate, Off Hours) /// </summary> /// <param name="pTransferOptionType"> /// The name of the transfer option to fetch (Standard, Alternate, Off Hours) /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public WebCallResult GetTransferOption(TransferOptionTypes pTransferOptionType) { string strUrl = string.Format("{0}handlers/callhandlers/{1}/transferoptions/{2}", HomeServer.BaseUrl, CallHandlerObjectId, pTransferOptionType.Description()); //issue the command to the CUPI interface var res = HomeServer.FillObjectWithRestGetResults(strUrl, this); ClearPendingChanges(); return(res); }
/// <summary> /// Fills the current instance of Credential in with properties fetched from the server. /// </summary> /// <param name="pUserObjectId"> /// GUID that identifies the user that owns the credential itself. /// </param> /// <param name="pCredentialType"> /// Credential type to fetch (PIN or Password) /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> private WebCallResult GetCredential(string pUserObjectId, CredentialType pCredentialType) { string strUrl; if (pCredentialType == CredentialType.Password) { strUrl = string.Format("{0}users/{1}/credential/password", HomeServer.BaseUrl, pUserObjectId); } else { strUrl = string.Format("{0}users/{1}/credential/pin", HomeServer.BaseUrl, pUserObjectId); } return(HomeServer.FillObjectWithRestGetResults(strUrl, this)); }
/// <summary> /// Fetch details for a single port by ObjectId and populate the local instance's properties with it /// </summary> /// <param name="pObjectId"> /// Unique identifier for port to fetch /// </param> /// <returns> /// Instance of the WebCallResults class with details of the fetch results. /// </returns> private WebCallResult GetPort(string pObjectId) { if (string.IsNullOrEmpty(pObjectId)) { return(new WebCallResult { ErrorText = "Empty ObjectId encountered in GetPort" }); } string strUrl = string.Format("{0}ports/{1}", HomeServer.BaseUrl, pObjectId); //issue the command to the CUPI interface var res = HomeServer.FillObjectWithRestGetResults(strUrl, this); ClearPendingChanges(); return(res); }
/// <summary> /// Fills the current instance of RoutineRuleCondition in with properties fetched from the server. If both the display name and ObjectId /// parameters are provided, the ObjectId is used for the search. /// </summary> /// <param name="pObjectId"> /// Unique GUID of the routing rule condition to fetch - can be blank if the display name is passed in. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> private WebCallResult GetRoutingRuleCondition(string pObjectId) { string strObjectId = pObjectId; if (string.IsNullOrEmpty(pObjectId)) { return(new WebCallResult { Success = false, ErrorText = "Empty objectId passed to GetRoutingRuleCondition" }); } string strUrl = string.Format("{0}routingrules/{1}/routingruleconditions/{2}", HomeServer.BaseUrl, RoutingRuleObjectId, strObjectId); return(HomeServer.FillObjectWithRestGetResults(strUrl, this)); }
public List <PrivateListMember> PrivateListMembers(bool pForceRefetchOfData = false) { if (pForceRefetchOfData) { _privateListMembers = null; } if (_privateListMembers == null) { WebCallResult res = PrivateListMember.GetPrivateListMembers(HomeServer, this.ObjectId, _userOwnerObjectId, out _privateListMembers); if (res.Success == false) { HomeServer.RaiseErrorEvent("Error getting private list members:" + res); } } return(_privateListMembers); }
/// <summary> /// Fills current instance of class with details of post greeting recording for objectId passed in if found. /// </summary> /// <param name="pObjectId"> /// Unique Id for post greeting recording to load /// </param> /// <param name="pDisplayName"> /// Optional name of post greeting recording to find /// </param> /// <returns> /// Instance of WebCallResult class /// </returns> private WebCallResult GetPostGreetingRecording(string pObjectId, string pDisplayName) { WebCallResult res = new WebCallResult(); res.Success = false; string strObjectId = pObjectId; if (string.IsNullOrEmpty(pObjectId)) { strObjectId = GetObjectIdFromName(pDisplayName); if (string.IsNullOrEmpty(strObjectId)) { res.ErrorText = "Could not find post greeting recording by name=" + pDisplayName; return(res); } } string strUrl = HomeServer.BaseUrl + "postgreetingrecordings/" + strObjectId; //issue the command to the CUPI interface res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } try { JsonConvert.PopulateObject(res.ResponseText, this, RestTransportFunctions.JsonSerializerSettings); } catch (Exception ex) { res.ErrorText = "Failure populating class instance form JSON response:" + ex; res.Success = false; } return(res); }
/// <summary> /// Fills the current instance of GetSchedule in with properties fetched from the server. If both the display name and ObjectId /// parameters are provided, the ObjectId is used for the search. /// </summary> /// <param name="pObjectId"> /// Unique GUID of the schedule to fetch - can be blank if the display name is passed in. /// </param> /// <param name="pDisplayName"> /// Display name of schedule set to fetch /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> private WebCallResult GetScheduleSet(string pObjectId, string pDisplayName) { string strObjectId = pObjectId; if (string.IsNullOrEmpty(pObjectId)) { strObjectId = GetObjectIdFromName(pDisplayName); if (string.IsNullOrEmpty(strObjectId)) { return new WebCallResult { Success = false, ErrorText = "Could not find schedule set by DisplayName=" + pDisplayName }; } } string strUrl = string.Format("{0}schedulesets/{1}", HomeServer.BaseUrl, strObjectId); return HomeServer.FillObjectWithRestGetResults(strUrl,this); }
/// <summary> /// Fills the current instance of Schedule in with properties fetched from the server. If both the display name and ObjectId /// parameters are provided, the ObjectId is used for the search. /// </summary> /// <param name="pObjectId"> /// Unique GUID of the schedule to fetch - can be blank if the display name is passed in. /// </param> /// <param name="pDisplayName"> /// Display name to search on a schedule by. Can be blank if the ObjectId parameter is provided. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> private WebCallResult GetSchedule(string pObjectId, string pDisplayName = "") { string strObjectId = pObjectId; if (string.IsNullOrEmpty(pObjectId)) { strObjectId = GetObjectIdFromName(pDisplayName); if (string.IsNullOrEmpty(strObjectId)) { return(new WebCallResult { Success = false, ErrorText = "No schedule found by name=" + pDisplayName }); } } string strUrl = string.Format("{0}schedules/{1}", HomeServer.BaseUrl, strObjectId); return(HomeServer.FillObjectWithRestGetResults(strUrl, this)); }
/// <summary> /// Fetch details for a single port group by ObjectId/name and populate the local instance's properties with it /// </summary> /// <param name="pObjectId"> /// Unique identifier for port group to fetch /// </param> /// <param name="pDisplayName"> /// Optional display name to search for a port group by /// </param> /// <returns> /// Instance of the WebCallResults class with details of the fetch results. /// </returns> private WebCallResult GetPortGroup(string pObjectId, string pDisplayName) { string strObjectId; //when fetching a phone system prefer the ObjectId if provided if (!string.IsNullOrEmpty(pObjectId)) { strObjectId = pObjectId; } else if (!string.IsNullOrEmpty(pDisplayName)) { //fetch the ObjectId for the name if possible strObjectId = GetObjectIdByPortGroupName(pDisplayName); if (string.IsNullOrEmpty(strObjectId)) { return(new WebCallResult { Success = false, ErrorText = "No port group found for display name passed into GetPortGroup:" + pDisplayName }); } } else { return(new WebCallResult { Success = false, ErrorText = "No value for ObjectId or display name passed to GetPortGroup." }); } string strUrl = string.Format("{0}portgroups/{1}", HomeServer.BaseUrl, strObjectId); //issue the command to the CUPI interface var res = HomeServer.FillObjectWithRestGetResults(strUrl, this); ClearPendingChanges(); return(res); }
/// <summary> /// Helper function to fill in the user instance with data from a user by their objectID string or their alias string. /// </summary> /// <param name="pObjectId"></param> /// <param name="pAlias"></param> /// <returns></returns> private WebCallResult GetGlobalUser(string pObjectId, string pAlias = "") { //when fetching a base user use the query construct (which returns less data and is quicker) than the users/(objectid) format for //UserFull object. string strObjectId = pObjectId; if (string.IsNullOrEmpty(pObjectId)) { strObjectId = GetObjectIdFromAlias(pAlias); if (string.IsNullOrEmpty(strObjectId)) { return(new WebCallResult { Success = false, ErrorText = "No global user found with alias = " + pAlias }); } } string strUrl = string.Format("{0}globalusers/{1}", HomeServer.BaseUrl, strObjectId); //issue the command to the CUPI interface return(HomeServer.FillObjectWithRestGetResults(strUrl, this)); }
/// <summary> /// Fetch an external service ObjectId by it's name - /// </summary> /// <param name="pServiceName"> /// Display name of the service to search for /// </param> /// <returns> /// ObjectId of the external service with the name if found, or blank string if not. /// </returns> private string GetObjectIdByServiceName(string pServiceName) { string strUrl = string.Format("{0}externalservices/?query=(DisplayName is {1})", HomeServer.BaseUrl, pServiceName.UriSafe()); WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false || res.TotalObjectCount == 0) { return(""); } List <ExternalService> oServices = HomeServer.GetObjectsFromJson <ExternalService>(res.ResponseText); foreach (var oService in oServices) { if (oService.DisplayName.Equals(pServiceName, StringComparison.InvariantCultureIgnoreCase)) { return(oService.ObjectId); } } return(""); }
/// <summary> /// Gets the list of all installed languages and resturns them as a generic list of InstalledLangauge objects. /// </summary> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> private WebCallResult GetInstalledLanguages() { string strUrl = HomeServer.BaseUrl + "installedlanguages"; //issue the command to the CUPI interface WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } //if the call was successful the JSON dictionary should always be populated with something, but just in case do a check here. //if this is empty that means an error in this case - should always be at least one template if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0) { InstalledLanguages = new List <InstalledLanguage>(); res.Success = false; return(res); } InstalledLanguages = HomeServer.GetObjectsFromJson <InstalledLanguage>(res.ResponseText); if (InstalledLanguages == null || InstalledLanguages.Count == 0) { res.Success = false; res.ErrorText = "Failed to fetch installed languages on server"; return(res); } foreach (var oLanguage in InstalledLanguages) { oLanguage.HomeServer = HomeServer; } return(res); }