示例#1
0
        public static bool SaveLTDInfoPageData(Dictionary<Guid, LTD_InfoPage> ltdInfoPageList)
        {
            bool ret = false;
            if (ltdInfoPageList.Count > 0)
            {
                List<LTD_InfoPage> ltdInfoPageValueList = new List<LTD_InfoPage>();
                LTD_InfoPage[] ltdInfoPageArray = new LTD_InfoPage[ltdInfoPageList.Values.Count];
                ltdInfoPageList.Values.CopyTo(ltdInfoPageArray, 0);
                ltdInfoPageValueList.AddRange(ltdInfoPageArray);
                ret = JsonStore<LTD_InfoPage>.SaveData(ltdInfoPageValueList, true);
            }

            return ret;
        }
示例#2
0
        public static bool UpdateLtdInfoPage(LTD_InfoPage ltdInfoPage)
        {
            bool ret = false;
          
			 UserInfo userInfo = GetUserInfo();
            ltdInfoPage.UserID = userInfo.Id;
            ltdInfoPage.UserGUID = userInfo.Guid;
            ltdInfoPage.LastUpdateDate = DateTime.UtcNow;
            Database db = HaveDb();
            if (db != null)
            {
                LTD_InfoPage ltdInfoPageExisting = GetLtdInfoPage(ltdInfoPage.InfoPageID, "");
                if (ltdInfoPageExisting != null)
                {
					ltdInfoPage.RevisionNo = GetMaxLtdInfoPageRevisionNo() + 1;                      
					using (ITransaction scope = db.GetTransaction())
					{
                        db.Update(ltdInfoPage);
                        scope.Complete();
                        ret = true;
                    }
                }
            }
            else
            {
                Dictionary<Guid, LTD_InfoPage> fileLtdInfoPageList = FileSource.LoadLTDInfoPageData();                
                if (fileLtdInfoPageList.ContainsKey(ltdInfoPage.InfoPageGUID) == true)
                {
                    fileLtdInfoPageList.Remove(ltdInfoPage.InfoPageGUID);
                    fileLtdInfoPageList.Add(ltdInfoPage.InfoPageGUID, ltdInfoPage);
                    FileSource.SaveLTDInfoPageData(fileLtdInfoPageList);
                }
            }

            return ret;
        }
示例#3
0
        public static long InsertLtdInfoPage(LTD_InfoPage ltdInfoPage)
        {
            long id = 0;
            if (ltdInfoPage.InfoPageGUID != Guid.Empty) throw new Exception("Cannot Set the GUID for a Insert");
            ltdInfoPage.InfoPageGUID = Guid.NewGuid();
          
			 UserInfo userInfo = GetUserInfo();
            ltdInfoPage.UserID = userInfo.Id;
            ltdInfoPage.UserGUID = userInfo.Guid;
            ltdInfoPage.CreatedDate = DateTime.UtcNow;
            ltdInfoPage.LastUpdateDate = DateTime.UtcNow;
            ltdInfoPage.RevisionNo = GetMaxLtdInfoPageRevisionNo() + 1;

            Database db = HaveDb();
            if (db != null)
            {
                using (ITransaction scope = db.GetTransaction())
                {
                    db.Insert(ltdInfoPage);
                    id = ltdInfoPage.InfoPageID;
                    scope.Complete();
                }
            }
            else
            {
                Dictionary<Guid, LTD_InfoPage> fileLtdInfoPageList = FileSource.LoadLTDInfoPageData();
	  			ltdInfoPage.InfoPageID = GetMaxLtdInfoPageId("") + 1;
  
                fileLtdInfoPageList.Add(ltdInfoPage.InfoPageGUID, ltdInfoPage);
                FileSource.SaveLTDInfoPageData(fileLtdInfoPageList);

                id = ltdInfoPage.InfoPageID;
            }

            return id;
        }
