public string QuerySpecPic() { _specTempMgr = new ProductSpecTempMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); string json = string.Empty; if (string.IsNullOrEmpty(Request.Params["product_id"])) { //查找臨時表記錄 ProductSpecTemp psTemp = new ProductSpecTemp(); psTemp.Writer_Id = (Session["caller"] as Caller).user_id; psTemp.spec_type = 1; //string str = "{success:true,items:"+JsonConvert.+"}"; List<ProductSpecTemp> results = _specTempMgr.Query(psTemp); //JsonConvert.SerializeObject(); foreach (var item in results) { if (item.spec_image != "") { item.spec_image = imgServerPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image; } } json = "{success:true,items:" + JsonConvert.SerializeObject(results) + "}"; json = json.Replace("spec_image", "img"); } else { //查找正式表 ProductSpec pSpec = new ProductSpec(); pSpec.product_id = uint.Parse(Request.Params["product_id"]); pSpec.spec_type = 1; List<ProductSpec> spList = _specMgr.Query(pSpec); foreach (var item in spList) { if (item.spec_image != "") { item.spec_image = imgServerPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image; } } json = "{success:true,items:" + JsonConvert.SerializeObject(spList) + "}"; json = json.Replace("spec_image", "img"); } return json; }
public HttpResponseBase spec2TempQuery() { string resultStr = "{success:false}"; Caller _caller = (Session["caller"] as Caller); try { if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { //product_spec uint pid = uint.Parse(Request.Form["ProductId"]); _specMgr = new ProductSpecMgr(connectionString); resultStr = "{success:true,data:" + JsonConvert.SerializeObject(_specMgr.Query(new ProductSpec { product_id = pid, spec_type = 2 })) + "}"; } else { //product_spec_temp _specTempMgr = new ProductSpecTempMgr(connectionString); ProductSpecTemp query = new ProductSpecTemp { Writer_Id = _caller.user_id, spec_type = 2 }; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { query.product_id = Request.Form["OldProductId"]; } resultStr = "{success:true,data:" + JsonConvert.SerializeObject(_specTempMgr.Query(query)) + "}"; } } 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); } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
public ActionResult upLoadImg() { try { HttpPostedFileBase file = Request.Files["Filedata"]; int type = Request["appOrexplain"] == null ? 0 : Convert.ToInt32(Request["appOrexplain"]); string nameType = Request.Params["nameType"]; // 將 nametype 提前 使其判斷傳入的圖片是否為商品主圖 edit by zhuoqin0830w 2015/01/29 int prodCheck = file.FileName.LastIndexOf("prod_"); // 將 proCheck 提前 使其判斷批量上傳的圖片中是否存在商品主圖 edit by zhuoqin0830w 2015/01/30 if (nameType == "spec") { type = 5; } if (prodCheck == 0 && type == 0) //批量上傳時type才會 ==0,其他單獨上傳時是不需要根據prod處理圖片的 { type = 3; } int mobileCheck = file.FileName.LastIndexOf("mobile_");//批量上傳時type才會 ==0,其他單獨上傳時是不需要根據prod處理圖片的 if (mobileCheck == 0 && type == 0) { type = 4; } string path = Server.MapPath(xmlPath); siteConfigMgr = new SiteConfigMgr(path); SiteConfig extention_config = siteConfigMgr.GetConfigByName("PIC_Extention_Format"); SiteConfig minValue_config = siteConfigMgr.GetConfigByName("PIC_Length_MinValue"); SiteConfig maxValue_config = null; //判斷 批量上傳 或 單個上傳 的圖片是否為 商品主圖 或 手機商品圖 edit by zhuoqin0830w 2015/03/24 switch (nameType) { //如果 nameType == prod 則表示 是 單個上傳 商品主圖 case "prod": maxValue_config = siteConfigMgr.GetConfigByName("PIC_280_Length_Max"); break; //如果 nameType == mobile 則表示 是 單個上傳 手機商品圖 case "mobile": maxValue_config = siteConfigMgr.GetConfigByName("PIC_640_Length_Max"); break; //如果 nameType == null 則表示 是 批量上傳 case null: //如果 prodCheck == 0 則表示 是 批量上傳 中包含 商品主圖 if (prodCheck == 0) { maxValue_config = siteConfigMgr.GetConfigByName("PIC_280_Length_Max"); } //如果 mobileCheck == 0 則表示 是 批量上傳 中包含 手機商品圖 else if (mobileCheck == 0) { maxValue_config = siteConfigMgr.GetConfigByName("PIC_640_Length_Max"); } else { maxValue_config = siteConfigMgr.GetConfigByName("PIC_Length_MaxValue"); } break; default: maxValue_config = siteConfigMgr.GetConfigByName("PIC_Length_MaxValue"); break; } string extention = extention_config.Value == "" ? extention_config.DefaultValue : extention_config.Value; string minValue = minValue_config.Value == "" ? minValue_config.DefaultValue : minValue_config.Value; string maxValue = maxValue_config.Value == "" ? maxValue_config.DefaultValue : maxValue_config.Value; if ((nameType == "mobile" && type == 4) || (mobileCheck == 0 && type == 4)) //add by wwei0216w 2015/4/1 添加原因:手機圖片要放在640*640路徑下 { prodPath = prodMobile640; } string localProdPath = imgLocalPath + prodPath; //string localProd50Path = imgLocalPath + prod50Path; //string localProd150Path = imgLocalPath + prod150Path; //string localProd280Path = imgLocalPath + prod280Path; string localSpecPath = imgLocalPath + specPath; //string localSpec100Path = imgLocalPath + spec100Path; //string localSpec280Path = imgLocalPath + spec280Path; string[] Mappath = new string[2]; FileManagement fileLoad = new FileManagement(); string fileName = string.Empty; string fileExtention = string.Empty; ViewBag.spec_id = -1; if (nameType != null) { fileName = nameType + fileLoad.NewFileName(file.FileName); fileName = fileName.Substring(0, fileName.LastIndexOf(".")); fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower(); } else { #region 批次上傳圖片操作 //此處由批次上傳進入. //判斷文件名格式是否正確 ViewBag.moreFileOneTime = true; //int prodCheck = file.FileName.LastIndexOf("prod_"); int specCheck = file.FileName.LastIndexOf("spec_"); int descCheck = file.FileName.LastIndexOf("desc_"); int appCheck = file.FileName.LastIndexOf("app_"); string errorMsg = "ERROR/"; if (prodCheck == -1 && specCheck == -1 && descCheck == -1 && appCheck == -1 && mobileCheck == -1) { errorMsg += "[" + file.FileName + "] "; errorMsg += Resources.Product.FILE_NAME_ERROR; ViewBag.fileName = errorMsg; return View("~/Views/Product/upLoad.cshtml"); } else { nameType = file.FileName.Split('_')[0]; if (nameType == "app") { type = 2; } else if (nameType == "desc") { type = 1; } else if (nameType == "spec") { type = 5; } fileName = nameType + fileLoad.NewFileName(file.FileName); fileName = fileName.Substring(0, fileName.LastIndexOf(".")); fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')); } if (specCheck == 0) { Caller _caller = (Session["caller"] as Caller); string spec = file.FileName.Split('_')[1].Split('.')[0]; bool checkStatus = true; if (!string.IsNullOrEmpty(Request.Params["product_id"].Split(';')[0].ToString())) { //product_spec uint pid = uint.Parse(Request.Params["product_id"].Split(';')[0].ToString()); _specMgr = new ProductSpecMgr(connectionString); List<ProductSpec> pSpecList = _specMgr.Query(new ProductSpec { product_id = pid, spec_type = 1 }); foreach (var item in pSpecList) { if (item.spec_name == spec) { checkStatus = false; ViewBag.spec_id = item.spec_id; } } } else { //product_spec_temp _specTempMgr = new ProductSpecTempMgr(connectionString); List<ProductSpecTemp> pSpecTempList = _specTempMgr.Query(new ProductSpecTemp { Writer_Id = _caller.user_id, spec_type = 1 }); foreach (var item in pSpecTempList) { if (item.spec_name == spec) { checkStatus = false; ViewBag.spec_id = item.spec_id; } } } if (checkStatus)//表示沒有要上傳圖片規格相同的規格一 { errorMsg += "[" + file.FileName + "] " + Resources.Product.SPEC_NOT_FIND; ViewBag.fileName = errorMsg; return View("~/Views/Product/upLoad.cshtml"); } } #endregion } SetPath(type);//設定圖片路徑 string localDescPath = imgLocalPath + descPath; //string localDesc400Path = imgLocalPath + desc400Path; string returnName = imgServerPath; bool result = false; string NewFileName = string.Empty; BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt(); NewFileName = hash.Md5Encrypt(fileName, "32"); string firstFolder = NewFileName.Substring(0, 2) + "/"; string secondFolder = NewFileName.Substring(2, 2) + "/"; string ServerPath = string.Empty; if (nameType == "spec") { Mappath[0] = firstFolder; Mappath[1] = secondFolder; CreateFolder(localSpecPath, Mappath); //CreateFolder(localSpec100Path, Mappath); //CreateFolder(localSpec280Path, Mappath); localSpecPath += firstFolder + secondFolder; //localSpec100Path += firstFolder + secondFolder; //localSpec280Path += firstFolder + secondFolder; specPath += firstFolder + secondFolder; returnName += specPath + NewFileName + fileExtention; //localSpec100Path += NewFileName + fileExtention; //localSpec280Path += NewFileName + fileExtention; NewFileName = localSpecPath + NewFileName + fileExtention; ServerPath = Server.MapPath(imgLocalServerPath + specPath); } else if (nameType == "desc" || nameType == "app") { Mappath[0] = firstFolder; Mappath[1] = secondFolder; CreateFolder(localDescPath, Mappath); //CreateFolder(localDesc400Path, Mappath); localDescPath += firstFolder + secondFolder; //localDesc400Path += firstFolder + secondFolder; descPath += firstFolder + secondFolder; //localDesc400Path += NewFileName + fileExtention; returnName += descPath + NewFileName + fileExtention; NewFileName = localDescPath + NewFileName + fileExtention; ServerPath = Server.MapPath(imgLocalServerPath + descPath); } else { Mappath[0] = firstFolder; Mappath[1] = secondFolder; //Data:2014/06/26 //author:Castle //在前台如果各种尺寸的图档没有的时候,前台会自动产生!!! CreateFolder(localProdPath, Mappath); //CreateFolder(localProd50Path, Mappath); //CreateFolder(localProd150Path, Mappath); //CreateFolder(localProd280Path, Mappath); localProdPath += firstFolder + secondFolder; //localProd50Path += firstFolder + secondFolder; //localProd150Path += firstFolder + secondFolder; //localProd280Path += firstFolder + secondFolder; prodPath += firstFolder + secondFolder; //localProd50Path += NewFileName + fileExtention; //localProd150Path += NewFileName + fileExtention; //localProd280Path += NewFileName + fileExtention; returnName += prodPath + NewFileName + fileExtention; NewFileName = localProdPath + NewFileName + fileExtention; ServerPath = Server.MapPath(imgLocalServerPath + prodPath); } string ErrorMsg = string.Empty; Resource.CoreMessage = new CoreResource("Product"); //上傳圖片 result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd); #region // //上傳對應大小圖片 //压缩图片至其它规格 //Data:2014/06/26 //author:Castle //在前台如果各种尺寸的图档没有的时候,前台会自动产生!!! //if (result) //{ // FTP ftp = null; // string newFileName = NewFileName.Substring(NewFileName.LastIndexOf("/")); // GigadeService.TransImageClient transImg = new GigadeService.TransImageClient(); // if (nameType == "spec") // { // string sourceImgPath = Server.MapPath(imgLocalServerPath + specPath + NewFileName.Substring(NewFileName.LastIndexOf("/"))); // ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + spec100Path + firstFolder + secondFolder), newFileName, 100, 100, admin_userName.Value, admin_passwd.Value); // if (string.IsNullOrWhiteSpace(ErrorMsg)) // { // file.SaveAs(Server.MapPath(imgLocalServerPath + spec100Path + firstFolder + secondFolder + newFileName)); // ftp = new FTP(localSpec100Path, ftpuser, ftppwd); // ftp.UploadFile(Server.MapPath(imgLocalServerPath + spec100Path + firstFolder + secondFolder + newFileName)); // } // if (!Directory.Exists(Server.MapPath(imgLocalServerPath + spec280Path + firstFolder + secondFolder))) // Directory.CreateDirectory(Server.MapPath(imgLocalServerPath + spec280Path + firstFolder + secondFolder)); // ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + spec280Path + firstFolder + secondFolder), newFileName, 280, 280, admin_userName.Value, admin_passwd.Value); // if (string.IsNullOrWhiteSpace(ErrorMsg)) // { // file.SaveAs(Server.MapPath(imgLocalServerPath + spec280Path + firstFolder + secondFolder + newFileName)); // ftp = new FTP(localSpec100Path, ftpuser, ftppwd); // ftp.UploadFile(Server.MapPath(imgLocalServerPath + spec280Path + firstFolder + secondFolder + newFileName)); // } // } // else if (nameType == "desc") // { // string sourceImgPath = Server.MapPath(imgLocalServerPath + descPath + NewFileName.Substring(NewFileName.LastIndexOf("/"))); // ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + desc400Path + firstFolder + secondFolder), newFileName, 400, 400, admin_userName.Value, admin_passwd.Value); // if (string.IsNullOrWhiteSpace(ErrorMsg)) // { // file.SaveAs(Server.MapPath(imgLocalServerPath + desc400Path + firstFolder + secondFolder + newFileName)); // ftp = new FTP(localSpec100Path, ftpuser, ftppwd); // ftp.UploadFile(Server.MapPath(imgLocalServerPath + desc400Path + firstFolder + secondFolder + newFileName)); // } // } // else // { // //string sourceImgPath = Server.MapPath(imgLocalServerPath + prodPath + NewFileName.Substring(NewFileName.LastIndexOf("/"))); // //ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + prod50Path + firstFolder + secondFolder), newFileName, 50, 50, admin_userName.Value, admin_passwd.Value); // //if (string.IsNullOrWhiteSpace(ErrorMsg)) // //{ // // file.SaveAs(Server.MapPath(imgLocalServerPath + prod50Path + firstFolder + secondFolder + newFileName)); // // ftp = new FTP(localProd50Path, ftpuser, ftppwd); // // ftp.UploadFile(Server.MapPath(imgLocalServerPath + prod50Path + firstFolder + secondFolder + newFileName)); // //} // //ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + prod150Path + firstFolder + secondFolder), newFileName, 150, 150, admin_userName.Value, admin_passwd.Value); // //if (string.IsNullOrWhiteSpace(ErrorMsg)) // //{ // // file.SaveAs(Server.MapPath(imgLocalServerPath + prod150Path + firstFolder + secondFolder + newFileName)); // // ftp = new FTP(localProd150Path, ftpuser, ftppwd); // // ftp.UploadFile(Server.MapPath(imgLocalServerPath + prod150Path + firstFolder + secondFolder + newFileName)); // //} // ////if (!Directory.Exists(Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder))) // //// Directory.CreateDirectory(Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder)); // ////ImageClass iC280 = new ImageClass(sourceImgPath); // //////iC280.ImageMagick(sourceImgPath, Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder + NewFileName.Substring(NewFileName.LastIndexOf("/"))), 280, 280, ref error); // ////iC150.MakeThumbnail(Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder + NewFileName.Substring(NewFileName.LastIndexOf("/"))), 280, 280, ref error); // //ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder), newFileName, 280, 280, admin_userName.Value, admin_passwd.Value); // //if (string.IsNullOrWhiteSpace(ErrorMsg)) // //{ // // file.SaveAs(Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder + newFileName)); // // ftp = new FTP(localProd280Path, ftpuser, ftppwd); // // ftp.UploadFile(Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder + newFileName)); // //} // } //} #endregion if (string.IsNullOrEmpty(ErrorMsg)) { ViewBag.fileName = returnName; ViewBag.Type = type; //獲取文件長度 add by zhuoqin0830w 2015/01/29 string[] strFile = file.FileName.Split('_'); //判斷文件名的長度是否大於 1 如果大於 1 則再次進行判斷是否為數字 如果不是則進行強制轉換 int image_sort = 0; int.TryParse(strFile.Length > 1 ? strFile[1] : "0", out image_sort); ViewBag.image_sort = image_sort; } else { // 判斷 批量上傳中 是否存在 商品圖 或 手機商品圖 edit by zhuoqin0830w 2015/03/24 if (prodCheck == 0 || mobileCheck == 0) { ViewBag.fileName = "ERROR/" + "[" + file.FileName + "] " + ErrorMsg; } else { ViewBag.fileName = "ERROR/" + "[" + file.FileName + "] " + ErrorMsg; } Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = "ERROR/" + ErrorMsg; logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } } 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); } return View("~/Views/Product/upLoad.cshtml"); }
private string QueryHistory(int itemType) { StringBuilder html = new StringBuilder(); try { _historyBatchMgr = new HistoryBatchMgr(connectionString); List<HistoryBatch> batches = _historyBatchMgr.QueryToday(itemType); //edit by hufeng0813w 2014/06/13 batches.Sort(CompareToRowid);//進行一個排序 //end edit by hufeng0813w 2014/06/13 if (batches != null & batches.Count > 0) { html.Append("<html><head><style type=\"text/css\">table{text-align:center; font-size: 13px;border:1px solid #99bce8}caption{text-align:center;border:1px solid #99bce8;} td{border:1px solid #99bce8}.red{color:red;}.green{color:green;}.tstyle{width:250px;}</style></head><body>"); _tableHistoryMgr = new TableHistoryMgr(connectionString); _tableHistoryItemMgr = new TableHistoryItemMgr(connectionString); html.Append("<ul style=\"list-style:none\">"); string channelInfo = ""; int batchIndex = -1; foreach (var batch in batches) { //edit by hufeng0813w Reason:如果是商品對照異動通知 batchIndex++; if (itemType == 1) { channelInfo += "<b>" + batch.channel_name_full + "</b> (外站商品編號:" + batch.channel_detail_id + ")<br/>"; if (batchIndex == 0 || (batches[batchIndex].channel_detail_id == batches[batchIndex - 1].channel_detail_id && batches[batchIndex].channel_name_full == batches[batchIndex].channel_name_full && batches[batchIndex].kdate == batches[batchIndex - 1].kdate) || batchIndex < batches.Count - 1) { continue; } } List<TableHistory> histories = _tableHistoryMgr.Query(new TableHistory { batchno = batch.batchno.ToString() }); if (histories != null && histories.Count > 0) { Array tbls = histories.GroupBy(m => m.table_name).Select(m => m.Key).ToArray(); List<TableHistoryItem> items; uint productId = 0; #region 初始化 StringBuilder pro = new StringBuilder(); StringBuilder spec = new StringBuilder(); StringBuilder category = new StringBuilder(); StringBuilder item = new StringBuilder(); StringBuilder master = new StringBuilder(); StringBuilder price = new StringBuilder(); #endregion foreach (var tbl in tbls) { string tblName = tbl.ToString().ToLower(); bool isAdd = false; #region 針對不同表的處理 switch (tblName) { case "product": #region PRODUCT items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = batch.batchno.ToString(), table_name = tblName }); if (items != null && items.Count > 0) { StringBuilder column_1 = new StringBuilder("<tr><td>欄位名稱</td>"); StringBuilder column_2 = new StringBuilder("<tr><td>修改前</td>"); StringBuilder column_3 = new StringBuilder("<tr><td>修改後</td>"); Array cols = items.GroupBy(m => m.col_name).Select(m => m.Key).ToArray(); foreach (var col in cols) { var tmp = items.FindAll(m => m.col_name == col.ToString()); if (tmp.Count == 1 && string.IsNullOrEmpty(tmp.FirstOrDefault().old_value)) { continue; } else { tmp.Remove(tmp.Find(m => string.IsNullOrEmpty(m.old_value))); var first = tmp.FirstOrDefault(); var last = tmp.LastOrDefault(); if (first == last) { GetParamCon(last, true); } else { GetParamCon(first, true); } GetParamCon(last, false); column_1.AppendFormat("<td>{0}</td>", first.col_chsname); column_2.AppendFormat("<td class=\"red\">{0}</td>", first == last ? last.old_value : first.old_value); column_3.AppendFormat("<td class=\"green\">{0}</td>", last.col_value); isAdd = true; } } if (isAdd) { pro.AppendFormat("<table class=\"tstyle\">{0}</tr>{1}</tr>{2}</tr></table>", column_1, column_2, column_3); } if (productId == 0) { productId = uint.Parse(histories.Find(m => m.table_name == tblName).pk_value); } } #endregion break; case "product_spec": #region SPEC StringBuilder spec_1 = new StringBuilder("<tr><td>修改前</td>"); StringBuilder spec_2 = new StringBuilder("<tr><td>修改後</td>"); Array specIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in specIds) { items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = batch.batchno.ToString(), table_name = tblName, pk_value = id.ToString() }); if (items.Count == 1 && string.IsNullOrEmpty(items.FirstOrDefault().old_value)) { continue; } else { items.Remove(items.Find(m => string.IsNullOrEmpty(m.old_value))); var first = items.FirstOrDefault(); var last = items.LastOrDefault(); spec_1.AppendFormat("<td class=\"red\">{0}</td>", first == last ? last.old_value : first.old_value); spec_2.AppendFormat("<td class=\"green\">{0}</td>", last.col_value); isAdd = true; } } if (isAdd) { spec.AppendFormat("<table class=\"tstyle\">{0}</tr>{1}</tr></table>", spec_1, spec_2); } if (productId == 0) { _productSpecMgr = new ProductSpecMgr(connectionString); ProductSpec pSpec = _productSpecMgr.Query(new ProductSpec { spec_id = uint.Parse(histories.Find(m => m.table_name == tblName).pk_value) }).FirstOrDefault(); if (pSpec != null) { productId = pSpec.product_id; } } #endregion break; case "product_category_set": #region CATEGORY if (productId == 0) { productId = uint.Parse(histories.Find(m => m.table_name.ToLower() == tblName).pk_value); } items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = batch.batchno.ToString(), table_name = tblName, pk_value = productId.ToString() }); if (items.Count > 0) { var first = items.FirstOrDefault(); var last = items.LastOrDefault(); category.Append("<table class=\"tstyle\"><tr><td>修改前</td><td>修改後</td></tr>"); category.AppendFormat("<tr><td class=\"red\">{0}</td>", first == last ? last.old_value : first.old_value); category.AppendFormat("<td class=\"green\">{0}</td></td></table>", last.col_value); } #endregion break; case "product_item": #region ITEM ProductItem pItem; _productItemMgr = new ProductItemMgr(connectionString); Array itemIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in itemIds) { isAdd = false; pItem = _productItemMgr.Query(new ProductItem { Item_Id = uint.Parse(id.ToString()) }).FirstOrDefault(); if (pItem != null) { if (productId == 0) { productId = pItem.Product_Id; } string title = pItem.GetSpecName(); string top = "<div style=\"float:left\"><table class=\"tstyle\"><caption>" + title + "</caption><tr><td>欄位名稱</td><td>修改前</td><td>修改后</td></tr>"; string bottom = "</table></div>"; string strContent = "<tr><td>{0}</td><td class=\"red\">{1}</td><td class=\"green\">{2}</td></tr>"; string content = BuildContent(batch.batchno.ToString(), tblName, id.ToString(), strContent, ref isAdd); if (isAdd) { item.Append(top); item.Append(content); item.Append(bottom); } } } #endregion break; case "price_master": #region PRICE_MASTER PriceMaster pMaster; _priceMasterMgr = new PriceMasterMgr(connectionString); Array masterIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in masterIds) { isAdd = false; pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = uint.Parse(id.ToString()) }).FirstOrDefault(); if (pMaster != null) { if (productId == 0) { productId = pMaster.product_id; } string siteName = QuerySiteName(pMaster.site_id.ToString()); string userLevel = QueryParaName(pMaster.user_level.ToString(), "UserLevel"); string userMail = pMaster.user_id == 0 ? "" : QueryMail(pMaster.user_id.ToString()); string childName = string.Empty; if (pMaster.child_id != 0 && pMaster.product_id != pMaster.child_id) { _productMgr = new ProductMgr(connectionString); Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(pMaster.child_id) }).FirstOrDefault(); if (tmpPro != null) { childName = tmpPro.Product_Name; } } string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail)) + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName); if (!title.Contains("子商品")) { title += "<br/>"; } string top = "<div style=\"float:left\"><table class=\"tstyle\"><caption>" + title + "</caption><tr><td>欄位名稱</td><td>修改前</td><td>修改后</td></tr>"; string bottom = "</table></div>"; string strContent = "<tr><td>{0}</td><td class=\"red\">{1}</td><td class=\"green\">{2}</td></tr>"; string content = BuildContent(batch.batchno.ToString(), tblName, id.ToString(), strContent, ref isAdd); if (isAdd) { master.Append(top); master.Append(content); master.Append(bottom); } } } #endregion break; case "item_price": #region ITEM_PRICE ItemPriceCustom itemPrice; PriceMaster tmpMaster; _itemPriceMgr = new ItemPriceMgr(connectionString); _priceMasterMgr = new PriceMasterMgr(connectionString); Array priceIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in priceIds) { isAdd = false; itemPrice = _itemPriceMgr.Query(new ItemPrice { item_price_id = uint.Parse(id.ToString()) }).FirstOrDefault(); if (itemPrice != null) { tmpMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = itemPrice.price_master_id }).FirstOrDefault(); if (tmpMaster != null) { if (productId == 0) { productId = tmpMaster.product_id; } string siteName = QuerySiteName(tmpMaster.site_id.ToString()); string userLevel = QueryParaName(tmpMaster.user_level.ToString(), "UserLevel"); string userMail = tmpMaster.user_id == 0 ? "" : QueryMail(tmpMaster.user_id.ToString()); string childName = string.Empty; if (tmpMaster.child_id != 0 && tmpMaster.product_id != tmpMaster.child_id) { _productMgr = new ProductMgr(connectionString); Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(tmpMaster.child_id) }).FirstOrDefault(); if (tmpPro != null) { childName = tmpPro.Product_Name; } } string strSpec = itemPrice.spec_name_1 + (string.IsNullOrEmpty(itemPrice.spec_name_2) ? "" : (" + " + itemPrice.spec_name_2)); string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail)) + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName) + "<br/>" + strSpec; if (strSpec == "") { title += "<br/>"; } string top = "<div style=\"float:left\"><table class=\"tstyle\"><caption>" + title + "</caption><tr><td>欄位名稱</td><td>修改前</td><td>修改后</td></tr>"; string bottom = "</table></div>"; string strContent = "<tr><td>{0}</td><td class=\"red\">{1}</td><td class=\"green\">{2}</td></tr>"; string content = BuildContent(batch.batchno.ToString(), tblName, id.ToString(), strContent, ref isAdd); if (isAdd) { price.Append(top); price.Append(content); price.Append(bottom); } } } } #endregion break; default: break; } #endregion } #region 單批次拼接 StringBuilder batchHtml = new StringBuilder(); if (pro.Length > 0) { batchHtml.AppendFormat("<tr><td>商品信息</td><td>{0}</td></tr>", pro); } if (spec.Length > 0) { batchHtml.AppendFormat("<tr><td>規格信息</td><td>{0}</td></tr>", spec); } if (category.Length > 0) { batchHtml.AppendFormat("<tr><td>前臺分類信息</td><td>{0}</td></tr>", category); } if (item.Length > 0) { batchHtml.AppendFormat("<tr><td>商品細項信息</td><td>{0}</td></tr>", item); } if (master.Length > 0) { batchHtml.AppendFormat("<tr><td>站臺商品信息</td><td>{0}</td></tr>", master); } if (price.Length > 0) { batchHtml.AppendFormat("<tr><td>站臺價格信息</td><td>{0}</td></tr>", price); }; if (batchHtml.Length > 0) { _productMgr = new ProductMgr(connectionString); Product product = _productMgr.Query(new Product { Product_Id = productId }).FirstOrDefault(); if (product != null) { string brand = string.Empty; _vendorBrandMgr = new VendorBrandMgr(connectionString); VendorBrand vendorBrand = _vendorBrandMgr.GetProductBrand(new VendorBrand { Brand_Id = product.Brand_Id }); if (vendorBrand != null) { brand = vendorBrand.Brand_Name; } html.AppendFormat("<li><table><tr><td colspan='2'>商品編號:<b>{0}</b> 品牌:<b>{1}</b></td></tr>", productId, brand); html.AppendFormat("<tr><td colspan='2'><b>{0}</b> (修改人:{1}", product.Product_Name, batch.kuser); html.AppendFormat(",修改時間:{0})</td></tr>", batch.kdate.ToString("yyyy/MM/dd HH:mm:ss")); html.Append(batchHtml); if (itemType == 1) { html.AppendFormat("<tr><td colspan='2'>{0}</td></tr>", channelInfo); } html.Append("</table></li>"); } } #endregion } } html.Append("</ul>"); html.Append("</body></html>"); } } catch (Exception) { throw; } return html.ToString(); }
public string QuerySpecPic() { BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];//獲取當前登入的供應商 string serverSpecPath = imgServerPath + specPath; string serverSpec100Path = imgServerPath + spec100Path; string serverSpec280Path = imgServerPath + spec280Path; _specTempMgr = new ProductSpecTempMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); string json = string.Empty; ProductSpecTemp psTemp = new ProductSpecTemp(); psTemp.Writer_Id = (int)vendorModel.vendor_id; psTemp.spec_type = 1; if (!string.IsNullOrEmpty(Request.Params["product_id"])) { psTemp.product_id = Request.Params["product_id"]; } uint pid = 0; if (uint.TryParse(Request.Params["product_id"], out pid)) { #region 正式表 ProductSpec pSpec = new ProductSpec(); pSpec.spec_type = 1; pSpec.product_id = Convert.ToUInt32(Request.Params["product_id"]); List<ProductSpec> spList = _specMgr.Query(pSpec); foreach (var item in spList) { if (item.spec_image != "") { item.spec_image = serverSpecPath + GetDetailFolder(item.spec_image) + item.spec_image; } else { item.spec_image = imgServerPath + "/product/nopic_50.jpg"; } } json = "{success:true,items:" + JsonConvert.SerializeObject(spList) + "}"; json = json.Replace("spec_image", "img"); #endregion } else { #region 供應商 臨時表 List<ProductSpecTemp> results = _specTempMgr.VendorQuery(psTemp); //JsonConvert.SerializeObject(); foreach (var item in results) { if (item.spec_image != "") { item.spec_image = serverSpecPath + GetDetailFolder(item.spec_image) + item.spec_image; } else { item.spec_image = imgServerPath + "/product/nopic_50.jpg"; } } json = "{success:true,items:" + JsonConvert.SerializeObject(results) + "}"; json = json.Replace("spec_image", "img"); #endregion } return json; }
public HttpResponseBase spec2TempQuery() { string resultStr = "{success:false}"; try { BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; int writerID = (int)vendorModel.vendor_id; uint pid = 0; if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { if (uint.TryParse(Request.Form["ProductId"].ToString(), out pid)) { //product_spec pid = uint.Parse(Request.Form["ProductId"]); _specMgr = new ProductSpecMgr(connectionString); resultStr = "{success:true,data:" + JsonConvert.SerializeObject(_specMgr.Query(new ProductSpec { product_id = pid, spec_type = 2 })) + "}"; } else { //product_spec_temp _specTempMgr = new ProductSpecTempMgr(connectionString); ProductSpecTemp query = new ProductSpecTemp { Writer_Id = writerID, spec_type = 2 }; query.product_id = Request.Form["ProductId"].ToString(); resultStr = "{success:true,data:" + JsonConvert.SerializeObject(_specTempMgr.VendorQuery(query)) + "}"; } } } 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); } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }