Ejemplo n.º 1
0
        public int Insert(WebContentType2 model)
        {
            model.Replace4MySQL();
            StringBuilder sb = new StringBuilder();
            try
            {
                if (model.content_status == 1)//啟用
                {
                    WebContentTypeSetupDao _setDao = new WebContentTypeSetupDao(_connStr);
                    WebContentTypeSetup smodel = new WebContentTypeSetup();
                    smodel.site_id = model.site_id;
                    smodel.page_id = model.page_id;
                    smodel.area_id = model.area_id;
                    smodel.web_content_type = "web_content_type2";
                    _setDao.UpdateLimitStatus(smodel);////當前已啟用的個數超過5筆時,使最舊的不啟用,
                }

                sb.AppendFormat(@"INSERT INTO web_content_type2(site_id,page_id,area_id,content_title,content_image,home_title,home_text,product_id,content_default,content_status,link_url,link_page,link_mode,start_time,end_time,update_on,created_on) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}') ", model.site_id, model.page_id, model.area_id, model.content_title, model.content_image, model.home_title, model.home_text, model.product_id, model.content_default, model.content_status, model.link_url, model.link_page, model.link_mode, CommonFunction.DateTimeToString(model.start_time), CommonFunction.DateTimeToString(model.end_time), CommonFunction.DateTimeToString(model.update_on), CommonFunction.DateTimeToString(model.created_on));
                return _access.execCommand(sb.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("WebContentType2Dao.Insert-->" + ex.Message + sb.ToString(), ex);
            }

        }
Ejemplo n.º 2
0
 public int GetDefault(WebContentType2 model)
 {
     try
     {
         return _wctdao.GetDefault(model);
     }
     catch (Exception ex)
     {
         throw new Exception("WebContentType2Mgr.GetDefault-->" + ex.Message, ex);
     }
 }
Ejemplo n.º 3
0
        public WebContentType2 GetModel(WebContentType2 model)
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendFormat(@"select * from web_content_type2 where content_id ={0}", model.content_id);
                return _access.getSinggleObj<WebContentType2>(sb.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("WebContentType2Dao.GetModel-->" + ex.Message + sb.ToString(), ex);
            }


        }
Ejemplo n.º 4
0
        public int delete(WebContentType2 model)
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendFormat(@"update web_content_type2  set content_status=0 where content_id='{0}'", model.content_id);
                return _access.execCommand(sb.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("WebContentType2Dao.delete-->" + ex.Message + sb.ToString(), ex);
            }

        }