示例#4
0
        public static long SaveLtdInfoSection(long infoPageId, string infoSectionName, string infoSectionDescription, bool isActive, bool isDeleted, long sequence, long infoSectionId, out string retMessage)
        {
            long id = 0;
            string message = "";
            try
            {
                bool validationFail = false;
                if ((UtilsSecurity.HaveAdminRole() == false) && (UtilsSecurity.HaveAuthorRole() == false))
                {
                    message = "Please login as User Having Admin/Author Role to Save Section Data";
                    validationFail = true;
                }

                if (validationFail == false)
                {
                    if ((infoPageId == 0) || (infoSectionName.Trim().Length == 0) || (infoSectionDescription.Trim().Length == 0))
                    {
                        message = "Missing or Empty Section Data Argument";
                        validationFail = true;
                    }
                }

                if (validationFail == false)
                {
                    if (isDeleted == true)
                    {
                        if ((UtilsSecurity.HaveAdminRole() == false) && (UtilsSecurity.HaveAuthorRole() == false))
                        {
                            message = "Is Deleted Can be Updated Only by Users having Admin/Author Role";
                            validationFail = true;
                        }
                    }
                }

                var ltdInfoPage = new LTD_InfoPage();
                if (validationFail == false)
                {
                    if (infoPageId != 0)
                    {
                        ltdInfoPage = GetLtdInfoPage(infoPageId);
                        if (ltdInfoPage == null)
                        {
                            message = "The Info Page having ID [" + infoPageId + "] cannot be Retrieved";
                            validationFail = true;
                        }
                    }
                }

                var ltdSection = new LTD_InfoSection();
                if (validationFail == false)
                {
                    if (infoSectionId != 0)
                    {
                        ltdSection = GetLtdInfoSection(infoSectionId);
                        if (ltdSection == null)
                        {
                            message = "The Info Section having ID [" + infoSectionId + "] cannot be Retrieved";
                            validationFail = true;
                        }
                    }
                }

                if (validationFail == false)
                {
                    ltdSection.InfoPageID = ltdInfoPage.InfoPageID;
                    ltdSection.InfoPageGUID = ltdInfoPage.InfoPageGUID;

                    ltdSection.InfoSectionName = infoSectionName;
                    ltdSection.InfoSectionDescription = infoSectionDescription;
                    ltdSection.IsActive = isActive;
                    ltdSection.IsDeleted = isDeleted;
                    ltdSection.Sequence = sequence;

                    if (infoSectionId == 0)
                    {
                        ltdSection.IsActive = true;
                        ltdSection.Sequence = GetMaxLtdInfoSectionId() + 1;
                    }

                    DataSource.BeginTransaction();
                    if (ltdSection.InfoSectionID == 0)
                    {
                        DataSource.InsertLtdInfoSection(ltdSection);
                        id = ltdSection.InfoSectionID;
                    }
                    else
                    {
                        DataSource.UpdateLtdInfoSection(ltdSection);
                        id = ltdSection.InfoSectionID;
                    }
                    if (id > 0) DataSource.CompleteTransaction();
                }
            }
            catch (Exception ex)
            {
                id = 0;
                message = "DBError:" + ex.Message;
                LogManager.Log(LogLevel.Error, "DataInfoList-SaveLtdInfoSection", message);
                DataSource.AbortTransaction();
            }

            retMessage = message;
            return id;
        }
