public static void DownloadTesterRecipe() { if (DownloadRecipe_Tester != null)// { UtilLog.Info("Redownload Tester Recipe"); DownloadRecipe_Tester(); } }
public static void UpdateSecsGem(object machine) { if (SecsGemConfig_Update != null)// { UtilLog.Info("Entering SecsGemConfig_Update"); SecsGemConfig_Update(machine); } }
private void btnShowSecsGem_Click(object sender, EventArgs e) { try { gv_machine.HandlerIp = txtHandlerIP.Text.Trim(); gv_machine.HandlerPort = int.Parse(txtHandlerPort.Text.Trim()); UtilLog.Info("IP = " + gv_machine.HandlerIp + "; Port = " + gv_machine.HandlerPort); MidMsgTransferModule.UpdateSecsGem(gv_machine); UtilMessage.ShowInfo("Secs/gem config Update Success!"); } catch (Exception ex) { UtilLog.Error(ex); } }
private void btnLogin_Click(object sender, EventArgs e) { try { using (TesterRecipe_Service.TesterRecipe_Service ts_rmsService = new TesterRecipe_Service.TesterRecipe_Service()) { string strDepartment = ""; UtilLog.Info("Verify user login :"******"Verify user login Result:" + sVerfiyResult); if (sVerfiyResult.Substring(0, 4) == "True") { if (sVerfiyResult.Length != 8) { strDepartment = sVerfiyResult.Substring(4, 5); } else { strDepartment = "NONE*"; } #region Set User Info Data UtilCommonInfo.UserName = txtUserName.Text.Trim(); UtilCommonInfo.Password = txtPassword.Text.Trim(); UtilCommonInfo.Dept = strDepartment; #endregion this.DialogResult = DialogResult.OK; } else if (sVerfiyResult.Substring(0, 4) == "miss") { string sMsg = "UserID or PassWord missmatch!用户名或密码不正确!"; UtilMessage.ShowError(sMsg); this.DialogResult = DialogResult.None; //return; } } } catch (Exception ex) { string sMsg = "Remote Host Not Responding!!远端服务器没有响应!"; UtilMessage.ShowWarn(sMsg); UtilLog.Error("LogIn Handle Send Message to Host Error :", ex); } }
/// <summary> /// ftp文件上传 /// </summary> /// <param name="filename">文件名称</param> /// <param name="remotefile">远程文件名,含相对路径。不能使用绝对路径。</param> /// <returns>是否上传成功</returns> public bool Upload(string filename, string remotefile = "") { bool is_ok = false; FileInfo fileInf = new FileInfo(filename); string uri = ftpURI + (string.IsNullOrWhiteSpace(remotefile) ? fileInf.Name : Path.Combine(remotefile, fileInf.Name)); //没有指定时,用文件名。否则用指定的文件名,含相对路径 ftplog.Info("上传文件路径:" + uri); FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri)); reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); reqFTP.KeepAlive = KeepAlive; reqFTP.Method = WebRequestMethods.Ftp.UploadFile; reqFTP.UseBinary = UseBinary; reqFTP.UsePassive = PassiveMode; //vsftpd对这个返回不正常,只能false reqFTP.ContentLength = fileInf.Length; int buffLength = 2048; //int buffLength = (int)fileInf.Length; byte[] buff = new byte[buffLength]; int contentLen; FileStream fs = fileInf.OpenRead(); try { Stream strm = reqFTP.GetRequestStream(); contentLen = fs.Read(buff, 0, buffLength); while (contentLen != 0) { strm.Write(buff, 0, contentLen); contentLen = fs.Read(buff, 0, buffLength); } strm.Close(); fs.Close(); is_ok = true; } catch (Exception ex) { ftplog.Error("ftp上传文件失败:" + ex.Message); } return(is_ok); }
public static List <Bin> readStatecList(string filePath, string fileName) { List <Bin> softBins = new List <Bin>(); string testStart = "", testEnd = "", totalTestCount = "", totalGoodCount = ""; int intRowCount = 0; bool boolFoundSoftBin = false; FileStream fileStream = null; StreamReader reader = null; try { fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Delete); reader = new StreamReader(fileStream); string ln = null; #region 解析文件 while ((ln = reader.ReadLine()) != null) { ln = ln.Trim(); if (ln.StartsWith("Total Test Count")) { totalTestCount = ln.Substring(ln.IndexOf(":") + 1).Trim(); continue; } if (ln.StartsWith("Total Good Count")) { totalGoodCount = ln.Substring(ln.IndexOf(":") + 1).Trim(); continue; } if (ln.StartsWith("Test Start")) { ln = ln.Replace(".......", ":"); testStart = ln.Substring(ln.IndexOf(":") + 1).Trim(); testStart = testStart.Replace(" ", " "); continue; } if (ln.StartsWith("Test End")) { ln = ln.Replace(".......", ":"); testEnd = ln.Substring(ln.IndexOf(":") + 1).Trim(); testEnd = testEnd.Replace(" ", " "); continue; } if (ln.Contains("<< TEST BIN REPORT >>")) { boolFoundSoftBin = true; intRowCount++; continue; } if (boolFoundSoftBin) { intRowCount++; if (intRowCount > 4) { if (ln.Length < 3) { break; } ln = UtilString.HandleSpace(ln, "_"); string[] strArray = ln.Split('_'); for (int i = 0; i < strArray.Length / 3; i++) { int rejectQty = int.Parse(strArray[i * 3 + 1]); if (rejectQty > 0) { Bin bin = new Bin(); //bin.BinNumber = int.Parse(strArray[i * 3]); bin.Name = "SoftBin" + strArray[i * 3]; bin.Qty = rejectQty; softBins.Add(bin); UtilLog.Info("Test Logger Name: " + fileName + ", " + bin.Name + ", Bin Qty: " + bin.Qty); } } } } } #endregion } catch (IOException e) { UtilLog.Error("Handle Read File IOErr :", e); } catch (Exception ex) { UtilLog.Error("Handle Read File Err :", ex); } finally { try { if (reader != null) { reader.Close(); reader.Dispose(); reader = null; } if (fileStream != null) { fileStream.Close(); fileStream.Dispose(); fileStream = null; } } catch (IOException e) { throw (e); } } return(softBins); }