예제 #1
0
        public static bool SaveLTDInfoSectionData(Dictionary <Guid, LTD_InfoSection> ltdInfoSectionList)
        {
            bool ret = false;

            if (ltdInfoSectionList.Count > 0)
            {
                List <LTD_InfoSection> ltdInfoSectionValueList = new List <LTD_InfoSection>();
                LTD_InfoSection[]      ltdInfoSectionArray     = new LTD_InfoSection[ltdInfoSectionList.Values.Count];
                ltdInfoSectionList.Values.CopyTo(ltdInfoSectionArray, 0);
                ltdInfoSectionValueList.AddRange(ltdInfoSectionArray);
                ret = JsonStore <LTD_InfoSection> .SaveData(ltdInfoSectionValueList, true);
            }

            return(ret);
        }
예제 #2
0
        public static string GetSaveDetailView(long infoDetailId, long pageNo, long itemsPerDetail, long dataIndex, string templateSuffix, long infoSectionId)
        {
            string message               = "";
            string htmlSaveDetail        = "";
            long   revisionNo            = 0;
            string infoSectionName       = "";
            string infoDetailName        = "";
            string infoDetailDescription = "";
            bool   isActive              = true;
            bool   isDeleted             = false;
            long   sequence              = 0;
            bool   showAdditional        = (infoDetailId != 0);

            if ((UtilsSecurity.HaveAdminRole() == false) && (UtilsSecurity.HaveAuthorRoleEnabled() == false))
            {
                TemplateInfoDetailView view = new TemplateInfoDetailView
                {
                    DataIndex      = dataIndex.ToString(),
                    PageNo         = pageNo.ToString(),
                    ItemsPerPage   = itemsPerDetail.ToString(),
                    TemplateSuffix = templateSuffix,
                    InfoSectionId  = infoSectionId.ToString(),
                };
                htmlSaveDetail = view.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
            }
            else
            {
                #region Get Section Details

                if (infoSectionId > 0)
                {
                    LTD_InfoSection ltdSectionExisting = DataInfoList.GetLtdInfoSection(infoSectionId);
                    if (ltdSectionExisting != null)
                    {
                        infoSectionName = ltdSectionExisting.InfoSectionName;
                    }
                }

                #endregion

                #region Get Detail Details

                if (infoDetailId > 0)
                {
                    LTD_InfoDetail ltdDetailExisting = DataInfoList.GetLtdInfoDetail(infoDetailId);
                    if (ltdDetailExisting != null)
                    {
                        infoDetailName        = ltdDetailExisting.InfoDetailName;
                        infoDetailDescription = ltdDetailExisting.InfoDetailDescription;
                        isActive   = ltdDetailExisting.IsActive;
                        isDeleted  = ltdDetailExisting.IsDeleted;
                        sequence   = ltdDetailExisting.Sequence;
                        revisionNo = ltdDetailExisting.RevisionNo;
                    }
                }

                #endregion

                #region Set Action

                bool showDeleted  = false;
                bool showUserInfo = false;
                bool enableSave   = true;
                bool enableDelete = true;
                if (UtilsSecurity.IsAuthenticated() == false)
                {
                    showUserInfo = true;
                    enableSave   = false;
                    enableDelete = false;
                }

                showDeleted = (!UtilsSecurity.HaveAdminRole() && (infoSectionId > 0));

                #endregion

                #region Set Template

                #region Additional

                List <TemplateInfoDetailSaveDetail.AdditionalVisible> additionalVisibleList = new List <TemplateInfoDetailSaveDetail.AdditionalVisible>();
                if (showAdditional == true)
                {
                    additionalVisibleList.Add(new TemplateInfoDetailSaveDetail.AdditionalVisible
                    {
                        IsActiveHidden  = (infoDetailId == 0),
                        IsActive        = isActive,
                        IsDeletedHidden = !showDeleted,
                        IsDeleted       = isDeleted,
                        SequenceHidden  = (infoDetailId == 0),
                        Sequence        = sequence.ToString(),
                    });
                }

                #endregion

                #region Action

                string addActionHtml  = "";
                string editActionHtml = "";
                if (infoDetailId == 0)
                {
                    var saveDetailAdd = new TemplateInfoDetailSaveDetailAdd
                    {
                        AddActionDisabled = !enableSave,
                        DataIndex         = dataIndex.ToString("N0", CultureInfo.InvariantCulture),
                        PageNo            = pageNo.ToString("N0", CultureInfo.InvariantCulture),
                        ItemsPerPage      = itemsPerDetail.ToString("N0", CultureInfo.InvariantCulture),
                        TemplateSuffix    = templateSuffix,
                        InfoSectionId     = infoSectionId.ToString(),
                    };
                    addActionHtml = saveDetailAdd.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
                }
                else
                {
                    var templateSaveEdit = new TemplateInfoDetailSaveDetailEdit
                    {
                        Id                   = infoDetailId.ToString(),
                        DataIndex            = dataIndex.ToString("N0", CultureInfo.InvariantCulture),
                        PageNo               = pageNo.ToString("N0", CultureInfo.InvariantCulture),
                        ItemsPerPage         = itemsPerDetail.ToString("N0", CultureInfo.InvariantCulture),
                        TemplateSuffix       = templateSuffix,
                        InfoSectionId        = infoSectionId.ToString(),
                        SaveActionDisabled   = !enableSave,
                        DeleteActionDisabled = !enableDelete,
                    };
                    editActionHtml = templateSaveEdit.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
                }

                #endregion

                var templateSaveDetail = new TemplateInfoDetailSaveDetail
                {
                    //Id = infoSectionId.ToString("N0", CultureInfo.InvariantCulture),
                    RevisionNo = revisionNo.ToString(),

                    InfoSectionName         = infoSectionName,
                    InfoDetailName          = infoDetailName,
                    InfoDetailDescription   = infoDetailDescription,
                    AdditionalActionVisible = showAdditional,
                    AdditionalVisibleList   = additionalVisibleList,

                    //AddMode = (levelId == 0) ? true : false,
                    AddAction    = addActionHtml,
                    EditAction   = editActionHtml,
                    ShowUserInfo = showUserInfo,
                };

                htmlSaveDetail = templateSaveDetail.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException,
                                                              out message);

                #endregion
            }

            return(htmlSaveDetail);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }