Exemple #1
0
        /// <summary>
        /// Create a new routing rule in the Connection directory
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server being edited
        /// </param>
        /// <param name="pDisplayName">
        /// Display Name of the new routing rule - must be unique.
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a property name and a new value for that property to apply to the rule being created.
        /// This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  Can be passed as null here.
        /// </param>
        /// <param name="pRoutingRule">
        /// Newly created routing rule instance is passed back in this out parameter
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class.
        /// </returns>
        public static WebCallResult AddRoutingRule(ConnectionServerRest pConnectionServer,
                                                   string pDisplayName,
                                                   ConnectionPropertyList pPropList,
                                                   out RoutingRule pRoutingRule)
        {
            pRoutingRule = null;

            WebCallResult res = AddRoutingRule(pConnectionServer, pDisplayName, pPropList);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                //fetch the instance of the rule just created.
                try
                {
                    pRoutingRule = new RoutingRule(pConnectionServer, res.ReturnedObjectId);
                }
                catch (Exception)
                {
                    res.Success   = false;
                    res.ErrorText = "Could not find newly created routing rule by objectId:" + res;
                }
            }

            return(res);
        }
        /// <summary>
        /// Create a new call handler template in the Connection directory
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server being edited
        /// </param>
        /// <param name="pDisplayName">
        /// Display Name of the new call handler template - must be unique.
        /// </param>
        /// <param name="pRecipientUserId">
        /// If a user is a recipient, pass the objectId in here - must pass either recipient or distribution list
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a property name and a new value for that property to apply to the template being created.
        /// This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  Can be passed as null here.
        /// </param>
        /// <param name="pCallHandlerTemplate">
        /// Newly created call handler template instance is passed back in this out parameter
        /// </param>
        /// <param name="pMediaSwitchObjectId">
        /// Phone system the interviewer will be associated with.
        /// </param>
        /// <param name="pRecipientDistributionListId">
        /// If a list is a recipient, pass the objectId in here - must pass either recipient or distribution list
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class.
        /// </returns>
        public static WebCallResult AddCallHandlerTemplate(ConnectionServerRest pConnectionServer,
                                                           string pDisplayName,
                                                           string pMediaSwitchObjectId,
                                                           string pRecipientDistributionListId,
                                                           string pRecipientUserId,
                                                           ConnectionPropertyList pPropList,
                                                           out CallHandlerTemplate pCallHandlerTemplate)
        {
            pCallHandlerTemplate = null;

            WebCallResult res = AddCallHandlerTemplate(pConnectionServer, pDisplayName, pMediaSwitchObjectId, pRecipientDistributionListId,
                                                       pRecipientUserId, pPropList);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                //fetc the instance of the template just created.
                try
                {
                    pCallHandlerTemplate = new CallHandlerTemplate(pConnectionServer, res.ReturnedObjectId);
                }
                catch (Exception)
                {
                    res.Success   = false;
                    res.ErrorText = "Could not find newly created handler template by objectId:" + res;
                }
            }

            return(res);
        }
Exemple #3
0
        /// <summary>
        /// Add a new MWI device for a user
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server the user is homed on
        /// </param>
        /// <param name="pUserObjectId">
        /// Unique identifier for user to add new MWI to
        /// </param>
        /// <param name="pDeviceDisplayName">
        /// Display name for MWI device
        /// </param>
        /// <param name="pMediaSwitchObjectId">
        /// Phone system the MWI will be associated with
        /// </param>
        /// <param name="pMwiExtension">
        /// Extension number for the new MWI device to activate
        /// </param>
        /// <param name="pActivated">
        /// Is the MWI active or not - you can add MWI devices that are not active that can be turned on later.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class with details of the request/response from the server.
        /// </returns>
        public static WebCallResult AddMwi(ConnectionServerRest pConnectionServer,
                                           string pUserObjectId,
                                           string pDeviceDisplayName,
                                           string pMediaSwitchObjectId,
                                           string pMwiExtension,
                                           bool pActivated)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddMwi";
                return(res);
            }

            //make sure that something is passed in for the 2 required params - the extension is optional.
            if (String.IsNullOrEmpty(pDeviceDisplayName) |
                (String.IsNullOrEmpty(pUserObjectId)) |
                (String.IsNullOrEmpty(pMediaSwitchObjectId)) |
                (String.IsNullOrEmpty(pMwiExtension)))
            {
                res.ErrorText = "Empty value passed for one or more required parameters in AddMwi";
                return(res);
            }

            ConnectionPropertyList oProps = new ConnectionPropertyList();

            oProps.Add("DisplayName", pDeviceDisplayName);
            oProps.Add("MwiExtension", pMwiExtension);
            oProps.Add("MediaSwitchObjectId", pMediaSwitchObjectId);
            oProps.Add("Active", pActivated);

            string strBody = "<Mwi>";

            //tack on the property value pair with appropriate tags
            foreach (var oProp in oProps)
            {
                strBody += string.Format("<{0}>{1}</{0}>", oProp.PropertyName, oProp.PropertyValue);
            }

            strBody += "</Mwi>";

            res = pConnectionServer.GetCupiResponse(string.Format("{0}users/{1}/mwis", pConnectionServer.BaseUrl, pUserObjectId),
                                                    MethodType.POST, strBody, false);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                string strPrefix = @"/vmrest/users/" + pUserObjectId + "/mwis/";
                if (res.ResponseText.Contains(strPrefix))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(strPrefix, "").Trim();
                }
            }

            return(res);
        }