Ejemplo n.º 5
0
        /// <summary>
        /// 獲取已啟用的個數
        /// </summary>
        /// <returns></returns>
        public int GetDefault(WebContentType2 model)
        {
            StringBuilder sql = new StringBuilder("");
            try
            {
                sql.AppendFormat(@" select count(*) as countSta from web_content_type2 where content_status=1  and  pag_id='{0}';", model.page_id);
                return Convert.ToInt32(_access.getDataTable(sql.ToString()).Rows[0]["countSta"].ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("WebContentType2Dao.GetDefault-->" + ex.Message + sql.ToString(), ex);
            }

        }
Ejemplo n.º 6
0
        public HttpResponseBase SaveWebContentType2()
        {
            WebContentType2 model = new WebContentType2();
            WebContentType2 oldModel = new WebContentType2();
            int isTranInt = 0;
            if (!String.IsNullOrEmpty(Request.Params["rowid"]))//如果不存在該id說明是添加頁面
            {
                model.content_id = Convert.ToInt32(Request.Params["rowid"].ToString());
                oldModel = _wctMgr2.GetModel(model);
            }
            #region 獲取數據
            model.site_id = 7;
            try
            {
                model.page_id = Convert.ToInt32(Request.Params["page_id"].ToString());
            }
            catch
            {
                model.page_id = oldModel.page_id;
            }
            try
            {
                model.area_id = Convert.ToInt32(Request.Params["area_id"].ToString());
            }
            catch
            {
                model.area_id = oldModel.area_id;
            }

            model.content_title = Request.Params["content_title"].ToString();
            model.home_title = Request.Params["home_title"].ToString();
            model.home_text = Request.Params["home_text"].ToString();
            #region 圖片上傳
            try
            {
                ImagePathConfig();
                for (int iFile = 0; iFile < Request.Files.Count; iFile++)
                {
                    HttpPostedFileBase file = Request.Files[iFile];
                    string fileName = string.Empty;//當前文件名
                    string fileExtention = string.Empty;//當前文件的擴展名
                    //獲取圖片名稱
                    fileName = fileLoad.NewFileName(file.FileName);
                    if (fileName != "")
                    {
                        fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                        fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();

                        string NewFileName = string.Empty;
                        BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                        NewFileName = hash.Md5Encrypt(fileName, "32");
                        string ServerPath = string.Empty;
                        //判斷目錄是否存在,不存在則創建
                        FTP f_cf = new FTP();
                        f_cf.MakeMultiDirectory(localHealthPath.Substring(0, localHealthPath.Length - healthPath.Length + 1), healthPath.Substring(1, healthPath.Length - 2).Split('/'), ftpuser, ftppwd);
                        // CreateFolder(localPromoPath.Substring(0, localPromoPath.Length - healthPath.Length + 1), healthPath.Substring(1, healthPath.Length - 2).Split('/'));
                        //  returnName += promoPath + NewFileName;
                        fileName = NewFileName + fileExtention;
                        NewFileName = localHealthPath + NewFileName + fileExtention;//絕對路徑
                        ServerPath = Server.MapPath(imgLocalServerPath + healthPath);
                        string ErrorMsg = string.Empty;
                        //上傳之前刪除已有的圖片
                        if (model.content_id != 0)
                        {
                            string oldFileName = oldModel.content_image;
                            CommonFunction.DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                            FTP ftp = new FTP(localHealthPath, ftpuser, ftppwd);
                            List<string> tem = ftp.GetFileList();
                            if (tem.Contains(oldFileName))
                            {
                                FTP ftps = new FTP(localHealthPath + oldFileName, ftpuser, ftppwd);
                                ftps.DeleteFile(localHealthPath + oldFileName);//刪除ftp:71.159上的舊圖片
                            }
                        }
                        try
                        {
                            //上傳   
                            Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件
                            bool result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                            if (result)//上傳成功
                            {
                                model.content_image = fileName;
                            }
                        }
                        catch (Exception ex)
                        {
                            Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                            logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                            logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                            log.Error(logMessage);
                            model.content_image = oldModel.content_image;
                        }
                        if (!string.IsNullOrEmpty(ErrorMsg))
                        {
                            string json = string.Empty;
                            json = "{success:true,msg:\"" + ErrorMsg + "\"}";
                            this.Response.Clear();
                            this.Response.Write(json);
                            this.Response.End();
                            return this.Response;
                        }
                    }
                    else
                    {
                        model.content_image = oldModel.content_image;
                    }
                }
            }
            catch (Exception)
            {

                model.content_image = oldModel.content_image;
            }
            #endregion
            if (!string.IsNullOrEmpty(Request.Params["product_id"].ToString()))
            {
                if (int.TryParse(Request.Params["product_id"].ToString(), out isTranInt))
                {
                    model.product_id = Convert.ToInt32(Request.Params["product_id"]);
                }
                else
                {
                    model.product_id = oldModel.product_id;
                }
            }
            else
            {
                model.product_id = 0;
            }
            model.content_default = Convert.ToInt32(Request.Params["content_default"]);
            model.content_status = Convert.ToInt32(Request.Params["content_status"]);
            model.link_url = Request.Params["link_url"].ToString();
            if (!string.IsNullOrEmpty(Request.Params["start_time"].ToString()))
            {
                model.start_time = DateTime.Parse(Request.Params["start_time"].ToString());
            }
            if (!string.IsNullOrEmpty(Request.Params["end_time"].ToString()))
            {
                model.end_time = DateTime.Parse(Request.Params["end_time"].ToString());
            }
            //model.link_page = Request.Params["link_page"].ToString();
            model.link_mode = Convert.ToInt32(Request.Params["link_mode"]);
            #endregion
            //判斷是否能夠獲取到rowid
            if (String.IsNullOrEmpty(Request.Params["content_id"]))//如果不存在該id說明是添加頁面
            {
                model.created_on = DateTime.Now;
                model.update_on = model.created_on;//這裡加上各種參數                
                return InsertWebContentType2(model);//如果獲取不到則進行新增
            }
            else
            {
                model.update_on = DateTime.Now;//這裡加上各種參數                
                return updateWebContentType2(model);//如果可以獲取到rowid則進行修改
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 更改活動使用狀態
        /// </summary>
        /// <returns>數據庫操作結果</returns>
        public JsonResult UpdateActive()
        {
            string storeType = Request.Params["storeType"].ToString();
            switch (storeType)
            {
                case "type1":
                    WebContentType1 model1 = new WebContentType1();
                    model1.content_id = Convert.ToInt32(Request.Params["id"]);
                    model1 = _wctMgr1.GetModel(model1);
                    model1.content_status = Convert.ToInt32(Request.Params["active"]);
                    model1.content_default = 1;
                    if (_wctMgr1.Update(model1) > 0)
                    {
                        return Json(new { success = "true", msg = "" });
                    }
                    else
                    {
                        return Json(new { success = "false", msg = "" });
                    }

                case "type2":
                    WebContentType2 model2 = new WebContentType2();
                    model2.content_id = Convert.ToInt32(Request.Params["id"]);
                    model2 = _wctMgr2.GetModel(model2);
                    model2.content_status = Convert.ToInt32(Request.Params["active"]);
                    model2.content_default = 1;
                    if (_wctMgr2.Update(model2) > 0)
                    {
                        return Json(new { success = "true", msg = "" });
                    }
                    else
                    {
                        return Json(new { success = "false", msg = "" });
                    }

                case "type3":
                    WebContentType3 model3 = new WebContentType3();
                    model3.content_id = Convert.ToInt32(Request.Params["id"]);
                    model3 = _wctMgr3.GetModel(model3);
                    model3.content_status = Convert.ToInt32(Request.Params["active"]);
                    model3.content_default = 1;
                    if (_wctMgr3.Update(model3) > 0)
                    {
                        return Json(new { success = "true", msg = "" });
                    }
                    else
                    {
                        return Json(new { success = "false", msg = "" });
                    }

                case "type4":
                    WebContentType4 model4 = new WebContentType4();
                    model4.content_id = Convert.ToInt32(Request.Params["id"]);
                    model4 = _wctMgr4.GetModel(model4);
                    model4.content_status = Convert.ToInt32(Request.Params["active"]);
                    model4.content_default = 1;
                    if (_wctMgr4.Update(model4) > 0)
                    {
                        return Json(new { success = "true", msg = "" });
                    }
                    else
                    {
                        return Json(new { success = "false", msg = "" });
                    }

                case "type5":
                    WebContentType5 model5 = new WebContentType5();
                    model5.content_id = Convert.ToInt32(Request.Params["id"]);
                    model5 = _wctMgr5.GetModel(model5);
                    model5.content_status = Convert.ToInt32(Request.Params["active"]);
                    model5.content_default = 1;
                    if (_wctMgr5.Update(model5) > 0)
                    {
                        return Json(new { success = "true", msg = "" });
                    }
                    else
                    {
                        return Json(new { success = "false", msg = "" });
                    }

                case "type6":
                    WebContentType6 model6 = new WebContentType6();
                    model6.content_id = Convert.ToInt32(Request.Params["id"]);
                    model6 = _wctMgr6.GetModel(model6);
                    model6.content_status = Convert.ToInt32(Request.Params["active"]);
                    model6.content_default = 1;
                    if (_wctMgr6.Update(model6) > 0)
                    {
                        return Json(new { success = "true", msg = "" });
                    }
                    else
                    {
                        return Json(new { success = "false", msg = "" });
                    }

                case "type7":
                    WebContentType7 model7 = new WebContentType7();
                    model7.content_id = Convert.ToInt32(Request.Params["id"]);
                    model7 = _wctMgr7.GetModel(model7);
                    model7.content_status = Convert.ToInt32(Request.Params["active"]);
                    model7.content_default = 1;
                    if (_wctMgr7.Update(model7) > 0)
                    {
                        return Json(new { success = "true", msg = "" });
                    }
                    else
                    {
                        return Json(new { success = "false", msg = "" });
                    }

                case "type8":
                    WebContentType8 model8 = new WebContentType8();
                    model8.content_id = Convert.ToInt32(Request.Params["id"]);
                    model8 = _wctMgr8.GetModel(model8);
                    model8.content_status = Convert.ToInt32(Request.Params["active"]);
                    model8.content_default = 1;
                    if (_wctMgr8.Update(model8) > 0)
                    {
                        return Json(new { success = "true", msg = "" });
                    }
                    else
                    {
                        return Json(new { success = "false", msg = "" });
                    }
                default:
                    return Json(new { success = "false", msg = "" });

            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 獲取參數表中設置的限制值
        /// </summary>
        /// <returns>數據庫操作結果</returns>
        public JsonResult GetDefaultLimit()
        {
            int statusListNum = 0; int limitNumStatus = 0;
            WebContentTypeSetup model = new WebContentTypeSetup();
            model.web_content_type = Request.Params["storeType"].ToString();
            model.site_id = Convert.ToInt32(Request.Params["site"].ToString());
            model.page_id = Convert.ToInt32(Request.Params["page"]);
            model.area_id = Convert.ToInt32(Request.Params["area"]);
            limitNumStatus = _wctsuMgr.Query(model)[0].content_status_num;

            if (limitNumStatus != 0 && !string.IsNullOrEmpty(limitNumStatus.ToString()))
            {

                switch (model.web_content_type)
                {
                    case "web_content_type1":
                        WebContentType1 model1 = new WebContentType1();
                        model1.page_id = model.page_id;
                        statusListNum = _wctMgr1.GetDefault(model1);//獲取列表中已啟用的數量
                        break;
                    case "web_content_type2":
                        WebContentType2 model2 = new WebContentType2();
                        model2.page_id = model.page_id;
                        statusListNum = _wctMgr2.GetDefault(model2);
                        break;
                    case "web_content_type3":
                        WebContentType3 model3 = new WebContentType3();
                        model3.page_id = model.page_id;
                        statusListNum = _wctMgr3.GetDefault(model3);
                        break;
                    case "web_content_type4":
                        WebContentType4 model4 = new WebContentType4();
                        model4.page_id = model.page_id;
                        statusListNum = _wctMgr4.GetDefault(model4);
                        break;
                    case "web_content_type5":
                        WebContentType5 model5 = new WebContentType5();
                        model5.page_id = model.page_id;
                        statusListNum = _wctMgr5.GetDefault(model5);
                        break;
                    case "web_content_type6":
                        WebContentType6 model6 = new WebContentType6();
                        model6.page_id = model.page_id;
                        statusListNum = _wctMgr6.GetDefault(model6);
                        break;
                    case "web_content_type7":
                        WebContentType7 model7 = new WebContentType7();
                        model7.page_id = model.page_id;
                        statusListNum = _wctMgr7.GetDefault(model7);
                        break;
                    case "web_content_type8":
                        WebContentType8 model8 = new WebContentType8();
                        model8.page_id = model.page_id;
                        statusListNum = _wctMgr8.GetDefault(model8);
                        break;
                    default:
                        break;

                }
            }
            return Json(new { success = "true", listNum = statusListNum, limitNum = limitNumStatus });
        }
Ejemplo n.º 9
0
 protected HttpResponseBase updateWebContentType2(WebContentType2 model)
 {
     string json = string.Empty;
     try
     {
         _wctMgr2.Update(model);
         json = "{success:true}";//返回json數據
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }