public int GetDefault(WebContentType7 model)
 {
     try
     {
         return _wctdao.GetDefault(model);
     }
     catch (Exception ex)
     {
         throw new Exception("WebContentType7Mgr.GetDefault-->" + ex.Message, 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 = "" });

            }
        }
 protected HttpResponseBase updateWebContentType7(WebContentType7 model)
 {
     string json = string.Empty;
     try
     {
         if (!model.link_url.Contains("?"))
         {
             model.link_url += "?content_id=" + model.content_id;
         }
         _wctMgr7.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;
 }
        /// <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 });
        }
        public HttpResponseBase SaveWebContentType7()
        {
            string rowid = Request.Params["rowid"];
            WebContentType7 model = new WebContentType7();
            WebContentType7 oldModel = new WebContentType7();
            if (!String.IsNullOrEmpty(rowid))//修改
            {
                model.content_id = Convert.ToInt32(rowid);
                oldModel = _wctMgr7.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();
                //文件名,文件擴展名,新文件名,舊文件名
                string fileName = String.Empty, fileExtention = String.Empty, newFileName = String.Empty, oldFileName = String.Empty;
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFileBase file = Request.Files[i];
                    fileName = fileLoad.NewFileName(file.FileName);
                    if (fileName != "")
                    {
                        fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                        fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();

                        newFileName = new BLL.gigade.Common.HashEncrypt().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);
                        fileName = newFileName + fileExtention;
                        newFileName = localHealthPath + newFileName + fileExtention;//絕對路徑
                        ServerPath = Server.MapPath(imgLocalServerPath + healthPath);
                        string ErrorMsg = string.Empty;
                        //上傳之前刪除已有的圖片
                        if (model.content_id != 0)
                        {
                            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 ftpDel = new FTP(localHealthPath + oldFileName, ftpuser, ftppwd);
                                ftpDel.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
            model.home_title = Request.Params["home_title"].ToString();
            model.home_text = Request.Params["home_text"].ToString();
            model.content_title = Request.Params["content_title"].ToString();
            model.content_html = Request.Params["content_html"].ToString();
            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();
            model.link_mode = Convert.ToInt32(Request.Params["link_mode"]);
            model.keywords = Request.Params["keywords"].ToString();
            model.sort = Convert.ToInt32(Request.Params["sort"]);
            if (!string.IsNullOrEmpty(Request.Params["start_time"].ToString()))
            {
                model.start_time = DateTime.Parse(Request.Params["start_time"].ToString());
            }
            model.end_time = DateTime.Parse(Request.Params["end_time"].ToString());
            #endregion
            //判斷是否能夠獲取到rowid
            if (String.IsNullOrEmpty(rowid))//新增
            {
                model.created_on = DateTime.Now;
                model.update_on = model.created_on;
                return InsertWebContentType7(model);//如果獲取不到則進行新增
            }
            else
            {
                model.update_on = DateTime.Now;
                return updateWebContentType7(model);//如果可以獲取到rowid則進行修改
            }
        }