Exemple #4
0
        /// <summary>
        /// Allows for the creation of a new private list for the currently logged in user.  The display name and number ID must be provided.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the list is being added.
        /// </param>
        /// <param name="pUserOwnerObjectId">
        /// User that will own the newly created private list
        /// </param>
        /// <param name="pDisplayName">
        /// Display name to be used for the new list.
        /// </param>
        /// <param name="pNumericId">
        /// Private list Id from 1 to 99 (depending on settings - by default private lists are limited to 20, however this routine does not check
        /// for that). Pass the default of 0 and the list will be created in the next available slot - this is the best method.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult AddPrivateList(ConnectionServerRest pConnectionServer,
                                                   string pUserOwnerObjectId,
                                                   string pDisplayName,
                                                   int pNumericId = 0)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddPrivateList";
                return(res);
            }

            //make sure that something is passed in for the 2 required params - the extension is optional.
            if (string.IsNullOrEmpty(pDisplayName))
            {
                res.ErrorText = "Empty value passed for DisplayName in AddPrivateList on ConnectionServer.cs";
                return(res);
            }

            if (pNumericId < 1 | pNumericId > 99)
            {
                res.ErrorText = "Invalid list Id passed to AddPrivateList on ConnectionServer.cs:" + pNumericId.ToString();
                return(res);
            }

            ConnectionPropertyList oPropList = new ConnectionPropertyList();

            //cheat here a bit and simply add the alias and display name values to the proplist where it can be tossed into the body later.
            oPropList.Add("DisplayName", pDisplayName);
            oPropList.Add("NumericId", pNumericId);

            string strBody = "<PrivateList>";

            foreach (var oPair in oPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</PrivateList>";

            res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + string.Format("users/{0}/privatelists",
                                                                                              pUserOwnerObjectId), MethodType.POST, strBody, false);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                string strTemp = string.Format(@"/vmrest/users/{0}/privatelists/", pUserOwnerObjectId);
                if (res.ResponseText.Contains(strTemp))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(strTemp, "").Trim();
                }
            }

            return(res);
        }
Exemple #5
0
        /// <summary>
        /// Import an LDAP user as a local Unity Connection user.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server to import the user on.
        /// </param>
        /// <param name="pTemplateAlias">
        /// Alias of the user template to use when importing the user, required.
        /// </param>
        /// <param name="pPkid">
        /// Unique ID from the Call Manager database for the LDAP synchronized user.
        /// </param>
        /// <param name="pAlias">
        /// Alias of the user in LDAP to import
        /// </param>
        /// <param name="pFirstName">
        /// First name of the user to import
        /// </param>
        /// <param name="pLastName">
        /// Last name of the user to import
        /// </param>
        /// <param name="pExtension">
        /// Extension number to assign the user in Connection's diretory
        /// </param>
        /// <param name="pPropList">
        /// Name value pair list of optional values to include in the import.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class with details of the call and results from the server.
        /// </returns>
        public static WebCallResult ImportLdapUser(ConnectionServerRest pConnectionServer, string pTemplateAlias,
                                                   string pPkid, string pAlias, string pFirstName, string pLastName,
                                                   string pExtension, ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to ImportLdapUser";
                return(res);
            }

            //make sure that something is passed in for the 3 required params
            if (String.IsNullOrEmpty(pTemplateAlias) || string.IsNullOrEmpty(pPkid) || string.IsNullOrEmpty(pExtension))
            {
                res.ErrorText = "Empty value passed for one or more required parameters in ImportLdapUser on ConnectionServer.cs";
                return(res);
            }

            //create an empty property list if it's passed as null since we use it below
            if (pPropList == null)
            {
                pPropList = new ConnectionPropertyList();
            }

            //cheat here a bit and simply add the alias and extension values to the proplist where it can be tossed into the body later.
            pPropList.Add("pkid", pPkid);
            pPropList.Add("alias", pAlias);
            pPropList.Add("firstName", pFirstName);
            pPropList.Add("lastName", pLastName);
            pPropList.Add("dtmfAccessId", pExtension);

            //use JSON style body payload
            string strBody = "{";

            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("\"{0}\":\"{1}\",", oPair.PropertyName, oPair.PropertyValue);
            }
            strBody = strBody.TrimEnd(',') + "}";

            res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "import/users/ldap?templateAlias=" + pTemplateAlias,
                                                    MethodType.POST, strBody);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                if (!string.IsNullOrEmpty(res.ResponseText) && res.ResponseText.Contains(@"/vmrest/users/"))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/users/", "").Trim();
                }
            }

            return(res);
        }
Exemple #6
0
        /// <summary>
        /// Generic constructor for Json parsing
        /// </summary>
        public TransferOption()
        {
            //make an instanced of the changed prop list to keep track of updated properties on this object
            _changedPropList = new ConnectionPropertyList();

            //little bit of a hack - CUPI does not return TimeExpires values for null TimeExpires fields so we can only assume that it's abscence
            //means the greeting is active
            TimeExpires = DateTime.Parse("2200/1/1");
            ClearPendingChanges();
        }
