public static string GetListAllItemView(long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, bool hideDisplay) { string message = ""; long totalPages; long totalItems; string htmlTextItemList = ""; string htmlAddItemList = ""; if ((UtilsSecurity.HaveAdminRole() == false) && (UtilsSecurity.HaveAuthorRole() == false)) { TemplateInfoCategoryView templateView = new TemplateInfoCategoryView { DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix, HideDisplay = hideDisplay.ToString().ToLower(), }; htmlTextItemList = templateView.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); }else { #region Add Link if (UtilsSecurity.HaveAuthorRoleEnabled() == true) { TemplateInfoCategorySaveAdd templateSaveAdd = new TemplateInfoCategorySaveAdd { DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix, }; htmlAddItemList = templateSaveAdd.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); } #endregion #region Get Fill List #region Get Paged Data List<LTD_InfoCategory> ltdInfoCategoryList = new List<LTD_InfoCategory>(); ltdInfoCategoryList = DataInfoList.GetPagedLtdInfoCategory(pageNo, itemsPerPage, out totalPages, out totalItems); #endregion if (ltdInfoCategoryList.Count > 0) { #region Get Pager Details string topPagerDetails = UtilsGeneric.GetItemPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalPages, RefreshListFunctionName, hideDisplay.ToString(CultureInfo.InvariantCulture).ToLower(), true, true); string bottomPagerDetails = UtilsGeneric.GetLinkPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalPages, totalItems, RefreshListFunctionName, hideDisplay.ToString(CultureInfo.InvariantCulture).ToLower()); #endregion #region Append Top Pager if (topPagerDetails.Trim().Length > 0) { htmlTextItemList += topPagerDetails; } #endregion #region Append Items int index = 0; for (; index < ltdInfoCategoryList.Count; index++) { LTD_InfoCategory ltdInfoCategory = ltdInfoCategoryList[index]; string htmlTextItemTemplate = GetListSingleItemView(ltdInfoCategory, pageNo, itemsPerPage, dataIndex, templateSuffix, hideDisplay); htmlTextItemList += htmlTextItemTemplate; } #endregion #region Append Bottom Pager if (bottomPagerDetails.Trim().Length > 0) { htmlTextItemList += bottomPagerDetails; } #endregion } #endregion #region Set Fill List if (htmlTextItemList.Length == 0) { TemplateInfoCategoryListDetailEmpty templateListDetailEmpty = new TemplateInfoCategoryListDetailEmpty { DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix, HideDisplay = hideDisplay.ToString().ToLower(), }; htmlTextItemList = templateListDetailEmpty.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); } #endregion } return 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 string GetSaveDetailView(long infoCategoryId, long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, bool hideDisplay) { string message; string htmlSaveDetail = ""; long revisionNo = 0; string infoCategoryName = ""; bool infoCategoryIsDefault = false; bool infoCategoryIsActive = true; bool infoCategoryIsSystem = false; if ((UtilsSecurity.HaveAdminRole() == false) && (UtilsSecurity.HaveAuthorRole() == false)) { TemplateInfoCategoryView templateView = new TemplateInfoCategoryView { DataIndex = dataIndex.ToString(), PageNo = pageNo.ToString(), ItemsPerPage = itemsPerPage.ToString(), TemplateSuffix = templateSuffix }; htmlSaveDetail = templateView.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); } else { #region Get Category Details if (infoCategoryId > 0) { LTD_InfoCategory ltdInfoCategoryExisting = DataInfoList.GetLtdInfoCategory(infoCategoryId); if (ltdInfoCategoryExisting != null) { infoCategoryName = ltdInfoCategoryExisting.InfoCategoryName; infoCategoryIsDefault = ltdInfoCategoryExisting.IsDefault; infoCategoryIsActive = ltdInfoCategoryExisting.IsActive; //infoCategoryIsSystem = ltdInfoCategoryExisting.IsSystem; revisionNo = ltdInfoCategoryExisting.RevisionNo; } } #endregion #region Set Action bool showUserInfo = false; bool enableSave = true; bool enableDelete = true; if (UtilsSecurity.IsAuthenticated() == false) { showUserInfo = true; enableSave = false; enableDelete = false; } #endregion #region Set Template string addActionHtml = ""; string editActionHtml = ""; if (infoCategoryId == 0) { var templateSaveAdd = new TemplateInfoCategorySaveDetailAdd { AddActionDisabled =!enableSave, DataIndex = dataIndex.ToString("N0", CultureInfo.InvariantCulture), PageNo = pageNo.ToString("N0", CultureInfo.InvariantCulture), ItemsPerPage = itemsPerPage.ToString("N0", CultureInfo.InvariantCulture), TemplateSuffix = templateSuffix, HideDisplay = hideDisplay.ToString().ToLower(), }; addActionHtml = templateSaveAdd.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); } else { var templateSaveEdit = new TemplateInfoCategorySaveDetailEdit { Id = infoCategoryId.ToString(), DataIndex = dataIndex.ToString("N0", CultureInfo.InvariantCulture), PageNo = pageNo.ToString("N0", CultureInfo.InvariantCulture), ItemsPerPage = itemsPerPage.ToString("N0", CultureInfo.InvariantCulture), TemplateSuffix = templateSuffix, HideDisplay = hideDisplay.ToString().ToLower(), SaveActionDisabled = !enableSave, DeleteActionDisabled = !enableDelete, }; editActionHtml = templateSaveEdit.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); } List<TemplateInfoCategorySaveDetail.IsDefaultVisible.IsDefault> isDefaultList = new List<TemplateInfoCategorySaveDetail.IsDefaultVisible.IsDefault>(); List<TemplateInfoCategorySaveDetail.IsDefaultVisible.IsNotDefault> isNotDefaultList = new List<TemplateInfoCategorySaveDetail.IsDefaultVisible.IsNotDefault>(); if (infoCategoryIsDefault == true) { isDefaultList.Add(new TemplateInfoCategorySaveDetail.IsDefaultVisible.IsDefault { DataIndex = dataIndex.ToString(), }); } else { isNotDefaultList.Add(new TemplateInfoCategorySaveDetail.IsDefaultVisible.IsNotDefault { DataIndex = dataIndex.ToString(), }); } List<TemplateInfoCategorySaveDetail.IsDefaultVisible> isDefaultVisibleList = new List<TemplateInfoCategorySaveDetail.IsDefaultVisible>(); if ((infoCategoryId != 0) && (UtilsSecurity.HaveAdminRole() ==true)) { isDefaultVisibleList.Add(new TemplateInfoCategorySaveDetail.IsDefaultVisible { DataIndex = dataIndex.ToString(), IsDefaultList = isDefaultList, IsNotDefaultList = isNotDefaultList, }); } List<TemplateInfoCategorySaveDetail.IsActiveVisible.IsActive> isActiveList = new List<TemplateInfoCategorySaveDetail.IsActiveVisible.IsActive>(); List<TemplateInfoCategorySaveDetail.IsActiveVisible.IsInActive> isInActiveList = new List<TemplateInfoCategorySaveDetail.IsActiveVisible.IsInActive>(); if (infoCategoryIsActive == true) { isActiveList.Add(new TemplateInfoCategorySaveDetail.IsActiveVisible.IsActive { DataIndex = dataIndex.ToString(), }); } else { isInActiveList.Add(new TemplateInfoCategorySaveDetail.IsActiveVisible.IsInActive { DataIndex = dataIndex.ToString(), }); } List<TemplateInfoCategorySaveDetail.IsActiveVisible> isActiveVisibleList = new List<TemplateInfoCategorySaveDetail.IsActiveVisible>(); if (infoCategoryId != 0) { isActiveVisibleList.Add(new TemplateInfoCategorySaveDetail.IsActiveVisible { DataIndex = dataIndex.ToString(), IsActiveList = isActiveList, IsInActiveList = isInActiveList, }); } var templateSaveDetail = new TemplateInfoCategorySaveDetail { //Id = groupId.ToString("N0", CultureInfo.InvariantCulture), DataIndex = dataIndex.ToString(), RevisionNo = revisionNo.ToString("N0", CultureInfo.InvariantCulture), InfoCategoryName =infoCategoryName, InfoCategoryNameDisabled = infoCategoryIsSystem, IsDefaultVisibleList = isDefaultVisibleList, IsActiveVisibleList = isActiveVisibleList, AddAction = addActionHtml, EditAction = editActionHtml, ShowUserInfo = showUserInfo, }; htmlSaveDetail = templateSaveDetail.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message); #endregion } return htmlSaveDetail; }
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); }