Пример #1
0
        public static bool SaveLTDInfoCategoryData(Dictionary<Guid, LTD_InfoCategory> ltdInfoCategoryList)
        {
            bool ret = false;
            if (ltdInfoCategoryList.Count > 0)
            {
                List<LTD_InfoCategory> ltdInfoCategoryValueList = new List<LTD_InfoCategory>();
                LTD_InfoCategory[] ltdInfoCategoryArray = new LTD_InfoCategory[ltdInfoCategoryList.Values.Count];
                ltdInfoCategoryList.Values.CopyTo(ltdInfoCategoryArray, 0);
                ltdInfoCategoryValueList.AddRange(ltdInfoCategoryArray);
                ret = JsonStore<LTD_InfoCategory>.SaveData(ltdInfoCategoryValueList, true);
            }

            return ret;
        }
Пример #2
0
        private static string GetListSingleItemView(LTD_InfoCategory ltdInfoCategory, long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, bool hideDisplay)
        {
            string htmlTextItem = "";
            if (ltdInfoCategory != null)
            {
                string message;
                List<TemplateInfoCategoryListDetailItem.EditAction> editActionList = new List<TemplateInfoCategoryListDetailItem.EditAction>();
                editActionList.Add(new TemplateInfoCategoryListDetailItem.EditAction
                {
                    Id = ltdInfoCategory.InfoCategoryID.ToString(),
                    DataIndex = dataIndex.ToString(),
                    PageNo = pageNo.ToString(),
                    ItemsPerPage = itemsPerPage.ToString(),
                    TemplateSuffix = templateSuffix,                    
                    //HideDisplay = hideDisplay.ToString().ToLower(),
                });
                string createdBy = UtilsSecurity.GetUserName(ltdInfoCategory.UserID);
                
                var templateListDetailItem = new TemplateInfoCategoryListDetailItem
                {
                    InfoCategoryName = ltdInfoCategory.InfoCategoryName,
                    IsDefault = ltdInfoCategory.IsDefault,
                    IsInActive = !ltdInfoCategory.IsActive,
                    CreatedBy = createdBy,

                    EditActionList = editActionList
                };
                htmlTextItem = templateListDetailItem.GetFilled(templateSuffix, UtilsGeneric.Validate,
                                                                        UtilsGeneric.ThrowException,
                                                                        out message);


            }
            return htmlTextItem;
        }
Пример #3
0
        public static long InsertLtdInfoCategory(LTD_InfoCategory ltdInfoCategory)
        {
            long id = 0;
            if (ltdInfoCategory.InfoCategoryGUID != Guid.Empty) throw new Exception("Cannot Set the GUID for a Insert");
            ltdInfoCategory.InfoCategoryGUID = Guid.NewGuid();
          
			 UserInfo userInfo = GetUserInfo();
            ltdInfoCategory.UserID = userInfo.Id;
            ltdInfoCategory.UserGUID = userInfo.Guid;
            ltdInfoCategory.CreatedDate = DateTime.UtcNow;
            ltdInfoCategory.LastUpdateDate = DateTime.UtcNow;
            ltdInfoCategory.RevisionNo = GetMaxLtdInfoCategoryRevisionNo() + 1;

            Database db = HaveDb();
            if (db != null)
            {
                using (ITransaction scope = db.GetTransaction())
                {
                    db.Insert(ltdInfoCategory);
                    id = ltdInfoCategory.InfoCategoryID;
                    scope.Complete();
                }
            }
            else
            {
                Dictionary<Guid, LTD_InfoCategory> fileLtdInfoCategoryList = FileSource.LoadLTDInfoCategoryData();
	  			ltdInfoCategory.InfoCategoryID = GetMaxLtdInfoCategoryId("") + 1;
  
                fileLtdInfoCategoryList.Add(ltdInfoCategory.InfoCategoryGUID, ltdInfoCategory);
                FileSource.SaveLTDInfoCategoryData(fileLtdInfoCategoryList);

                id = ltdInfoCategory.InfoCategoryID;
            }

            return id;
        }
