Пример #1
0
        public void Upd_Disable(HttpContext context)
        {
            int ret = -1;
            String jSonString = "";
            try {
                ContentsBO aContentsBO = new ContentsBO();
                List<Contents> listContents = new List<Contents>();
                string Code = aContentsBO.Sel_ByID(int.Parse(context.Request.QueryString["IDContents"])).Code;
                //listContents = aContentsBO.Sel_all_ByCode(Code);
                for (int i = 0; i < listContents.Count; i++) {
                    listContents[i].Disable = true;
                    ret = aContentsBO.Upd(listContents[i]);
                }

                if (ret != 0) {
                    jSonString = "{\"status\":\"error|" + ret.ToString() + "\"}";

                }

                if (ret == 0) { jSonString = "{\"status\": \"success\"}"; }
            }
            catch (Exception ex) {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message.ToString() + "\"}";
            }
            finally {
                context.Response.Write(jSonString);
            }
        }
Пример #2
0
        public void Upd_ViewCount(HttpContext context, int NUM_LANG)
        {
            int ret = -1;
            String jSonString = "";
            String Code = context.Request.QueryString["CodeContents"];

            //if ( context.Request.Cookies["ViewCount"] == null)
            if (context.Session[Code] == null) {
                try {
                    if (NUM_LANG < 1) {
                        NUM_LANG = 1;
                    }
                    List<Contents> aListContents = new List<Contents>();
                    ContentsBO aContentsBO = new ContentsBO();

                    //aListContents = aContentsBO.Sel_all_ByCode(Code);

                    int LoopUpdate = 0;

                    if (aListContents.Count <= NUM_LANG) {
                        LoopUpdate = aListContents.Count;
                        for (int i = 0; i < LoopUpdate; i++) {

                            aListContents[i].ViewCount = !String.IsNullOrEmpty(aListContents[i].ViewCount.ToString()) ? Convert.ToInt64(aListContents[i].ViewCount + 1) : 1;

                            ret = aContentsBO.Upd(aListContents[i]);
                            if (ret == 0) {
                                jSonString = "{\"status\":\"error|" + ret.ToString() + "\"}";
                                break;
                            }

                        }
                    }
                    if (ret != 0) { jSonString = "{\"status\": \"success\"}"; }
                    //HttpCookie aHttpCookie = new HttpCookie("ViewCount");
                    //aHttpCookie.Expires = DateTime.Now.AddDays(10);
                    //context.Request.Cookies.Add(aHttpCookie);
                    context.Session[Code] = 1;

                }
                catch (Exception ex) {
                    jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message.ToString() + "\"}";
                }
                finally {
                    context.Response.Write(jSonString);
                }

            }
        }
