Exemple #1
0
 /// <summary>
 /// Creates the authentication component used for calling the Guidewire Metadata Update service
 /// </summary>
 /// <param name="web">The SPWeb that the configuration objects are stored in</param>
 /// <returns></returns>
 private static GuidewireWS.authentication CreateAuthentication(SPWeb web)
 {
     GuidewireWS.authentication authentication = new GuidewireWS.authentication();
     // Use the configured values in the web's configuration list
     authentication.username = Configuration.GetConfigurationValue(web, Resource.ConfigGWWsUserName);
     authentication.password = Configuration.GetConfigurationValue(web, Resource.ConfigGWWsPassword);
     return(authentication);
 }
Exemple #2
0
        /// <summary>
        /// Call the Guidewire Update Metadata service for a SPListItem and an operation type
        /// </summary>
        /// <param name="item">The SPListItem to send to ClaimCenter</param>
        /// <param name="type">The Guidewire Operation Type</param>
        /// <param name="manualDocId">Optional. An overridable document ID in the case that the original document ID is changing</param>
        /// <returns></returns>
        public static Boolean CallGuideWire(SPListItem item, GuidewireOperationType type, string manualDocId = null)
        {
            Boolean success = false;
            // Create the Guidewire WS Client
            EndpointAddress endpointAddress = new EndpointAddress(Configuration.GetConfigurationValue(item.ParentList.ParentWeb, Resource.ConfigGWWsEndpoint));

            System.ServiceModel.Channels.Binding            binding = CreateBinding();
            GuidewireWS.trg_UpdateMetadataAPIPortTypeClient client  = new GuidewireWS.trg_UpdateMetadataAPIPortTypeClient(binding, endpointAddress);
            // Create authentication
            GuidewireWS.authentication authentication = CreateAuthentication(item.ParentList.ParentWeb);
            GuidewireWS.locale         locale         = new GuidewireWS.locale();
            locale.Value = "en_US"; //CultureInfo.CurrentCulture.ToString(); //
            // Create document info
            GuidewireWS.trg_DocumentInfo documentInfo = new GuidewireWS.trg_DocumentInfo();
            documentInfo.operation = (int)type;
            if (manualDocId != null)
            {
                documentInfo.documentID = manualDocId;
            }
            else
            {
                documentInfo.documentID = Util.GetDocumentId(item);
            }
            List <GuidewireWS.trg_MetadataPair> metadata = CreateMetadata(item);

            if (metadata != null)
            {
                documentInfo.metadata = metadata.ToArray();
                // Call Guidewire
                try
                {
                    success = client.updateMetadata(authentication, locale, documentInfo);
                    if (!success)
                    {
                        Util.LogError("Call to Guidewire was unsuccessful operation type = " + type.ToString());
                    }
                }
                catch (Exception e)
                {
                    success = false;
                    LogError("CallGuidewire failed with exception:  " + e.Message);
                }
            }
            else
            {
                return(false);
            }

            return(success);
        }