Пример #1
0
        public static string GetListAllItemView(long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, string configToken, long filterDataRefTypeId, long filterDataTypeId)
        {
            string message = "";
            if (itemsPerPage == 0) itemsPerPage = UtilsGeneric.DefaultItemsPerPage;
            long totalPages;
            long totalItems;
            string htmlTextItemList = "";
            string htmlAddItemList = "";
            string htmlFilterItemList = "";

            #region Retrieve Config Values

            long dataRefTypeId = 0;
            long dataRefId = 0;
            long dataTypeId = 0;
            string dataValueName = "Data";

            bool enableRefTypeId = false;
            bool enableRefId = false;
            bool enableDataTypeId = false;
            bool showRefType = false;
            bool showRefId = false;
            bool showDataType = false;

            bool showItemHeader = false;
            bool showItemEdit = false;
            bool showItemAppend = false;
            string itemAddName = "Add";
            string itemEditName = "Edit";
            string itemAppendName = "Append";
            bool isPublic = false;

            DataView.ProcessConfigToken(configToken, out dataRefTypeId, out dataRefId, out dataTypeId, out dataValueName, out enableRefTypeId, out enableRefId, out enableDataTypeId, out showRefType, out showRefId, out showDataType, out showItemHeader, out showItemEdit, out showItemAppend, out itemAddName, out itemEditName, out itemAppendName, out isPublic);

            #endregion

            if ((UtilsSecurity.IsAuthenticated() == false) && (isPublic ==false))
            {
                TemplateDataView dataView = new TemplateDataView
                {
                    DataIndex = dataIndex.ToString(),
                    PageNo = pageNo.ToString(),
                    ItemsPerPage = itemsPerPage.ToString(),
                    TemplateSuffix = templateSuffix,
                    DataValueName = dataValueName,
                };
                htmlTextItemList = dataView.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
            }
            else
            {
                bool hideFilter = true;
                if (filterDataRefTypeId > 0) dataRefTypeId = filterDataRefTypeId;
                if (filterDataTypeId > 0) dataTypeId = filterDataTypeId;
                if ((filterDataRefTypeId > 0) || (filterDataTypeId > 0)) hideFilter = false;

                #region Filter Section

                #region Get Ref Type List

                List<CNS_DataRefType> cnsDataRefTypeList = DataCommon.GetAllCnsDataRefType();

                List<TemplateDataListDetailFilter.DataRefTypeItem> dataRefTypeItemList = new List<TemplateDataListDetailFilter.DataRefTypeItem>();
                if (cnsDataRefTypeList.Count == 0)
                {
                    dataRefTypeItemList.Add(new TemplateDataListDetailFilter.DataRefTypeItem
                    {
                        DataRefTypeText = "No RefType Found",
                        DataRefTypeValue = "1",
                        DataRefTypeSelected = true
                    });
                }
                bool firstRecord = true;
                foreach (CNS_DataRefType cnsDataRefType in cnsDataRefTypeList)
                {
                    if ((cnsDataRefType.DataRefTypeID == dataRefTypeId) || ((dataRefTypeId == 0) && (firstRecord == true)))
                    {
                        dataRefTypeItemList.Add(new TemplateDataListDetailFilter.DataRefTypeItem
                        {
                            DataRefTypeText = cnsDataRefType.DataRefType,
                            DataRefTypeValue = cnsDataRefType.DataRefTypeID.ToString(),
                            DataRefTypeSelected = true
                        });
                    }
                    else
                    {
                        dataRefTypeItemList.Add(new TemplateDataListDetailFilter.DataRefTypeItem
                        {
                            DataRefTypeText = cnsDataRefType.DataRefType,
                            DataRefTypeValue = cnsDataRefType.DataRefTypeID.ToString(),
                            DataRefTypeSelected = false
                        });
                    }
                    firstRecord = false;
                }


                #endregion

                #region Get Data Type List

                List<CNS_DataType> cnsDataTypeList = DataCommon.GetAllCnsDataType();
                List<TemplateDataListDetailFilter.DataTypeItem> dataTypeItemList = new List<TemplateDataListDetailFilter.DataTypeItem>();
                if (cnsDataTypeList.Count == 0)
                {
                    dataTypeItemList.Add(new TemplateDataListDetailFilter.DataTypeItem
                    {
                        DataTypeText = "No DataType Found",
                        DataTypeValue = "1",
                        DataTypeSelected = true
                    });
                }
                firstRecord = true;
                foreach (CNS_DataType cnsDataType in cnsDataTypeList)
                {
                    if ((cnsDataType.DataTypeID == dataTypeId) || ((dataTypeId == 0) && (firstRecord == true)))
                    {
                        dataTypeItemList.Add(new TemplateDataListDetailFilter.DataTypeItem
                        {
                            DataTypeText = cnsDataType.DataType,
                            DataTypeValue = cnsDataType.DataTypeID.ToString(),
                            DataTypeSelected = true
                        });
                    }
                    else
                    {
                        dataTypeItemList.Add(new TemplateDataListDetailFilter.DataTypeItem
                        {
                            DataTypeText = cnsDataType.DataType,
                            DataTypeValue = cnsDataType.DataTypeID.ToString(),
                            DataTypeSelected = false
                        });
                    }
                    firstRecord = false;
                }

                #endregion

                List<TemplateDataSaveAdd.FilterAction> filterActionList = new List<TemplateDataSaveAdd.FilterAction>();

                if (UtilsSecurity.HaveAdminRole() == true)
                {
                    filterActionList.Add(new TemplateDataSaveAdd.FilterAction
                    {
                        DataIndex = dataIndex.ToString(),                       
                    });

                    TemplateDataListDetailFilter listDetailFilter = new TemplateDataListDetailFilter
                    {
                        DataListFilterHidden = hideFilter,
                        DataRefTypeItemList = dataRefTypeItemList,
                        DataTypeItemList = dataTypeItemList,
                        DataIndex = dataIndex.ToString(),
                        PageNo = pageNo.ToString(),
                        ItemsPerPage = itemsPerPage.ToString(),
                        TemplateSuffix = templateSuffix,
                        ConfigToken = configToken,
                    };
                    htmlFilterItemList = listDetailFilter.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
                }

                #endregion

                #region Add Link

                TemplateDataSaveAdd dataSaveAdd = new TemplateDataSaveAdd
                {
                    DataIndex = dataIndex.ToString(),
                    PageNo = pageNo.ToString(),
                    ItemsPerPage = itemsPerPage.ToString(),
                    TemplateSuffix = templateSuffix,
                    ConfigToken = configToken,
                    AddTitle = itemAddName,
                    FilterActionList = filterActionList,
                };
                htmlAddItemList = dataSaveAdd.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);

                #endregion

                #region Get Fill List

                #region Get Paged Data

                List<CND_Data> cndDataList = DataCommon.GetAllParentCndData(dataRefTypeId, dataRefId, dataTypeId, pageNo, itemsPerPage, out totalPages, out totalItems);

                #endregion

                if (cndDataList.Count > 0)
                {
                    #region Get Pager Details

                    string configTokenParam = "'" + configToken + "'";
                    string topPagerDetails = UtilsGeneric.GetItemPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalPages, RefreshListFunctionName, configTokenParam, false);
                    string bottomPagerDetails = UtilsGeneric.GetLinkPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalPages, totalItems, RefreshListFunctionName, configTokenParam, false);

                    #endregion

                    #region Append Top Pager

                    if (topPagerDetails.Trim().Length > 0)
                    {
                        htmlTextItemList += topPagerDetails;
                    }

                    #endregion

                    #region Append Items

                    int index = 0;
                    for (; index < cndDataList.Count; index++)
                    {
                        CND_Data cndData = cndDataList[index];
                        string htmlTextItemTemplate = GetListSingleItemView(cndData, pageNo, itemsPerPage, dataIndex, templateSuffix, configToken);
                        htmlTextItemList += htmlTextItemTemplate;
                    }

                    #endregion

                    #region Append Bottom Pager

                    if (bottomPagerDetails.Trim().Length > 0)
                    {
                        htmlTextItemList += bottomPagerDetails;
                    }

                    #endregion
                }

                #endregion

                #region Set Fill List

                if (htmlTextItemList.Length == 0)
                {
                    htmlAddItemList = "";

                    List<TemplateDataListDetailEmpty.AddAction> addActionList = new List<TemplateDataListDetailEmpty.AddAction>();
                    addActionList.Add(new TemplateDataListDetailEmpty.AddAction
                    {
                        DataIndex = dataIndex.ToString(),
                        PageNo = pageNo.ToString(),
                        ItemsPerPage = itemsPerPage.ToString(),
                        TemplateSuffix = templateSuffix,
                        ConfigToken = configToken,
                    });

                    TemplateDataListDetailEmpty dataListDetailEmpty = new TemplateDataListDetailEmpty
                    {
                        DataIndex = dataIndex.ToString(),
                        PageNo = pageNo.ToString(),
                        ItemsPerPage = itemsPerPage.ToString(),
                        TemplateSuffix = templateSuffix,
                        ConfigToken = configToken,
                        DataValueName = dataValueName,
                        AddActionList = addActionList
                    };
                    htmlTextItemList = dataListDetailEmpty.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
                }

                #endregion
            }

            return htmlFilterItemList + htmlAddItemList + htmlTextItemList;
        }
Пример #2
0
        public static string GetAppendView(long dataId, long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, string configToken)
        {
            string message = "";
            string htmlTextList = "";

            #region Retrieve Config Values

            long refTypeId = 0;
            long refId = 0;
            long dataTypeId = 0;
            string dataValueName = "";

            bool enableRefTypeId = false;
            bool enableRefId = false;
            bool enableDataTypeId = false;
            bool showRefType = false;
            bool showRefId = false;
            bool showDataType = false;

            bool showItemHeader = false;
            bool showItemEdit = false;
            bool showItemAppend = false;
            string itemAddName = "Add";
            string itemEditName = "Edit";
            string itemAppendName = "Append";
            bool isPublic = false;

            ProcessConfigToken(configToken, out refTypeId, out refId, out dataTypeId, out dataValueName, out enableRefTypeId, out enableRefId, out enableDataTypeId, out showRefType, out showRefId, out showDataType, out showItemHeader, out showItemEdit, out showItemAppend, out itemAddName, out itemEditName, out itemAppendName, out isPublic);

            #endregion

            if ((UtilsSecurity.IsAuthenticated() == false) && (isPublic ==false))
            {
                TemplateDataView dataView = new TemplateDataView
                {
                    DataIndex = dataIndex.ToString(),
                    PageNo = pageNo.ToString(),
                    ItemsPerPage = itemsPerPage.ToString(),
                    TemplateSuffix = templateSuffix,
                    DataValueName = dataValueName,
                };
                htmlTextList = dataView.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
            }
            else
            {
                htmlTextList = GetSaveDetailView(refTypeId, refId, dataTypeId, dataValueName, false, false, false, showRefType, showRefId, showDataType, showItemHeader, showItemEdit, showItemAppend, itemAddName, itemEditName, itemAppendName, isPublic, dataId, 0, pageNo, itemsPerPage, dataIndex, templateSuffix, out configToken);
            }

            return htmlTextList;
        }