/// <summary> /// 结束属性类型,并将属性值返回 /// </summary> /// <param name="property"></param> /// <returns></returns> private string GetPropertyValue(Property property) { try { Type theType = property.GetType(); if (theType == (new StringProperty()).GetType()) { //字符串 StringProperty theObject = (StringProperty)property; return theObject.Value; } if (theType == (new LookupProperty()).GetType()) { //引用 LookupProperty theObject = (LookupProperty)property; return theObject.Value.name; } if (theType == (new CrmMoneyProperty()).GetType()) { //金钱 CrmMoneyProperty theObject = (CrmMoneyProperty)property; return theObject.Value.formattedvalue; } if (theType == (new CrmNumberProperty ()).GetType()) { //整形数字 CrmNumberProperty theObject = (CrmNumberProperty)property; return theObject.Value.Value.ToString() ; } if (theType == (new CrmBooleanProperty ()).GetType()) { //bool型 CrmBooleanProperty theObject = (CrmBooleanProperty)property; return theObject.Value.name; } if (theType == (new PicklistProperty ()).GetType()) { //Picklist型 PicklistProperty theObject = (PicklistProperty)property; return theObject.Value.name; } if (theType == (new CrmDateTimeProperty ()).GetType()) { //datetime型 CrmDateTimeProperty theObject = (CrmDateTimeProperty)property; return theObject.Value.date; } if (theType == (new CrmDecimalProperty()).GetType()) { //十进数型 CrmDecimalProperty theObject = (CrmDecimalProperty)property; return theObject.Value.Value.ToString (); } if (theType == (new CrmFloatProperty()).GetType()) { //浮点数型 CrmFloatProperty theObject = (CrmFloatProperty)property; return theObject.Value.Value.ToString(); } if (theType == (new OwnerProperty ()).GetType()) { //自我型 OwnerProperty theObject = (OwnerProperty)property; return theObject.Value .name ; } if (theType == (new StateProperty ()).GetType()) { //状态型 StateProperty theObject = (StateProperty)property; return theObject.Value; } if (theType == (new KeyProperty ()).GetType()) { //主键型 KeyProperty theObject = (KeyProperty)property; return theObject.Value.Value.ToString (); } if (theType == (new DynamicEntityArrayProperty()).GetType()) { //主键型 DynamicEntityArrayProperty theObject = (DynamicEntityArrayProperty)property; return "无法解析DynamicEntityArrayProperty数据类型,请在代码中添加相应的解释!"; } throw new Exception("无法解析此数据类型,请在代码中添加相应的解释!"); } catch (Exception ex) { throw ex; } }