public static void MakeDLL() { if (FileOP.IsExist(DLLWork.DLLName, FileOPMethod.File)) { FileOP.Delete(DLLWork.DLLName, FileOPMethod.File); } Type type = MethodBase.GetCurrentMethod().DeclaringType; string _namespace = type.Namespace; //获得当前运行的Assembly Assembly _assembly = Assembly.GetExecutingAssembly(); //根据名称空间和文件名生成资源名称 #if DEBUG string resourceName = _namespace + ".DebugDLL.KeyDAL.dll";// +DLLWork.DLLName; System.IO.Stream so = new System.IO.FileStream(DLLWork.DLLName, System.IO.FileMode.Create); #else string resourceName = _namespace + ".ReleaseDLL.KeyDAL.vmp.dll";// + DLLWork.DLLName; System.IO.Stream so = new System.IO.FileStream(DLLWork.DLLName, System.IO.FileMode.Create); #endif //根据资源名称从Assembly中获取此资源的Stream Stream stream = _assembly.GetManifestResourceStream(resourceName); //byte[] dll=Properties.Resources.KeyDAL; //so.Write(dll, 0, dll.Length); stream.CopyTo(so); so.Close(); }
private void WFSession_Load() { if (FileOP.IsExist(this.filePath, FileOPMethod.File)) { // 文件存在,将当前 XML 文件中的数据读入到 DataSet 中 // ds.ReadXml(this.filePath, XmlReadMode.DiffGram); DataTable dt = ConvertXmlToDataTable(this.rootName); for (int i = 0; i < dt.Columns.Count; i++) { DataTable dd = ConvertXmlToDataTable("//" + this.rootName + "/" + dt.Columns[i].ColumnName); dd.TableName = dt.Columns[i].ColumnName; this.SessionDs.Tables.Add(dd); } WFGlobal.writeLine.Append("公有表 " + dt.Columns.Count + " 个\r\n"); } else { // 文件不存在,开始创建 OperateXml oXml = new OperateXml(); oXml.filePath = this.filePath; oXml.CreateXml(this.rootName); DataTable dt = new DataTable(this.tableName); DataRow dr; dr = dt.NewRow(); dt.Rows.Add(dr); this.SessionDs.Tables.Add(dt); oXml.xPath = this.rootName; oXml.CreateNode(this.tableName, dt); } if (this.SessionDs.Tables.Contains(this.tableName)) { } else { // 当前操作的表不存在,创建该表 DataTable dt = new DataTable(this.tableName); DataRow dr; dr = dt.NewRow(); dt.Rows.Add(dr); this.SessionDs.Tables.Add(dt); OperateXml oXml = new OperateXml(); oXml.filePath = this.filePath; oXml.xPath = this.rootName; oXml.CreateNode(this.tableName, dt); } }
private void toolStripButton5_Click(object sender, EventArgs e) { SystemParam.DeviceID = InputBox.ShowInputBox("请设定当前测试器件的芯片编号", SystemParam.DeviceID); iniFileOP.Write("System Run", "DeviceID", SystemParam.DeviceID); strCCDINIPath = SystemParam.ccdParamFilePath + SystemParam.DeviceID + ".ini"; string Osat = iniFileOP.Read("CCD Param", "Osat", strCCDINIPath); if (!FileOP.IsExist(strCCDINIPath, FileOPMethod.File)) { FileOP.CopyFile(System.Windows.Forms.Application.StartupPath + "\\ccdParamFileTemplate.ini", strCCDINIPath); } CCDTest(); }
protected void Page_Load(object sender, EventArgs e) { string DeviceID, PocketIndex; string ret = ""; try { DeviceID = Request.QueryString["DeviceID"]; PocketIndex = Request.QueryString["PocketIndex"]; //信息|用户id|实验id,实验名,实验室; if (string.IsNullOrEmpty(DeviceID) || string.IsNullOrEmpty(PocketIndex))//没有这两个变量 { ret = webAPIFunc.GetRetString(ErrType.MissParam); Response.Write(ret); return; } int index; if (!int.TryParse(PocketIndex, out index)) { ret = webAPIFunc.GetRetString(ErrType.ErrParam); Response.Write(ret); return; } if (index == 1) { DeviceInfoData did = DeviceInfoDataDBOption.Get(DeviceID); if (did == null) { ret = webAPIFunc.GetRetString(ErrType.NoRegDevice); Response.Write(ret); return; } } string fileName = Global.hexBINFolder + DeviceID + ".bin"; if (!FileOP.IsExist(fileName, FileOPMethod.File)) { ret = webAPIFunc.GetRetString(ErrType.NoHexBin); Response.Write(ret); return; } FileInfo f; f = new FileInfo(fileName); Stream stream = File.OpenRead(f.FullName); byte[] pBuf = new byte[stream.Length]; stream.Read(pBuf, 0, (int)stream.Length); stream.Close(); if (index == 0) { ret = webAPIFunc.GetRetString(ErrType.retOK, pBuf.Length.ToString()); Response.Write(ret); return; } else { int size = 1024 * 5; // 0480; int count = pBuf.Length / size; int left = pBuf.Length % size; int x = size * (index - 1); string str; if (index > count)//最后一包 { //ret = ((int)ErrType.retOK).ToString() + ","; str = StringsFunction.byteToHexStr(pBuf, x, left, ""); Response.Write(webAPIFunc.GetRetString(ErrType.retOK, str)); return; } else { //ret = ((int)ErrType.retOK).ToString() + ","; str = StringsFunction.byteToHexStr(pBuf, x, size, ""); ret = ret + str; //Debug.WriteLine(ret); Response.Write(webAPIFunc.GetRetString(ErrType.retOK, str)); return; } } } catch (System.Exception ex) { ret = webAPIFunc.GetRetString(ErrType.UnkownErr); TextLog.AddTextLog("GetHexData_Unkown:" + ex.Message, Global.txtLogFolder + "Update.txt", true); } Response.Write(ret); }