Exemple #7
0
        /// <summary>
        /// Allows for the creation of a new COS on the Connection server directory.  The display name must be provided .
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the COS is being added.
        /// </param>
        /// <param name="pDisplayName">
        /// Display name to be used for the new list.
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a property name and a new value for that property to apply to the object being created.
        /// This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  Can be passed as null here.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult AddClassOfService(ConnectionServerRest pConnectionServer,
                                                      string pDisplayName,
                                                      ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddClassOfService";
                return(res);
            }

            //make sure that something is passed in for the 2 required params - the extension is optional.
            if (string.IsNullOrEmpty(pDisplayName))
            {
                res.ErrorText = "Empty value passed for display name in AddClassOfService";
                return(res);
            }

            //create an empty property list if it's passed as null since we use it below
            if (pPropList == null)
            {
                pPropList = new ConnectionPropertyList();
            }

            //cheat here a bit and simply add the alias and display name values to the proplist where it can be tossed into the body later.
            pPropList.Add("DisplayName", pDisplayName);

            string strBody = "<Cos>";

            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</Cos>";

            res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "coses", MethodType.POST, strBody, false);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                if (res.ResponseText.Contains(@"/vmrest/coses/"))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/coses/", "").Trim();
                }
            }

            return(res);
        }
Exemple #8
0
        /// <summary>
        /// Create a new routing rule in the Connection directory
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server being edited
        /// </param>
        /// <param name="pDisplayName">
        /// Display Name of the new routing rule - must be unique.
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a property name and a new value for that property to apply to the rule being created.
        /// This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  Can be passed as null here.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class.
        /// </returns>
        public static WebCallResult AddRoutingRule(ConnectionServerRest pConnectionServer, string pDisplayName, ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddRoutingRule";
                return(res);
            }

            if (String.IsNullOrEmpty(pDisplayName))
            {
                res.ErrorText = "Empty value passed for display name in AddRoutingRule";
                return(res);
            }

            //create an empty property list if it's passed as null since we use it below
            if (pPropList == null)
            {
                pPropList = new ConnectionPropertyList();
            }

            pPropList.Add("DisplayName", pDisplayName);

            string strBody = "<RoutingRule>";

            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</RoutingRule>";

            res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "routingrules",
                                                    MethodType.POST, strBody, false);

            //fetch the objectId of the newly created object off the return
            if (res.Success)
            {
                if (res.ResponseText.Contains(@"/vmrest/routingrules/"))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/routingrules/", "").Trim();
                }
            }

            return(res);
        }
Exemple #9
0
        /// <summary>
        /// Import an LDAP user as a local Unity Connection user.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server to import the user on.
        /// </param>
        /// <param name="pTemplateAlias">
        /// Alias of the user template to use when importing the user, required.
        /// </param>
        /// <param name="pPkid">
        /// Unique ID from the Call Manager database for the LDAP synchronized user.
        /// </param>
        /// <param name="pAlias">
        /// Alias of the user in LDAP to import
        /// </param>
        /// <param name="pFirstName">
        /// First name of the user to import
        /// </param>
        /// <param name="pLastName">
        /// Last name of the user to import
        /// </param>
        /// <param name="pExtension">
        /// Extension number to assign the user in Connection's diretory
        /// </param>
        /// <param name="pPropList">
        /// Name value pair list of optional values to include in the import.
        /// </param>
        /// <param name="pUser">
        /// Instance of the UserFull class is passed back filled in with the details of the newly import user if the
        /// import succeeds.  Null if the import fails.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class with details of the call and results from the server.
        /// </returns>
        public static WebCallResult ImportLdapUser(ConnectionServerRest pConnectionServer, string pTemplateAlias,
                                                   string pPkid, string pAlias, string pFirstName, string pLastName,
                                                   string pExtension, ConnectionPropertyList pPropList, out UserFull pUser)
        {
            pUser = null;

            var res = ImportLdapUser(pConnectionServer, pTemplateAlias, pPkid, pAlias, pFirstName, pLastName,
                                     pExtension, pPropList);

            if (res.Success)
            {
                return(UserFull.GetUser(pConnectionServer, res.ReturnedObjectId, out pUser));
            }
            return(res);
        }
Exemple #10
0
        /// <summary>
        /// Allows for the creation of a new COS on the Connection server directory.  The name must be provided
        /// </summary>
        /// <remarks>
        /// This is an alternateive AddClassOfService that passes back a ClassOfService object with the newly created list filled
        /// out in it if the add goes through.
        /// </remarks>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the list is being added.
        /// </param>
        /// <param name="pDisplayName">
        /// Display name to be used for the new cos.
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a list's property name and a new value for that property to apply to the list being created.
        /// This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  Can be passed as null here.
        /// </param>
        /// <param name="oClassOfService">
        /// Out parameter that instance of Class of Service class is returned on if a match is found - null if no match is found.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult AddClassOfService(ConnectionServerRest pConnectionServer,
                                                      string pDisplayName,
                                                      ConnectionPropertyList pPropList,
                                                      out ClassOfService oClassOfService)
        {
            oClassOfService = null;

            WebCallResult res = AddClassOfService(pConnectionServer, pDisplayName, pPropList);

            //if the create goes through, fetch the list as an object and return it all filled in.
            if (res.Success)
            {
                res = GetClassOfService(out oClassOfService, pConnectionServer, res.ReturnedObjectId);
            }

            return(res);
        }
Exemple #11
0
        /// <summary>
        /// Interview handler questions have only 3 properties that can be updated besides the recorded media which is handled via
        /// specific WAV or resourceId udpate methods.  If the question is active, the maximum length of a response the caller is
        /// allowed for the question and some text describing the question.  All those are presented as parameters to the update
        /// method here.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server the interviewer in question is homed on.
        /// </param>
        /// <param name="pInterviewHandlerObjectId">
        /// Unique identifier for the interview handler this question is associated with.
        /// </param>
        /// <param name="pInterviewQuestionNumber">
        /// questions are numbers 1 through 20.
        /// </param>
        /// <param name="pActive">
        /// True is active, false is disabled
        /// </param>
        /// <param name="pMaxResponseLength">
        /// Maximum length of recorded response for question (in seconds)
        /// </param>
        /// <param name="pStreamText">
        /// Text description of question - shown on web admin only.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class with details of the request and response from the server.
        /// </returns>
        public static WebCallResult UpdateInterviewHandlerQuestion(ConnectionServerRest pConnectionServer,
                                                                   string pInterviewHandlerObjectId,
                                                                   int pInterviewQuestionNumber,
                                                                   bool pActive, int pMaxResponseLength,
                                                                   string pStreamText = "")
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to UpdateInterviewHandler";
                return(res);
            }

            ConnectionPropertyList oPropList = new ConnectionPropertyList();

            oPropList.Add("IsActive", pActive);
            oPropList.Add("MaxMsgLength", pMaxResponseLength);

            if (!string.IsNullOrEmpty(pStreamText))
            {
                oPropList.Add("StreamText", pStreamText);
            }

            string strBody = "<InterviewQuestion>";

            foreach (var oPair in oPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</InterviewQuestion>";

            string strUri = string.Format("{0}handlers/interviewhandlers/{1}/interviewquestions/{2}",
                                          pConnectionServer.BaseUrl, pInterviewHandlerObjectId, pInterviewQuestionNumber);

            return(pConnectionServer.GetCupiResponse(strUri, MethodType.PUT, strBody, false));
        }
Exemple #12
0
        /// <summary>
        /// Allows one or more properties on a port group to be udpated.  The caller needs to construct a list of property
        /// names and new values using the ConnectionPropertyList class's "Add" method.  At least one property pair needs to be passed in
        /// but as many as are desired can be included in a single call.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the port group is homed.
        /// </param>
        /// <param name="pPortGroupObjectId">
        /// Unique identifier for the port group to update.
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a transfer option property name and a new value for that property to apply to the option
        /// being updated. This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  At least one
        /// property pair needs to be included for the funtion to execute.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult UpdatePortGroup(ConnectionServerRest pConnectionServer,
                                                    string pPortGroupObjectId,
                                                    ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to UpdatePortGroup";
                return(res);
            }

            if (string.IsNullOrEmpty(pPortGroupObjectId))
            {
                res.ErrorText = "Empty PortGroupObjectId passed to UpdatePortGroup";
                return(res);
            }

            //the update command takes a body in the request, construct it based on the name/value pair of properties passed in.
            //at lest one such pair needs to be present
            if (pPropList == null || pPropList.Count < 1)
            {
                res.ErrorText = "empty property list passed to UpdatePortGroup";
                return(res);
            }

            string strBody = "<PortGroup>";

            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</PortGroup>";

            return(pConnectionServer.GetCupiResponse(string.Format("{0}portgroups/{1}", pConnectionServer.BaseUrl, pPortGroupObjectId),
                                                     MethodType.PUT, strBody, false));
        }
Exemple #13
0
        /// <summary>
        /// Allows one or more properties on a MWI.  The caller needs to construct a list
        /// of property names and new values using the ConnectionPropertyList class's "Add" method.  At least one property pair needs to be passed in
        /// but as many as are desired can be included in a single call.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the alternate extension is homed.
        /// </param>
        /// <param name="pUserObjectId">
        /// Unique identifier for user that owns the alternate extension being edited.
        /// </param>
        /// <param name="pObjectId">
        /// The unqiue GUID identifying the alternate extension owned by the user to be updated.
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a alternate extension property name and a new value for that property to apply to the extension
        /// being updated. This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  At least one
        /// property pair needs to be included for the funtion to execute.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult UpdateMwi(ConnectionServerRest pConnectionServer,
                                              string pUserObjectId,
                                              string pObjectId,
                                              ConnectionPropertyList pPropList)
        {
            string        strBody = "";
            WebCallResult res     = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to UpdateMwi";
                return(res);
            }

            //the update command takes a body in the request, construct it based on the name/value pair of properties passed in.
            //at lest one such pair needs to be present
            if (pPropList == null || pPropList.Count < 1)
            {
                res.ErrorText = "empty property list passed to UpdateMwi";
                return(res);
            }

            strBody += "<Mwi>";

            //construct the full path to the device type off this user
            string strUrl = string.Format("{0}users/{1}/mwis/{2}", pConnectionServer.BaseUrl, pUserObjectId, pObjectId);

            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</Mwi>";

            return(pConnectionServer.GetCupiResponse(strUrl, MethodType.PUT, strBody, false));
        }
