public int GetDefault(WebContentType4 model)
 {
     try
     {
         return _wctdao.GetDefault(model);
     }
     catch (Exception ex)
     {
         throw new Exception("WebContentType4Mgr.GetDefault-->" + ex.Message, ex);
     }
 }
 /// <summary>
 /// 獲取已啟用的個數
 /// </summary>
 /// <returns></returns>
 public int GetDefault(WebContentType4 model)
 {
     StringBuilder sql = new StringBuilder("");
     try
     {
         sql.AppendFormat(@" select count(*) as countSta from web_content_type4 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("WebContentType4Dao.GetDefault-->" + ex.Message + sql.ToString(), ex); 
     }
    
 }
        /// <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 = "" });

            }
        }
        /// <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 });
        }
 protected HttpResponseBase updateWebContentType4(WebContentType4 model)
 {
     string json = string.Empty;
     try
     {
         _wctMgr4.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;
 }
        public HttpResponseBase SaveWebContentType4()
        {
            WebContentType4 model = new WebContentType4();
            WebContentType4 oldModel = new WebContentType4();
            if (!String.IsNullOrEmpty(Request.Params["rowid"]))//如果不存在該id說明是添加頁面
            {
                model.content_id = Convert.ToInt32(Request.Params["rowid"].ToString());
                oldModel = _wctMgr4.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;
            }
            try
            {
                model.type_id = Convert.ToInt32(Request.Params["type_id"]);
            }
            catch
            {
                model.type_id = oldModel.type_id;
            }
            #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);
            //        fileName = fileName.Substring(0, fileName.LastIndexOf("."));
            //        fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.'));
            //        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(localPromoPath.Substring(0, localPromoPath.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 = localPromoPath + 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(localPromoPath, ftpuser, ftppwd);
            //            List<string> tem = ftp.GetFileList();
            //            if (tem.Contains(oldFileName))
            //            {
            //                FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd);
            //                ftps.DeleteFile(localPromoPath + oldFileName);//刪除ftp:71.159上的舊圖片

            //            }
            //        }
            //        try
            //        {//上傳                        
            //            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)
            //        {
            //            model.content_image = oldModel.content_image;
            //        }
            //    }
            //}
            //catch (Exception)
            //{
            //    model.content_image = oldModel.content_image;
            //}
            #endregion
            try
            {
                model.brand_id = Convert.ToInt32(Request.Params["brand_id"].ToString());
            }
            catch
            {
                model.brand_id = oldModel.brand_id;
            }
            try
            {
                model.content_html = Request.Params["home_text"].ToString();
            }
            catch
            {
                model.content_html = oldModel.content_html;
            }
            try
            {
                model.content_default = Convert.ToInt32(Request.Params["content_default"]);
            }
            catch
            {
                model.content_default = oldModel.content_default;
            }
            try
            {
                model.content_status = Convert.ToInt32(Request.Params["content_status"]);
            }
            catch
            {
                model.content_status = oldModel.content_status;
            }
            try
            {
                model.link_url = Request.Params["link_url"].ToString();
            }
            catch
            {
                model.content_status = oldModel.content_status;
            }
            try
            {
                model.link_mode = Convert.ToInt32(Request.Params["link_mode"]);
            }
            catch
            {
                model.link_mode = oldModel.link_mode;
            }

            #endregion
            //判斷是否能夠獲取到rowid
            if (String.IsNullOrEmpty(Request.Params["content_id"]))//如果不存在該id說明是添加頁面
            {
                model.created_on = DateTime.Now;
                model.update_on = model.created_on;
                //這裡加上各種參數
                return InsertWebContentType4(model);//如果獲取不到則進行新增
            }
            else
            {
                model.update_on = DateTime.Now;//這裡加上各種參數                
                return updateWebContentType4(model);//如果可以獲取到rowid則進行修改
            }
        }