private string GetValueFromProperty(Microsoft.Crm.Sdk.Property inputProperty) { Type propType = inputProperty.GetType(); string propValue = string.Empty; if (propType == typeof(Microsoft.Crm.Sdk.StringProperty)) { propValue = ((Microsoft.Crm.Sdk.StringProperty)inputProperty).Value; } else if (propType == typeof(Microsoft.Crm.Sdk.CustomerProperty)) { propValue = ((Microsoft.Crm.Sdk.CustomerProperty)inputProperty).Value.Value.ToString(); } else if (propType == typeof(Microsoft.Crm.Sdk.CrmBooleanProperty)) { propValue = ((Microsoft.Crm.Sdk.CrmBooleanProperty)inputProperty).Value.Value.ToString(); } else if (propType == typeof(Microsoft.Crm.Sdk.CrmMoneyProperty)) { propValue = ((Microsoft.Crm.Sdk.CrmMoneyProperty)inputProperty).Value.Value.ToString(); } else if (propType == typeof(Microsoft.Crm.Sdk.CrmDateTimeProperty)) { CrmDateTimeProperty dtProperty = (Microsoft.Crm.Sdk.CrmDateTimeProperty)inputProperty; if (dtProperty != null && dtProperty.Value != null) { propValue = dtProperty.Value.Value; } } else if (propType == typeof(Microsoft.Crm.Sdk.CrmDecimalProperty)) { propValue = ((Microsoft.Crm.Sdk.CrmDecimalProperty)inputProperty).Value.Value.ToString(); } else if (propType == typeof(Microsoft.Crm.Sdk.CrmFloatProperty)) { propValue = ((Microsoft.Crm.Sdk.CrmFloatProperty)inputProperty).Value.Value.ToString(); } else if (propType == typeof(Microsoft.Crm.Sdk.CrmNumberProperty)) { propValue = ((Microsoft.Crm.Sdk.CrmNumberProperty)inputProperty).Value.Value.ToString(); } else if (propType == typeof(Microsoft.Crm.Sdk.LookupProperty)) { if (inputProperty.Name.ToString() != "owningbusinessunit") { propValue = ((Microsoft.Crm.Sdk.LookupProperty)inputProperty).Value.Value.ToString(); } } else if (propType == typeof(Microsoft.Crm.Sdk.OwnerProperty)) { propValue = ((Microsoft.Crm.Sdk.OwnerProperty)inputProperty).Value.Value.ToString(); } else if (propType == typeof(Microsoft.Crm.Sdk.StatusProperty)) { propValue = ((Microsoft.Crm.Sdk.StatusProperty)inputProperty).Value.Value.ToString(); } else if (propType == typeof(Microsoft.Crm.Sdk.PicklistProperty)) { propValue = ((Microsoft.Crm.Sdk.PicklistProperty)inputProperty).Value.name; } else if (propType == typeof(Microsoft.Crm.Sdk.KeyProperty)) { propValue = ((Microsoft.Crm.Sdk.KeyProperty)inputProperty).Value.Value.ToString(); } return(propValue); }
private string GetValueFromProperty(Microsoft.Crm.Sdk.Property inputProperty) { Type propType = inputProperty.GetType(); string propValue = string.Empty; if (propType == typeof(Microsoft.Crm.Sdk.StringProperty)) { propValue = ((Microsoft.Crm.Sdk.StringProperty)inputProperty).Value; } else if (propType == typeof(Microsoft.Crm.Sdk.CustomerProperty)) { var crmCustomer = ((Microsoft.Crm.Sdk.CustomerProperty)inputProperty).Value; if (!crmCustomer.IsNull || !crmCustomer.IsNullSpecified) { propValue = crmCustomer.Value.ToString(); } } else if (propType == typeof(Microsoft.Crm.Sdk.CrmBooleanProperty)) { var crmBoolean = ((Microsoft.Crm.Sdk.CrmBooleanProperty)inputProperty).Value; if (!crmBoolean.IsNull || !crmBoolean.IsNullSpecified) { propValue = crmBoolean.Value.ToString(); } } else if (propType == typeof(Microsoft.Crm.Sdk.CrmMoneyProperty)) { propValue = ((Microsoft.Crm.Sdk.CrmMoneyProperty)inputProperty).Value.Value.ToString(); } else if (propType == typeof(Microsoft.Crm.Sdk.CrmDateTimeProperty)) { string myValue; myValue = ((Microsoft.Crm.Sdk.CrmDateTimeProperty)inputProperty).Value.Value.ToString(); propValue = Convert.ToDateTime(myValue).GetDateTimeFormats()[3]; } else if (propType == typeof(Microsoft.Crm.Sdk.CrmDecimalProperty)) { var crmDecimal = ((Microsoft.Crm.Sdk.CrmDecimalProperty)inputProperty).Value; if (!crmDecimal.IsNull || !crmDecimal.IsNullSpecified) { propValue = crmDecimal.Value.ToString(); } } else if (propType == typeof(Microsoft.Crm.Sdk.CrmFloatProperty)) { var crmFloat = ((Microsoft.Crm.Sdk.CrmFloatProperty)inputProperty).Value; if (!crmFloat.IsNull || !crmFloat.IsNullSpecified) { propValue = crmFloat.Value.ToString(); } } else if (propType == typeof(Microsoft.Crm.Sdk.CrmNumberProperty)) { var crmNumber = ((Microsoft.Crm.Sdk.CrmNumberProperty)inputProperty).Value; if (!crmNumber.IsNull || !crmNumber.IsNullSpecified) { propValue = crmNumber.Value.ToString(); } } else if (propType == typeof(Microsoft.Crm.Sdk.LookupProperty)) { if (inputProperty.Name.ToString() != "owningbusinessunit") { propValue = ((Microsoft.Crm.Sdk.LookupProperty)inputProperty).Value.Value.ToString(); } } else if (propType == typeof(Microsoft.Crm.Sdk.OwnerProperty)) { propValue = ((Microsoft.Crm.Sdk.OwnerProperty)inputProperty).Value.Value.ToString(); } else if (propType == typeof(Microsoft.Crm.Sdk.StatusProperty)) { propValue = ((Microsoft.Crm.Sdk.StatusProperty)inputProperty).Value.Value.ToString(); } else if (propType == typeof(Microsoft.Crm.Sdk.PicklistProperty)) { var crmPicklist = ((Microsoft.Crm.Sdk.PicklistProperty)inputProperty).Value; if (!crmPicklist.IsNull || !crmPicklist.IsNullSpecified) { propValue = crmPicklist.name; } } else if (propType == typeof(Microsoft.Crm.Sdk.KeyProperty)) { propValue = ((Microsoft.Crm.Sdk.KeyProperty)inputProperty).Value.Value.ToString(); } return(propValue); }