/// <summary> /// 图片存到阿里云--主款号表 /// </summary> public bool UploadScodePicStyle() { bool flag = false; try { int i = 1; DataTable dtpath = new DataTable(); DataTable dtcount = new DataTable(); string srcs = Request.QueryString["Arrysrc"]; string Style = Request.QueryString["Style"]; string[] arrysrc; string filename = ""; arrysrc = srcs.Split(','); string Picurl; string path = CAliyun.GetObjectlistStyle(Style);//得到款号文件夹路径 string pathsql = @"select * from product where Style='" + Style + "'"; dtpath = DbHelperSQL.Query(pathsql).Tables[0]; string newpath = rootName + dtpath.Rows[0]["Cat"] + "/" + dtpath.Rows[0]["Cat2"] + "/" + dtpath.Rows[0]["Style"] + "/" + dtpath.Rows[0]["Style"] + "/"; dtcount = DbHelperSQL.Query(@"select count(*) from stylepic where style='" + Style + "' ").Tables[0]; i = Convert.ToInt32(dtcount.Rows[0][0]) + 1; //判断数据中对应款号存放图片的个数 if (CAliyun.ScodeExist(Style.Replace("*", "_"))) //判断该款号文件夹是否存在 { foreach (var temp in arrysrc) { filename = Style + "." + temp.Substring(temp.LastIndexOf('/') + 1).Split('.')[temp.Split('.').Length - 1]; string getFile = temp.Substring(temp.LastIndexOf('/') + 1); Picurl = "http://best-bms.pbxluxury.com/" + path + i + "_" + filename; string sql = @"insert into stylepic values ('" + Style + "','" + Picurl.Replace("*", "_") + "','1','1','" + userInfo.User.Id + "','1','1','1','1','" + getFile.Substring(0, getFile.LastIndexOf('.')) + "')"; int n = DbHelperSQL.ExecuteSql(sql); if (n != -1) { PutObject(getFile, path + i + "_" + filename);//存入新上传图片 } i++; } } else { newpath = newpath.Replace("*", "_"); CAliyun.CreateEmptyFolder(newpath);//创建款号文件夹 foreach (var temp in arrysrc) { filename = Style + "." + temp.Substring(temp.LastIndexOf('/') + 1).Split('.')[temp.Split('.').Length - 1]; string getFile = temp.Substring(temp.LastIndexOf('/') + 1); Picurl = "http://best-bms.pbxluxury.com/" + newpath + i + "_" + filename; string sql = @"insert into stylepic values ('" + Style + "','" + Picurl.Replace("*", "_") + "','1','1','" + userInfo.User.Id + "','1','1','1','1','" + getFile.Substring(0, getFile.LastIndexOf('.')) + "')"; int n = DbHelperSQL.ExecuteSql(sql); if (n != -1) { PutObject(getFile, newpath + i + "_" + filename);//存入新上传图片 } i++; } } flag = true; } catch (Exception ex) { flag = false; } return(flag); }
////鼠标指到相应款号上显示缩略图 //public string retImgPath() //{ // string style = Request.QueryString["style"]; // string sql = @"select stylePicSrc from styledescript where style='" + style + "' "; // string path = ""; // if (DbHelperSQL.Query(sql).Tables[0].Rows.Count != 0) // { // path = DbHelperSQL.Query(sql).Tables[0].Rows[0][0].ToString(); // } // return path; //} /// <summary> /// 图片存到阿里云--主货号表 /// </summary> public bool UploadScodePic() { bool flag = false; try { int i = 1; DataTable dtpath = new DataTable(); DataTable dtcount = new DataTable(); string srcs = Request.QueryString["Arrysrc"]; string scode = Request.QueryString["scode"]; string[] arrysrc; string filename = ""; arrysrc = srcs.Split(','); string Picurl; string path = CAliyun.GetObjectlistScode(scode.Replace("*", "_"));//得到货号文件夹路径 string pathsql = @"select * from product where Scode='" + scode + "'"; dtpath = DbHelperSQL.Query(pathsql).Tables[0]; //得到货号文件夹路径 rootName+品牌缩写+类别+款号+货号+文件名 string newpath = rootName + dtpath.Rows[0]["Cat"] + "/" + dtpath.Rows[0]["Cat2"] + "/" + dtpath.Rows[0]["Style"].ToString() + "/" + dtpath.Rows[0]["Scode"].ToString() + "/"; dtcount = DbHelperSQL.Query(@"select count(*) from scodepic where scode='" + scode + "' ").Tables[0]; i = Convert.ToInt32(dtcount.Rows[0][0]) + 1;//判断数据中对应货号存放图片的个数 //string num = dtcount.Rows[dtcount.Rows.Count - 1]["scodePicSrc"].ToString(); //i = Convert.ToInt32(num.Substring(num.LastIndexOf('/') + 1).Split('_')[0]) + 1;//判断数据中对应货号存放图片的个数 if (CAliyun.ScodeExist(scode.Replace("*", "_")))//判断该货号文件夹是否存在 { foreach (var temp in arrysrc) { filename = scode.Replace(".", "-") + "." + temp.Substring(temp.LastIndexOf('/') + 1).Split('.')[temp.Split('.').Length - 1]; string getFile = temp.Substring(temp.LastIndexOf('/') + 1); Picurl = "http://best-bms.pbxluxury.com/" + path + i + "_" + filename; string sql = @"insert into scodepic values ('" + scode + "','" + Picurl.Replace("*", "_") + "','1','1','1','" + userInfo.User.Id + "','1','1','1','1','" + getFile.Substring(0, getFile.LastIndexOf('.')) + "')"; int n = DbHelperSQL.ExecuteSql(sql); if (n != -1) { PutObject(getFile, path + i + "_" + filename);//存入新上传图片 } i++; } } else { newpath = newpath.Replace("*", "_"); CAliyun.CreateEmptyFolder(newpath);//创建款号文件夹 foreach (var temp in arrysrc) { filename = scode.Replace(".", "-") + "." + temp.Substring(temp.LastIndexOf('/') + 1).Split('.')[temp.Split('.').Length - 1]; string getFile = temp.Substring(temp.LastIndexOf('/') + 1); Picurl = "http://best-bms.pbxluxury.com/" + newpath + i + "_" + filename; string sql = @"insert into scodepic values ('" + scode + "','" + Picurl.Replace("*", "_") + "','1','1','1','" + userInfo.User.Id + "','1','1','1','1','" + getFile.Substring(0, getFile.LastIndexOf('.')) + "')"; int n = DbHelperSQL.ExecuteSql(sql); if (n != -1) { PutObject(getFile, newpath + i + "_" + filename);//存入新上传图片 } i++; } } flag = true; string date = DateTime.Now.ToString("yyyy-MM-dd"); string updatetime = @"update product set Def1='" + date + "',Def9='0' where Scode='" + scode + "'"; DbHelperSQL.ExecuteSql(updatetime); } catch (Exception ex) { flag = false; } return(flag); }