Пример #4
0
        public static bool UpdateLtdInfoCategory(LTD_InfoCategory ltdInfoCategory)
        {
            bool ret = false;
          
			 UserInfo userInfo = GetUserInfo();
            ltdInfoCategory.UserID = userInfo.Id;
            ltdInfoCategory.UserGUID = userInfo.Guid;
            ltdInfoCategory.LastUpdateDate = DateTime.UtcNow;
            Database db = HaveDb();
            if (db != null)
            {
                LTD_InfoCategory ltdInfoCategoryExisting = GetLtdInfoCategory(ltdInfoCategory.InfoCategoryID, "");
                if (ltdInfoCategoryExisting != null)
                {
					ltdInfoCategory.RevisionNo = GetMaxLtdInfoCategoryRevisionNo() + 1;                      
					using (ITransaction scope = db.GetTransaction())
					{
                        db.Update(ltdInfoCategory);
                        scope.Complete();
                        ret = true;
                    }
                }
            }
            else
            {
                Dictionary<Guid, LTD_InfoCategory> fileLtdInfoCategoryList = FileSource.LoadLTDInfoCategoryData();                
                if (fileLtdInfoCategoryList.ContainsKey(ltdInfoCategory.InfoCategoryGUID) == true)
                {
                    fileLtdInfoCategoryList.Remove(ltdInfoCategory.InfoCategoryGUID);
                    fileLtdInfoCategoryList.Add(ltdInfoCategory.InfoCategoryGUID, ltdInfoCategory);
                    FileSource.SaveLTDInfoCategoryData(fileLtdInfoCategoryList);
                }
            }

            return ret;
        }
Пример #5
0
        public static long SaveLtdInfoCategory(string infoCategoryName, bool isDefault, bool isActive, long infoCategoryId, 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 Info Category";
                    validationFail = true;
                }

                if (validationFail == false)
                {
                    if (infoCategoryName.Trim().Length == 0)
                    {
                        message = "Missing or Empty Category Argument";
                        validationFail = true;
                    }
                }

                if (validationFail == false)
                {
                    LTD_InfoCategory ltdInfoCategoryNameExisting = GetLtdInfoCategory(infoCategoryName);
                    if ((ltdInfoCategoryNameExisting != null) && (ltdInfoCategoryNameExisting.InfoCategoryID != infoCategoryId))
                    {
                        message = "The Info Category [" + infoCategoryName + "] allready exists";
                        validationFail = true;
                    }
                }

                var ltdInfoCategory = new LTD_InfoCategory();
                if (validationFail == false)
                {
                    if (infoCategoryId != 0)
                    {
                        ltdInfoCategory = GetLtdInfoCategory(infoCategoryId);
                        if (ltdInfoCategory == null)
                        {
                            message = "The Info Category having ID [" + infoCategoryId + "] cannot be Retrieved";
                            validationFail = true;
                        }
                    }
                }

                if (validationFail == false)
                {
                    ltdInfoCategory.IsActive = isActive;
                    if (infoCategoryId == 0)
                    {
                        ltdInfoCategory.Sequence = GetMaxLtdInfoCategoryId() + 1;
                        ltdInfoCategory.IsActive = true;
                        ltdInfoCategory.IsSystem = false;
                    }
                    ltdInfoCategory.InfoCategoryName = infoCategoryName;
                    ltdInfoCategory.IsDefault = isDefault;

                    DataSource.BeginTransaction();
                    if (ltdInfoCategory.IsDefault)
                    {
                        LTD_InfoCategory defaultLtdInfoCategory = GetDefaultLtdInfoCategory();
                        if (defaultLtdInfoCategory != null)
                        {
                            if (defaultLtdInfoCategory.InfoCategoryID != ltdInfoCategory.InfoCategoryID)
                            {
                                defaultLtdInfoCategory.IsDefault = false;
                                DataSource.UpdateLtdInfoCategory(defaultLtdInfoCategory);
                            }
                        }
                    }

                    if (ltdInfoCategory.InfoCategoryID == 0)
                    {
                        DataSource.InsertLtdInfoCategory(ltdInfoCategory);
                        id = ltdInfoCategory.InfoCategoryID;
                    }
                    else
                    {
                        DataSource.UpdateLtdInfoCategory(ltdInfoCategory);
                        id = ltdInfoCategory.InfoCategoryID;
                    }
                    DataSource.CompleteTransaction();
                }
            }
            catch (Exception ex)
            {
                id = 0;
                message = "DBError:" + ex.Message;
                LogManager.Log(LogLevel.Error, "DataInfoList-SaveLtdInfoCategory", message);
                DataSource.AbortTransaction();
            }

            retMessage = message;
            return id;
        }