public bool ExeScriptFile(string FileName, ref string RdStr) { string SptFilePath = null, ErrInfo = null, CleanCmd = null; int ErrCode = 0; SL_IO_Util IOUtil = new SL_IO_Util(); List <ScriptInfo> lScriptInfo = new List <ScriptInfo>(); if (!IOUtil.FileExist(FileName, ref SptFilePath)) { RdStr += "Script not Exist"; return(false); } ErrInfo = ElecsSpt.ExamScript(IOUtil.ReadFile(SptFilePath), ref lScriptInfo); if (!String.IsNullOrEmpty(ErrInfo)) { RdStr = ErrInfo; return(false); } for (int i = 0; i < lScriptInfo.Count; i++) { if (ElecsSpt.ExamCmd(lScriptInfo[i].Command.Trim(), ref CleanCmd, ref ErrCode)) { if (ElecsSpt.GetCmdClass() == 0 || ElecsSpt.GetCmdClass() == 2 || ElecsSpt.GetCmdClass() == 3) { SetDevices(ElecsSpt.getCommAddr(), ref ElecsComm, ElecsSpt.getInstruAddr()); ProcessCmd(ElecsSpt.GetElecsCmd(), ElecsSpt.GetElecsClass(), ref RdStr); Thread.Sleep(20); } } } return(true); }
public static void f(string funName, string message) { if (!OutLog) { return; } SL_IO_Util fileUtil = new SL_IO_Util(); if (!fileUtil.FileExist(FilePath)) { FilePath = LogFilePath; } if (string.IsNullOrEmpty(FilePath)) { FilePath = Directory.GetCurrentDirectory(); } FileInfo finfo = new FileInfo(FilePath); if (finfo.Directory.Exists == false) { finfo.Directory.Create(); } string writeString = string.Format("{0:yyyy/MM/dd HH:mm:ss} {1}: {2}", DateTime.Now, funName, message) + Environment.NewLine; File.AppendAllText(FilePath, writeString, Encoding.Unicode); }