Exemplo n.º 1
0
        /// <summary>
        /// 取得報名明細 其中參賽群組已判斷報名數量
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public ApplyViewDetailsModel GetViewActivityDetailsByID(int ID)
        {
            ApplyViewDetailsModel details =
                DB.OLACT.Where(w => w.ID == ID)
                .Select(s => new ApplyViewDetailsModel()
            {
                ID             = s.ID,
                Disable        = s.DISABLE,
                PublishDateStr = s.PUB_DT_STR,
                Sort           = s.SQ,
                Title          = s.ACTITLE,
                ActivityDateTimeDescription = s.ACT_DATE_DESC,
                ActivityContent             = s.ACT_CONTENT,
                ApplyDateTimeBegin          = s.APPLY_DATE_BEGIN,
                ApplyDateTimeEnd            = s.APPLY_DATE_END,
                ActivityNumber = s.ACT_NUM
            })
                .FirstOrDefault();

            PublicMethodRepository.HtmlDecode(details);

            if (details != null)
            {
                var group = DB.OLACTGROUP
                            .Where(o => o.MAP_ACT_ID == ID)
                            .Select(s => new ApplyViewGroup()
                {
                    GroupID         = s.ID,
                    GroupName       = s.GROUP_NAME,
                    GroupApplyLimit = s.TEAM_APPLY_LIMIT,
                    CountApplyLimit = s.COUNT_APPLY_LIMIT
                })
                            .ToList();

                foreach (var g in group)
                {
                    var applyGorupLimitCount = DB.APPLY.Where(o => o.MAP_ACT_ID == ID && o.MAP_ACT_GUP_ID == g.GroupID).Count();
                    g.CountApplyLastLimit = (g.GroupApplyLimit - applyGorupLimitCount) <= 0 ? 0 : (g.GroupApplyLimit - applyGorupLimitCount);
                    details.ActivityGroup.Add(g);
                }
                details.ApplyGroupJsonString = JsonConvert.SerializeObject(details.ActivityGroup);
            }
            return(details);
        }
Exemplo n.º 2
0
        public int DoSaveData(FormCollection form, int?ID = null)
        {
            RESULT saveModel;

            if (ID == 0)
            {
                saveModel        = new RESULT();
                saveModel.BUD_ID = UserProvider.Instance.User.ID;
                saveModel.BUD_DT = DateTime.UtcNow.AddHours(8);
            }
            else
            {
                saveModel = this.DB.RESULT.Where(s => s.ID == ID).FirstOrDefault();
            }
            saveModel.TITLE      = form["title"];
            saveModel.DISABLE    = form["disable"] == null ? false : Convert.ToBoolean(form["disable"]);
            saveModel.SQ         = form["sortIndex"] == null ? 1 : Convert.ToDouble(form["sortIndex"]);
            saveModel.CONTENT    = form["contenttext"];
            saveModel.PUB_DT_STR = form["publishDate"];
            saveModel.UPT_DT     = DateTime.UtcNow.AddHours(8);
            saveModel.UPT_ID     = UserProvider.Instance.User.ID;
            PublicMethodRepository.FilterXss(saveModel);

            if (ID == 0)
            {
                this.DB.RESULT.Add(saveModel);
            }
            else
            {
                this.DB.Entry(saveModel).State = EntityState.Modified;
            }

            try
            {
                this.DB.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            int identityId = (int)saveModel.ID;

            return(identityId);
        }
Exemplo n.º 3
0
        public BannerListResultModel DoGetList(BannerFilterModel filterModel)
        {
            PublicMethodRepository.FilterXss(filterModel);
            BannerListResultModel result = new BannerListResultModel();
            List <BANNER>         data   = new List <BANNER>();

            try
            {
                data = DB.BANNER.ToList();

                //關鍵字搜尋
                if (!string.IsNullOrEmpty(filterModel.QueryString))
                {
                    this.ListFilter(filterModel.QueryString, ref data);
                }

                //上下架
                if (!string.IsNullOrEmpty(filterModel.Disable))
                {
                    this.ListStatusFilter(filterModel.Disable, ref data);
                }

                //排序
                this.ListSort(filterModel.SortColumn, ref data);

                PaginationResult pagination;
                //分頁
                this.ListPageList(filterModel.CurrentPage, ref data, out pagination);
                result.Pagination = pagination;
                foreach (var d in data)
                {
                    PublicMethodRepository.HtmlDecode(d);
                }

                result.Data = data;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Exemplo n.º 4
0
        public ApplyMaintainListResultModel DoGetList(ApplyMaintainListFilterModel filterModel)
        {
            ApplyMaintainListResultModel      result = new ApplyMaintainListResultModel();
            List <ApplyMaintainListDataModel> data   = new List <ApplyMaintainListDataModel>();

            try
            {
                data = DB.OLACT
                       .AsEnumerable()
                       .Select(s => new ApplyMaintainListDataModel()
                {
                    ID                = s.ID,
                    ActivityName      = s.ACTITLE,
                    PublishDateString = s.PUB_DT_STR,
                    Sort              = s.SQ,
                    ApplyStatus       = ActivityStatusCheckByID(s.ID),
                    RegisteredCount   = DB.APPLY.Where(g => g.MAP_ACT_ID == s.ID).Count(),
                    LimitCount        = DB.OLACTGROUP.Where(o => o.MAP_ACT_ID == s.ID).Sum(m => m.TEAM_APPLY_LIMIT),
                    ActivityDateRange = s.ACT_DATE_DESC
                })
                       .ToList();

                //排序
                this.ListSort(filterModel.SortColumn, ref data);

                PaginationResult pagination;
                //分頁
                this.ListPageList(filterModel.CurrentPage, ref data, out pagination);
                result.Pagination = pagination;
                foreach (var d in data)
                {
                    PublicMethodRepository.HtmlDecode(d);
                }

                result.Data = data;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Exemplo n.º 5
0
        public override object DoGetDetailsByID(int ID)
        {
            ProductDetailsDataModel result = new ProductDetailsDataModel();
            PRODUCT data = new PRODUCT();

            if (PublicMethodRepository.CurrentMode == SiteMode.FronEnd)
            {
                data = DB.PRODUCT.Where(w => w.ID == ID && !w.DISABLE).FirstOrDefault();
            }
            else if (PublicMethodRepository.CurrentMode == SiteMode.Home)
            {
                data = DB.PRODUCT.Where(w => w.ID == ID && !w.DISABLE && w.HOME_PAGE_DISPLAY).FirstOrDefault();
            }
            else
            {
                data = DB.PRODUCT.Where(w => w.ID == ID).FirstOrDefault();
            }
            PublicMethodRepository.HtmlDecode(data);
            result.Data = data;
            return(result);
        }
Exemplo n.º 6
0
        public DownloadFrontResultModel GetList(int page)
        {
            DownloadFrontResultModel result = new DownloadFrontResultModel();

            try
            {
                var data = this.DB.DLFILES
                           .AsEnumerable()
                           .OrderByDescending(o => o.PUB_DT_STR).ThenByDescending(a => a.SQ)
                           .Where(o => o.DISABLE == false)
                           .Select(o => new DownloadFrontDataModel()
                {
                    ID             = o.ID,
                    Title          = o.TITLE,
                    PublishDateStr = o.PUB_DT_STR
                })
                           .ToList();
                result.Data = data;
                result      = this.ListPagination(ref result, page, Convert.ToInt32(PublicMethodRepository.GetConfigAppSetting("DefaultPageSize")));

                foreach (var item in data)
                {
                    PublicMethodRepository.HtmlDecode(item);
                }


                using (var fileModule = new FileModule())
                {
                    foreach (var item in data)
                    {
                        item.Files = fileModule.GetFiles((int)item.ID, "Download", "F");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Exemplo n.º 7
0
        public void SaveContent(string content)
        {
            FileRepository fileRepository = new FileRepository();
            EDITOR         agent          = null;
            var            @base          = DB.EDITOR.FirstOrDefault();

            if (@base == null)
            {
                agent = new EDITOR()
                {
                    CONTENT = content
                }
            }
            ;
            else
            {
                @base.CONTENT = content;
                agent         = @base;
            }

            PublicMethodRepository.FilterXss(agent);

            if (@base == null)
            {
                this.DB.EDITOR.Add(agent);
            }
            else
            {
                this.DB.Entry(agent).State = EntityState.Modified;
            }
            try
            {
                this.DB.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 8
0
        public SearchListResultModel SearchSite(SearchListFilterModel filter)
        {
            PublicMethodRepository.FilterXss(filter);

            string str = filter.QueryString;
            SearchListResultModel      result = new SearchListResultModel();
            List <SearchListDataModel> data   = new List <SearchListDataModel>();

            SearchAbout(filter.QueryString, filter.LangCode, ref data);
            SearchEducation(filter.QueryString, filter.LangCode, ref data);
            SearchJoinUs(filter.QueryString, filter.LangCode, ref data);
            SearchEventLatest(filter.QueryString, filter.LangCode, ref data);
            SearchStates(filter.QueryString, filter.LangCode, ref data);
            SearchAnnouncement(filter.QueryString, filter.LangCode, ref data);
            SearchFocus(filter.QueryString, filter.LangCode, ref data);

            //result.Data = data.OrderByDescending(o => o.UpDateTime).ToList();
            result.Data = data.OrderByDescending(o => o.Sort).ThenByDescending(x => x.BD_DTString).ToList();
            result      = ListPagination(result, (int)filter.CurrentPage, (int)PageSizeConfig.SIZE10);

            return(result);
        }
Exemplo n.º 9
0
        public bool ChangePassword(FormCollection form)
        {
            if (UserProvider.Instance.User == null)
            {
                throw new Exception("請先登入!");
            }
            var oldPwd     = form["oldPw"];
            var newPwd     = form["newPw"];
            var rePwd      = form["rePw"];
            var entityUser = this.DB.USER
                             .Where(o => o.ID == UserProvider.Instance.User.ID &&
                                    o.USR_ID == UserProvider.Instance.User.UserAccount).First();

            PublicMethodRepository.HtmlDecode(entityUser);


            bool isTruePw = (oldPwd == entityUser.USR_PWD);

            if (isTruePw)
            {
                if (newPwd.Equals(rePwd))
                {
                    PublicMethodRepository.FilterXss(entityUser);
                    entityUser.USR_PWD = rePwd;
                    this.DB.Entry(entityUser).State = EntityState.Modified;
                    this.DB.SaveChanges();
                }
                else
                {
                    throw new Exception("新密碼兩次輸入密碼不同.");
                }
            }
            else
            {
                throw new Exception("原密碼輸入錯誤.");
            }
            return(true);
        }
Exemplo n.º 10
0
        public ApplyListViewModel GetList(int page, bool getContent = false)
        {
            ApplyListViewModel model = new ApplyListViewModel();
            var data = DB.OLACT
                       .AsEnumerable()
                       .OrderByDescending(o => o.PUB_DT_STR).ThenByDescending(a => a.SQ)
                       .Select(s => new ApplyListViewDataModel()
            {
                ID = s.ID,
                ActivityDateTimeDescription = s.ACT_DATE_DESC,
                ApplyDateRange = string.Concat(s.APPLY_DATE_BEGIN, "~", s.APPLY_DATE_END),
                Sort           = s.SQ,
                Title          = s.ACTITLE,
                Remark         = s.ACT_CONTENT
            })
                       .ToList();

            using (var actModule = new ActivityModule())
            {
                foreach (var d in data)
                {
                    d.GroupApplyLimit = DB.OLACTGROUP.Where(o => o.MAP_ACT_ID == d.ID).Sum(o => o.TEAM_APPLY_LIMIT);
                    d.Registered      = DB.APPLY.Where(g => g.MAP_ACT_ID == d.ID).Count();
                    d.ActivityStatus  = actModule.ActivityStatusCheckByID((int)d.ID);
                }
            }
            model.ListData = data;
            foreach (var d in data)
            {
                PublicMethodRepository.HtmlDecode(d);
            }

            if (!getContent)
            {
                model = this.ListPagination(ref model, page, Convert.ToInt32(PublicMethodRepository.GetConfigAppSetting("DefaultPageSize")));
            }
            return(model);
        }
Exemplo n.º 11
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            this.ControllerID = filterContext.RouteData.Values["controller"].ToString();
            this.ActionID     = filterContext.RouteData.Values["action"].ToString();
            var    parameters = filterContext.ActionDescriptor.GetParameters();
            string lang       = "";

            //判斷action是否有帶lang參數
            foreach (var parameter in parameters)
            {
                if (parameter.ParameterName == "lang")
                {
                    lang = filterContext.HttpContext.Request[parameter.ParameterName];
                    break;
                }
            }
            //var lang = parameters.Select(s => new
            //{
            //    Name = s.ParameterName,
            //    Value = filterContext.HttpContext.Request[s.ParameterName]
            //})
            //.Where(w => w.Name == "lang").FirstOrDefault();

            if (string.IsNullOrEmpty(lang))
            {
                PublicMethodRepository.CurrentLanguageEnum = Enums.Language.NotSet;
            }
            else
            {
                PublicMethodRepository.CurrentLanguageEnum = PublicMethodRepository.GetLanguageEnumByCode(lang);
            }


            base.OnAuthorization(filterContext);

            //string ip = filterContext.RequestContext.HttpContext.Request.UserHostAddress;
            //IpHistoryModule.WriteIp(ip);
        }
        public ActionResult ProductDataEdit(FormCollection form, List <HttpPostedFileBase> image, List <HttpPostedFileBase> images)
        {
            string            langCode   = form["lang"] ?? PublicMethodRepository.CurrentLanguageCode;
            Language          language   = PublicMethodRepository.GetLanguageEnumByCode(langCode);
            int?              ID         = Convert.ToInt32(form["ProductID"]);
            ProductKindModule typeModule = new ProductKindModule();

            #region 判斷狀態是否已被停用 被停用 不得啟用前台顯示
            if (ID.HasValue)
            {
                int chkTypeID = Convert.ToInt16(form["type"]);
                ProductKindDetailsDataModel tModel = (typeModule.DoGetDetailsByID(chkTypeID) as ProductKindDetailsDataModel);
                bool tpStatus  = tModel.Status == "Y" ? true : false;
                bool setStatus = form["fSt"] == null ? false : true;
                if ((!tpStatus) && (setStatus))
                {
                    var redirectErrorUrl = new UrlHelper(Request.RequestContext).Action("ProductDataEdit", "_SysAdm", new { ID = ID, error = true });
                    return(Json(new { Url = redirectErrorUrl }));
                }
            }

            #endregion
            ListModuleService module      = ListFactoryService.Create(ListMethodType.PRODUCT);
            int identityId                = module.DoSaveData(form, language, ID, image, images);
            ProductDetailsDataModel model = (module.DoGetDetailsByID((int)identityId) as ProductDetailsDataModel);
            //取圖檔
            ImgModule imgModule = new ImgModule();
            model.ImagesData      = imgModule.GetImages(model.ID, "Product", "S").FirstOrDefault();
            model.OtherImagesData = imgModule.GetImages(model.ID, "Product", "M");
            //產品分類下拉選單
            SelectList typeList = typeModule.CreateProductKindDropList(model.TypeID, false, model.DisplayForFrontEnd);
            ViewBag.TypeList = typeList;

            var redirectUrl = new UrlHelper(Request.RequestContext).Action("ProductDataEdit", "_SysAdm", new { ID = identityId });
            return(Json(new { Url = redirectUrl }));
        }
Exemplo n.º 13
0
        public JsonResult ValidRecaptcha(FormCollection form)
        {
            PublicMethodRepository.GoogleValidIsSuccess = false;
            var    content = new JsonResult();
            bool   isValid = true;
            string msg     = string.Empty;

            string secret = PublicMethodRepository.GetConfigAppSetting("reCAPTCHASecret");

            if (secret == null)
            {
                isValid = false;
                msg     = "無法取得Google金鑰";
            }
            else
            {
                IRecaptcha <RecaptchaV2Result> recaptcha = new RecaptchaV2(new RecaptchaV2Data()
                {
                    Secret = secret
                });

                var result = recaptcha.Verify();
                if (!result.Success)
                {
                    isValid = false;
                }
            }

            PublicMethodRepository.GoogleValidIsSuccess = isValid;
            content.Data = JsonConvert.SerializeObject(new { success = isValid, msg = msg }, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            content.ContentType         = "application/json";
            content.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(content);
        }
Exemplo n.º 14
0
        public ActivityDetailsModel DoGetDetailsByID(int ID)
        {
            ActivityDetailsModel details =
                DB.OLACT.Where(w => w.ID == ID)
                .Select(s => new ActivityDetailsModel()
            {
                ID             = s.ID,
                Disable        = s.DISABLE,
                PublishDateStr = s.PUB_DT_STR,
                Sort           = s.SQ,
                Title          = s.ACTITLE,
                ActivityDateTimeDescription = s.ACT_DATE_DESC,
                ActivityContent             = s.ACT_CONTENT,
                ApplyDateTimeBegin          = s.APPLY_DATE_BEGIN,
                ApplyDateTimeEnd            = s.APPLY_DATE_END,
                ActivityNumber = s.ACT_NUM
            })
                .FirstOrDefault();

            PublicMethodRepository.HtmlDecode(details);

            if (details != null)
            {
                details.ActivityGroup = DB.OLACTGROUP
                                        .Where(o => o.MAP_ACT_ID == ID)
                                        .Select(s => new ActivityGroup()
                {
                    GroupID         = s.ID,
                    GroupName       = s.GROUP_NAME,
                    GroupApplyLimit = s.TEAM_APPLY_LIMIT,
                    CountApplyLimit = s.COUNT_APPLY_LIMIT
                })
                                        .ToList();
            }
            return(details);
        }
Exemplo n.º 15
0
 public PublicService()
 {
     _PublicRep  = new PublicMethodRepository();
     ReturnModel = new PublicMethodResult();
 }
Exemplo n.º 16
0
        public ApplyDetailsDataModel GetApplyDetails(ApplyDetailsDataModel details)
        {
            details.GroupList = GetActivityGroupListByID(details.ActivityID);
            var activityData = DB.OLACT.Where(o => o.ID == details.ActivityID).FirstOrDefault();

            if (activityData == null)
            {
                throw new Exception("無喇取得該活動賽事,是否已被移除?");
            }

            details.ActivityID        = activityData.ID;
            details.ActivityDateRange = activityData.ACT_DATE_DESC;
            details.ActivityName      = activityData.ACTITLE;

            var applyLstData =
                DB.APPLY
                .Where(w => w.MAP_ACT_ID == details.ActivityID)
                .AsEnumerable()
                .Select(s => new ApplyDetailsListDataModel()
            {
                ID                   = s.ID,
                ApplyDate            = s.BUD_DT.ConvertDateTimeTo10CodeString(),
                ApplyNumber          = s.APPLY_IDEN_NUM,
                ApplySuccessStatus   = s.APPLY_SUCCESS,
                ApplyTeamName        = s.TEAM_NM,
                ApplyTeamMemberCount = DB.APPLY_MEMBER.Where(o => o.MAP_APPLY_ID == s.ID && o.REF_ACT_ID == details.ActivityID).Count(),
                GroupID              = s.MAP_ACT_GUP_ID,
                ContactPhone         = s.CONTACT_PHONE
            })
                .ToList();

            details.ListData.Result.Data             = applyLstData;
            details.GroupInfo.RegisteredSuccessCount = DB.APPLY.Where(o => o.MAP_ACT_ID == details.ActivityID && o.APPLY_SUCCESS == true).Count();
            details.GroupInfo.RegisteredCount        = DB.APPLY.Where(g => g.MAP_ACT_ID == details.ActivityID).Count();
            details.GroupInfo.GroupApplyLimit        = DB.OLACTGROUP.Where(o => o.MAP_ACT_ID == details.ActivityID).Sum(m => m.TEAM_APPLY_LIMIT);

            if (details.ListData.Filter.GroupID.HasValue)
            {
                applyLstData = applyLstData.Where(o => o.GroupID == details.ListData.Filter.GroupID).ToList();
                details.ListData.Result.Data = applyLstData;
                //若要在上方訊息區塊秀出對應的組別資料 移除下面註解
                //details.GroupInfo = GetGroupInfoByID(details.ActivityID, (int)details.ListData.Filter.GroupID);
            }

            if (!string.IsNullOrEmpty(details.ListData.Filter.QueryString))
            {
                details.ListData.Result.Data = applyLstData.Where(o => o.ApplyTeamName.Contains(details.ListData.Filter.QueryString)).ToList();
            }

            //排序
            switch (details.ListData.Filter.SortColumn)
            {
            case "sortApplyStatus/asc":
                details.ListData.Result.Data = details.ListData.Result.Data.OrderBy(o => o.ApplySuccessStatus).ThenByDescending(o => o.ApplyDate).ToList();
                break;

            case "sortApplyStatus/desc":
                details.ListData.Result.Data = details.ListData.Result.Data.OrderByDescending(o => o.ApplySuccessStatus).ThenByDescending(o => o.ApplyDate).ToList();
                break;

            default:
                details.ListData.Result.Data = details.ListData.Result.Data.OrderByDescending(o => o.ApplyDate).ThenByDescending(g => g.ApplySuccessStatus).ToList();
                break;
            }
            PaginationResult pagination;
            var tempData = details.ListData.Result.Data;

            //分頁
            this.ListPageList(details.ListData.Filter.CurrentPage, ref tempData, out pagination);
            details.ListData.Result.Data       = tempData;
            details.ListData.Result.Pagination = pagination;
            foreach (var d in details.ListData.Result.Data)
            {
                PublicMethodRepository.HtmlDecode(d);
            }
            return(details);
        }
Exemplo n.º 17
0
        public int DoSaveData(DownloadDataModel model)
        {
            DLFILES        saveModel;
            FileRepository fileRepository = new FileRepository();

            if (model.ID == 0)
            {
                saveModel        = new DLFILES();
                saveModel.BUD_ID = UserProvider.Instance.User.ID;
                saveModel.BUD_DT = DateTime.UtcNow.AddHours(8);
            }
            else
            {
                saveModel = this.DB.DLFILES.Where(s => s.ID == model.ID).FirstOrDefault();
            }
            saveModel.TITLE      = model.Title;
            saveModel.SQ         = model.Sort;
            saveModel.PUB_DT_STR = model.PublishDateStr;
            saveModel.DISABLE    = model.Disable;
            saveModel.UPT_ID     = UserProvider.Instance.User.ID;
            saveModel.UPT_DT     = DateTime.UtcNow.AddHours(8);
            PublicMethodRepository.FilterXss(saveModel);

            if (model.ID == 0)
            {
                this.DB.DLFILES.Add(saveModel);
            }
            else
            {
                this.DB.Entry(saveModel).State = EntityState.Modified;
            }

            try
            {
                this.DB.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            int identityId = (int)saveModel.ID;

            #region 檔案處理


            FilesModel fileModel = new FilesModel()
            {
                ActionName = "Download",
                ID         = identityId,
                OldFileIds = model.OldFilesId
            };



            fileRepository.UploadFile("Post", fileModel, model.Files, "M");
            fileRepository.SaveFileToDB(fileModel);


            #endregion 檔案處理

            return(identityId);
        }
Exemplo n.º 18
0
        public override object DoGetList(object filter)
        {
            ListResultBase result      = new ListResultBase();
            TFilter        filterModel = (filter as TFilter);

            PublicMethodRepository.FilterXss(filterModel);
            List <TData> data = new List <TData>();

            try
            {
                var enumerable = (IEnumerable <TData>)(typeof(REDOXDB).GetProperty(typeof(TData).Name).GetValue(DB, null));
                if (PublicMethodRepository.CurrentMode == SiteMode.FronEnd)
                {
                    data = enumerable.Where(s => !s.DISABLE).ToList();
                }
                else if (PublicMethodRepository.CurrentMode == SiteMode.Home)
                {
                    data = enumerable.Where(s => !s.DISABLE && s.HOME_PAGE_DISPLAY).ToList();
                }
                else
                {
                    data = enumerable.ToList();
                }


                //關鍵字搜尋
                if (!string.IsNullOrEmpty(filterModel.QueryString))
                {
                    data = this.DoListFilterStringQuery(filterModel.QueryString, data);
                }
                //PUB_DT_STR搜尋
                if (!string.IsNullOrEmpty(filterModel.PublishStartDate) && !string.IsNullOrEmpty(filterModel.PublishEndate))
                {
                    data = this.DoListDateFilter(Convert.ToDateTime(filterModel.PublishStartDate), Convert.ToDateTime(filterModel.PublishEndate), data);
                }

                //前台顯示
                if (!string.IsNullOrEmpty(filterModel.DisplayForFrontEnd))
                {
                    data = this.DoListStatusFilter(filterModel.DisplayForFrontEnd, "F", data);
                }

                //SQ
                data = this.DoListSort(filterModel.SortColumn, filterModel.Status, data);

                //分頁
                //分頁
                bool isDoPage = PublicMethodRepository.CurrentMode == SiteMode.FronEnd ||
                                PublicMethodRepository.CurrentMode == SiteMode.Home ? false : true;
                data = this.DoListPageList(filterModel.CurrentPage, data, out PaginationResult pagination, isDoPage);
                result.Pagination = pagination;
                foreach (var d in data)
                {
                    PublicMethodRepository.HtmlDecode(d);
                }
                result.Data = data;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Exemplo n.º 19
0
        public override int DoSaveData(FormCollection form, int?ID = null, List <HttpPostedFileBase> files = null)
        {
            NEWS           saveModel;
            FileRepository fileRepository = new FileRepository();

            if (!ID.HasValue)
            {
                saveModel        = new NEWS();
                saveModel.BUD_DT = DateTime.UtcNow.AddHours(8);

                saveModel.BUD_ID = UserProvider.Instance.User.ID;
            }
            else
            {
                saveModel = this.DB.NEWS.Where(s => s.ID == ID).FirstOrDefault();
            }
            saveModel.TITLE             = form["TITLE"];
            saveModel.HOME_PAGE_DISPLAY = form["HOME_PAGE_DISPLAY"] == "on" ? true : false;
            saveModel.DISABLE           = form["DISABLE"] == "Y" ? true : false;
            saveModel.SQ         = form["SQ"] == null ? 1 : form["SQ"] == string.Empty ? 1 : Convert.ToInt32(form["SQ"]);
            saveModel.CONTENT    = form["contenttext"];
            saveModel.PUB_DT_STR = form["PUB_DT_STR"];
            saveModel.UPT_DT     = DateTime.UtcNow.AddHours(8);
            saveModel.UPT_ID     = UserProvider.Instance.User.ID;
            PublicMethodRepository.FilterXss(saveModel);

            if (ID.HasValue)
            {
                this.DB.Entry(saveModel).State = EntityState.Modified;
            }
            else
            {
                this.DB.NEWS.Add(saveModel);
            }

            try
            {
                this.DB.SaveChanges();
            }
            catch (Exception ex)
            {
                ex.AppException();
            }
            int identityId = (int)saveModel.ID;

            #region FILEBASE處理

            List <int> oldFileList = new List <int>();

            #region 將原存在的ServerFILEBASE保留 記錄FILEBASEID

            //將原存在的ServerFILEBASE保留 記錄FILEBASEID
            foreach (var f in form.Keys)
            {
                if (f.ToString().StartsWith("FileData"))
                {
                    var id = Convert.ToInt16(form[f.ToString().Split('.')[0] + ".ID"]);
                    if (!oldFileList.Contains(id))
                    {
                        oldFileList.Add(id);
                    }
                }
            }

            #endregion 將原存在的ServerFILEBASE保留 記錄FILEBASEID

            #region 建立FILEBASE模型

            FilesModel fileModel = new FilesModel()
            {
                ActionName = _actionName,
                ID         = identityId,
                OldFileIds = oldFileList
            };

            #endregion 建立FILEBASE模型

            #region 若有null則是前端html的name重複於ajax formData名稱

            if (files != null)
            {
                if (files.Count > 0)
                {
                    files.RemoveAll(item => item == null);
                }
            }

            #endregion 若有null則是前端html的name重複於ajax formData名稱

            #region img data binding 單筆多筆裝在不同容器

            fileRepository.UploadFile(fileModel, files, identityId, _actionName);
            fileRepository.SaveFileToDB(fileModel);

            #endregion img data binding 單筆多筆裝在不同容器

            #endregion FILEBASE處理

            return(identityId);
        }
Exemplo n.º 20
0
        public TeamListResultModel DoGetList(TeamListFilterModel filterModel)
        {
            PublicMethodRepository.FilterXss(filterModel);
            TeamListResultModel result = new TeamListResultModel();
            List <TEAM>         data   = new List <TEAM>();

            using (var db = new RITUAL())
            {
                try
                {
                    data = db.TEAM.ToList();

                    //關鍵字搜尋
                    if (!string.IsNullOrEmpty(filterModel.QueryString))
                    {
                        this.ListFilter(filterModel.QueryString, ref data);
                    }

                    if (filterModel.CityID.HasValue)
                    {
                        this.ListFilterCity(filterModel.CityID.Value, ref data);
                    }

                    if (filterModel.AreaID.HasValue)
                    {
                        this.ListFilterArea(filterModel.AreaID.Value, ref data);
                    }

                    //發佈日期搜尋
                    //if (!string.IsNullOrEmpty(filterModel.PublishDate))
                    //{
                    //    this.ListDateFilter(filterModel.PublishDate, ref data);
                    //}

                    //前台顯示
                    //if (!string.IsNullOrEmpty(filterModel.Disable))
                    //{
                    //    this.ListStatusFilter(filterModel.Disable, "Display", ref data);
                    //}

                    //上下架
                    //if (!string.IsNullOrEmpty(filterModel.Disable))
                    //{
                    //    this.ListStatusFilter(filterModel.Disable, "Disable", ref data);
                    //}

                    //排序
                    this.ListSort(filterModel.SortColumn, ref data);
                    PaginationResult pagination;
                    //分頁
                    this.ListPageList(filterModel.CurrentPage, ref data, out pagination, filterModel.DoPagination);
                    result.Pagination = pagination;
                    foreach (var d in data)
                    {
                        PublicMethodRepository.HtmlDecode(d);
                    }

                    result.Data = data;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(result);
        }
Exemplo n.º 21
0
        public ActionResult Index()
        {
            ViewBag.IsFirstPage = true;
            var mdu = new ProductsModule <ListFilterBase, PRODUCT>();
            Dictionary <bool, string> productInfo = mdu.GetProductInfo();

            TempData["productInfo"] = productInfo;

            HomeDataModel model = new HomeDataModel();
            Dictionary <int, List <FileViewModel> > productFiles = new Dictionary <int, List <FileViewModel> >();
            Dictionary <int, List <FileViewModel> > newstFiles   = new Dictionary <int, List <FileViewModel> >();

            using (var module = ListFactoryService.Create(ListMethodType.PRODUCT))
            {
                ListViewBase   temp            = new ListViewBase();
                List <PRODUCT> bindProductData = new List <PRODUCT>();
                var            productResult   = (module.DoGetList(temp.Filter) as ListResultBase);

                foreach (var data in (productResult.Data as List <PRODUCT>).Take(2))
                {
                    //取檔案
                    using (FileModule fileModule = new FileModule())
                    {
                        var file = fileModule.GetFiles((int)data.ID, "Products");
                        if (!productFiles.ContainsKey(data.ID))
                        {
                            productFiles.Add(data.ID, new List <FileViewModel>());
                        }
                        productFiles[data.ID] = file;
                    }
                    bindProductData.Add(data);
                }
                temp.Result.Data = bindProductData;
                model.Result.Add("Products", temp);
            }
            TempData["ProductFiles"] = productFiles;

            using (var module = ListFactoryService.Create(ListMethodType.NEWS))
            {
                ListViewBase temp         = new ListViewBase();
                List <NEWS>  bindNewsData = new List <NEWS>();

                var newResult = (module.DoGetList(temp.Filter) as ListResultBase);

                foreach (var data in (newResult.Data as List <NEWS>).Take(3))
                {
                    data.CONTENT = data.CONTENT = PublicMethodRepository.StripHTML(data.CONTENT).SplitLengthString(60);
                    //取檔案
                    using (FileModule fileModule = new FileModule())
                    {
                        var file = fileModule.GetFiles((int)data.ID, "News");
                        if (!newstFiles.ContainsKey(data.ID))
                        {
                            newstFiles.Add(data.ID, new List <FileViewModel>());
                        }
                        newstFiles[data.ID] = file;
                        bindNewsData.Add(data);
                    }
                }
                temp.Result.Data = bindNewsData;
                model.Result.Add("News", temp);
            }
            TempData["NewstFiles"] = newstFiles;


            return(View(model));
        }
Exemplo n.º 22
0
        public int DoSaveData(ActivityDataModel model)
        {
            OLACT          saveModel;
            FileRepository fileRepository = new FileRepository();

            if (!model.ID.HasValue)
            {
                saveModel        = new OLACT();
                saveModel.BUD_ID = UserProvider.Instance.User.ID;
                saveModel.BUD_DT = DateTime.UtcNow.AddHours(8);
            }
            else
            {
                saveModel = this.DB.OLACT.Where(s => s.ID == model.ID).FirstOrDefault();
            }
            saveModel.ACTITLE          = model.Title;
            saveModel.SQ               = model.Sort;
            saveModel.PUB_DT_STR       = model.PublishDateStr;
            saveModel.APPLY_DATE_BEGIN = model.ApplyDateTimeBegin;
            saveModel.APPLY_DATE_END   = model.ApplyDateTimeEnd;
            saveModel.ACT_CONTENT      = model.contenttext;
            saveModel.ACT_NUM          = model.ActivityNumber;
            saveModel.ACT_DATE_DESC    = model.ActivityDateTimeDescription;
            saveModel.DISABLE          = model.Disable;
            saveModel.UPD_ID           = UserProvider.Instance.User.ID;
            saveModel.UPD_DT           = DateTime.UtcNow.AddHours(8);
            PublicMethodRepository.FilterXss(saveModel);

            if (!model.ID.HasValue)
            {
                this.DB.OLACT.Add(saveModel);
            }
            else
            {
                this.DB.Entry(saveModel).State = EntityState.Modified;
            }

            try
            {
                this.DB.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            int identityId = (int)saveModel.ID;

            #region 組別
            List <OLACTGROUP> groupUpdateEntity = new List <OLACTGROUP>();
            List <OLACTGROUP> groupAddEntity    = new List <OLACTGROUP>();
            List <int>        oldIds            = model.ActivityGroup.Where(o => o.GroupID > 0).Select(s => s.GroupID).ToList();
            using (var transation = DB.Database.CurrentTransaction ?? DB.Database.BeginTransaction())
            {
                var removeNotInEntities = DB.OLACTGROUP.Where(o => o.MAP_ACT_ID == identityId && !oldIds.Contains(o.ID));
                if (removeNotInEntities.Count() > 0)
                {
                    DB.OLACTGROUP.RemoveRange(removeNotInEntities);
                }

                foreach (var group in model.ActivityGroup)
                {
                    OLACTGROUP temp = null;
                    if (group.GroupID == 0)
                    {
                        temp = new OLACTGROUP();

                        temp.BUD_DT = DateTime.UtcNow.AddHours(8);
                        temp.BUD_ID = UserProvider.Instance.User.ID;
                    }
                    else
                    {
                        temp = DB.OLACTGROUP.Where(o => o.ID == group.GroupID).First();
                    }
                    temp.MAP_ACT_ID        = identityId;
                    temp.GROUP_NAME        = group.GroupName;
                    temp.TEAM_APPLY_LIMIT  = group.GroupApplyLimit;
                    temp.COUNT_APPLY_LIMIT = group.CountApplyLimit;
                    temp.UPD_DT            = DateTime.UtcNow.AddHours(8);
                    temp.UPD_ID            = UserProvider.Instance.User.ID;

                    if (group.GroupID == 0)
                    {
                        groupAddEntity.Add(temp);
                    }
                    else
                    {
                        groupUpdateEntity.Add(temp);
                    }
                }

                foreach (var item in groupUpdateEntity)
                {
                    this.DB.Entry(item).State = EntityState.Modified;
                }

                if (groupAddEntity.Count > 0)
                {
                    this.DB.OLACTGROUP.AddRange(groupAddEntity);
                }
                try
                {
                    DB.SaveChanges();
                    transation.Commit();
                }
                catch (Exception ex)
                {
                    transation.Rollback();
                    throw ex;
                }
            }
            #endregion


            #region 檔案處理

            FilesModel fileModel = new FilesModel()
            {
                ActionName = "Activity",
                ID         = identityId,
                OldFileIds = model.OldFilesId
            };

            fileRepository.UploadFile("Post", fileModel, model.Files, "M");
            fileRepository.SaveFileToDB(fileModel);

            #endregion 檔案處理

            return(identityId);
        }