示例#5
0
        public static long SaveLtdInfoPage(string infoPageName, string infoPageDescription, long infoPageCategoryId, long accessGroupId, bool asyncLoading, bool isActive, DateTime expiryDate, bool commentable, string commentorRoleList, bool isPublic, bool isCommon, bool isDeleted, long sequence, long infoPageId, out string retMessage)
        {
            long id = 0;
            string message = "";
            try
            {
                bool validationFail = false;
                if (UtilsSecurity.HaveAuthorRole() == false)
                {
                    if (isPublic == true)
                    {
                        if (UtilsSecurity.HaveAdminRole() == false)
                        {
                            message = "Please login as User Having Admin Role to Make Info Page Public";
                            validationFail = true;
                        }
                    }
                    else
                    {
                        message = "Please login as User Having Author Role to Save Info Page Data";
                        validationFail = true;
                    }
                }


                if (validationFail == false)
                {
                    if ((infoPageName.Trim().Length == 0) || (infoPageDescription.Trim().Length == 0) || (infoPageCategoryId == 0))
                    {
                        message = "Missing or Empty Info Page Data Argument";
                        validationFail = true;
                    }
                }

                if (validationFail == false)
                {
                    if (isDeleted == true)
                    {
                        if ((UtilsSecurity.HaveAdminRole() == false) && (UtilsSecurity.HaveAuthorRole() == false))
                        {
                            message = "Is Deleted Can be Updated Only by Users having Admin/Author Role";
                            validationFail = true;
                        }
                    }
                }

                LTD_InfoCategory ltdInfoCategory = null;
                ltdInfoCategory = GetLtdInfoCategory(infoPageCategoryId);
                if (validationFail == false)
                {
                    if (ltdInfoCategory == null)
                    {
                        message = "The Category having ID [" + infoPageCategoryId + "] cannot be Retrieved";
                        validationFail = true;
                    }
                }

                var ltdInfoPage = new LTD_InfoPage();
                if (validationFail == false)
                {
                    if (infoPageId != 0)
                    {
                        ltdInfoPage = GetLtdInfoPage(infoPageId);
                        if (ltdInfoPage == null)
                        {
                            message = "The Page having ID [" + infoPageId + "] cannot be Retrieved";
                            validationFail = true;
                        }
                    }
                }

                if (validationFail == false)
                {                    
                    ltdInfoPage.InfoPageName = infoPageName;
                    ltdInfoPage.InfoPageDescription = infoPageDescription;

                    if (expiryDate == DateTime.MinValue) expiryDate = DateTime.Now.AddYears(1);
                    ltdInfoPage.ExpiryDate = expiryDate;
                    ltdInfoPage.IsActive = isActive;

                    ltdInfoPage.InfoCategoryID = ltdInfoCategory.InfoCategoryID;
                    ltdInfoPage.InfoCategoryGUID = ltdInfoCategory.InfoCategoryGUID;

                    if (UtilsSecurity.HaveAdminRole())
                    {
                        ltdInfoPage.IsPublic = isPublic;
                        ltdInfoPage.IsCommon = isCommon;
                        ltdInfoPage.IsDeleted = isDeleted;
                        ltdInfoPage.Sequence = sequence;
                    }

                    if (accessGroupId > 0)
                    {
                        SCD_Group scdGroup = UtilsSecurity.GetScdGroup(accessGroupId);
                        if (scdGroup != null)
                        {
                            ltdInfoPage.AccessGroupID = scdGroup.GroupID;
                            ltdInfoPage.AccessGroupGUID = scdGroup.GroupGUID;
                        }
                    }

                    ltdInfoPage.AsyncLoading = asyncLoading;
                    ltdInfoPage.Commentable = commentable;
                    ltdInfoPage.CommentorRoleList = commentorRoleList;

                    if (infoPageId == 0)
                    {
                        ltdInfoPage.IsActive = true;
                        ltdInfoPage.Sequence = GetMaxLtdInfoPageId() + 1;
                    }

                    DataSource.BeginTransaction();

                    if (ltdInfoPage.InfoPageID == 0)
                    {
                        ltdInfoPage.CreatedUserID = UtilsSecurity.GetUserId();
                        ltdInfoPage.CreatedUserGUID = UtilsSecurity.GetUserGuid();

                        DataSource.InsertLtdInfoPage(ltdInfoPage);
                        id = ltdInfoPage.InfoPageID;
                    }
                    else
                    {
                        DataSource.UpdateLtdInfoPage(ltdInfoPage);
                        id = ltdInfoPage.InfoPageID;
                    }
                    if (id > 0) DataSource.CompleteTransaction();
                }
            }
            catch (Exception ex)
            {
                id = 0;
                message = "DBError:" + ex.Message;
                LogManager.Log(LogLevel.Error, "DataInfoList-SaveLtdInfoPage", message);
                DataSource.AbortTransaction();
            }

            retMessage = message;
            return id;
        }
示例#6
0
        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;
        }