public static LTD_InfoCategory GetLtdInfoCategory(string infoCategoryName) { LTD_InfoCategory ltdInfoCategory = null; long userId = UtilsSecurity.GetUserId(); Database db = HaveDb(); if (db != null) { long totalPages = 0; long totalItems = 0; List<LTD_InfoCategory> categoryList = GetPagedLtdInfoCategory(1, 1, out totalPages, out totalItems, "", " Where InfoCategoryName=@0 and UserID=@1", infoCategoryName, userId); if (totalItems > 0) { ltdInfoCategory = categoryList[0]; } } else { Dictionary<Guid, LTD_InfoCategory> allLtdInfoCategoryList = FileSource.LoadLTDInfoCategoryData(); foreach (KeyValuePair<Guid, LTD_InfoCategory> item in allLtdInfoCategoryList) { if ((item.Value.InfoCategoryName == infoCategoryName) && (item.Value.UserID == userId)) { ltdInfoCategory = item.Value; break; } } } return ltdInfoCategory; }
public static string GetListAllItemView(long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, long infoSectionId) { string message = ""; if (itemsPerPage == 0) { itemsPerPage = UtilsGeneric.DefaultInnerItemsPerPage; } long totalDetails; long totalItems; string htmlTextItemList = ""; string htmlAddItemList = ""; #region Add Link LTD_InfoSection ltdInfoSection = DataInfoList.GetLtdInfoSection(infoSectionId); if (ltdInfoSection != null) { LTD_InfoPage ltdInfoPage = DataInfoList.GetLtdInfoPage(ltdInfoSection.InfoPageID); if (UtilsSecurity.HaveAuthorRoleEnabled() == true) { if ((ltdInfoPage != null) && (ltdInfoPage.UserID == UtilsSecurity.GetUserId())) { TemplateInfoDetailSaveAdd saveAdd = new TemplateInfoDetailSaveAdd { DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix, InfoSectionId = infoSectionId.ToString(), }; htmlAddItemList = saveAdd.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); } } } #endregion #region Get Fill List #region Get Detaild Data List <LTD_InfoDetail> ltdDetailList = new List <LTD_InfoDetail>(); if ((UtilsSecurity.HaveAdminRole() == true) || (UtilsSecurity.HaveAuthorRoleEnabled() == true)) { ltdDetailList = DataInfoList.GetPagedLtdInfoDetail(infoSectionId, false, pageNo, itemsPerPage, out totalDetails, out totalItems); } else { ltdDetailList = DataInfoList.GetPagedLtdInfoDetail(infoSectionId, true, pageNo, itemsPerPage, out totalDetails, out totalItems); } #endregion if (ltdDetailList.Count > 0) { #region Get Detail Details string topDetailrDetails = UtilsGeneric.GetItemPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalDetails, RefreshListFunctionName, infoSectionId.ToString()); string bottomDetailrDetails = UtilsGeneric.GetLinkPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalDetails, totalItems, RefreshListFunctionName, infoSectionId.ToString(), false); #endregion #region Append Top Details if (topDetailrDetails.Trim().Length > 0) { htmlTextItemList += topDetailrDetails; } #endregion #region Append Items int index = 0; for (; index < ltdDetailList.Count; index++) { LTD_InfoDetail ltdDetail = ltdDetailList[index]; string htmlTextItemTemplate = GetListSingleItemView(ltdDetail, pageNo, itemsPerPage, dataIndex, templateSuffix, infoSectionId); htmlTextItemList += htmlTextItemTemplate; } #endregion #region Append Bottom Detailr if (bottomDetailrDetails.Trim().Length > 0) { htmlTextItemList += bottomDetailrDetails; } #endregion } #endregion #region Set Fill List if ((htmlTextItemList.Length == 0) && (UtilsSecurity.HaveAuthorRoleEnabled() == true)) { //TemplateInfoDetailListDetailEmpty listDetailEmpty = new TemplateInfoDetailListDetailEmpty //{ // DataIndex = dataIndex.ToString(), // PageNo = pageNo.ToString(), // ItemsPerPage = itemsPerPage.ToString(), // TemplateSuffix = templateSuffix, // InfoSectionId = infoSectionId.ToString(), //}; //htmlTextItemList = listDetailEmpty.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); } #endregion return(htmlAddItemList + htmlTextItemList); }
private static string GetListSingleItemView(LTD_InfoDetail ltdDetail, long pageNo, long itemsPerDetail, long dataIndex, string templateSuffix, long infoSectionId) { string htmlTextItem = ""; LTD_InfoPage ltdInfoPage = DataInfoList.GetLtdInfoPage(ltdDetail.InfoPageID); if ((ltdDetail != null) && (ltdInfoPage != null)) { string message; List <TemplateInfoDetailListDetailItem.EditAction> editActionList = new List <TemplateInfoDetailListDetailItem.EditAction>(); if (((UtilsSecurity.HaveAdminRole() == true) && (UtilsSecurity.HaveAuthorRoleEnabled() == true)) || ((UtilsSecurity.HaveAuthorRoleEnabled() == true) && (ltdInfoPage.UserID == UtilsSecurity.GetUserId()))) { editActionList.Add(new TemplateInfoDetailListDetailItem.EditAction { Id = ltdDetail.InfoDetailID.ToString(), DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerDetail.ToString(), TemplateSuffix = templateSuffix, InfoSectionId = infoSectionId.ToString(), }); } var templateItem = new TemplateInfoDetailListDetailItem { InfoDetailName = ltdDetail.InfoDetailName, InfoDetailDescription = ltdDetail.InfoDetailDescription, IsInActive = !ltdDetail.IsActive, EditActionList = editActionList }; htmlTextItem = templateItem.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); } return(htmlTextItem); }
private static string GetListSingleItemView(LTD_InfoSection ltdSection, long pageNo, long itemsPerSection, long dataIndex, string templateSuffix, long infoPageId, long recordCount, bool asyncLoading) { string htmlTextItem = ""; LTD_InfoPage ltdInfoPage = DataInfoList.GetLtdInfoPage(infoPageId); if ((ltdSection != null) && (ltdInfoPage != null)) { string message; List <TemplateInfoSectionListDetailItem.EditAction> editActionList = new List <TemplateInfoSectionListDetailItem.EditAction>(); List <TemplateInfoSectionListDetailItem.AsyncAction> asyncActionList = new List <TemplateInfoSectionListDetailItem.AsyncAction>(); if (((UtilsSecurity.HaveAdminRole() == true) && (UtilsSecurity.HaveAuthorRoleEnabled() == true)) || ((UtilsSecurity.HaveAuthorRoleEnabled() == true) && (ltdInfoPage.UserID == UtilsSecurity.GetUserId()))) { editActionList.Add(new TemplateInfoSectionListDetailItem.EditAction { Id = ltdSection.InfoSectionID.ToString(), DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerSection.ToString(), TemplateSuffix = templateSuffix, InfoPageId = infoPageId.ToString(), }); } string infoDetailListView = ""; string infoDetailSaveView = ""; if ((ltdInfoPage.AsyncLoading == false) || ((ltdInfoPage.AsyncLoading == true) && (asyncLoading == false))) { infoDetailListView = InfoDetailView.GetView(ltdSection.InfoSectionID, dataIndex + 1, templateSuffix, false, true, true, false); } else { asyncActionList.Add(new TemplateInfoSectionListDetailItem.AsyncAction { Id = ltdSection.InfoSectionID.ToString(), DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerSection.ToString(), TemplateSuffix = templateSuffix, }); infoDetailSaveView = InfoDetailView.GetView(ltdSection.InfoSectionID, dataIndex + 1, templateSuffix, false, false, false, false); } var templateListDetailItem = new TemplateInfoSectionListDetailItem { InfoSectionName = ltdSection.InfoSectionName, InfoSectionDescription = ltdSection.InfoSectionDescription, IsInActive = !ltdSection.IsActive, EditActionList = editActionList, AsyncActionList = asyncActionList, InfoDetailView = infoDetailSaveView + infoDetailListView }; htmlTextItem = templateListDetailItem.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); } return(htmlTextItem); }
private static string GetListSingleItemView(LTD_InfoPage ltdInfoPage, long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, long recordIndex, bool asyncLoading) { string htmlTextItem = ""; if (ltdInfoPage != null) { string message; List <TemplateInfoPageListDetailItem.EditAction> editActionList = new List <TemplateInfoPageListDetailItem.EditAction>(); List <TemplateInfoPageListDetailItem.AsyncAction> asyncActionList = new List <TemplateInfoPageListDetailItem.AsyncAction>(); if (((UtilsSecurity.HaveAdminRole() == true) && (UtilsSecurity.HaveAuthorRoleEnabled() == true)) || ((UtilsSecurity.HaveAuthorRoleEnabled() == true) && (ltdInfoPage.UserID == UtilsSecurity.GetUserId()))) { editActionList.Add(new TemplateInfoPageListDetailItem.EditAction { Id = ltdInfoPage.InfoPageID.ToString(), DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix }); } string infoCategoryName = ""; LTD_InfoCategory ltdInfoCategory = DataInfoList.GetLtdInfoCategory(ltdInfoPage.InfoCategoryID); if (ltdInfoCategory != null) { infoCategoryName = ltdInfoCategory.InfoCategoryName; } string infoSectionListView = ""; string infoSectionSaveView = ""; if ((ltdInfoPage.AsyncLoading == false) || ((ltdInfoPage.AsyncLoading == true) && (asyncLoading == false))) { infoSectionListView = InfoSectionView.GetView(ltdInfoPage.InfoPageID, dataIndex + 1, templateSuffix, false, true, true, false); } else { asyncActionList.Add(new TemplateInfoPageListDetailItem.AsyncAction { DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix, AsyncLoading = asyncLoading.ToString().ToLower(), InfoPageId = ltdInfoPage.InfoPageID.ToString(), }); infoSectionSaveView = InfoSectionView.GetView(ltdInfoPage.InfoPageID, dataIndex + 1, templateSuffix, false, false, false, false); } List <TemplateInfoPageListDetailItem.CommentView> commentViewList = new List <TemplateInfoPageListDetailItem.CommentView>(); if ((ltdInfoPage.Commentable == true) && (UtilsSecurity.IsAuthenticated() == true)) { if ((UtilsSecurity.HaveRole(ltdInfoPage.CommentorRoleList, false) == true)) //|| ((ltdInfoPage.IsPublic == true) && (ltdInfoPage.CommentorRoleList.Contains(UtilsSecurity.GuestRole) == true))) { bool allowPublicComments = false; string commentViewHtml = DataView.GetView(true, ltdInfoPage.InfoPageID, templateSuffix, false, CommonRefType.PageInfo, ltdInfoPage.InfoPageID, CommonDataType.CommentData, "Comment", false, false, false, false, false, false, false, true, true, "Add Comment", "Edit Comment", "Reply", allowPublicComments); commentViewList.Add(new TemplateInfoPageListDetailItem.CommentView { CommentViewDetail = commentViewHtml, }); } } var templateListDetailItem = new TemplateInfoPageListDetailItem { InfoPageName = ltdInfoPage.InfoPageName, InfoPageDescription = ltdInfoPage.InfoPageDescription, InfoCategoryName = infoCategoryName, CreatedBy = UtilsSecurity.GetUserName(ltdInfoPage.CreatedUserID), LastUpdateDate = ltdInfoPage.LastUpdateDate.ToString(UtilsGeneric.DefaultDateFormat), //ExpiryDate = ltdInfoPage.ExpiryDate.ToString(AppCommon.DateFormat), IsInActive = !ltdInfoPage.IsActive, IsDeleted = ltdInfoPage.IsDeleted, EditActionList = editActionList, AsyncActionList = asyncActionList, InfoSectionView = infoSectionSaveView + infoSectionListView, CommentViewList = commentViewList, }; htmlTextItem = templateListDetailItem.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); } return(htmlTextItem); }
public static string GetListAllItemView(long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, bool asyncLoading, long filterInfoCategoryId, string filterInfoPage, bool filterInfoPagePublic, long filterCreatedUserId, bool hideFilter) { string message = ""; if (itemsPerPage == 0) { itemsPerPage = UtilsGeneric.DefaultItemsPerPage; } long totalPages; long totalItems; string htmlTextItemList = ""; string htmlAddItemList = ""; string htmlFilterItemList = ""; //if ((filterInfoCategoryId > 0) || (filterInfoPage.Trim().Length > 0) || (filterInfoPagePublic == true)) hideFilter = false; #region Filter Section List <TemplateInfoPageListDetailFilter.ShowPublicChecked> showPublicCheckedList = new List <TemplateInfoPageListDetailFilter.ShowPublicChecked>(); List <TemplateInfoPageListDetailFilter.ShowPublicUnChecked> showPublicUnCheckedList = new List <TemplateInfoPageListDetailFilter.ShowPublicUnChecked>(); if (filterInfoPagePublic == true) { showPublicCheckedList.Add(new TemplateInfoPageListDetailFilter.ShowPublicChecked { DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix, AsyncLoading = asyncLoading.ToString().ToLower() }); } else { showPublicUnCheckedList.Add(new TemplateInfoPageListDetailFilter.ShowPublicUnChecked { DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix, AsyncLoading = asyncLoading.ToString().ToLower() }); } #region Get Info Category List List <LTD_InfoCategory> ltdInfoCategoryList = DataInfoList.GetAllActiveLtdInfoCategory(); bool firstRecord = true; List <TemplateInfoPageListDetailFilter.InfoCategoryItem> infoCategoryItemList = new List <TemplateInfoPageListDetailFilter.InfoCategoryItem>(); if (ltdInfoCategoryList.Count == 0) { infoCategoryItemList.Add(new TemplateInfoPageListDetailFilter.InfoCategoryItem { InfoCategoryText = "No Info Category Found", InfoCategoryValue = "1", InfoCategorySelected = true }); } else { infoCategoryItemList.Add(new TemplateInfoPageListDetailFilter.InfoCategoryItem { InfoCategoryText = "Select Category Filter", InfoCategoryValue = "0", InfoCategorySelected = (filterInfoCategoryId == 0) }); if (filterInfoCategoryId == 0) { firstRecord = false; } } if (filterInfoCategoryId != 0) { LTD_InfoCategory ltdInfoCategory = DataInfoList.GetLtdInfoCategory(filterInfoCategoryId); if (ltdInfoCategory != null) { infoCategoryItemList.Add(new TemplateInfoPageListDetailFilter.InfoCategoryItem { InfoCategoryText = ltdInfoCategory.InfoCategoryName, InfoCategoryValue = ltdInfoCategory.InfoCategoryID.ToString(), InfoCategorySelected = true, }); firstRecord = false; } } foreach (LTD_InfoCategory ltdInfoCategory in ltdInfoCategoryList) { if (ltdInfoCategory.InfoCategoryID != filterInfoCategoryId) { if ((filterInfoCategoryId == 0) && (firstRecord == true)) { infoCategoryItemList.Add(new TemplateInfoPageListDetailFilter.InfoCategoryItem { InfoCategoryText = ltdInfoCategory.InfoCategoryName, InfoCategoryValue = ltdInfoCategory.InfoCategoryID.ToString(), InfoCategorySelected = true }); } else { infoCategoryItemList.Add(new TemplateInfoPageListDetailFilter.InfoCategoryItem { InfoCategoryText = ltdInfoCategory.InfoCategoryName, InfoCategoryValue = ltdInfoCategory.InfoCategoryID.ToString(), InfoCategorySelected = false, }); } } firstRecord = false; } #endregion long selectedUserId = 0; string selectUserDetailsHtml = ""; string userSelectNameId = "infoPageUserFilter"; if (UtilsSecurity.HaveAdminRole() == true) { selectedUserId = UtilsSecurity.GetUserId(); if (filterCreatedUserId > 0) { selectedUserId = filterCreatedUserId; } #region User Select View long userViewDataIndex = dataIndex + 5; string showFunctionScript = ""; string selectChangeCallback = " filterInfoPageList(" + pageNo + "," + itemsPerPage + "," + dataIndex + ",'" + templateSuffix + "'," + asyncLoading.ToString().ToLower() + ") "; selectUserDetailsHtml = UserAdminView.GetUserSelectView(userViewDataIndex, 1, 25, templateSuffix, selectedUserId, false, showFunctionScript, "", userSelectNameId, selectChangeCallback, out selectedUserId); #endregion } TemplateInfoPageListDetailFilter listDetailFilter = new TemplateInfoPageListDetailFilter { InfoPageListFilterHidden = hideFilter, ShowPublicCheckedList = showPublicCheckedList, ShowPublicUnCheckedList = showPublicUnCheckedList, InfoCategoryItemList = infoCategoryItemList, InfoPageFilter = filterInfoPage, DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix, AsyncLoading = asyncLoading.ToString().ToLower(), UserSelect = selectUserDetailsHtml, }; htmlFilterItemList = listDetailFilter.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); #endregion #region Add Link List <TemplateInfoPageSaveAdd.AddAction> addActionList = new List <TemplateInfoPageSaveAdd.AddAction>(); if (UtilsSecurity.HaveAuthorRoleEnabled() == true) { addActionList.Add(new TemplateInfoPageSaveAdd.AddAction { DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix, }); } TemplateInfoPageSaveAdd templateSaveAdd = new TemplateInfoPageSaveAdd { AddActionList = addActionList, }; htmlAddItemList = templateSaveAdd.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); #endregion #region Get Fill List #region Get Paged Data List <LTD_InfoPage> ltdInfoPageList = new List <LTD_InfoPage>(); if (UtilsSecurity.IsAuthenticated() == true) { if (filterInfoPagePublic == true) { ltdInfoPageList = DataInfoList.GetPublicPagedLtdInfoPage(filterInfoCategoryId, filterInfoPage, selectedUserId, pageNo, itemsPerPage, out totalPages, out totalItems); } else { if (UtilsSecurity.HaveAdminRole() == true) { ltdInfoPageList = DataInfoList.GetPagedLtdInfoPage(filterInfoCategoryId, filterInfoPage, selectedUserId, pageNo, itemsPerPage, out totalPages, out totalItems); } else { ltdInfoPageList = DataInfoList.GetUserPagedLtdInfoPage(filterInfoCategoryId, filterInfoPage, pageNo, itemsPerPage, out totalPages, out totalItems); } long commonTotalPages = 0; long commonTotalItems = 0; List <LTD_InfoPage> commonltdInfoPageList = DataInfoList.GetCommonPagedLtdInfoPage(filterInfoCategoryId, filterInfoPage, pageNo, itemsPerPage, out commonTotalPages, out commonTotalItems); if (commonltdInfoPageList.Count > 0) { ltdInfoPageList.AddRange(commonltdInfoPageList); totalItems = totalItems + commonTotalItems; if (commonTotalPages > 1) { totalPages = totalPages + commonTotalPages - 1; } } } } else { ltdInfoPageList = DataInfoList.GetPublicPagedLtdInfoPage(filterInfoCategoryId, filterInfoPage, selectedUserId, pageNo, itemsPerPage, out totalPages, out totalItems); } #endregion if (ltdInfoPageList.Count > 0) { #region Get Pager Details string topPagerDetails = UtilsGeneric.GetItemPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalPages, RefreshListFunctionName, asyncLoading.ToString().ToLower()); string bottomPagerDetails = UtilsGeneric.GetLinkPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalPages, totalItems, RefreshListFunctionName, asyncLoading.ToString().ToLower(), false); #endregion #region Append Top Pager if (topPagerDetails.Trim().Length > 0) { htmlTextItemList += topPagerDetails; } #endregion #region Append Items int index = 0; for (; index < ltdInfoPageList.Count; index++) { LTD_InfoPage ltdInfoPage = ltdInfoPageList[index]; string htmlTextItemTemplate = GetListSingleItemView(ltdInfoPage, pageNo, itemsPerPage, dataIndex, templateSuffix, index, asyncLoading); htmlTextItemList += htmlTextItemTemplate; } #endregion #region Append Bottom Pager if (bottomPagerDetails.Trim().Length > 0) { htmlTextItemList += bottomPagerDetails; } #endregion } #endregion #region Set Fill List if (htmlTextItemList.Length == 0) { TemplateInfoPageListDetailEmpty templateListDetailEmpty = new TemplateInfoPageListDetailEmpty { DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix, AsyncLoading = asyncLoading.ToString().ToLower() }; htmlTextItemList = templateListDetailEmpty.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); } #endregion return(htmlFilterItemList + htmlAddItemList + htmlTextItemList); }
public static bool DeleteCndData(long dataId, out string retMessage) { bool ret = false; string message = ""; try { bool validationFail = false; if ((UtilsSecurity.HaveAuthorRole() == false) && (UtilsSecurity.HaveAdminRole() == false)) { message = "Please login as User having Author Role to Delete Data"; validationFail = true; } if (validationFail == false) { if (dataId == 0) { message = "Missing or Empty Data ID Argument"; validationFail = true; } } if (validationFail == false) { CND_Data cndDataExisting = GetCndData(dataId); if (cndDataExisting == null) { message = "The Data with ID [" + dataId.ToString(CultureInfo.InvariantCulture) + "] does not exist"; validationFail = true; } else if (cndDataExisting.UserID != UtilsSecurity.GetUserId()) { if (UtilsSecurity.HaveAdminRole() == false) { message = "You cannot Delete Data of Another User Unless you have Admin Role"; validationFail = true; } } if (cndDataExisting != null) { if (HaveChildCndData(cndDataExisting.DataID) == true) { message = "You cannot Delete this Data Unless you delete all the Child Data of this Data"; validationFail = true; } } } if (validationFail == false) { DataSource.BeginTransaction(); DataSource.DeleteCndData(dataId); DataSource.CompleteTransaction(); ret = true; } } catch (Exception ex) { message = "DBError:" + ex.Message; LogManager.Log(LogLevel.Error, "DataCommon-DeleteCndData", message); } retMessage = message; return(ret); }
public static long SaveCndData(long parentDataId, long dataRefId, long dataRefTypeId, long dataTypeId, string dataValue, bool dataIsActive, bool isPublic, long dataId, out string retMessage) { long id = 0; string message = ""; try { bool validationFail = false; if (isPublic == false) { if ((UtilsSecurity.HaveAdminRole() == false) && (UtilsSecurity.HaveAuthorRole() == false)) { message = "Please login as User Having Admin/Author Role to Save Data"; validationFail = true; } } if (validationFail == false) { if ((dataRefTypeId == 0) || (dataTypeId == 0) || (string.IsNullOrEmpty(dataValue) == true)) { message = "Missing or Empty Data Argument"; validationFail = true; } } CND_Data cndData = new CND_Data(); if (validationFail == false) { if (dataId != 0) { cndData = GetCndData(dataId); if (cndData == null) { message = "The Data having ID [" + dataId + "] cannot be Retrieved"; validationFail = true; } else { if ((cndData.UserID != UtilsSecurity.GetUserId()) && (UtilsSecurity.HaveAdminRole() == false)) { message = "The Data having ID [" + dataId + "] can be edited only the User who created it"; validationFail = true; } } } } Guid parentDataGuid = Guid.Empty; if (validationFail == false) { if (parentDataId != 0) { CND_Data cndDataParent = GetCndData(parentDataId); if (cndDataParent == null) { message = "The Parent Data having ID [" + parentDataId + "] cannot be Retrieved"; validationFail = true; } else { parentDataGuid = cndDataParent.DataGUID; } } } CNS_DataType cnsDataType = GetCnsDataType(dataTypeId); if (validationFail == false) { if (cnsDataType == null) { message = "The DataType [" + dataTypeId + "] does not exist"; validationFail = true; } } CNS_DataRefType cnsDataRefType = GetCnsDataRefType(dataRefTypeId); if (validationFail == false) { if (cnsDataRefType == null) { message = "The DataRefType [" + dataRefTypeId + "] does not exist"; validationFail = true; } } if (validationFail == false) { cndData.IsActive = dataIsActive; if (dataId == 0) { cndData.Sequence = GetMaxCndDataId() + 1; cndData.IsActive = true; } cndData.DataTypeID = cnsDataType.DataTypeID; cndData.DataTypeGUID = cnsDataType.DataTypeGUID; cndData.DataRefTypeID = cnsDataRefType.DataRefTypeID; cndData.DataRefTypeGUID = cnsDataRefType.DataRefTypeGUID; cndData.DataRefID = dataRefId; cndData.DataValue = dataValue; if (parentDataId > 0) { cndData.ParentDataID = parentDataId; cndData.ParentDataGUID = parentDataGuid; } DataSource.BeginTransaction(); if (cndData.DataID == 0) { DataSource.InsertCndData(cndData); id = cndData.DataID; } else { DataSource.UpdateCndData(cndData); id = cndData.DataID; } DataSource.CompleteTransaction(); } } catch (Exception ex) { id = 0; message = "DBError:" + ex.Message; LogManager.Log(LogLevel.Error, "DataCommon-SaveCndData", message); DataSource.AbortTransaction(); } retMessage = message; return(id); }