コード例 #1
0
        /// <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);
        }
コード例 #2
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));
        }
コード例 #3
0
        public static WebCallResult GetRestrictionTable(ConnectionServerRest pConnectionServer, string pRestrictionTableObjectId, out RestrictionTable pRestrictionTable)
        {
            WebCallResult res = new WebCallResult {
                Success = false
            };

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

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

            res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, "");

            if (res.Success == false)
            {
                return(res);
            }

            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.ErrorText = "Empty response received";
                res.Success   = false;
                return(res);
            }

            try
            {
                pRestrictionTable            = JsonConvert.DeserializeObject <RestrictionTable>(res.ResponseText);
                pRestrictionTable.HomeServer = pConnectionServer;
            }
            catch (Exception ex)
            {
                res.ErrorText = "Could not convert response text into a RestrictionTable object:" + ex;
                res.Success   = false;
                return(res);
            }

            return(res);
        }