Exemple #14
0
        /// <summary>
        /// Allows one or more properties on a transfer option to be udpated.  The caller needs to construct a list of property
        /// names and new values using the ConnectionPropertyList class's "Add" method.  At least one property pair needs to be passed in
        /// but as many as are desired can be included in a single call.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the transfer option is homed.
        /// </param>
        /// <param name="pCallHandlerObjectId">
        /// Unique identifier for call handler that owns the transfer option being updated
        /// </param>
        /// <param name="pTransferOptionType">
        /// Name of the transfer rule to update (Alternate, Standard, OffHours)
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a transfer option property name and a new value for that property to apply to the option
        /// being updated. This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  At least one
        /// property pair needs to be included for the funtion to execute.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult UpdateTransferOption(ConnectionServerRest pConnectionServer,
                                                         string pCallHandlerObjectId,
                                                         TransferOptionTypes pTransferOptionType,
                                                         ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to UpdateTransferOption";
                return(res);
            }

            //the update command takes a body in the request, construct it based on the name/value pair of properties passed in.
            //at lest one such pair needs to be present
            if (pPropList == null || pPropList.Count < 1)
            {
                res.ErrorText = "empty property list passed to UpdateTransferOption";
                return(res);
            }

            string strBody = "<TransferOption>";

            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</TransferOption>";

            return(pConnectionServer.GetCupiResponse(string.Format("{0}handlers/callhandlers/{1}/transferoptions/{2}",
                                                                   pConnectionServer.BaseUrl, pCallHandlerObjectId, pTransferOptionType.Description()), MethodType.PUT, strBody, false));
        }
 /// <summary>
 /// default constructor used by JSON parser
 /// </summary>
 public CallHandlerTemplate()
 {
     _changedPropList = new ConnectionPropertyList();
 }
Exemple #16
0
        /// <summary>
        /// Allows one or more properties on an external service to be udpated.  The caller needs to construct a list of property
        /// names and new values using the ConnectionPropertyList class's "Add" method.  At least one property pair needs to be passed in
        /// but as many as are desired can be included in a single call.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the service is homed.
        /// </param>
        /// <param name="pObjectId">
        /// Unique identifier for the external service to update.
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a property name and a new value for that property to apply to the object
        /// being updated.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult UpdateExternalService(ConnectionServerRest pConnectionServer, string pObjectId, ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult {
                Success = false
            };

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to UpdateExternalService";
                return(res);
            }

            if (pPropList == null || pPropList.Count < 1)
            {
                res.ErrorText = "empty property list passed to UpdateExternalService";
                return(res);
            }

            string strBody = "<ExternalService>";

            foreach (var oPair in pPropList)
            {
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</ExternalService>";

            return(pConnectionServer.GetCupiResponse(string.Format("{0}externalservices/{1}", pConnectionServer.BaseUrl, pObjectId),
                                                     MethodType.PUT, strBody, false));
        }
Exemple #17
0
 /// <summary>
 /// Generic constructor for JSON parsing library
 /// </summary>
 public ExternalService()
 {
     _changedPropList = new ConnectionPropertyList();
 }
Exemple #18
0
 /// <summary>
 /// default constructor used by JSON parser
 /// </summary>
 public RoutingRule()
 {
     _changedPropList = new ConnectionPropertyList();
 }
Exemple #19
0
 /// <summary>
 /// General constructor used in the JSON parsing routines.
 /// </summary>
 public AlternateExtension()
 {
     //make an instanced of the changed prop list to keep track of updated properties on this object
     _changedPropList = new ConnectionPropertyList();
 }
Exemple #20
0
 /// <summary>
 /// Generic constructor for JSON parsing library
 /// </summary>
 public ClassOfService()
 {
     //make an instanced of the changed prop list to keep track of updated properties on this object
     _changedPropList = new ConnectionPropertyList();
 }
Exemple #21
0
 /// <summary>
 /// Generic constructor for Json parsing libraries
 /// </summary>
 public Port()
 {
     _changedPropList = new ConnectionPropertyList();
 }
Exemple #22
0
        /// <summary>
        /// Adds a new port to the system
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server to add the port to
        /// </param>
        /// <param name="pMediaPortGroupObjectId">
        /// Media port group to associate the port with
        /// </param>
        /// <param name="pNumberOfPorts">
        /// Number of ports to add to the port group - should be an even number but that's not enforced.
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a property name and a new value for that property to apply to the port being created.
        /// This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  Can be passed as null here.
        /// </param>
        /// <param name="pPimgPort">
        /// If adding ports for PIMG/TIMG pass this as true - the VMSServer value needs to be empty in that case.  For SIP and SCCP this needs to
        /// be passed.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult AddPort(ConnectionServerRest pConnectionServer, string pMediaPortGroupObjectId, int pNumberOfPorts,
                                            ConnectionPropertyList pPropList, bool pPimgPort = false)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddPort";
                return(res);
            }

            //make sure that something is passed in for the required param
            if (String.IsNullOrEmpty(pMediaPortGroupObjectId))
            {
                res.ErrorText = "Empty value passed for portgroupObjecTId in AddPort";
                return(res);
            }

            //create an empty property list if it's passed as null since we use it below
            if (pPropList == null)
            {
                pPropList = new ConnectionPropertyList();
            }

            pPropList.Add("MediaPortGroupObjectId", pMediaPortGroupObjectId);
            pPropList.Add("NumberOfPorts", pNumberOfPorts);

            //for SIP and SCCP the VMSserverObjectId is needed, for TIMG/PIMG it needs to be left out
            if (!pPimgPort)
            {
                pPropList.Add("VmsServerObjectId", pConnectionServer.VmsServerObjectId);
            }

            string strBody = "<Port>";

            //tack on the property value pair with appropriate tags
            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</Port>";

            res = pConnectionServer.GetCupiResponse(string.Format("{0}ports", pConnectionServer.BaseUrl),
                                                    MethodType.POST, strBody, false);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                const string strPrefix = @"/vmrest/ports/";
                if (res.ResponseText.Contains(strPrefix))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(strPrefix, "").Trim();
                }
            }

            return(res);
        }
