Default.aspx.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using BizCom;
  2. using SevenZip;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Reflection;
  8. using System.Threading;
  9. using System.Web;
  10. using System.Web.UI;
  11. using System.Web.UI.WebControls;
  12. public partial class _Default : System.Web.UI.Page
  13. {
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. //string fileName = "(C2_1975999718512169836)-80x40mm-1000张-不干胶铜版纸烫金覆膜模切--YJSJ-郑凌宇1-四川省-金陵-[C2].cdr";
  17. //string ctid = MidStrEx(fileName, "(", ")").Trim();
  18. // CeErpTradeCell entity=CeErpTradeCell.GetByCtid("C2_1975999718512169836");
  19. //entity.Update();
  20. //Response.Write(entity.ctid + "<br>");
  21. //if (IntPtr.Size == 4)
  22. //{
  23. // SevenZipCompressor.SetLibraryPath(@"D:\fireant\ecomerp\UploadWeb\Bin\x64\7z.dll");
  24. //}
  25. //else
  26. //{
  27. // SevenZipCompressor.SetLibraryPath(@"D:\fireant\ecomerp\UploadWeb\Bin\x86\7z.dll");
  28. //}
  29. //SevenZipCompressor.SetLibraryPath(@"D:\fireant\ecomerp\UploadWeb\Bin\x64\7z.dll");
  30. //SevenZipExtractor.SetLibraryPath(@"\x64\7z.dll");
  31. //SevenZip.SevenZipExtractor
  32. //LibraryFeature lf = SevenZipExtractor.CurrentLibraryFeatures;
  33. SevenZipExtractor.SetLibraryPath(Server.MapPath("bin\\7z.dll"));
  34. //var path = Path.Combine(Server.MapPath("bin"), Environment.Is64BitProcess ? "x64" : "x86", "7z.dll");
  35. //SevenZip.SevenZipBase.SetLibraryPath(path);
  36. //SevenZipExtractor.SetLibraryPath(path);
  37. //using (SevenZipExtractor szExtra = new SevenZipExtractor("d:\\4.rar"))
  38. // {
  39. //szExtra.ExtractArchive("d:\\temp");
  40. // foreach (string afn in szExtra.ArchiveFileNames)
  41. //{
  42. //if (afn.IndexOf("123123", StringComparison.OrdinalIgnoreCase) != -1)
  43. // szExtra.ExtractFiles("d:\\temp", afn);
  44. // }
  45. //}
  46. }
  47. private void CdrExportPng(string path, string cdrFile)
  48. {
  49. if (!File.Exists(cdrFile))
  50. {
  51. Response.Write("找不到文件:"+cdrFile);
  52. return;
  53. }
  54. string fname = path + "\\" + Path.GetFileNameWithoutExtension(cdrFile) + ".png";
  55. CorelDRAW.Application cdr = new CorelDRAW.Application();
  56. cdr.OpenDocument(cdrFile, 1);
  57. object obj = new object();
  58. Response.Write(Utils.Serialization.JsonString.Convert(cdr.ActiveDocument.ActiveLayer.Shapes[0]));
  59. return;
  60. cdr.ActiveDocument.ExportBitmap(
  61. fname,
  62. CorelDRAW.cdrFilter.cdrPNG,
  63. CorelDRAW.cdrExportRange.cdrCurrentPage,
  64. CorelDRAW.cdrImageType.cdrRGBColorImage,
  65. 0, 0, 72, 72,
  66. CorelDRAW.cdrAntiAliasingType.cdrNoAntiAliasing,
  67. false,
  68. true,
  69. true,
  70. false,
  71. CorelDRAW.cdrCompressionType.cdrCompressionNone,
  72. null).Finish();
  73. cdr.ActiveDocument.Close();
  74. cdr.Quit();
  75. }
  76. public static string MidStrEx(string sourse, string startstr, string endstr)
  77. {
  78. string result = string.Empty;
  79. int startindex, endindex;
  80. try
  81. {
  82. startindex = sourse.IndexOf(startstr);
  83. if (startindex == -1)
  84. return result;
  85. string tmpstr = sourse.Substring(startindex + startstr.Length);
  86. endindex = tmpstr.IndexOf(endstr);
  87. if (endindex == -1)
  88. return result;
  89. result = tmpstr.Remove(endindex);
  90. }
  91. catch (Exception ex)
  92. {
  93. Console.WriteLine("MidStrEx Err:" + ex.Message);
  94. }
  95. return result;
  96. }
  97. private string formatMemo(object memo)
  98. {
  99. string m = memo.ToString();
  100. m = m.Replace("\\", "").Replace("/", "").Replace(":", "").Replace("*", "").Replace("?", "").Replace("<", "").Replace(">", "").Replace("|", "");
  101. return m;
  102. }
  103. }