|
|
@@ -97,8 +97,48 @@ namespace UAS_MES_NEW.Query
|
|
|
Worksheet she = workbook.Worksheets[i];
|
|
|
if (JPG.Checked)
|
|
|
{
|
|
|
- var myThread = new Thread(() => SaveFileToJPG(she));
|
|
|
- myThread.Start();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ DataHelper dh = new DataHelper();
|
|
|
+ if (!Directory.Exists(Application.StartupPath + @"\" + ps_prodcode.Text))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(Application.StartupPath + @"\" + ps_prodcode.Text);
|
|
|
+ }
|
|
|
+ string sheetname = she.Name;
|
|
|
+ sheetname = sheetname.Replace("01", "1");
|
|
|
+ sheetname = sheetname.Replace("02", "2");
|
|
|
+ sheetname = sheetname.Replace("03", "3");
|
|
|
+ sheetname = sheetname.Replace("04", "4");
|
|
|
+ sheetname = sheetname.Replace("05", "5");
|
|
|
+ sheetname = sheetname.Replace("06", "6");
|
|
|
+ sheetname = sheetname.Replace("07", "7");
|
|
|
+ sheetname = sheetname.Replace("08", "8");
|
|
|
+ sheetname = sheetname.Replace("09", "9");
|
|
|
+
|
|
|
+ ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
|
|
|
+ imgOptions.ImageFormat = ImageFormat.Png;
|
|
|
+ imgOptions.OnePagePerSheet = true;
|
|
|
+ imgOptions.CheckWorkbookDefaultFont = false;
|
|
|
+ imgOptions.DefaultFont = "宋体";
|
|
|
+ imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
|
|
|
+ imgOptions.SetDesiredSize(1565, 1043);
|
|
|
+ SheetRender sr = new SheetRender((Aspose.Cells.Worksheet)she, imgOptions);
|
|
|
+ sr.ToImage(0, Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + sheetname + ".jpg");
|
|
|
+ //// 创建一个图片
|
|
|
+ OperatResult.AppendText("解析图片【" + sheetname + ".jpg】" + "\n");
|
|
|
+ Dictionary<string, object> dic = new Dictionary<string, object>();
|
|
|
+ dic.Add("em_name", "管理员");
|
|
|
+ dic.Add("em_code", "ADMIN");
|
|
|
+ dic.Add("caller", "ProductSOP");
|
|
|
+ OperatResult.AppendText("上传文件【" + sheetname + ".jpg" + "】\n");
|
|
|
+ string fp_id = UploadFilesToRemoteUrl("http://192.168.0.85:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + sheetname + ".jpg", dic);
|
|
|
+ string ps_id = dh.getFieldDataByCondition("ProductSOP", "ps_id", "ps_prodcode='" + ps_prodcode.Text + "'").ToString();
|
|
|
+ dh.ExecuteSql("insert into ProductSOPdetail(psd_id,psd_psid,psd_attach) select ProductSOPdetail_seq.nextval,ps_id,'" + sheetname + ".jpg" + ";" + fp_id + "' from ProductSOP where ps_prodcode='" + ps_prodcode.Text + "'", "insert");
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ OperatResult.AppendText(ex.Message + ex.StackTrace);
|
|
|
+ }
|
|
|
filename.Add(she.Name + ".jpg");
|
|
|
}
|
|
|
}
|
|
|
@@ -109,79 +149,6 @@ namespace UAS_MES_NEW.Query
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void SaveFileToJPG(Worksheet sheet)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- DataHelper dh = new DataHelper();
|
|
|
- //OperatResult.AppendText("解析图片【" + sheet.Name + ".jpg】添加水印" + "\n");
|
|
|
- if (!Directory.Exists(Application.StartupPath + @"\" + ps_prodcode.Text))
|
|
|
- {
|
|
|
- Directory.CreateDirectory(Application.StartupPath + @"\" + ps_prodcode.Text);
|
|
|
- }
|
|
|
- string sheetname = sheet.Name;
|
|
|
- sheetname = sheetname.Replace("01", "1");
|
|
|
- sheetname = sheetname.Replace("02", "2");
|
|
|
- sheetname = sheetname.Replace("03", "3");
|
|
|
- sheetname = sheetname.Replace("04", "4");
|
|
|
- sheetname = sheetname.Replace("05", "5");
|
|
|
- sheetname = sheetname.Replace("06", "6");
|
|
|
- sheetname = sheetname.Replace("07", "7");
|
|
|
- sheetname = sheetname.Replace("08", "8");
|
|
|
- sheetname = sheetname.Replace("09", "9");
|
|
|
- //if (sheetname.Contains("-"))
|
|
|
- //{
|
|
|
- // sheetname = sheetname.Split('-')[0];
|
|
|
- //}
|
|
|
- int width = 0;
|
|
|
- int height = 0;
|
|
|
- //Console.WriteLine(sheet.Name);
|
|
|
- //for (int i = 0; i < sheet.Cells.Columns.Count; i++)
|
|
|
- //{
|
|
|
- // width +=(int) sheet.Cells.Columns[i].Width;
|
|
|
- //}
|
|
|
- //for (int i = 0; i < sheet.Cells.Rows.Count; i++)
|
|
|
- //{
|
|
|
- // height += (int)sheet.Cells.Rows[i].Height;
|
|
|
- //}
|
|
|
- //Console.WriteLine("width:"+width);
|
|
|
- //Console.WriteLine("height:"+height);
|
|
|
- //sheet.Pictures.Add(0, 18, @"图片\电子受控章.png");
|
|
|
- //sheet.Pictures.Add(0, 15, @"图片\签名.png");
|
|
|
- //sheet.PageSetup.LeftMargin = 0;
|
|
|
- //sheet.PageSetup.RightMargin = 0;
|
|
|
- //sheet.PageSetup.BottomMargin = 0;
|
|
|
- //sheet.PageSetup.TopMargin = 0;
|
|
|
- ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
|
|
|
- imgOptions.ImageFormat = ImageFormat.Png;
|
|
|
- imgOptions.OnePagePerSheet = true;
|
|
|
- imgOptions.CheckWorkbookDefaultFont = false;
|
|
|
- imgOptions.DefaultFont = "宋体";
|
|
|
- imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
|
|
|
- imgOptions.SetDesiredSize(1565, 1043);
|
|
|
- SheetRender sr = new SheetRender((Aspose.Cells.Worksheet)sheet, imgOptions);
|
|
|
- sr.ToImage(0, Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + sheetname + ".jpg");
|
|
|
- //// 创建一个图片
|
|
|
- OperatResult.AppendText("解析图片【" + sheetname + ".jpg】" + "\n");
|
|
|
- Dictionary<string, object> dic = new Dictionary<string, object>();
|
|
|
- dic.Add("em_name", "管理员");
|
|
|
- dic.Add("em_code", "ADMIN");
|
|
|
- dic.Add("caller", "ProductSOP");
|
|
|
- OperatResult.AppendText("上传文件【" + sheetname + ".jpg" + "】\n");
|
|
|
- //string fp_id = UploadFilesToRemoteUrl("http://192.168.0.85:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + sheetname + ".jpg", dic);
|
|
|
- //string ps_id = dh.getFieldDataByCondition("ProductSOP", "ps_id", "ps_prodcode='" + ps_prodcode.Text + "'").ToString();
|
|
|
- //dh.ExecuteSql("insert into ProductSOPdetail(psd_id,psd_psid,psd_attach) select ProductSOPdetail_seq.nextval,ps_id,'" + sheetname + ".jpg" + ";" + fp_id + "' from ProductSOP where ps_prodcode='" + ps_prodcode.Text + "'", "insert");
|
|
|
- //if (fp_id != "")
|
|
|
- //{
|
|
|
- // dh.ExecuteSql("update ProductSOP set ps_attachsop=ps_attachsop||" + fp_id + "||';' where ps_prodcode='" + pr_code.Text + "'", "update");
|
|
|
- //}
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- OperatResult.AppendText(ex.Message + ex.StackTrace);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 请求上传图片到阿里云
|
|
|
/// </summary>
|