Exemple #23
0
        /// <summary>
        /// Special helper function for dealing with the enabled/disabled status of transfer options.  This can be done directly using the timeExpiresSetNull
        /// option found in the propertis seciton above but it's less than intuative and most users do not get how the timeExpires functionality works for
        /// transfer options and greeting rules - as such this routine wraps it up in a simple single call option.
        /// If TRUE is passed for the enabled then the greeting TimeExpires is set to null (meaning it's always enabled) unless a pTillDate value is passed.
        /// If this value is passed then the TimeExpires value is set to that.
        /// If a pTillDate is a time in the passed  and it's a time in the past then nothing is  done and and error is returned - a TimeExpires in the future
        /// means to enable it till that time, there is no reason to pass a time in the past.
        /// If the pEnabled is passed as FALSE then the TimeExpires is set to "10/11/1999" which disables it.  This date is used for all TimeExpires disabling
        /// routines in the ConnectionCUPIFunctions libarary.
        /// </summary>
        /// <remarks>
        /// The change queue will be cleared when this is called - if you wish to make other changes do it ahead of time or after making this call.
        /// </remarks>
        /// <param name="pConnectionServer">
        /// Connection server that the transfer option being edited lives on.
        /// </param>
        /// <param name="pCallHandlerObjectId">
        /// The GUID that identifies the call handler which owns the transfer option being edited.
        /// </param>
        /// <param name="pTransferOptionType">
        /// The transfer option type being edited (Standard, Off Hours, Alternate).  You cannot edit the Standard transfer option in this routine, it is always
        /// set to enabled on the server and that cannot be changed.
        /// </param>
        /// <param name="pEnabled">
        /// Pass TRUE to enable the transfer option, FALSE to disable it.  If you pass TRUE you may optionally pass a pTillDate DateTime property to indicate the
        /// date the rule will disable itself automatically.
        /// </param>
        /// <param name="pTillDate">
        /// Optional parameter that can be passed when pEnabled is passed as TRUE.  This must be a date/time in the future, a date/time in the past will result in
        /// the method returning a failure.
        /// </param>
        /// <returns></returns>
        public static WebCallResult UpdateTransferOptionEnabledStatus(ConnectionServerRest pConnectionServer,
                                                                      string pCallHandlerObjectId,
                                                                      TransferOptionTypes pTransferOptionType,
                                                                      bool pEnabled,
                                                                      DateTime?pTillDate = null)
        {
            WebCallResult res = new WebCallResult();

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to UpdateTransferOptionEnabledStatus";
                return(res);
            }

            if (string.IsNullOrEmpty(pCallHandlerObjectId))
            {
                res.ErrorText = "Empty handler ObjectId or TransferType passed to UpdateTransferOptionEnabledStatus";
                return(res);
            }

            //first make sure the user isn't trying to change the enabled status on the Standard transfer option - this will fail since that option needs to
            //always be enabled on the server - fail it up front and pass back the WebCallResult with this information.
            if (pTransferOptionType == TransferOptionTypes.Standard)
            {
                res.ErrorText = "Attempt made to modify Standard transfer option in UpdateTransferOptionEnabledStatus.";
                return(res);
            }

            //invalid
            if (pEnabled == false & (pTillDate != null))
            {
                res.ErrorText = "A date ending time was passed along with enabled=false in UpdateTransferOptionEnabledStatus.";
                return(res);
            }

            //finally - no date in the past is valid
            if ((pTillDate != null) && (pTillDate < DateTime.Now))
            {
                res.ErrorText = "A  pTillDate in the past was passed in UpdateTransferOptionEnabledStatus.";
                return(res);
            }

            //ok, everthing looks valid, make the change.  The enabled/disaled status of a transfer option rides on the TimeExpires field.
            ConnectionPropertyList oProp = new ConnectionPropertyList();

            if (pEnabled == false)
            {
                //use the 10/11/1999 date to disable the transfer rule.
                oProp.Add("TimeExpires", DateTime.Parse("10/11/1999"));
            }
            else
            {
                if (pTillDate != null)
                {
                    //use the date passed in for the expiration time.
                    oProp.Add("TimeExpires", pTillDate.Value);
                }
                else
                {
                    //set it to null to make it never expire - you also have to pass the enabled flag in this case, it's only valid
                    //for update when the date is cleared.
                    oProp.Add("TimeExpires", "");
                    oProp.Add("Enabled", true);
                }
            }

            string strBody = "<TransferOption>";

            foreach (var oPair in oProp)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</TransferOption>";

            return(pConnectionServer.GetCupiResponse(string.Format("{0}handlers/callhandlers/{1}/transferoptions/{2}",
                                                                   pConnectionServer.BaseUrl, pCallHandlerObjectId, pTransferOptionType.Description()), MethodType.PUT, strBody, false));
        }
Exemple #24
0
 /// <summary>
 /// Generic constructor for JSON parsing library
 /// </summary>
 public PhoneSystem()
 {
     _changedPropList = new ConnectionPropertyList();
 }
Exemple #25
0
 /// <summary>
 /// General constructor for Json parsing library
 /// </summary>
 public RestrictionTable()
 {
     _changedPropList = new ConnectionPropertyList();
 }
        /// <summary>
        /// Create a new call handler template in the Connection directory
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server being edited
        /// </param>
        /// <param name="pMediaSwitchObjectId">
        /// The ObjectId of a the media switch this call handler should be associated with
        /// </param>
        /// <param name="pDisplayName">
        /// Display Name of the new call handler template - must be unique.
        /// </param>
        /// <param name="pRecipientUserId">
        /// If a user is a recipient, pass the objectId in here - must pass either recipient or distribution list
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a property name and a new value for that property to apply to the template being created.
        /// This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  Can be passed as null here.
        /// </param>
        /// <param name="pRecipientDistributionListId">
        /// If a list is a recipient, pass the objectId in here - must pass either recipient or distribution list
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class.
        /// </returns>
        public static WebCallResult AddCallHandlerTemplate(ConnectionServerRest pConnectionServer, string pDisplayName,
                                                           string pMediaSwitchObjectId, string pRecipientDistributionListId, string pRecipientUserId,
                                                           ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddCallHandlerTemplate";
                return(res);
            }

            if (String.IsNullOrEmpty(pDisplayName) || string.IsNullOrEmpty(pMediaSwitchObjectId))
            {
                res.ErrorText = "Empty value passed for display name or mediaSwitchObjectId in AddCallHandlerTemplate";
                return(res);
            }

            if (string.IsNullOrEmpty(pRecipientDistributionListId) & string.IsNullOrEmpty(pRecipientUserId))
            {
                res.ErrorText = "Both user and dl recipientIds passed as blank - a handler template requires a recipient";
                return(res);
            }

            //create an empty property list if it's passed as null since we use it below
            if (pPropList == null)
            {
                pPropList = new ConnectionPropertyList();
            }

            if (string.IsNullOrEmpty(pRecipientUserId))
            {
                pPropList.Add("RecipientDistributionListObjectId", pRecipientDistributionListId);
            }
            else
            {
                pPropList.Add("RecipientSubscriberObjectId", pRecipientUserId);
            }

            pPropList.Add("DisplayName", pDisplayName);
            pPropList.Add("MediaSwitchObjectId", pMediaSwitchObjectId);

            string strBody = "<CallhandlerTemplate>";

            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</CallhandlerTemplate>";

            res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "callhandlertemplates", MethodType.POST, strBody, false);

            //fetch the objectId of the newly created object off the return
            if (res.Success)
            {
                if (res.ResponseText.Contains(@"/vmrest/callhandlertemplates/"))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/callhandlertemplates/", "").Trim();
                }
            }

            return(res);
        }
Exemple #27
0
        /// <summary>
        /// Allows one or more properties on a menu entry to be udpated (for instance Action).  The caller needs to construct a list
        /// of property names and new values using the ConnectionPropertyList class's "Add" method.  At least one property pair needs to be passed in
        /// but as many as are desired can be included in a single call.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the menu entry is homed.
        /// </param>
        /// <param name="pCallHandlerObjectId">
        /// Unique identifier for the call handler that owns the menu entry being edited.
        /// </param>
        /// <param name="pKeyName">
        /// The key name to update (0-9 * or #)
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a menu entry property name and a new value for that property to apply to the entry
        /// being updated. This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  At least one
        /// property pair needs to be included for the funtion to execute.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult UpdateMenuEntry(ConnectionServerRest pConnectionServer, string pCallHandlerObjectId, string pKeyName, ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to UpdateMenuEntry";
                return(res);
            }

            //the update command takes a body in the request, construct it based on the name/value pair of properties passed in.
            //at lest one such pair needs to be present
            if (pPropList == null || pPropList.Count < 1)
            {
                res.ErrorText = "empty property list passed to UpdateMenuEntry";
                return(res);
            }

            //both the objectID and key name should be passed here.
            if (string.IsNullOrEmpty(pCallHandlerObjectId) | string.IsNullOrEmpty(pKeyName))
            {
                res.ErrorText = "Empty call handler ObjectId or Key Name passed to UpdateMenuEntry";
                return(res);
            }

            string strBody = "<MenuEntry>";

            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</MenuEntry>";

            return(pConnectionServer.GetCupiResponse(string.Format("{0}handlers/callhandlers/{1}/menuentries/{2}", pConnectionServer.BaseUrl,
                                                                   pCallHandlerObjectId, pKeyName), MethodType.PUT, strBody, false));
        }
Exemple #28
0
        /// <summary>
        /// Add a new schedule detail to the schedule
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server being edited
        /// </param>
        /// <param name="pSubject">
        /// optional description string for the schedule item
        /// </param>
        /// <param name="pScheduleObjectId">
        /// Schedule to add the detail item to
        /// </param>
        /// <param name="pStartTime">
        /// the start time (in minutes) for the active day or days.  the start time is stored as the number of minutes from
        /// midnight.  so a value of 480 would mean 8:00 am and 1020 would mean 5:00 pm.  in addition, a value of 0 for the
        /// start time indicates 12:00 am.
        /// </param>
        /// <param name="pEndTime">
        /// the end time (in minutes) for the active day or days.  the end time is stored as the number of minutes from
        /// midnight. so a value of 480 would mean 8:00 am and 1020 would mean 5:00 pm. in addition, a value of 0 means
        /// "till the end of the day" (e.g.  11:59:59 pm in linux land).
        /// </param>
        /// <param name="pStartDate">
        /// the date when this schedule detail becomes active.  a value of null means the schedule is active immediately.
        /// </param>
        /// <param name="pEndDate">
        /// the date when this schedule detail ends.  a value of null indicates the scheule is active indefinitely.
        /// </param>
        /// <param name="pActiveMonday"></param>
        /// <param name="pActiveTuesday"></param>
        /// <param name="pActiveWednesday"></param>
        /// <param name="pActiveThursday"></param>
        /// <param name="pActiveFriday"></param>
        /// <param name="pActiveSaturday"></param>
        /// <param name="pActiveSunday"></param>
        /// <returns>
        /// Instance of the WebCallResult
        /// </returns>
        public static WebCallResult AddScheduleDetail(ConnectionServerRest pConnectionServer, string pScheduleObjectId, string pSubject,
                                                      int pStartTime, int pEndTime,
                                                      bool pActiveMonday, bool pActiveTuesday, bool pActiveWednesday, bool pActiveThursday,
                                                      bool pActiveFriday, bool pActiveSaturday, bool pActiveSunday,
                                                      DateTime?pStartDate = null, DateTime?pEndDate = null)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddScheduleSetMember";
                return(res);
            }

            if (string.IsNullOrEmpty(pScheduleObjectId))
            {
                res.ErrorText = "Empty pScheduleObjectId passed to AddScheduleDetail";
                return(res);
            }

            ConnectionPropertyList oProps = new ConnectionPropertyList();

            oProps.Add("ScheduleObjectId", pScheduleObjectId);
            oProps.Add("StartDate", pStartDate);
            oProps.Add("StartTime", pStartTime);
            oProps.Add("EndTime", pEndTime);
            oProps.Add("EndDate", pEndDate);
            oProps.Add("IsActiveMonday", pActiveMonday);
            oProps.Add("IsActiveTuesday", pActiveTuesday);
            oProps.Add("IsActiveWednesday", pActiveWednesday);
            oProps.Add("IsActiveThursday", pActiveThursday);
            oProps.Add("IsActiveFriday", pActiveFriday);
            oProps.Add("IsActiveSaturday", pActiveSaturday);
            oProps.Add("IsActiveSunday", pActiveSunday);

            string strBody = "<ScheduleDetail>";

            //tack on the property value pair with appropriate tags
            foreach (var oProp in oProps)
            {
                strBody += string.Format("<{0}>{1}</{0}>", oProp.PropertyName, oProp.PropertyValue);
            }

            strBody += "</ScheduleDetail>";

            string strPath = string.Format("schedules/{0}/scheduledetails", pScheduleObjectId);

            res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + strPath, MethodType.POST, strBody, false);

            //if the call went through then the ObjectId will be returned in the URI form.
            strPath += "/";
            if (res.Success)
            {
                if (res.ResponseText.Contains(@"/vmrest/" + strPath))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/" + strPath, "").Trim();
                }
            }

            return(res);
        }
Exemple #29
0
 /// <summary>
 /// Generic constructor for Json libraries
 /// </summary>
 public PortGroupServer()
 {
     _changedPropList = new ConnectionPropertyList();
 }
Exemple #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pConnectionServer"></param>
        /// <param name="pRestrictionTable"></param>
        /// <param name="pPropList"></param>
        /// <returns></returns>
        public static WebCallResult UpdateRestrictionTable(ConnectionServerRest pConnectionServer, RestrictionTable pRestrictionTable, ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult {
                Success = false
            };

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to UpdateRestrictionTable";
                return(res);
            }

            if (pRestrictionTable == null)
            {
                res.ErrorText = "Null RestrictionTable passed to UpdateRestrictionTable";
                return(res);
            }

            string strBody = "<RestrictionTable>";

            foreach (var oPair in pPropList)
            {
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</RestrictionTable>";

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "restrictiontables/" + pRestrictionTable.ObjectId);

            res = pConnectionServer.GetCupiResponse(strUrl, MethodType.PUT, strBody, false);
            if (res.Success == false)
            {
                return(res);
            }

            strBody = "<RestrictionPattern>";
            foreach (RestrictionPattern oPattern in pRestrictionTable.RestrictionPatterns())
            {
                strBody += string.Format("<{0}>{1}</{0}>", "ObjectId", oPattern.ObjectId);
            }
            strBody += "</RestrictionPattern>";
            strUrl   = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "restrictiontables/" + pRestrictionTable.ObjectId + "/restrictionpatterns");
            return(pConnectionServer.GetCupiResponse(strUrl, MethodType.PUT, strBody, false));
        }