Пример #3
0
        //TODO: hàm này có vấn đề
        public void Upd_ByCode(HttpContext context, int NUM_LANG)
        {
            string jSonString = string.Empty;
            try{
                if (NUM_LANG < 1) NUM_LANG = 1;
                ContentsBO aContentsBO = new ContentsBO();
                String code = context.Request.Form["txtCode"];

                var aListContents = aContentsBO.Sel_ByCode(code);

                if (aListContents.Count <= NUM_LANG){
                    for (int i = 0; i < aListContents.Count; i++){
                        aListContents[i].UpdateBy = aCurrentSystemUsers.Username;

                        aListContents[i].Type = !String.IsNullOrEmpty(context.Request.Form["txtType"])
                            ? Convert.ToInt32(context.Request.Form["txtType"])
                            : aListContents[i].Type;

                        aListContents[i].Title = !String.IsNullOrEmpty(context.Request.Form["txtTitle_Lang" + (i + 1)])
                            ? Convert.ToString(context.Request.Form["txtTitle_Lang" + (i + 1)])
                            : aListContents[i].Title;

                        aListContents[i].Info = !String.IsNullOrEmpty(context.Request.Form["txtInfo_Lang" + (i + 1)])
                            ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtInfo_Lang" + (i + 1)]))
                            : aListContents[i].Info;

                        aListContents[i].Intro = !String.IsNullOrEmpty(context.Request.Form["txtIntro_Lang" + (i + 1)])
                            ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtIntro_Lang" + (i + 1)]))
                            : aListContents[i].Intro;

                        aListContents[i].Status = !String.IsNullOrEmpty(context.Request.Form["ddlStatus"])
                            ? Convert.ToInt32(context.Request.Form["ddlStatus"])
                            : aListContents[i].Status;

                        aListContents[i].CreatedBy = !String.IsNullOrEmpty(context.Request.Form["txtCreatedBy"])
                            ? Convert.ToString(context.Request.Form["txtCreatedBy"])
                            : aListContents[i].CreatedBy;

                        aListContents[i].Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"])
                            ? Convert.ToBoolean(context.Request.Form["cbbDisable"])
                            : aListContents[i].Disable;

                        aListContents[i].Tag = !String.IsNullOrEmpty(context.Request.Form["txtTag"])
                            ? Convert.ToString(context.Request.Form["txtTag"])
                            : aListContents[i].Tag;

                        aListContents[i].DateCreated = !String.IsNullOrEmpty(context.Request.Form["dtpDateCreated"])
                            ? DateTime.ParseExact(context.Request.Form["dtpDateCreated"], "dd/MM/yyyy", culture)
                            : aListContents[i].DateCreated;

                        aListContents[i].DateEdited = !String.IsNullOrEmpty(context.Request.Form["dtpDateEdited"])
                            ? DateTime.ParseExact(context.Request.Form["dtpDateEdited"], "dd/MM/yyyy", culture)
                            : aListContents[i].DateEdited;

                        aListContents[i].PublishDate = !String.IsNullOrEmpty(context.Request.Form["dtpPublishDate"])
                            ? DateTime.ParseExact(context.Request.Form["dtpPublishDate"], "dd/MM/yyyy", culture)
                            : aListContents[i].PublishDate;

                        aListContents[i].ExpireDate = !String.IsNullOrEmpty(context.Request.Form["dtpExpireDate"])
                            ? DateTime.ParseExact(context.Request.Form["dtpExpireDate"], "dd/MM/yyyy", culture)
                            : aListContents[i].ExpireDate;

                        aListContents[i].Image = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"])
                            ? Convert.ToString(context.Request.Form["txtImage_1"])
                            : "";
                        aListContents[i].Image1 = !String.IsNullOrEmpty(context.Request.Form["txtImage_2"])
                            ? Convert.ToString(context.Request.Form["txtImage_2"])
                            : "";
                        aListContents[i].Image2 = !String.IsNullOrEmpty(context.Request.Form["txtImage_3"])
                            ? Convert.ToString(context.Request.Form["txtImage_3"])
                            : "";
                        aListContents[i].Image3 = !String.IsNullOrEmpty(context.Request.Form["txtImage_4"])
                            ? Convert.ToString(context.Request.Form["txtImage_4"])
                            : "";

                        aListContents[i].IDAlbum = !String.IsNullOrEmpty(context.Request.Form["txtIDAlbum"])
                            ? Convert.ToInt32(context.Request.Form["txtIDAlbum"])
                            : aListContents[i].IDAlbum;

                        aListContents[i].IDLang =
                            !String.IsNullOrEmpty(context.Request.Form["IDLanguage_Lang" + (i + 1)])
                                ? Convert.ToInt32(context.Request.Form["IDLanguage_Lang" + (i + 1)])
                                : aListContents[i].IDLang;

                        aListContents[i].Code = !String.IsNullOrEmpty(context.Request.Form["txtCode"])
                            ? Convert.ToString(context.Request.Form["txtCode"])
                            : aListContents[i].Code;

                        aListContents[i].ExtendProperties1 =
                            !String.IsNullOrEmpty(context.Request.Form["txtExtendProperties1_Lang" + (i + 1)])
                                ? Convert.ToString(context.Request.Form["txtExtendProperties1_Lang" + (i + 1)])
                                : aListContents[i].ExtendProperties1;

                        aListContents[i].ExtendProperties2 =
                            !String.IsNullOrEmpty(context.Request.Form["txtExtendProperties2_Lang" + (i + 1)])
                                ? Convert.ToString(context.Request.Form["txtExtendProperties2_Lang" + (i + 1)])
                                : aListContents[i].ExtendProperties2;

                        aListContents[i].ExtendProperties3 =
                            !String.IsNullOrEmpty(context.Request.Form["txtExtendProperties3_Lang" + (i + 1)])
                                ? Convert.ToString(context.Request.Form["txtExtendProperties3_Lang" + (i + 1)])
                                : aListContents[i].ExtendProperties3;

                        aListContents[i].ViewCount = !String.IsNullOrEmpty(context.Request.Form["txtViewCount"])
                            ? Convert.ToInt64(context.Request.Form["txtViewCount"])
                            : 0;
                    }

                    var ret1 = aContentsBO.Upd(aListContents);
                    if (!(ret1 >= 0 && ret1 <= NUM_LANG)){
                        jSonString = "{\"status\":\"error\" ,\"message\":Ret1= " + ret1 + "\"}";
                        context.Response.Write(jSonString);
                        return;
                    }

                    //TODO: delete all record with CodeContents = content.Code
                    string listTempt = Convert.ToString(context.Request.Form["ckbCodeCategoryLevel1[]"]);
                    if (!string.IsNullOrEmpty(listTempt)){
                        List<string> listString = listTempt.Split(',').ToList();
                        Contents_CategoryLevel1BO aContents_CategoryLevel1BO = new Contents_CategoryLevel1BO();

                        List<Contents_CategoryLevel1> listTemp =
                            aContents_CategoryLevel1BO.Sel_ByCodeContents(aListContents[0].Code);
                        aContents_CategoryLevel1BO.Del(listTemp);
                        listTemp.Clear();

                        listTemp.AddRange(from content in aListContents
                            from s in listString
                            select new Contents_CategoryLevel1{
                                Disable = content.Disable, Status = content.Status, Type = content.Type, CodeContents = content.Code, CodeCategoryLevel1 = s, IDLang = content.IDLang
                            });
                        //List<Contents_CategoryLevel1> list = Contents_CategoryLevel1BO.Sel_ByCodeContents()
                        var ret2 = aContents_CategoryLevel1BO.Upd(listTemp);
                        jSonString = "{\"status\": \"success\"}";

                        if (ret2 != listTemp.Count) {
                            jSonString = "{\"status\":\"error\" ,\"message\":Ret2= " + ret2 + "\"}";
                        }
                    }
                    else{
                        jSonString = "{\"status\":\"error\" ,\"message\": listTempt is Empty \"}";
                    }
                }
            }
            catch (Exception ex){
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message + "\"}";
            }
            finally{
                context.Response.Write(jSonString);
            }
        }