protected virtual bool TryConnection() { CloseConnections(); clsLog oLog = new clsLog(); try { if (!this.is_ready) { this.CurDBEngine = new DatabaseEngine(base.PrivateConfig.DatabaseType, base.PrivateConfig.DatabaseConnectionString); if (this.CurDBEngine.Connect()) { this.is_ready = true; oLog.WriteToDebugLogFile("Connected", "TryConnection"); } else { this.error_occured = true; base.ErrMsg = this.CurDBEngine.ErrorMessage; } } } catch (Exception exception) { this.error_occured = true; base.ErrMsg = exception.Message; } return(this.is_ready); }
public string DownloadMasterUsersByJSON(DateTime dtCreated) { UploadManager CurUploadManager = new UploadManager(); clsLog oLog = new clsLog(); oLog.WriteToDebugLogFile("Starting Function", "DownloadMasterUsersByJSON"); ApplicationUserCollection UserCollection = CurUploadManager.DownloadMasterUsersInColl(dtCreated); // DataTable objDataSet = CurUploadManager.DownloadMasterUsers(dtCreated); // Create a multidimensional jagged array // string[][] JaggedArray = new string[objDataSet.Rows.Count][]; // int i = 0; // foreach (DataRow rs in objDataSet.Rows) // { //JaggedArray[i] = new string[] { rs["user_id"].ToString(), rs["user_password"].ToString(), rs["user_firstname"].ToString() }; // i = i + 1; //user.FirstName = ; // } // Return JSON data string json = JsonConvert.SerializeObject(UserCollection); return(json); }
public override void Dispose() { clsLog oLog = new clsLog(); oLog.WriteToDebugLogFile("Starting Function", "Dispose"); if (this.is_detroyable) { oLog.WriteToDebugLogFile("Before Destroy", "Dispose"); if (this.IsReady) { oLog.WriteToDebugLogFile("Before Disconnect", "Dispose"); if (CurDBEngine != null) { this.CurDBEngine.Disconnect(); oLog.WriteToDebugLogFile("After Disconnect", "Dispose"); } else { oLog.WriteToDebugLogFile("DB Engine is Null", "Dispose"); } } this.CurDBEngine = null; this.CurSQLFactory = null; oLog.WriteToDebugLogFile("Ending Function", "Dispose"); } }
public DataTable CloseConnections() { clsLog oLog = new clsLog(); DataTable table = null; try { //if (this.TryConnection()) //{ oLog.WriteToDebugLogFile("executing Procedure", "CloseConnection"); DatabaseParameters parameters = new DatabaseParameters(); CurSQLFactory.ExecuteStoredProcedure(this.DataStructrure.StoredProcedures.closeConnections.ActualTableName, parameters); table = CurDBEngine.SelectQuery(CurSQLFactory.SQL); if (table == null) { error_occured = true; ErrMsg = "[SwordfishManagerBase] : CloseConnections : " + CurDBEngine.ErrorMessage; } return(table); //} //error_occured = true; //ErrMsg = "[SwordfishManagerBase] : CloseConnections : " + ErrMsg; } catch (Exception ex) { oLog.WriteToErrorLogFile(ex.Message.ToString(), "CloseConnection"); } return(table); }
public bool Server_insert(clsLog log) { server_command.Parameters["@DANGER"].Value = log.danger; server_command.Parameters["@DATE"].Value = log.time; server_command.Parameters["@NAME"].Value = log.name; server_command.Parameters["@ID_FOMS_REGION"].Value = log.id_foms_region; server_command.Parameters["@ID_TASK"].Value = log.id_task; server_command.Parameters["@DATE_START"].Value = log.date_start; server_command.Parameters["@DATE_FINISH"].Value = log.date_finish; server_command.Parameters["@COMMENT"].Value = log.comment; if (log.danger < 1 && adminInform) { clsLibrary.SendMail( MailServerIp, //"192.168.1.2", gatewayMail, //"AOFOMS Gateware [email protected]", gatewayPassword, // "A3z4y5", adminMail, //"*****@*****.**", "Внимание!", log.name + "|" + log.comment); } bool status; try { server_command.ExecuteNonQuery(); status = true; } catch { status = false; } return(status); }
/// <summary> /// Log 클래스를 초기화 시킨다.프로그램 폴더에 Log_PlcModule폴더에 Log가 기록. /// </summary> /// <param name="strLogFileName">Log파일 생성 이름</param> private void InitClass(string folderPath, string strLogFileName) { strLogFileName = strLogFileName.Trim(); if (strLogFileName == string.Empty) { strLogFileName = "plcModuleLog"; } clsLog = new clsLog(folderPath, strLogFileName, 30, true); dtAddress = new DataTable("PLC Address"); dtAddress.Columns.Add(new DataColumn("Address", System.Type.GetType("System.String"))); dtAddress.Columns.Add(new DataColumn("Value", System.Type.GetType("System.Int16"))); dtAddress.Columns.Add(new DataColumn("Value(HEX)", System.Type.GetType("System.String"))); dtAddress.PrimaryKey = new DataColumn[] { dtAddress.Columns["Address"] }; clsPLC.dtWriteOrder.Columns.Add(new DataColumn("Address", System.Type.GetType("System.String"))); clsPLC.dtWriteOrder.Columns.Add(new DataColumn("Value", System.Type.GetType("System.Int16"))); //변수 및 이벤트 연결.. clsPLC.dtAddress = this.dtAddress; //dtAddress.ColumnChanged += new DataColumnChangeEventHandler(dtAddress_ColumnChanged); strLogHeader = enPLCType.ToString(); }
public frmInputOrder_Paint(Function.clsOracle.strConnect clsdb, clsLog clslog, string _SystemID, string _strOrderType, string _strStationID) { InitializeComponent(); clsDB = clsdb; clsLog = clslog; SYSTEMID = _SystemID; strStationID = _strStationID; }
public string DownloadMasterLookUp(DateTime dtCreated) { UploadManager CurUploadManager = new UploadManager(); clsLog oLog = new clsLog(); oLog.WriteToDebugLogFile("Starting Function", "DownloadMasterLookUp"); MasterLookUpCollection lookUpCollection = CurUploadManager.DownloadMasterLookUp(dtCreated); string json = JsonConvert.SerializeObject(lookUpCollection); return(json); }
public string DownloadMasterCausesByJSON(DateTime dtCreated) { clsLog oLog = new clsLog(); oLog.WriteToDebugLogFile("Starting Function", "DownloadMasterCausesByJSON"); UploadManager CurUploadManager = new UploadManager(); MasterCauseCollection CausesCollection = CurUploadManager.DownloadMasterCauses(dtCreated); string json = JsonConvert.SerializeObject(CausesCollection); return(json); }
public string DownloadMasterCheckListType(DateTime dtCreated) { clsLog oLog = new clsLog(); oLog.WriteToDebugLogFile("Starting Function", "DownloadMasterCheckListType"); UploadManager CurUploadManager = new UploadManager(); MasterCheckListTypeCollection masterCheckListTypeColleaction = CurUploadManager.DownloadMasterCheckListType(dtCreated); string json = JsonConvert.SerializeObject(masterCheckListTypeColleaction); return(json); }
public string DownloadQuickNotes() { clsLog oLog = new clsLog(); oLog.WriteToDebugLogFile("Starting Function", "DownloadQuickNotes"); UploadManager CurUploadManager = new UploadManager(); MasterQuickNotesCollection quickNotesCollection = CurUploadManager.DownloadQuickNotes(); string json = JsonConvert.SerializeObject(quickNotesCollection); return(json); }
public bool UploadOpNotificationByJSON(string json) { bool smooth = true; clsLog oLog = new clsLog(); oLog.WriteToDebugLogFile("Starting Function", "UploadOpNotificationByJSON"); WebObjects.obj_notification[] CurOpNotificationCollection = JsonConvert.DeserializeObject <WebObjects.obj_notification[]>(json); UploadManager CurUploadManager = new UploadManager(); smooth = CurUploadManager.UploadOpNotificationCollectionToSQLServer(CurOpNotificationCollection); return(smooth); }
public static void InsertLog(clsLog objLog) { try { String strSQL = "INSERT INTO tbl_Log VALUES(TBL_LOG_SEQ.NEXTVAL, '" + objLog.strIP + "', SYSDATE, '" + objLog.strAction + "', '" + objLog.strTarget_Name + "')"; clsOracleDBMS objDBMS = new clsOracleDBMS(); objDBMS.ExecuteSQL(strSQL); } catch (Exception ex) { throw new Exception(clsUtilities.GetErr(ex.Message.ToString())); } }
static void Main(string[] args) { //try //{ Console.WriteLine("Get Configuration"); GetConfig(); Log = new clsLog(_conStr); Console.WriteLine($"Connecting FTP {_ftpserver}..."); clsSFTP sftp = new clsSFTP(); sftp.sftpIP = _ftpserver; sftp.Sftpuser = _ftpuser; sftp.Sftppwd = _ftppassword; sftp.Remotefolder = _ftpFolder; _logDownloadProcessid = Log.LogProcessInsert(clsLog.Logger.Inventory, clsLog.ProcessCategory.Inventory, "Start Download File from SFTP", DateTime.Now); try { Console.WriteLine("Trying to download file from FTP..."); if (sftp.DownloadLatestFile(true) != 0) { Console.WriteLine("Problem on download file. So Quit job now"); Log.LogAlert(clsLog.Logger.Inventory, clsLog.ErrorLevel.MiddleImpact, clsLog.ProcessCategory.Inventory, $"Problem found on Download file"); return; } Log.LogProcessUpdate(_logDownloadProcessid, DateTime.Now); Console.WriteLine("Download file success"); } catch (Exception ex) { Console.WriteLine($"Download file has an error {ex.Message}"); Log.LogAlert(clsLog.Logger.Inventory, clsLog.ErrorLevel.MiddleImpact, clsLog.ProcessCategory.Inventory, $"Inventory snapshot download problem found:{ex.Message}"); } try { Console.WriteLine("Trying to import data into O2D inventory..."); Inventory inv = new Inventory(_conStr); inv.ImportOpening(sftp.LocalFile); Console.WriteLine("Import inventory is success"); } catch (Exception ex) { Console.WriteLine($"Error found on step ImportOpening:{ex.Message}"); Log.LogAlert(clsLog.Logger.Inventory, clsLog.ErrorLevel.MiddleImpact, clsLog.ProcessCategory.Inventory, $"Inventory snapshot IMPORT problem found:{ex.Message}"); } }
/// <summary> /// Log 클래스를 초기화 시킨다.프로그램 폴더에 Log_PlcModule폴더에 Log가 기록. /// </summary> /// <param name="strLogFileName">Log파일 생성 이름</param> private void InitClass(string strLogFileName) { string strLogDirectory = @"\Log_PlcModule\"; strLogFileName = strLogFileName.Trim(); if (strLogFileName == string.Empty) { strLogFileName = "plcModuleLog"; } clsLog = new clsLog(strLogDirectory, strLogFileName, 30, true); //변수 및 이벤트 연결.. this.dtAddress = clsPLC.dtAddress; //this.evtChConnectionStatus += new delChConnectionStatus(clsPLCModule_evtChConnectionStatus); }
protected void Page_Load(object sender, EventArgs e) { HttpBrowserCapabilities objHttpBrowserCapabilities = Request.Browser; if (!IsPostBack) { dgridShowData.DataSource = clsServersDataManager.SelectView(); dgridShowData.DataBind(); dgridProjects.DataSource = clsServersDataManager.SelectProjects(); dgridProjects.DataBind(); clsLog objLog = new clsLog(); objLog.strIP = Request.UserHostAddress; objLog.strLog_Date = DateTime.Now.ToString(); objLog.strTarget_Name = ""; objLog.strAction = "L"; clsLogManager.InsertLog(objLog); } }
//public string ConStr { get => _conStr; set => _conStr = value; } public ATPCTP(String customDBconnectionString, String StdDBConnectionString) { ConStr = customDBconnectionString; log = new clsLog(StdDBConnectionString); }
public SplitItem(String customDBconnectionString, String StdDBConnectionString) { ConStr = customDBconnectionString; log = new clsLog(StdDBConnectionString); }
protected void btnRead_Click(object sender, EventArgs e) { try { if ((lblIDData.Text == "") || (lblIPAddressData.Text == "") || (lblServerNameData.Text == "")) { lblMessageData01.Text = "Please select a server."; lblMessageData02.Text = ""; } else { DataTable objDataTable = new DataTable(); objDataTable = clsServersDataManager.SelectServer(dgridShowData.SelectedRow.Cells[1].Text); stringArr = objDataTable.Rows[0].ItemArray.Select(arrServer => arrServer.ToString()).ToArray(); using (var ssh = new SshClient(stringArr[2], stringArr[6], stringArr[7])) { ssh.Connect(); intStartLine = Int32.Parse(lblTemp.Text); int intLastLine = Int32.Parse(ssh.CreateCommand("wc -l " + stringArr[4] + " | awk '{print $1}'").Execute()); int intLinesToShow; intLinesToShow = intLastLine - intStartLine; if (intLinesToShow == 0) { txtOutput.Text = "There is nothing to show."; } else { txtOutput.Text = ""; String strLog = ssh.CreateCommand("tail -" + intLinesToShow.ToString() + " " + stringArr[4]).Execute(); strLog = strLog.Replace("\n", "\r\n"); txtOutput.Text = strLog; lblMessageData01.Text = ""; lblMessageData02.Text = ""; ssh.Disconnect(); btnDownloadLog.Enabled = true; } lblStatus.Text = "Not Set"; lblStatus.ForeColor = System.Drawing.Color.Red; btnRead.Enabled = false; clsLog objLog = new clsLog(); objLog.strIP = Request.UserHostAddress; objLog.strLog_Date = DateTime.Now.ToString(); objLog.strTarget_Name = stringArr[1]; objLog.strAction = "R"; clsLogManager.InsertLog(objLog); } } } catch (Exception ex) { Guid objGUID = Guid.NewGuid(); String strException = ex.ToString(); File.WriteAllText(strLogPath + DateTime.Today.ToString("yyyyMMdd") + "-" + objGUID.ToString() + ".log", strException); lblMessageData01.Text = "خطایی در سیستم رخ داده است. لطفا کد خطای زیر را به همراه آی دی سرور به واحد نصب و راه اندازی ارسال نمایید.\r\n"; lblMessageData02.Text = DateTime.Today.ToString("yyyyMMdd") + "-" + objGUID.ToString(); } }
/// <summary> /// /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="subject"></param> /// <param name="body"></param> /// <param name="attachments"></param> /// <returns></returns> public static string SendEmail(string from, string[] tos, string subject, string body, Attachment[] attachments, string embeddedImage) { string sErrDesc = string.Empty; string sFuncName = string.Empty; const Int16 DEBUG_ON = 1; clsLog oLog = new clsLog(); Int16 p_iDebugMode = DEBUG_ON; try { sFuncName = "SendEmail"; var smtp = new System.Net.Mail.SmtpClient(); { smtp.Host = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"].ToString(); smtp.Port = int.Parse(System.Configuration.ConfigurationManager.AppSettings["SMTPPort"].ToString());; smtp.EnableSsl = true; smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential(System.Configuration.ConfigurationManager.AppSettings["SMTPUser"].ToString(), System.Configuration.ConfigurationManager.AppSettings["SMTPPassword"].ToString()); smtp.Timeout = 900000; } MailMessage mail = new MailMessage(); if (embeddedImage != null) { AlternateView View; LinkedResource resource; View = AlternateView.CreateAlternateViewFromString(body.ToString(), null, "text/html"); resource = new LinkedResource(embeddedImage); resource.ContentId = "Logo"; View.LinkedResources.Add(resource); mail.AlternateViews.Add(View); } mail.From = new MailAddress(from); foreach (string to in tos) { mail.To.Add(to); } string ccAddress = System.Configuration.ConfigurationManager.AppSettings["CCEmail"].ToString(); MailAddress cc = new MailAddress(ccAddress); mail.CC.Add(cc); mail.Subject = subject; //mail.Body = body; if (attachments != null) { foreach (Attachment attachment in attachments) { mail.Attachments.Add(attachment); } } mail.Body = body; mail.IsBodyHtml = true; smtp.Send(mail); return("Success"); } catch (Exception ex) { sErrDesc = ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) { oLog.WriteToDebugLogFile("Completed With ERROR", sFuncName); } return(ex.Message); } }
public PLSInterface(String customDBconnectionString, String StdDBConnectionString) { _conStr = customDBconnectionString; log = new clsLog(StdDBConnectionString); }
protected void btnDownload_Click(object sender, EventArgs e) { try { if ((lblIDData.Text == "") || (lblIPAddressData.Text == "") || (lblServerNameData.Text == "")) { lblMessageData01.Text = "Please select a server."; lblMessageData02.Text = ""; } else { String strDesktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); DataTable objDataTable = new DataTable(); objDataTable = clsServersDataManager.SelectServer(dgridShowData.SelectedRow.Cells[1].Text); stringArr = objDataTable.Rows[0].ItemArray.Select(arrServer => arrServer.ToString()).ToArray(); String strFilePath = stringArr[4].Remove(stringArr[4].LastIndexOf("/"), stringArr[4].Length - stringArr[4].LastIndexOf("/")); String strFileName = stringArr[4].Remove(0, stringArr[4].LastIndexOf("/") + 1); using (var ssh = new SshClient(stringArr[2], stringArr[6], stringArr[7])) { ssh.Connect(); String strCommandChain = "cd " + strFilePath + "; tar -czvf " + strFileName + ".tgz " + strFileName; ssh.CreateCommand(strCommandChain).Execute(); ssh.Disconnect(); } using (var objScpClient = new ScpClient(stringArr[2], stringArr[6], stringArr[7])) using (var ssh = new SshClient(stringArr[2], stringArr[6], stringArr[7])) { objScpClient.Connect(); string objTempFile = Path.GetTempFileName(); FileInfo objFileInfo = new FileInfo(objTempFile); objScpClient.Download(stringArr[4] + ".tgz", objFileInfo); Guid objGUID = Guid.NewGuid(); String strDestinationPath = strTempPath + strFileName + objGUID.ToString() + ".tgz"; objFileInfo.MoveTo(strDestinationPath); objScpClient.Disconnect(); Response.ContentType = "application/x-compressed"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + strFileName + ".tgz"); Response.TransmitFile(Server.MapPath("~/temp/" + strFileName + objGUID.ToString() + ".tgz")); Response.Flush(); Response.SuppressContent = true; ApplicationInstance.CompleteRequest(); clsLog objLog = new clsLog(); objLog.strIP = Request.UserHostAddress; objLog.strLog_Date = DateTime.Now.ToString(); objLog.strTarget_Name = stringArr[1]; objLog.strAction = "D"; clsLogManager.InsertLog(objLog); } lblMessageData01.Text = ""; lblMessageData02.Text = ""; } } catch (Exception ex) { Guid objGUID = Guid.NewGuid(); String strException = ex.ToString(); File.WriteAllText(strLogPath + DateTime.Today.ToString("yyyyMMdd") + "-" + objGUID.ToString() + ".log", strException); lblMessageData01.Text = "خطایی در سیستم رخ داده است. لطفا کد خطای زیر را به همراه آی دی سرور به واحد نصب و راه اندازی ارسال نمایید.\r\n"; lblMessageData02.Text = DateTime.Today.ToString("yyyyMMdd") + "-" + objGUID.ToString(); } }