private void addUpdateRequest(string[] row, List <CrmOperation> crmOp, AttributeMetadata currentAttribute)
        {
            IEnumerable <IExtensibleDataObject> excelAttrMetadataList = attributeReader(row);

            if (excelAttrMetadataList.Count() > 0)
            {
                IExtensibleDataObject excelAttrMetadata = excelAttrMetadataList.First();
                if (excelAttrMetadata != null)
                {
                    if (excelAttrMetadata is AttributeMetadata || excelAttrMetadata is CreateOneToManyRequest)
                    {
                        if (excelAttrMetadata is CreateOneToManyRequest)
                        {
                            excelAttrMetadata = ((CreateOneToManyRequest)excelAttrMetadata).Lookup;
                        }
                        IEnumerable <string> fieldToCahnge = checkDifferenceAttributeMetadata(currentAttribute, excelAttrMetadata as AttributeMetadata);
                        if (fieldToCahnge != null && fieldToCahnge.Count() != 0)
                        {
                            UpdateAttributeRequest updateAttributeRequest = new UpdateAttributeRequest
                            {
                                EntityName  = filteredMetadata[0].EntityLogicalName,
                                Attribute   = currentAttribute,
                                MergeLabels = false
                            };
                            crmOp.Add(new CrmOperation(CrmOperation.CrmOperationType.update, CrmOperation.CrmOperationTarget.attribute, updateAttributeRequest, "Update field " + currentAttribute.SchemaName + " in " + filteredMetadata[0].EntityLogicalName));
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void btnLoad_Click(object sender, RoutedEventArgs e)
        {
            using (CustomerServiceClient serviceClient = new CustomerServiceClient())
            {
                serviceClient.Open();

                Customer customer = serviceClient.GetCustomer(int.Parse(this.txtId.Text));
                this.txtName.Text        = customer.Name;
                this.txtStartDate.Text   = customer.StartDate.ToShortDateString();
                this.txtCreditLimit.Text = customer.CreditLimit.ToString();
                this.imgLogo.Source      = ImageFromBuffer(customer.Logo);

                IExtensibleDataObject extendedCustomer = customer as IExtensibleDataObject;
                if (extendedCustomer != null)
                {
                    //ES - ordinarily the data signature is hidden from the client,
                    //and cannot be modified; access with reflection to display it:
                    object dataSiganture = ExtensionDataHelper.GetExtensionDataMemberValue(extendedCustomer, "dataSignature");
                    this.lblDataSignature.Content = string.Format("Data Signature: {0}", dataSiganture);
                }

                this.CurrentCustomer = customer;

                serviceClient.Close();
            }
        }
        public static object GetExtensionDataMemberValue(IExtensibleDataObject extensibleObject, string dataMemberName)
        {
            object innerValue = null;

            PropertyInfo membersProperty = typeof(ExtensionDataObject).GetProperty("Members", BindingFlags.NonPublic | BindingFlags.Instance);

            IList members = (IList)membersProperty.GetValue(extensibleObject.ExtensionData, null);

            foreach (object member in members)
            {
                PropertyInfo nameProperty = member.GetType().GetProperty("Name");

                string name = (string)nameProperty.GetValue(member, null);

                if (name == dataMemberName)
                {
                    PropertyInfo valueProperty = member.GetType().GetProperty("Value");

                    object value = valueProperty.GetValue(member, null);

                    PropertyInfo innerValueProperty = value.GetType().GetProperty("Value");

                    innerValue = innerValueProperty.GetValue(value, null);

                    break;
                }
            }
            return innerValue;
        }
Esempio n. 4
0
        public static object GetExtensionDataMemberValue(IExtensibleDataObject extensibleObject, string dataMemberName)
        {
            object innerValue = null;

            PropertyInfo membersProperty = typeof(ExtensionDataObject).GetProperty("Members", BindingFlags.NonPublic | BindingFlags.Instance);

            IList members = (IList)membersProperty.GetValue(extensibleObject.ExtensionData, null);

            foreach (object member in members)
            {
                PropertyInfo nameProperty = member.GetType().GetProperty("Name");

                string name = (string)nameProperty.GetValue(member, null);

                if (name == dataMemberName)
                {
                    PropertyInfo valueProperty = member.GetType().GetProperty("Value");

                    object value = valueProperty.GetValue(member, null);

                    PropertyInfo innerValueProperty = value.GetType().GetProperty("Value");

                    innerValue = innerValueProperty.GetValue(value, null);

                    break;
                }
            }
            return(innerValue);
        }
Esempio n. 5
0
        /// <summary>
        /// Serializes the specified obj, returning it's xml serialized value.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="indent"></param>
        /// <returns></returns>
        public static string Serialize(this IExtensibleDataObject obj, bool indent = false)
        {
            var serializer = new NetDataContractSerializer();

            using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
                using (var writer = new System.Xml.XmlTextWriter(stringWriter))
                {
                    if (indent)
                    {
                        writer.Formatting  = System.Xml.Formatting.Indented;
                        writer.Indentation = 2;
                    }
                    serializer.WriteObject(writer, obj);
                    return(stringWriter.ToString());
                }
        }
Esempio n. 6
0
 internal GlsAsyncState(AsyncCallback clientCallback, object clientAsyncState, LocatorService serviceProxy, int retryCount, GlsLoggerContext loggerContext, IExtensibleDataObject request, string methodName, string glsApiName, object parameterValue, bool isRead, Func <LocatorService, GlsLoggerContext, IAsyncResult> methodToRetry)
 {
     this.clientCallback   = clientCallback;
     this.clientAsyncState = clientAsyncState;
     this.serviceProxy     = serviceProxy;
     this.retryCount       = retryCount;
     this.loggerContext    = loggerContext;
     this.request          = request;
     this.methodName       = methodName;
     this.glsApiName       = glsApiName;
     this.parameterValue   = parameterValue;
     this.isRead           = isRead;
     this.methodToRetry    = methodToRetry;
 }