public HttpResponseBase productPictrueTempSave() { string json = "{success:true}"; ProductTemp pTemp = new ProductTemp(); _productTempMgr = new ProductTempMgr(connectionString); _specTempMgr = new ProductSpecTempMgr(connectionString); _productPicMgr = new ProductPictureMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); if (string.IsNullOrEmpty(Request.Params["product_id"])) { if (!string.IsNullOrEmpty(Request.Params["image_InsertValue"])) pTemp.Product_Image = Request.Params["image_InsertValue"]; if (!string.IsNullOrEmpty(Request.Params["image_MobileValue"])) pTemp.Mobile_Image = Request.Params["image_MobileValue"];//如果手機說明圖有值,將值賦予Moibile_Image edit by wwei0216w 2015/3/18 if (!string.IsNullOrEmpty(Request.Params["productMedia"])) pTemp.product_media = Request.Params["productMedia"]; if (!string.IsNullOrEmpty(Request.Params["specify_Product_alt"])) pTemp.Product_alt = Request.Params["specify_Product_alt"];//add by wwei0216w 2015/4/9 pTemp.Writer_Id = (Session["caller"] as Caller).user_id; pTemp.Combo_Type = COMBO_TYPE; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } ProductSpecTemp pSpec = new ProductSpecTemp(); List<ProductSpecTemp> pSpecList = new List<ProductSpecTemp>(); if (!string.IsNullOrEmpty(Request.Params["spec_InsertValue"])) { string[] Values = Request.Form["spec_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pSpec = new ProductSpecTemp(); pSpec.Writer_Id = (Session["caller"] as Caller).user_id; pSpec.product_id = pTemp.Product_Id; string[] perValue = Values[i].Split(','); if (!string.IsNullOrEmpty(perValue[0])) { pSpec.spec_image = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pSpec.spec_id = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pSpec.spec_sort = uint.Parse(perValue[2]); }; if (!string.IsNullOrEmpty(perValue[3])) { pSpec.spec_status = uint.Parse(perValue[3]); }; pSpecList.Add(pSpec); } } List<ProductPictureTemp> picList = new List<ProductPictureTemp>(); _pPicTempMgr = new ProductPictureTempImplMgr(connectionString); ProductPictureTemp pPic = new ProductPictureTemp(); if (!string.IsNullOrEmpty(Request.Params["picture_InsertValue"])) { string[] Values = Request.Form["picture_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pPic = new ProductPictureTemp(); string[] perValue = Values[i].Split(','); pPic.combo_type = COMBO_TYPE; pPic.writer_Id = (Session["caller"] as Caller).user_id; pPic.product_id = pTemp.Product_Id; if (!string.IsNullOrEmpty(perValue[0])) { pPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pPic.image_state = uint.Parse(perValue[2]); }; picList.Add(pPic); } } //關於手機APP的代碼部份 List<ProductPictureTemp> picAppList = new List<ProductPictureTemp>(); //IProductPictureTempImplAppMgr ppt = new ProductPictureAppTempImplMgr(connectionString); ProductPictureTemp pa = new ProductPictureTemp(); if (!string.IsNullOrEmpty(Request.Params["mobilePic_InsertValue"])) { string[] Values = Request.Form["mobilePic_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pa = new ProductPictureTemp(); string[] AppValue = Values[i].Split(','); pa.combo_type = COMBO_TYPE; pa.writer_Id = (Session["caller"] as Caller).user_id; pa.product_id = pTemp.Product_Id; if (!string.IsNullOrEmpty(AppValue[0])) { pa.image_filename = AppValue[0]; }; if (!string.IsNullOrEmpty(AppValue[1])) { pa.image_sort = uint.Parse(AppValue[1]); }; if (!string.IsNullOrEmpty(AppValue[2])) { pa.image_state = uint.Parse(AppValue[2]); }; picAppList.Add(pa); } } try { int type = 1;//1:商品說明圖,2:手機App說明圖 int writer_id = (Session["caller"] as Caller).user_id; //保存至productTemp if (pTemp.Product_Image != "" || pTemp.product_media != "" || pTemp.Mobile_Image != "" || pTemp.Product_alt != "") { _productTempMgr.ProductTempUpdate(pTemp, "pic"); } //保存規格圖 _specTempMgr.Update(pSpecList, "image"); //保存說明圖 string oldProductId = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { oldProductId = Request.Form["OldProductId"]; } _pPicTempMgr.Save(picList, new ProductPictureTemp() { writer_Id = writer_id, combo_type = COMBO_TYPE, product_id = oldProductId }, type);// edit by wangwei0216w 註釋掉_pPicTempMgr.Save 以解決複製后不能讀取圖片路勁到數據庫 type = 2; _pPicTempMgr.Save(picAppList, new ProductPictureTemp() { writer_Id = writer_id, combo_type = COMBO_TYPE, product_id = oldProductId }, type); } 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,msg:\"" + Resources.Product.EDIT_FAIL + "\"}"; } } else//更新正式表 { Product p = new Product(); uint productId = uint.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(Request.Params["image_InsertValue"])) p.Product_Image = Request.Params["image_InsertValue"];//如果商品說明圖有值,將值賦予Product_Image if (!string.IsNullOrEmpty(Request.Params["image_MobileValue"])) p.Mobile_Image = Request.Params["image_MobileValue"];//如果手機說明圖有值,將值賦予Moibile_Image edit by wwei0216w 2015/3/18 if (!string.IsNullOrEmpty(Request.Params["productMedia"])) p.product_media = Request.Params["productMedia"]; if (!string.IsNullOrEmpty(Request.Params["specify_Product_alt"])) p.Product_alt = Request.Params["specify_Product_alt"];//add by wwei0216w 2015/4/9 p.Product_Id = productId; _productMgr = new ProductMgr(connectionString); ProductSpec pSpec = new ProductSpec(); List<ProductSpec> pSpecList = new List<ProductSpec>(); if (!string.IsNullOrEmpty(Request.Params["spec_InsertValue"])) { string[] Values = Request.Form["spec_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pSpec = new ProductSpec(); pSpec.product_id = productId; string[] perValue = Values[i].Split(','); if (!string.IsNullOrEmpty(perValue[0])) { pSpec.spec_image = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pSpec.spec_id = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pSpec.spec_sort = uint.Parse(perValue[2]); }; if (!string.IsNullOrEmpty(perValue[3])) { pSpec.spec_status = uint.Parse(perValue[3]); }; pSpecList.Add(pSpec); } } List<ProductPicture> picList = new List<ProductPicture>(); _productPicMgr = new ProductPictureMgr(connectionString); ProductPicture pPic = new ProductPicture(); if (!string.IsNullOrEmpty(Request.Params["picture_InsertValue"])) { string[] Values = Request.Form["picture_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pPic = new ProductPicture(); string[] perValue = Values[i].Split(','); pPic.product_id = int.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(perValue[0])) { pPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pPic.image_state = uint.Parse(perValue[2]); }; picList.Add(pPic); } } //手機app圖檔 List<ProductPicture> appList = new List<ProductPicture>(); _productPicMgr = new ProductPictureMgr(connectionString); ProductPicture apppPic = new ProductPicture(); if (!string.IsNullOrEmpty(Request.Params["mobilePic_InsertValue"])) { string[] Values = Request.Form["mobilePic_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { apppPic = new ProductPicture(); string[] perValue = Values[i].Split(','); apppPic.product_id = int.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(perValue[0])) { apppPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { apppPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { apppPic.image_state = uint.Parse(perValue[2]); }; appList.Add(apppPic); } } try { _productMgr.Update_Product_Spec_Picture(p, pSpecList, picList, appList); json = "{success:true,msg:\"" + Resources.Product.SAVE_SUCCESS + "\"}"; } 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:true,msg:\"" + Resources.Product.SAVE_FAIL + "\"}"; } } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }