public HttpResponseBase DeletePic() { string json = "{success:true,msg:\"" + Resources.Product.DELETE_SUCCESS + "\"}"; string deleteType = Request.Params["type"]; int apporexplain = Convert.ToInt32(Request["apporexplain"]);//判斷是從前臺的APP傳來還是從explain傳來 ProductSpecTemp psTemp = new ProductSpecTemp(); ProductSpec pSpec = new ProductSpec(); List<ProductSpecTemp> psList = new List<ProductSpecTemp>(); _specTempMgr = new ProductSpecTempMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); string[] record = Request.Params["rec"].Split(','); string fileName = record[0].Split('/')[imgNameIdx]; SetPath(apporexplain); if (deleteType == "desc") { string imageName = imgLocalPath + descPath + GetDetailFolder(fileName) + fileName; string imageName400 = imgLocalPath + desc400Path + GetDetailFolder(fileName) + fileName; DeletePicFile(imageName); DeletePicFile(imageName400); } if (string.IsNullOrEmpty(Request.Params["product_id"])) { psTemp.Writer_Id = (Session["caller"] as Caller).user_id; try { _specTempMgr.Update(psList, "image"); } 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.DELETE_SPEC_FAIL + "\"}"; } } else { pSpec.product_id = uint.Parse(Request.Params["product_id"]); try { _specMgr.UpdateSingle(pSpec); } 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.DELETE_SPEC_FAIL + "\"}"; } } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase DeletePic() { string json = "{success:true,msg:\"" + Resources.Product.DELETE_SUCCESS + "\",path:\"" + default50Path + "\"}"; try { string deleteType = Request.Params["type"]; int apporexplain = Convert.ToInt32(Request["apporexplain"]);//判斷是從前臺的APP傳來還是從explain傳來 ProductSpecTemp psTemp = new ProductSpecTemp(); ProductSpec pSpec = new ProductSpec(); List<ProductSpecTemp> psList = new List<ProductSpecTemp>(); List<ProductSpec> pspList = new List<ProductSpec>(); _specTempMgr = new ProductSpecTempMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); string[] records = Request.Params["rec"].Split('|'); foreach (var item in records) { string[] record = item.Split(','); if (record[0].Split('/').Length == defaultImgLength) //默认图片无法删除 { json = "{success:false,msg:\"" + Resources.Product.DEFAULT_CANNOT_DELETE + "\"}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } string fileName = record[0].Split('/')[imgNameIdx]; if (deleteType == "spec") { psTemp.spec_image = string.Empty; psTemp.spec_id = uint.Parse(record[1]); psTemp.spec_sort = uint.Parse(record[2]); psTemp.spec_status = uint.Parse(record[3]); pSpec.spec_image = string.Empty; pSpec.spec_id = uint.Parse(record[1]); pSpec.spec_sort = uint.Parse(record[2]); pSpec.spec_status = uint.Parse(record[3]); psList.Add(psTemp); pspList.Add(pSpec); string imageName = imgLocalPath + specPath + GetDetailFolder(fileName) + fileName; string image100 = imgLocalPath + spec100Path + GetDetailFolder(fileName) + fileName; string image280 = imgLocalPath + spec280Path + GetDetailFolder(fileName) + fileName; //刪除服務器上對應的圖片 DeletePicFile(imageName); DeletePicFile(image100); DeletePicFile(image280); } else if (deleteType == "desc") { SetPath(apporexplain); string imageName = imgLocalPath + descPath + GetDetailFolder(fileName) + fileName; string imageName400 = imgLocalPath + desc400Path + GetDetailFolder(fileName) + fileName; DeletePicFile(imageName); DeletePicFile(imageName400); } } //string[] record = Request.Params["rec"].Split(','); //if (record[0].Split('/').Length == defaultImgLength) //默认图片无法删除 //{ // json = "{success:false,msg:\"" + Resources.Product.DEFAULT_CANNOT_DELETE + "\"}"; // this.Response.Clear(); // this.Response.Write(json); // this.Response.End(); // return this.Response; //} //string fileName = record[0].Split('/')[imgNameIdx]; //if (deleteType == "spec") //{ // psTemp.spec_image = string.Empty; // psTemp.spec_id = uint.Parse(record[1]); // psTemp.spec_sort = uint.Parse(record[2]); // psTemp.spec_status = uint.Parse(record[3]); // pSpec.spec_image = string.Empty; // pSpec.spec_id = uint.Parse(record[1]); // pSpec.spec_sort = uint.Parse(record[2]); // pSpec.spec_status = uint.Parse(record[3]); // psList.Add(psTemp); // string imageName = imgLocalPath + specPath + GetDetailFolder(fileName) + fileName; // string image100 = imgLocalPath + spec100Path + GetDetailFolder(fileName) + fileName; // string image280 = imgLocalPath + spec280Path + GetDetailFolder(fileName) + fileName; // //刪除服務器上對應的圖片 // DeletePicFile(imageName); // DeletePicFile(image100); // DeletePicFile(image280); //} //else if (deleteType == "desc") //{ // //if (apporexplain == 1) // //{ // SetPath(apporexplain); // string imageName = imgLocalPath + descPath + GetDetailFolder(fileName) + fileName; // string imageName400 = imgLocalPath + desc400Path + GetDetailFolder(fileName) + fileName; // DeletePicFile(imageName); // DeletePicFile(imageName400); // //} // //else if(apporexplain == 2) // //{ // // string imageName = imgLocalPath + descMobilePath + GetDetailFolder(fileName) + fileName; // // string imageName400 = imgLocalPath + desc400MobilePath + GetDetailFolder(fileName) + fileName; // // DeletePicFile(imageName); // // DeletePicFile(imageName400); // //} //} if (string.IsNullOrEmpty(Request.Params["product_id"])) { psTemp.Writer_Id = (Session["caller"] as Caller).user_id; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { psTemp.product_id = Request.Form["OldProductId"]; } _specTempMgr.Update(psList, "image"); } else { uint productId = uint.Parse(Request.Params["product_id"]); foreach (var item in pspList) { item.product_id = productId; _specMgr.UpdateSingle(item); } //pSpec.product_id = uint.Parse(Request.Params["product_id"]); //_specMgr.UpdateSingle(pSpec); } } 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.DELETE_SPEC_FAIL + "\"}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }