Exemplo n.º 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;
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        public static long InsertLtdInfoSection(LTD_InfoSection ltdInfoSection)
        {
            long id = 0;
            if (ltdInfoSection.InfoSectionGUID != Guid.Empty) throw new Exception("Cannot Set the GUID for a Insert");
            ltdInfoSection.InfoSectionGUID = Guid.NewGuid();
          
			 UserInfo userInfo = GetUserInfo();
            ltdInfoSection.UserID = userInfo.Id;
            ltdInfoSection.UserGUID = userInfo.Guid;
            ltdInfoSection.CreatedDate = DateTime.UtcNow;
            ltdInfoSection.LastUpdateDate = DateTime.UtcNow;
            ltdInfoSection.RevisionNo = GetMaxLtdInfoSectionRevisionNo() + 1;

            Database db = HaveDb();
            if (db != null)
            {
                using (ITransaction scope = db.GetTransaction())
                {
                    db.Insert(ltdInfoSection);
                    id = ltdInfoSection.InfoSectionID;
                    scope.Complete();
                }
            }
            else
            {
                Dictionary<Guid, LTD_InfoSection> fileLtdInfoSectionList = FileSource.LoadLTDInfoSectionData();
	  			ltdInfoSection.InfoSectionID = GetMaxLtdInfoSectionId("") + 1;
  
                fileLtdInfoSectionList.Add(ltdInfoSection.InfoSectionGUID, ltdInfoSection);
                FileSource.SaveLTDInfoSectionData(fileLtdInfoSectionList);

                id = ltdInfoSection.InfoSectionID;
            }

            return id;
        }
Exemplo n.º 4
0
        public static bool UpdateLtdInfoSection(LTD_InfoSection ltdInfoSection)
        {
            bool ret = false;
          
			 UserInfo userInfo = GetUserInfo();
            ltdInfoSection.UserID = userInfo.Id;
            ltdInfoSection.UserGUID = userInfo.Guid;
            ltdInfoSection.LastUpdateDate = DateTime.UtcNow;
            Database db = HaveDb();
            if (db != null)
            {
                LTD_InfoSection ltdInfoSectionExisting = GetLtdInfoSection(ltdInfoSection.InfoSectionID, "");
                if (ltdInfoSectionExisting != null)
                {
					ltdInfoSection.RevisionNo = GetMaxLtdInfoSectionRevisionNo() + 1;                      
					using (ITransaction scope = db.GetTransaction())
					{
                        db.Update(ltdInfoSection);
                        scope.Complete();
                        ret = true;
                    }
                }
            }
            else
            {
                Dictionary<Guid, LTD_InfoSection> fileLtdInfoSectionList = FileSource.LoadLTDInfoSectionData();                
                if (fileLtdInfoSectionList.ContainsKey(ltdInfoSection.InfoSectionGUID) == true)
                {
                    fileLtdInfoSectionList.Remove(ltdInfoSection.InfoSectionGUID);
                    fileLtdInfoSectionList.Add(ltdInfoSection.InfoSectionGUID, ltdInfoSection);
                    FileSource.SaveLTDInfoSectionData(fileLtdInfoSectionList);
                }
            }

            return ret;
        }
Exemplo n.º 5
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;
        }