示例#1
0
        public static void GetInitialsFrom(CrmServiceClient client, tcm.WebRioSsoConfig configuration)
        {
            if (client == null)
            {
                return;
            }
            if (configuration == null)
            {
                return;
            }

            RetrieveRequest request = new RetrieveRequest
            {
                ColumnSet = new ColumnSet("tc_initials"),
                Target    = new Microsoft.Xrm.Sdk.EntityReference("opportunity", new Guid(configuration.TravelPlannerId))
            };
            var response = (RetrieveResponse)client.ExecuteCrmOrganizationRequest(request, "Fetching travel planner record for Web Rio");

            if (response == null)
            {
                return;
            }
            var travelPlanner = response.Entity;

            if (travelPlanner == null || !travelPlanner.Contains("tc_initials") || travelPlanner["tc_initials"] == null)
            {
                return;
            }
            configuration.Initials = travelPlanner["tc_initials"].ToString();
        }
示例#2
0
        public static void GetWebRioSsoConfiguration(CrmServiceClient client, tcm.WebRioSsoConfig configuration)
        {
            if (client == null)
            {
                return;
            }
            if (configuration == null)
            {
                return;
            }

            var query = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                            <entity name = 'tc_configuration' >
                                <attribute name = 'tc_configurationid' />
                                <attribute name = 'tc_name' />
                                <attribute name = 'tc_value' />
                                <attribute name = 'tc_longvalue' />
                                <attribute name = 'tc_group' />
                                <order attribute = 'tc_name' descending = 'false' />
                                <filter type = 'and' >
                                    <condition attribute = 'tc_group' operator= 'eq' value = 'WebRio' />
                                    <condition attribute = 'statecode' operator= 'eq' value = '0' />
                                </filter >
                            </entity >
                        </fetch > ";

            var response = (RetrieveMultipleResponse)client.ExecuteCrmOrganizationRequest(new RetrieveMultipleRequest {
                Query = new FetchExpression(query)
            }, "Fetching cnfiguration records for Web Rio");

            if (response == null)
            {
                return;
            }
            var configRecords = response.EntityCollection;

            if (configRecords == null || configRecords.Entities == null || configRecords.Entities.Count == 0)
            {
                return;
            }

            foreach (var item in configRecords.Entities)
            {
                if (!item.Contains(Configuration.Name))
                {
                    continue;
                }
                if (!item.Contains(Configuration.Value))
                {
                    continue;
                }

                var key   = item[Configuration.Name] != null ? item[Configuration.Name].ToString() : null;
                var value = item[Configuration.Value] != null ? item[Configuration.Value].ToString() : null;

                if (string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(value))
                {
                    return;
                }

                if (key.Equals(Er.Configuration.WebRioAdminApi, StringComparison.OrdinalIgnoreCase))
                {
                    configuration.AdminApi = value;
                }
                else if (key.Equals(Er.Configuration.WebRioOpenConsultationApi, StringComparison.OrdinalIgnoreCase))
                {
                    configuration.OpenConsultationApi = value;
                }
                else if (key.Equals(Er.Configuration.WebRioNewConsultationApi, StringComparison.OrdinalIgnoreCase))
                {
                    configuration.NewConsultationApi = value;
                }
                else if (key.Equals(Er.Configuration.WebRioServiceUrl, StringComparison.OrdinalIgnoreCase))
                {
                    configuration.ServiceUrl = value;
                }
                else if (key.Equals(Er.Configuration.WebRioExpirySecondsFromNow, StringComparison.OrdinalIgnoreCase))
                {
                    configuration.ExpirySeconds = value;
                }
                else if (key.Equals(Er.Configuration.WebRioNotBeforeTimeSecondsFromNow, StringComparison.OrdinalIgnoreCase))
                {
                    configuration.NotBeforeTime = value;
                }
                else
                {
                    continue;
                }
            }
        }
示例#3
0
        public static void GetConsultationReferenceFromBookingSummary(CrmServiceClient client, tcm.WebRioSsoConfig configuration)
        {
            if (client == null)
            {
                return;
            }
            if (configuration == null)
            {
                return;
            }

            RetrieveRequest request = new RetrieveRequest
            {
                ColumnSet = new ColumnSet("tc_name"),
                Target    = new Microsoft.Xrm.Sdk.EntityReference("tc_bookingsummary", new Guid(configuration.BookingSummaryId))
            };
            var response = (RetrieveResponse)client.ExecuteCrmOrganizationRequest(request, "Fetching booking summary record for Web Rio");

            if (response == null)
            {
                return;
            }
            var bookingSummary = response.Entity;

            if (bookingSummary == null || !bookingSummary.Contains("tc_name") || bookingSummary["tc_name"] == null)
            {
                return;
            }
            configuration.ConsultationReference = bookingSummary["tc_name"].ToString();
        }