void Application_Start(object sender, EventArgs e) { ServicePointManager.ServerCertificateValidationCallback = (sender1, certificate, chain, sslPolicyErrors) => true; CLogManager.Init(); //CLogManager.Init(); // Code that runs on application startup }
/// <summary> /// single Insert,update,delete /// </summary> /// <param name="_sql">완성된 Insert,update,delete 문</param> /// <returns></returns> public static int SqlExecute(string _SqlQuery, bool _CreateTable, string _CreateComm = "") { try { string StrFilePath = String.Format(@"{0}\History.db", connStrFolderPath); StrFilePath = String.Format(@"{0}{1}; PRAGMA Journa_Mode=WAL", connStr, StrFilePath); using (SQLiteConnection SQLiteConnection = new SQLiteConnection(StrFilePath)) { SQLiteConnection.Open(); SQLiteCommand SQLiteComm; int iRet = 0; if (_CreateTable == true) { // string CreateComm = ""; // CreateComm = string.Format("{0} (Date Datetime, RecipeName char, Result char, ResultX char, ResultTheta char, InspResult char, SendResult char, InspImagePath char);", SqlDefine.CREATE_TABLE); SQLiteComm = new SQLiteCommand(_CreateComm, SQLiteConnection); iRet = SQLiteComm.ExecuteNonQuery(); } SQLiteComm = new SQLiteCommand(_SqlQuery, SQLiteConnection); iRet = SQLiteComm.ExecuteNonQuery(); SQLiteConnection.Close(); return(iRet); } } catch (System.Exception ex) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.ERR, "SqliteManager SqlExecute Exception!!", CLogManager.LOG_LEVEL.LOW); return(0); } }
/// <summary> /// 네트워크 상태 변경시 호출될 콜백 매소드. /// </summary> /// <param name="server_token"></param> void on_status_changed(NETWORK_EVENT status) { switch (status) { // 접속 성공. case NETWORK_EVENT.connected: { CLogManager.log("on connected"); this.received_msg += "on connected\n"; // if (SaveServer == false) GetComponent <CMainTitle>().on_connected(); //else // GetComponent<CSaveServerNet>().on_connected(); } break; // 연결 끊김. case NETWORK_EVENT.disconnected: GetComponent <CMainTitle>().on_Disconnected(); CLogManager.log("disconnected"); this.received_msg += "disconnected\n"; Awake(); break; } }
private static string GetModelsConfig(int userId, int gridId, int languageId) { string ret = ""; try { string inputValue = string.Format("<InputValue UserID='{0}' GridID='{1}' />", userId, gridId); CGridColumnConfig[] lst = service.GetGridConfigColumn(inputValue); strColNames = ""; foreach (CGridColumnConfig cfg in lst) { ret += cfg.ToString(); strColNames += "'" + cfg.Heading + "'"; if (cfg != lst[lst.Length - 1]) { ret += ",\n"; strColNames += ","; } } } catch (Exception ex) { CLogManager.WritePL("PMSA.iMarkets.Presentation.WebApp.Mods.PriceBoard.Class.GetModelsConfig", ex.Message); } return(ret); }
public void SaveAlgoRecipe() { CogBlobReferAlgoRcp.ForeGround = Convert.ToInt32(graLabelForeground.Text); CogBlobReferAlgoRcp.ThresholdMin = Convert.ToInt32(graLabelThresholdValue.Text); CogBlobReferAlgoRcp.BlobAreaMin = Convert.ToDouble(textBoxBlobAreaMin.Text); CogBlobReferAlgoRcp.BlobAreaMax = Convert.ToDouble(textBoxBlobAreaMax.Text); CogBlobReferAlgoRcp.Width = Convert.ToDouble(textBoxWidthSize.Text); CogBlobReferAlgoRcp.WidthPos = Convert.ToDouble(textBoxWidthSpecPos.Text); CogBlobReferAlgoRcp.WidthNeg = Convert.ToDouble(textBoxWidthSpecNeg.Text); CogBlobReferAlgoRcp.Height = Convert.ToDouble(textBoxHeightSize.Text); CogBlobReferAlgoRcp.HeightPos = Convert.ToDouble(textBoxWidthSpecPos.Text); CogBlobReferAlgoRcp.HeightNeg = Convert.ToDouble(textBoxWidthSpecNeg.Text); CogBlobReferAlgoRcp.BenchMarkPosition = Convert.ToInt32(textBoxBenchMarkPosition.Text); CogBlobReferAlgoRcp.BodyArea = Convert.ToDouble(textBoxBodyArea.Text); CogBlobReferAlgoRcp.BodyWidth = Convert.ToDouble(textBoxBodyWidth.Text); CogBlobReferAlgoRcp.BodyHeight = Convert.ToDouble(textBoxBodyHeight.Text); CogBlobReferAlgoRcp.BodyAreaPermitPercent = Convert.ToDouble(numUpDownBodyArea.Value); CogBlobReferAlgoRcp.BodyWidthPermitPercent = Convert.ToDouble(numUpDownBodyWidth.Value); CogBlobReferAlgoRcp.BodyHeightPermitPercent = Convert.ToDouble(numUpDownBodyHeight.Value); CogBlobReferAlgoRcp.DummyHistoMeanValue = Convert.ToDouble(numUpDownDummyValue.Value); CogBlobReferAlgoRcp.UseBodyArea = ckBodyArea.Checked; CogBlobReferAlgoRcp.UseBodyWidth = ckBodyWidth.Checked; CogBlobReferAlgoRcp.UseBodyHeight = ckBodyHeight.Checked; CogBlobReferAlgoRcp.UseDummyValue = ckDummyUsable.Checked; CogBlobReferAlgoRcp.OriginX = OriginX; CogBlobReferAlgoRcp.OriginY = OriginY; CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, "Teaching BlobReference SaveAlgoRecipe", CLogManager.LOG_LEVEL.MID); }
private bool SeraialReceiveEventFunction(string _SerialData) { string[] ReceiveData = _SerialData.Split(','); eMainProcCmd ReceiveCmd = eMainProcCmd.LOT_CHANGE; CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, _SerialData, CLogManager.LOG_LEVEL.LOW); switch (ReceiveData[0]) { case "@S": ReceiveCmd = eMainProcCmd.RCP_CHANGE; break; case "@L": ReceiveCmd = eMainProcCmd.LOT_CHANGE; break; case "@E": ReceiveCmd = eMainProcCmd.LOT_CHANGE; break; case "@N": ReceiveCmd = eMainProcCmd.LOT_CHANGE; break; } if (ReceiveCmd == eMainProcCmd.LOT_CHANGE) { OnMainProcessCommand(ReceiveCmd, _SerialData); } else { OnMainProcessCommand(ReceiveCmd, ReceiveData[1]); } return(true); }
private void ApplyImageCell(ExcelWorksheet ws, string cellAddress, string format, string filename) { CLogManager.WriteSL("ApplyImageCell", "Cell:" + cellAddress + " format:" + format + " file:" + filename); try { filename = Path.Combine(ConfigurationManager.AppSettings["UploadDirectory"], filename); if (!File.Exists(filename)) { filename = Path.Combine(ConfigurationManager.AppSettings["UploadDirectory"], "NoImageAvailable.png"); } if (File.Exists(filename)) { Image image = Image.FromFile(filename); var picture = ws.Drawings.AddPicture("FrontImage_" + cellAddress, image); picture.From.Column = GetColIndex(cellAddress) - 1; // colIndex; picture.From.Row = GetRowIndex(cellAddress) - 1; // rowIndex; picture.SetSize(220, 220); // 2x2 px space for better alignment picture.From.ColumnOff = Pixel2MTU(5); picture.From.RowOff = Pixel2MTU(5); } else { CLogManager.WriteSL("ApplyImageCell", "File not found:" + filename); } } catch (Exception ex) { CLogManager.WriteSL("ApplyImageCell-Ex", ex.ToString()); } }
public string Get(int userID, string session, string funcPara) { //string pInput = string.Format("<InputValue UserID=\"{0}\" Session=\"{1}\" {2}/>", userId, session, funcPara); string InputValue = CXmlPara.CreatePara(funcPara); CAccountList account = service.GetAccount(InputValue); StringBuilder ret = new StringBuilder(); if (account != null) { ret.Append("{"); try { ret.AppendFormat("ID:'{0}',\n", account.ID); ret.AppendFormat("Code:'{0}',\n", account.Code); ret.AppendFormat("Name:'{0}',\n", account.Name); ret.AppendFormat("ParentID:'{0}',\n", account.ParentID); ret.AppendFormat("Type:'{0}'\n", account.ParentID); } catch (Exception ex) { CLogManager.Write("ChartAccountUI:Get(int, string, string)", ex.ToString(), "Account"); } ret.Append("}"); } else { ret.Append("{}"); } return(ret.ToString()); }
private bool Inspection(CogImage8Grey _SrcImage, CogRectangle _InspArea, bool _IsRotate = false) { bool _Result = true; try { if (true == _IsRotate) { CogRectangleAffine _Area = new CogRectangleAffine(); _Area.SetCenterLengthsRotationSkew(_InspArea.CenterX, _InspArea.CenterY, _InspArea.Width, _InspArea.Height, -3.14, 0); IDResults = IDProc.Execute(_SrcImage, _Area); } else { IDResults = IDProc.Execute(_SrcImage, _InspArea); } } catch (Exception ex) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.ERR, "InspectionID - Inspection Exception : " + ex.ToString(), CLogManager.LOG_LEVEL.LOW); _Result = false; } return(_Result); }
public static string CreateFolder(string pFolderName) { StringBuilder ret = new StringBuilder(); string template = "{{\"Code\":\"{0}\", \"Desc\":\"{1}\"}}"; try { string path = CReportConfig.Report_Url + "/" + pFolderName; DirectoryInfo dirInfo = new DirectoryInfo(path); if (!dirInfo.Exists) { DirectoryInfo dir = Directory.CreateDirectory(path); if (dir.Exists) { ret.AppendFormat(template, "00", "Folder create successful!"); } else { ret.AppendFormat(template, "11", "Folder create false!"); } } else { ret.AppendFormat(template, "01", "Folder is exist!"); } } catch (Exception ex) { ret.AppendFormat(template, "99", "Error system!!!: " + ex.Message); CLogManager.WritePL("ReportFunction.CreateFolder", ex.Message); } return(ret.ToString()); }
private bool ExecuteImport(string ClientKey, string inputValue) { try { System.Data.DataSet ds = new CCoreDao().ExecuteAction(ClientKey, inputValue); if (ds == null || ds.Tables.Count < 2) { return(false); } if (ds.Tables[1].Rows.Count == 0) { return(false); } if (!ds.Tables[0].Columns.Contains("Result")) { return(false); } var result = ds.Tables[0].Rows[0]["Result"]; if (result == null || result.ToString() == "0") { return(false); } return(true); } catch (Exception ex) { CLogManager.WritePL("ExecuteImport", ex.ToString()); } return(false); }
private void btnRecipeAdd_Click(object sender, EventArgs e) { IsRecipeNew = true; RecipeNewNameWindow _RcpNewNameWnd = new RecipeNewNameWindow(ProjectType); _RcpNewNameWnd.RecipeCopyEvent += new RecipeNewNameWindow.RecipeCopyHandler(RecipeCopyEventFunction); string[] _RecipeList = new string[listBoxRecipe.Items.Count]; for (int iLoopCount = 0; iLoopCount < _RecipeList.Count(); ++iLoopCount) { _RecipeList[iLoopCount] = listBoxRecipe.Items[iLoopCount].ToString(); } _RcpNewNameWnd.SetCurrentRecipe("[Default]", _RecipeList); if (_RcpNewNameWnd.ShowDialog() == DialogResult.OK) { LoadRecipeList(); this.Hide(); CParameterManager.SystemMode = eSysMode.RCP_MANUAL_CANGE; RecipeChange(_RcpNewNameWnd.NewRecipeName, "[Default]"); this.Show(); } CLogManager.AddSystemLog(CLogManager.LOG_TYPE.INFO, "RecipeWindow - RecipeAdd Complete", CLogManager.LOG_LEVEL.LOW); _RcpNewNameWnd.RecipeCopyEvent -= new RecipeNewNameWindow.RecipeCopyHandler(RecipeCopyEventFunction); IsRecipeNew = false; }
public void SaveAlgoRecipe() { CogBarCodeIDAlgoRcp.Symbology = comboBoxSymbology.Text; CogBarCodeIDAlgoRcp.FindCount = Convert.ToInt32(numUpDownNumtoFind.Value); CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, "Teaching CogID SaveAlgoRecipe", CLogManager.LOG_LEVEL.MID); }
private void rbExit_Click(object sender, EventArgs e) { try { for (int iLoopCount = 0; iLoopCount < ISMModuleCount; ++iLoopCount) { InspSysManager[iLoopCount].ImageContinuesGrabStop(); } DialogResult dlgResult = MessageBox.Show(new Form { TopMost = true }, "Do you want exit program ? ", "Exit Program", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2); if (DialogResult.Yes != dlgResult) { return; } CLogManager.AddSystemLog(CLogManager.LOG_TYPE.INFO, "MainProcess : CIPOS lead inspection program exit!!"); DeInitialize(); Environment.Exit(0); } catch (Exception ex) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.ERR, "MainForm Exit : " + ex.ToString(), CLogManager.LOG_LEVEL.LOW); Environment.Exit(0); } }
private bool LOTChange(string _LOTInfo) { bool _Result = false; string[] _LOTInfoTemp = _LOTInfo.Split(','); string _LOTName = _LOTInfoTemp[1]; try { if (_LOTName == "LotEnd") { ResultBaseWnd.LOTEnd(); ResultBaseWnd.ClearResultData(); } else { ResultBaseWnd.ClearResultData(_LOTName, ParamManager.SystemParam.InDataFolderPath, ParamManager.SystemParam.OutDataFolderPath); ResultBaseWnd.LOTStart(_LOTInfoTemp); string IndataTotalCount = ResultBaseWnd.GetTotalCount(); if (IndataTotalCount != null) { MainProcess.SendSerialData(eMainProcCmd.LOT_RETURN, IndataTotalCount); } } _Result = true; } catch (Exception ex) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.INFO, String.Format("Main : LOTChange Exception!!!"), CLogManager.LOG_LEVEL.LOW); } return(_Result); }
public void UpdateReceiveString(string _RecvMessage) { //ㄱ,1,0.05,0.02,0.03,0.01,ㄴ string _RecvString = _RecvMessage.Trim(); _RecvString = _RecvString.Replace(" ", ""); string[] _RecvCmd = _RecvString.Split(','); for (int iLoopCount = 0; iLoopCount < _RecvCmd.Length; ++iLoopCount) { CommandQueue.Enqueue(_RecvCmd[iLoopCount]); } if (true == ProtocolCommandProcess()) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.INFO, "Receive Data : " + _RecvString); CLogManager.AddSystemLog(CLogManager.LOG_TYPE.INFO, "ProtocolCommandProcess : Good"); } else { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.INFO, "Receive Data : " + _RecvString); CLogManager.AddSystemLog(CLogManager.LOG_TYPE.INFO, "ProtocolCommandProcess : Bad"); } ControlInvoke(textBoxRecvString, _RecvString); }
//LDH, 2018.08.13, History 추가용 함수 private void InspectionHistory(int _ID, string _Result) { CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, String.Format("InspectionHistory Start"), CLogManager.LOG_LEVEL.LOW); DateTime dateTime = DateTime.Now; string InspScreenshotPath = @"D:\VisionInspectionData\CIPOSLeadInspection\HistoryData\Screenshot\"; string ImageSaveFolder = String.Format("{0}{1:D4}\\{2:D2}\\{3:D2}", InspScreenshotPath, dateTime.Year, dateTime.Month, dateTime.Day); if (false == Directory.Exists(ImageSaveFolder)) { Directory.CreateDirectory(ImageSaveFolder); } string ImageSaveFile; ImageSaveFile = String.Format("{0}\\{1:D2}{2:D2}{3:D2}{4:D3}.bmp", ImageSaveFolder, dateTime.Hour, dateTime.Minute, dateTime.Second, dateTime.Millisecond); //LDH, 2018.08.13, 프로젝트별로 DB에 해당하는 history 내역을 string 배열로 전달 HistoryParam[0] = LastRecipeName; HistoryParam[1] = _ID.ToString(); HistoryParam[2] = _Result; HistoryParam[3] = ImageSaveFile; CHistoryManager.AddHistory(HistoryParam); CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, String.Format("InspectionHistory End"), CLogManager.LOG_LEVEL.LOW); CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, String.Format("Screenshot Start"), CLogManager.LOG_LEVEL.LOW); var _ScreenshotEvent = ScreenshotEvent; _ScreenshotEvent?.Invoke(ImageSaveFile); //ScreenshotEvent(ImageSaveFile); CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, String.Format("Screenshot End"), CLogManager.LOG_LEVEL.LOW); }
public void SaveAlgoRecipe() { CogLeadAlgoRcp.ForeGround = Convert.ToInt32(graLabelForeground.Text); CogLeadAlgoRcp.ThresholdMin = Convert.ToInt32(graLabelThresholdValue.Text); CogLeadAlgoRcp.BlobAreaMin = Convert.ToDouble(textBoxBlobAreaMin.Text); CogLeadAlgoRcp.BlobAreaMax = Convert.ToDouble(textBoxBlobAreaMax.Text); CogLeadAlgoRcp.WidthMin = Convert.ToDouble(textBoxWidthSizeMin.Text); CogLeadAlgoRcp.WidthMax = Convert.ToDouble(textBoxWidthSizeMax.Text); CogLeadAlgoRcp.HeightMin = Convert.ToDouble(textBoxHeightSizeMin.Text); CogLeadAlgoRcp.HeightMax = Convert.ToDouble(textBoxHeightSizeMax.Text); CogLeadAlgoRcp.IsLeadBentInspection = ckLeadBent.Checked; CogLeadAlgoRcp.LeadBent = Convert.ToDouble(textBoxLeadBentAngle.Text); CogLeadAlgoRcp.LeadBentMin = Convert.ToDouble(textBoxLeadBentAngleMin.Text); CogLeadAlgoRcp.LeadBentMax = Convert.ToDouble(textBoxLeadBentAngleMax.Text); CogLeadAlgoRcp.LeadCount = Convert.ToInt32(textBoxLeadCount.Text); CogLeadAlgoRcp.IsLeadPitchInspection = ckLeadPitch.Checked; CogLeadAlgoRcp.LeadPitch = Convert.ToDouble(textBoxLeadPitch.Text); CogLeadAlgoRcp.LeadPitchMin = Convert.ToDouble(textBoxLeadPitchMin.Text); CogLeadAlgoRcp.LeadPitchMax = Convert.ToDouble(textBoxLeadPitchMax.Text); CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, "Teaching LeadInspection SaveAlgoRecipe", CLogManager.LOG_LEVEL.MID); }
private void ThreadImageAutoDeleteFunc() { DateTime TimeNow; bool IsDeleted = false; try { while (false == IsThreadImageAutoDeleteExit) { TimeNow = DateTime.Now; if (true == IsThreadImageAutoDeleteTrigger) { if (TimeNow.Hour == 0 && IsDeleted == false) { IsThreadImageAutoDeleteTrigger = false; TimeNow = TimeNow.AddDays(-GetDeleteDate()); SetDeleteFolderName(TimeNow); IsDeleted = true; } else if (TimeNow.Hour != 0) { IsDeleted = false; } } Thread.Sleep(100); } } catch (System.Exception ex) { //MessageBox.Show(new Form { TopMost = true }, ex.Message + " ->" + ex.StackTrace); CLogManager.AddSystemLog(CLogManager.LOG_TYPE.INFO, String.Format(ex.Message + " ->" + ex.StackTrace), CLogManager.LOG_LEVEL.LOW); } }
private void OutputSignalCheck() { if (false == IsInitialize) { return; } short[] _BitNum = new short[IOCnt]; byte[] _Data = new byte[IOCnt]; for (int iLoopCount = 0; iLoopCount < IOCnt; ++iLoopCount) { _BitNum[iLoopCount] = (short)iLoopCount; } if (DigitalIO.OutputEchoBackMultiBitData(_BitNum, IOCnt, _Data) != (int)CDioConst.DIO_ERR_SUCCESS) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.ERR, "Output Check Error"); return; } for (int iLoopCount = 0; iLoopCount < IOCnt; iLoopCount++) { if (_Data[iLoopCount] == (short)DIOEnum.ON) { ControlInvoke(btnOutputSignal[iLoopCount], Color.DarkGreen); OutputSignalFlag[iLoopCount] = true; } else if (_Data[iLoopCount] == (short)DIOEnum.OFF) { ControlInvoke(btnOutputSignal[iLoopCount], Color.Maroon); OutputSignalFlag[iLoopCount] = false; } } }
private void ThreadInspectionFunction() { try { while (false == IsThreadInspectionExit) { if (true == IsThreadInspectionTrigger) { IsThreadInspectionTrigger = false; InspWnd.IsInspectionComplete = false; CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, String.Format("Vision : ISM{0} IsInspectionComplete false", ID + 1), CLogManager.LOG_LEVEL.LOW); if (!IsSimulationMode) { ImageGrabSnap(); } else { InspWnd.IsThreadInspectionProcessTrigger = true; } Thread.Sleep(50); } Thread.Sleep(10); } } catch (System.Exception ex) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.ERR, "ThreadInspectionFunction Exception : " + ex.ToString(), CLogManager.LOG_LEVEL.LOW); } }
protected T CallFunction <T>(int functionID, string inputValue) where T : new() { try { DataSet ds = CallFunction(functionID, inputValue); //List<T> list = new List<T>(); if (ds == null) { return(default(T)); } if (ds.Tables.Count == 0) { return(default(T)); } return(CDb.Map <T>(ds.Tables[0])); } catch (Exception ex) { CLogManager.WritePL("CallFunction", ex.Message + " " + ex.StackTrace); if (typeof(T) == typeof(CApplicationMessage)) { return(CDb.Map <T>("<Message Code=\"SYSTEM_ERROR\" Name = \"Unknow Error\" Result=\"0\" Description = \"" + ex.Message + "\" />")); //return (T)new CApplicationMessage() { Code = "SYSTEM_ERROR", Name = "Unknow Error", Description = ex.Message }; } } return(default(T)); }
private void InputSignalCheck() { if (false == IsInitialize) { return; } short[] _BitNum = new short[IOCnt]; for (int iLoopCount = 0; iLoopCount < IOCnt; ++iLoopCount) { _BitNum[iLoopCount] = (short)iLoopCount; } if (DigitalIO.InputMultiBitData(_BitNum, IOCnt, InputMultiSignal) != (int)CDioConst.DIO_ERR_SUCCESS) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.ERR, "Input Check Error"); return; } for (int iLoopCount = 0; iLoopCount < IOCnt; iLoopCount++) { if (InputMultiSignal[iLoopCount] == (short)DIOEnum.ON) { ControlInvoke(btnInputSignal[iLoopCount], Color.DarkGreen); } else if (InputMultiSignal[iLoopCount] == (short)DIOEnum.OFF) { ControlInvoke(btnInputSignal[iLoopCount], Color.Maroon); } } }
private void WaitingRoofFunction(byte[] _SendData) { while (RetryCount < RETRY_COUNT - 1) { lock (Lock_Recv) { string _Command = Encoding.Unicode.GetString(_SendData); if (_Command.IndexOf("ACK") != -1) { break; } if (false == WaitReceiveMessage(300, 10)) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.WARN, @"ASK/NAK Return Message TimeOut(" + _Command + ") : " + RetryCount.ToString()); } else { } } RetryCount++; } }
public void Connection() { try { SockArgs.Dispose(); SockArgs = new SocketAsyncEventArgs(); SockArgs.RemoteEndPoint = IPEndPoint; SockClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); SockClient.ConnectAsync(SockArgs); if (ThreadClientReceive != null && ThreadClientReceive.IsAlive == false) { Thread.Sleep(100); ClientStart(); CLogManager.AddSystemLog(CLogManager.LOG_TYPE.INFO, "ThreadClientReceive Start"); } IsInitialize = true; } catch { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.ERR, "Connect Exception", CLogManager.LOG_LEVEL.LOW); } }
public static List <CReportImage> GetListImagesBySession(string pSessionName) { List <CReportImage> list = new List <CReportImage>(); try { DirectoryInfo dirInfo = new DirectoryInfo(CReportConfig.Images_Url); if (dirInfo.Exists) { FileInfo[] files = dirInfo.GetFiles(); foreach (FileInfo file in files) { if (file.Name.IndexOf(pSessionName) != -1) { byte[] content = GetBytesFromFile(file.FullName); CReportImage image = new CReportImage(); image.Content = content; image.FileName = file.Name; image.Location = file.DirectoryName; list.Add(image); File.Delete(file.FullName); } } } } catch (Exception ex) { CLogManager.WritePL("ReportFunction.GetFilesByName", ex.Message); } return(list); }
private void SetResultData(object _Result) { SendResultParameter _SendResParam = _Result as SendResultParameter; ResultBaseWnd.SetResultData(_SendResParam); CLogManager.AddSystemLog(CLogManager.LOG_TYPE.INFO, String.Format("Main : SetResultData")); }
private void ThreadSignalToggleFunc() { try { SleepTime = 10; while (false == IsThreadSignalToggleExit) { for (int iLoopCount = SignalToggleList.Count - 1; iLoopCount >= 0; --iLoopCount) { SignalToggleList[iLoopCount].ToggleTime -= SleepTime; if (SignalToggleList[iLoopCount].ToggleTime <= 0) { byte _Data = Convert.ToByte(!SignalToggleList[iLoopCount].CurrentSignal); DigitalIO.OutputBitData(SignalToggleList[iLoopCount].Signal, _Data); SignalToggleList.RemoveAt(iLoopCount); } } Thread.Sleep(SleepTime); } } catch (System.Exception ex) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.ERR, "ThreadSignalToggleFunc Err : " + ex.Message, CLogManager.LOG_LEVEL.LOW); } }
public static string GetDirrectoryInfo(string pDirectoryUrl) { StringBuilder ret = new StringBuilder(); try { string[] dir = Directory.GetDirectories(pDirectoryUrl); ret.Append("{"); if (dir.Length > 0) { for (int i = 0; i < dir.Length; i++) { DirectoryInfo dirInfo = new DirectoryInfo(dir[i]); ret.AppendFormat("[\"Name\":\"{0}\"]", dirInfo.Name); if (i != dir.Length - 1) { ret.Append(","); } } } ret.Append("}"); } catch (Exception ex) { CLogManager.WritePL("ReportFunction.GetDirrectoryInfo", ex.Message); } return(ret.ToString()); }
/// <summary> /// Doc file excel chi tiet dua vao database /// </summary> /// <param name="clientKey"></param> /// <param name="excelfile"></param> /// <returns></returns> public string ImportExcel(string clientKey, string excelfile) { try { CLogManager.WriteSL("IMPORT", "File:" + excelfile); int startDataRow = 11; CMixExcel mixExcel = new CMixExcel(excelfile, false); ExcelPackage pck = (ExcelPackage)mixExcel.ExcelMixCore; var worksheet = pck.Workbook.Worksheets[1]; bool isAllOk = true; CLogManager.WriteSL("IMPORT", "Begin For to :" + worksheet.Dimension.End.Row.ToString()); for (int row = startDataRow; row <= worksheet.Dimension.End.Row; row++) { string inputValue = GetRowInXml(worksheet, row); CLogManager.WriteSL("IMPORT", "Input :" + inputValue); if (string.IsNullOrEmpty(inputValue)) { continue; } inputValue = "<RequestParams Sys_ViewID=\"28\" Action=\"INSERT\" " + inputValue + "/>"; if (ExecuteImport(clientKey, inputValue)) { //Delete imported row worksheet.DeleteRow(row); row--; } else { isAllOk = false; } } string downloadDir = System.Configuration.ConfigurationManager.AppSettings["DownloadDirectory"]; string tempFile = downloadDir + "\\Product\\Error";// + Guid.NewGuid().ToString() + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx"; if (!Directory.Exists(tempFile)) { Directory.CreateDirectory(tempFile); } string fileName = Guid.NewGuid().ToString() + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx"; tempFile = tempFile + "/" + fileName; //Khi xong thi luu file con lai vao temp pck.SaveAs(new System.IO.FileInfo(tempFile)); mixExcel.CloseStream(); if (isAllOk) { return("Code\n00-OK"); } else { return("Code\n01-//Product//Error//" + fileName); } } catch (Exception ex) { CLogManager.WriteSL("IMPORT", ex.ToString()); return("Code\n02-" + ex.Message); } }