public bool UpdateBasicData(Guid objectCustomFieldId, object value, BasicCustomFieldTypeEnum basicCustomFieldType, CustomFieldTypeFlag customFieldTypeFlag) { BasicCustomFieldTypeBOBase basicCustomFieldTypeBO = null; switch (basicCustomFieldType) { case BasicCustomFieldTypeEnum.STRING: basicCustomFieldTypeBO = new CustomFieldDataStringBO(); break; case BasicCustomFieldTypeEnum.DATETIME: basicCustomFieldTypeBO = new CustomFieldDataDateTimeBO(); break; case BasicCustomFieldTypeEnum.FLOAT: basicCustomFieldTypeBO = new ObjectCustomFieldDataFloatBO(); break; case BasicCustomFieldTypeEnum.INTEGER: basicCustomFieldTypeBO = new ObjectCustomFieldDataIntegerBO(); break; default: break; } return(basicCustomFieldTypeBO.UpdateCustomFieldData(objectCustomFieldId, value, customFieldTypeFlag)); }
public bool UpdateBasicData(Guid cmsObjectId, Guid objectTypeCustomFieldId, object value, BasicCustomFieldTypeEnum basicCustomFieldType, CustomFieldTypeFlag customFieldTypeFlag) { Session session = null; try { session = XpoHelper.GetNewSession(); ObjectCustomFieldBO objectCustomFieldBO = new ObjectCustomFieldBO(); ObjectCustomField objectCustomField = objectCustomFieldBO.GetObjectCustomField(session, cmsObjectId, objectTypeCustomFieldId); if (objectCustomField == null) { throw new Exception("Could not found ObjectCustomField"); } BasicCustomFieldTypeBOBase basicCustomFieldTypeBO = null; switch (basicCustomFieldType) { case BasicCustomFieldTypeEnum.STRING: basicCustomFieldTypeBO = new CustomFieldDataStringBO(); break; case BasicCustomFieldTypeEnum.DATETIME: basicCustomFieldTypeBO = new CustomFieldDataDateTimeBO(); break; case BasicCustomFieldTypeEnum.FLOAT: basicCustomFieldTypeBO = new ObjectCustomFieldDataFloatBO(); break; case BasicCustomFieldTypeEnum.INTEGER: basicCustomFieldTypeBO = new ObjectCustomFieldDataIntegerBO(); break; default: break; } return(basicCustomFieldTypeBO.UpdateCustomFieldData(objectCustomField.ObjectCustomFieldId, value, customFieldTypeFlag)); } catch (Exception) { throw; } finally { if (session != null) { session.Dispose(); } } }
public bool UpdateUserDefinedListData(Guid objectCustomFieldId, IEnumerable <Guid> itemIds, CustomFieldTypeFlag customFieldTypeFlag) { ObjectCustomFieldDataUserDefinedListBO objectCustomFieldDataUserDefinedListBO = new ObjectCustomFieldDataUserDefinedListBO(); return(objectCustomFieldDataUserDefinedListBO .UpdateCustomFieldData(objectCustomFieldId, itemIds, customFieldTypeFlag)); }
private bool AttachObjectCustomFieldWithDefaultValue(Session session , DAL.CMS.ObjectDocument.Object CMSObject , NAS.DAL.CMS.ObjectDocument.ObjectTypeCustomField objectTypeCustomField , CustomFieldTypeFlag option) { try { //Create ObjectCustomField ObjectCustomField objectCustomField = new ObjectCustomField(session) { ObjectCustomFieldId = Guid.NewGuid(), ObjectId = CMSObject, ObjectTypeCustomFieldId = objectTypeCustomField, CustomFieldType = option.Value }; objectCustomField.Save(); //Insert default value for custom field CustomFieldData customFieldData = null; string customFieldTypeCode = objectTypeCustomField.CustomFieldId.CustomFieldTypeId.Code; BasicCustomFieldTypeEnum basicCustomFieldType = BasicCustomFieldTypeEnum.NONE; bool isBasicType = Enum.TryParse <BasicCustomFieldTypeEnum>(customFieldTypeCode, out basicCustomFieldType); if (isBasicType) { customFieldData = InitDefaultDataForBasicCustomFieldType(session, (BasicCustomFieldTypeEnum)Enum.Parse(typeof(BasicCustomFieldTypeEnum), customFieldTypeCode), objectTypeCustomField.CustomFieldId.CustomFieldId); if (customFieldData != null) { //Insert into ObjectCustomFieldData ObjectCustomFieldData defaultObjectCustomFieldData = new ObjectCustomFieldData(session) { ObjectCustomFieldDataId = Guid.NewGuid(), CustomFieldDataId = customFieldData, ObjectCustomFieldId = objectCustomField }; defaultObjectCustomFieldData.Save(); } } return(true); } catch (Exception) { throw; } }
public bool UpdatePredefinitionData(Guid objectCustomFieldId, IEnumerable <Guid> refIds, PredefinitionCustomFieldTypeEnum predefinitionCustomFieldType, CustomFieldTypeFlag customFieldTypeFlag) { ObjectCustomFieldDataPreDefinitionBO objectCustomFieldDataPreDefinitionBO = new ObjectCustomFieldDataPreDefinitionBO(); return(objectCustomFieldDataPreDefinitionBO.UpdateCustomFieldData( objectCustomFieldId, refIds, predefinitionCustomFieldType, customFieldTypeFlag)); }
//private object _NewBasicDataValue; //private BasicCustomFieldTypeEnum _BasicCustomFieldTypeEnum; //private List<NASCustomFieldPredefinitionData> _NewBuiltInData; //private List<Guid> _NewCustomFieldDataIds; public CustomFieldDataEntityBase ( Guid objectCustomFieldId, Guid objectTypeCustomFieldId, Guid cmsObjectId, Guid customFieldId, CustomFieldTypeFlag customFieldTypeFlag, CustomFieldCategoryEnum customFieldCategory ) { this._ObjectCustomFieldId = objectCustomFieldId; this._ObjectTypeCustomFieldId = objectTypeCustomFieldId; this._CMSObjectId = cmsObjectId; this._CustomFieldId = customFieldId; this._CustomFieldCategory = customFieldCategory; this._ObjectCustomFieldFlag = customFieldTypeFlag; }
public UserDefinedListCustomFieldDataEntity ( Guid objectCustomFieldId, Guid objectTypeCustomFieldId, Guid cmsObjectId, Guid customFieldId, CustomFieldTypeFlag customFieldTypeFlag, CustomFieldCategoryEnum customFieldCategory, IEnumerable <Guid> userDefinedItemIds ) : base(objectCustomFieldId, objectTypeCustomFieldId, cmsObjectId, customFieldId, customFieldTypeFlag, customFieldCategory) { this._UserDefinedItemIds = userDefinedItemIds; }
public PredefinitionCustomFieldEntity ( Guid objectCustomFieldId, Guid objectTypeCustomFieldId, Guid cmsObjectId, Guid customFieldId, CustomFieldTypeFlag customFieldTypeFlag, CustomFieldCategoryEnum customFieldCategory, IEnumerable <Guid> predefinitionRefIds, string predefinitionType ) : base(objectCustomFieldId, objectTypeCustomFieldId, cmsObjectId, customFieldId, customFieldTypeFlag, customFieldCategory) { this._PredefinitionRefIds = predefinitionRefIds; this._PredefinitionType = predefinitionType; }
public BasicCustomFieldDataEntity ( Guid objectCustomFieldId, Guid objectTypeCustomFieldId, Guid cmsObjectId, Guid customFieldId, CustomFieldTypeFlag customFieldTypeFlag, CustomFieldCategoryEnum customFieldCategory, object basicDataValue, BasicCustomFieldTypeEnum basicCustomFieldTypeEnum ) : base(objectCustomFieldId, objectTypeCustomFieldId, cmsObjectId, customFieldId, customFieldTypeFlag, customFieldCategory) { this._DataValue = basicDataValue; this._BasicCustomFieldTypeEnum = basicCustomFieldTypeEnum; }
public bool UpdatePredefinitionData(Guid cmsObjectId, Guid objectTypeCustomFieldId, IEnumerable <Guid> refIds, PredefinitionCustomFieldTypeEnum predefinitionCustomFieldType, CustomFieldTypeFlag customFieldTypeFlag) { Session session = null; try { session = XpoHelper.GetNewSession(); ObjectCustomFieldDataPreDefinitionBO objectCustomFieldDataPreDefinitionBO = new ObjectCustomFieldDataPreDefinitionBO(); ObjectCustomFieldBO objectCustomFieldBO = new ObjectCustomFieldBO(); ObjectCustomField objectCustomField = objectCustomFieldBO.GetObjectCustomField(session, cmsObjectId, objectTypeCustomFieldId); if (objectCustomField == null) { throw new Exception("Could not found ObjectCustomField"); } return(objectCustomFieldDataPreDefinitionBO.UpdateCustomFieldData( objectCustomField.ObjectCustomFieldId, refIds, predefinitionCustomFieldType, customFieldTypeFlag)); } catch (Exception) { throw; } finally { if (session != null) { session.Dispose(); } } }
public NAS.DAL.CMS.ObjectDocument.Object CreateCMSObject(Session session, ObjectTypeEnum type, params ObjectCustomFieldOption[] options) { NAS.DAL.CMS.ObjectDocument.Object CMSObject = null; try { //Get object type NAS.DAL.CMS.ObjectDocument.ObjectType CMSObjectType = ObjectType.GetDefault(session, type); //Create new CMS Object CMSObject = new DAL.CMS.ObjectDocument.Object(session) { ObjectId = Guid.NewGuid(), ObjectTypeId = CMSObjectType }; CMSObject.Save(); foreach (var objectTypeCustomField in CMSObjectType.ObjectTypeCustomFields) { CustomFieldTypeFlag flag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_DEFAULT; if (options.Length > 0) { ObjectCustomFieldOption option = options.Where(r => r.CustomFieldId == objectTypeCustomField.CustomFieldId.CustomFieldId).FirstOrDefault(); if (option != null) { flag = option.ObjectCustomFieldFlag; } } AttachObjectCustomFieldWithDefaultValue(session, CMSObject, objectTypeCustomField, flag); } return(CMSObject); } catch (Exception) { throw; } }
public override bool UpdateCustomFieldData(Guid objectCustomFieldId, object value, CustomFieldTypeFlag flag) { UnitOfWork uow = null; try { uow = XpoHelper.GetNewUnitOfWork(); //Get ObjectCustomField by Id ObjectCustomField objectCustomField = uow.GetObjectByKey <ObjectCustomField>(objectCustomFieldId); if (objectCustomField.ObjectCustomFieldDatas.FirstOrDefault() != null) { objectCustomField.CustomFieldType = flag.Value; uow.FlushChanges(); CustomFieldDataString customFieldData = (CustomFieldDataString)objectCustomField.ObjectCustomFieldDatas .FirstOrDefault().CustomFieldDataId; customFieldData.StringValue = (string)value; ObjectBO objectBO = new ObjectBO(); DynamicObjectListSerializeDataItem dataitem = new DynamicObjectListSerializeDataItem() { ObjectCustomFieldId = objectCustomFieldId, CustomFieldName = customFieldData.CustomFieldId.Name, CustomFieldData = customFieldData.StringValue }; objectBO.SetDynamicObjectListItem(uow, objectCustomField.ObjectId.ObjectId, dataitem); uow.CommitChanges(); } else { throw new Exception(); } return(true); } catch (Exception) { throw; } finally { if (uow != null) { uow.Dispose(); } } }
public bool UpdateCustomFieldData(Guid objectCustomFieldId, IEnumerable <Guid> refIds, PredefinitionCustomFieldTypeEnum preDefinitionType, CustomFieldTypeFlag flag) { bool ret = false; UnitOfWork uow = null; try { uow = XpoHelper.GetNewUnitOfWork(); ObjectCustomField objectCustomField = uow.GetObjectByKey <ObjectCustomField>(objectCustomFieldId); objectCustomField.CustomFieldType = flag.Value; uow.FlushChanges(); NAS.DAL.CMS.ObjectDocument.CustomField customField = objectCustomField.ObjectTypeCustomFieldId.CustomFieldId; //Delete all old data uow.Delete(objectCustomField.ObjectCustomFieldDatas); uow.FlushChanges(); //Insert new data for object if (refIds != null) { foreach (var refId in refIds) { PredefinitionData predefinitionData = new PredefinitionData(uow) { CustomFieldId = customField, PredefinitionType = Enum.GetName(typeof(PredefinitionCustomFieldTypeEnum), preDefinitionType), RefId = refId }; //predefinitionData.Save(); ObjectCustomFieldData objectCustomFieldData = new ObjectCustomFieldData(uow) { CustomFieldDataId = predefinitionData, ObjectCustomFieldId = objectCustomField }; //objectCustomFieldData.Save(); uow.FlushChanges(); } } ICustomFieldDataPreDefinitionDataGetter getter = GetDataGetter(preDefinitionType); ObjectBO objectBO = new ObjectBO(); DynamicObjectListSerializeDataItem dataitem = new DynamicObjectListSerializeDataItem() { ObjectCustomFieldId = objectCustomFieldId, CustomFieldName = customField.Name, CustomFieldData = getter.GetData(objectCustomFieldId).ToString() }; objectBO.SetDynamicObjectListItem(uow, objectCustomField.ObjectId.ObjectId, dataitem); uow.CommitChanges(); ret = true; return(ret); } catch (Exception) { throw; } finally { if (uow != null) { uow.Dispose(); } } }
public CustomFieldDataEntityBase GetObjectCustomFieldData(ObjectCustomField objectCustomField) { try { CustomFieldDataEntityBase ret = null; if (objectCustomField == null) { return(null); } //Determine CustomFieldCategoryEnum string customFieldTypeString = objectCustomField.ObjectTypeCustomFieldId.CustomFieldId.CustomFieldTypeId.Code; CustomFieldTypeEnum customFieldTypeEnum; bool isParseSuccess = Enum.TryParse <CustomFieldTypeEnum>(customFieldTypeString, out customFieldTypeEnum); if (!isParseSuccess) { throw new Exception(String.Format("Not supported the CustomFieldType '{0}'", customFieldTypeString)); } var customFieldData = objectCustomField.ObjectCustomFieldDatas.Select(r => r.CustomFieldDataId); if (customFieldData == null || customFieldData.Count() == 0) { return(null); } ObjectCustomFieldData objectCustomFieldData = customFieldData.First().ObjectCustomFieldDatas.First(); CustomFieldTypeFlag customFieldTypeFlag = CustomFieldTypeFlag.Parse(objectCustomField.CustomFieldType); #region User defined list data type if (customFieldTypeEnum == CustomFieldTypeEnum.MULTI_CHOICE_LIST || customFieldTypeEnum == CustomFieldTypeEnum.SINGLE_CHOICE_LIST) { ret = new UserDefinedListCustomFieldDataEntity( objectCustomFieldData.ObjectCustomFieldId.ObjectCustomFieldId, objectCustomFieldData.ObjectCustomFieldId.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId, objectCustomFieldData.ObjectCustomFieldId.ObjectId.ObjectId, objectCustomFieldData.ObjectCustomFieldId.ObjectTypeCustomFieldId.CustomFieldId.CustomFieldId, customFieldTypeFlag, CustomFieldCategoryEnum.LIST, customFieldData.Select(r => r.CustomFieldDataId) ); } #endregion #region Basic data type else if (customFieldTypeEnum == CustomFieldTypeEnum.DATETIME || customFieldTypeEnum == CustomFieldTypeEnum.FLOAT || customFieldTypeEnum == CustomFieldTypeEnum.INTEGER || customFieldTypeEnum == CustomFieldTypeEnum.STRING) { BasicCustomFieldTypeEnum basicType = (BasicCustomFieldTypeEnum)Enum.Parse(typeof(BasicCustomFieldTypeEnum), Enum.GetName(typeof(CustomFieldTypeEnum), customFieldTypeEnum)); object dataValue = null; switch (customFieldTypeEnum) { case CustomFieldTypeEnum.STRING: basicType = BasicCustomFieldTypeEnum.STRING; dataValue = ((CustomFieldDataString)customFieldData.First()).StringValue; break; case CustomFieldTypeEnum.DATETIME: basicType = BasicCustomFieldTypeEnum.DATETIME; dataValue = ((CustomFieldDataDateTime)customFieldData.First()).DateTimeValue; break; case CustomFieldTypeEnum.FLOAT: basicType = BasicCustomFieldTypeEnum.FLOAT; dataValue = ((CustomFieldDataFloat)customFieldData.First()).FloatValue; break; case CustomFieldTypeEnum.INTEGER: basicType = BasicCustomFieldTypeEnum.INTEGER; dataValue = ((CustomFieldDataInt)customFieldData.First()).IntValue; break; } ret = new BasicCustomFieldDataEntity( objectCustomFieldData.ObjectCustomFieldId.ObjectCustomFieldId, objectCustomFieldData.ObjectCustomFieldId.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId, objectCustomFieldData.ObjectCustomFieldId.ObjectId.ObjectId, objectCustomFieldData.ObjectCustomFieldId.ObjectTypeCustomFieldId.CustomFieldId.CustomFieldId, customFieldTypeFlag, CustomFieldCategoryEnum.BASIC, dataValue, basicType); } #endregion Basic data type #region Predefinition data type //Predefinition data type else { string predefinitionTypeString = ((PredefinitionData)customFieldData.First()).PredefinitionType; ret = new PredefinitionCustomFieldEntity( objectCustomFieldData.ObjectCustomFieldId.ObjectCustomFieldId, objectCustomFieldData.ObjectCustomFieldId.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId, objectCustomFieldData.ObjectCustomFieldId.ObjectId.ObjectId, objectCustomFieldData.ObjectCustomFieldId.ObjectTypeCustomFieldId.CustomFieldId.CustomFieldId, customFieldTypeFlag, CustomFieldCategoryEnum.BUILT_IN, customFieldData.Select(r => ((PredefinitionData)r).RefId), predefinitionTypeString ); } #endregion Predefinition data type return(ret); } catch (Exception) { throw; } }
public bool UpdateCustomFieldData(Guid objectCustomFieldId, IEnumerable <Guid> itemIds, CustomFieldTypeFlag customFieldTypeFlag) { return(UpdateSelecteCustomFieldAllDataItems(objectCustomFieldId, itemIds, customFieldTypeFlag)); }
public abstract bool UpdateCustomFieldData(Guid objectCustomFieldId, object value, CustomFieldTypeFlag flag);
/* 2013-12-14 Khoa.Truong INS START * Copy from NAS.BO.CMS.ObjectDocument.ObjectCustomFieldDataMultiSelectionListBO */ private bool UpdateSelecteCustomFieldAllDataItems(Guid objectCustomFieldId, IEnumerable <Guid> list, CustomFieldTypeFlag customFieldTypeFlag) { using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork()) { try { ObjectCustomField objectCustomField = uow.GetObjectByKey <ObjectCustomField>(objectCustomFieldId); if (objectCustomField == null) { throw new Exception("The key is not exist in ObjectCustomField"); } objectCustomField.CustomFieldType = customFieldTypeFlag.Value; uow.FlushChanges(); int cnt = objectCustomField.ObjectCustomFieldDatas.Count; if (objectCustomField.ObjectCustomFieldDatas != null && cnt > 0) { uow.Delete(objectCustomField.ObjectCustomFieldDatas); uow.FlushChanges(); } foreach (Guid g in list) { AddItemToSelectedCustomFieldDataItems(uow, objectCustomFieldId, g); } uow.FlushChanges(); objectCustomField = uow.GetObjectByKey <ObjectCustomField>(objectCustomFieldId); string displayText = String.Empty; foreach (var item in objectCustomField.ObjectCustomFieldDatas) { if (objectCustomField.ObjectCustomFieldDatas.IndexOf(item) == 0) { displayText = ((CustomFieldDataString)item.CustomFieldDataId).StringValue; } else { displayText += String.Format(";{0}", ((CustomFieldDataString)item.CustomFieldDataId).StringValue); } } ObjectBO objectBO = new ObjectBO(); DynamicObjectListSerializeDataItem dataitem = new DynamicObjectListSerializeDataItem() { ObjectCustomFieldId = objectCustomFieldId, CustomFieldName = objectCustomField.ObjectTypeCustomFieldId.CustomFieldId.Name, CustomFieldData = displayText }; objectBO.SetDynamicObjectListItem(uow, objectCustomField.ObjectId.ObjectId, dataitem); uow.CommitChanges(); return(true); } catch { //uow.ExplicitRollbackTransaction(); throw; } } }