コード例 #1
0
        /// <summary>
        /// Update the agent account oauth custom field timestamp with a new value 15 mins in the future.
        /// Only add-ins that leverage this library will update the timestamp, so scripts that validate against the timestamp will only succeed
        /// if this add-in is active and updating this field every 15 mins.
        /// </summary>
        /// <param name="globalContext"></param>
        private void SetValidRequestTime(IGlobalContext globalContext)
        {
            var now       = System.DateTime.UtcNow;
            var validTime = now.AddSeconds(900);

            //Update the agent field through the SOAP API
            var rntService = new RightNowService(globalContext);
            var agent      = new RightNowServiceReference.Account()
            {
                ID = new RightNowServiceReference.ID()
                {
                    id          = globalContext.AccountId,
                    idSpecified = true
                }
            };

            //Get the current process so that we can use process ID as one of the validation mechanisms that we use when posting a request
            //To the Oauth controller.
            var process = System.Diagnostics.Process.GetCurrentProcess();

            //Setup the custom fields to be saved to the agent record via the SOAP API
            var processIdField = GenericObjectFactory.CreateGenericIntegerField(@"OAuthProcessId", process.Id);
            var timestampField = GenericObjectFactory.CreateGenericDateTimeField(@"OAuthRequestValidUntil", validTime);
            var accountCustomFieldsAccelerator = GenericObjectFactory.CreateGenericObject(@"AccountCustomFieldsAccelerator", null);

            accountCustomFieldsAccelerator.GenericFields = new RightNowServiceReference.GenericField[] { timestampField, processIdField };
            var cField = GenericObjectFactory.CreateGenericObjectField("Accelerator", accountCustomFieldsAccelerator);

            agent.CustomFields = GenericObjectFactory.CreateGenericObject("AgentCustomFields", null);
            agent.CustomFields.GenericFields = new RightNowServiceReference.GenericField[] { cField };

            rntService.updateObject(new RightNowServiceReference.RNObject[] { agent });

            //Update our stored config object with the new timestamp
            OAuthRequestTimeout = ConvertToTimestamp(validTime);
        }
コード例 #2
0
 /// <summary>
 /// Intializes connect web services
 /// </summary>
 /// <param name="_gContext"></param>
 public static void initCWSS(IGlobalContext _gContext)
 {
     rnSrv  = new RightNowService(_gContext);
     client = rnSrv._rnowClient;
 }