public static string GetMessage(string code) { var language = ConfigFacade.sy_language; var sql = SqlFacade.SqlSelect(TableName, "value", "code = lower(:code) and language = :language"); var message = SqlFacade.Connection.ExecuteScalar <string>(sql, new { code, language }); if (message == null) { ErrorLogFacade.Log("Message: code=" + code + " not exist"); } return(message); }
public static bool Init() { SetVersion(); // Splash screen fSplash = new frmSplash(); fSplash.SetAppName(" v " + SYS.App.version); fSplash.Show(); fSplash.ShowMsg("Initializing the application..."); fSplash.TopMost = true; // Database connection string from setting.ini try { fSplash.ShowMsg("Loading settings..."); LoadSettings(); fSplash.ShowMsg("Connecting to the database ..."); SqlFacade.OpenConnection(); // Database connection: open/test fSplash.ShowMsg("Ensuring database setup ..."); SqlFacade.EnsureDBSetup(); // Create tables if not exist } catch (Exception ex) { fSplash.ShowError(ex.Message); fSplash.Visible = false; fSplash.ShowDialog(); ErrorLogFacade.LogToFile(ex); return(false); } //Session session.Username = "******"; //todo: logged in user (to be removed) session.Branch_Code = "000"; session.Machine_Name = Environment.MachineName; session.Machine_User_Name = Environment.UserName; session.Version = version; LabelFacade.LoadSystemLabel(); MessageFacade.LoadSystemMessage(); // Log ErrorLogFacade.logFile.FileName = Path.Combine(Application.StartupPath, "Error.log"); AccessLog.FileName = Path.Combine(Application.StartupPath, "Access.log"); AccessLog.Write(DateTime.Now.ToString("yyy-MM-dd ddd hh:mm:ss tt") + " Application started. Process Id: " + ProcessID + ", Machine: " + session.Machine_Name + ", machine's username: "******", version: " + session.Version); session.Id = SessionFacade.Save(session); SessionLogFacade.Log(Type.Priority_Information, "Application", Type.Log_Launch, "Application started"); return(true); }
public void Save() { if (!Changed) { return; } var sql = SqlFacade.SqlUpdate(TableName, "value", "", "id = :id"); try { SqlFacade.Connection.Execute(sql, new { Value, Id }); } catch (Exception ex) { ErrorLogFacade.LogToFile(ex, "sql='" + sql + "')"); } }