/// <summary> /// If the Email preferences are not already in UserDefaults, this loads them. /// </summary> public static void LoadEmailDefaults() { if (!TUserDefaults.HasDefault("SmtpFromAccount") || (TUserDefaults.GetStringDefault("SmtpFromAccount") == "")) { TUserDefaults.SetDefault("SmtpFromAccount", TAppSettingsManager.GetValue("SmtpFromAccount", "")); } if (!TUserDefaults.HasDefault("SmtpDisplayName") || (TUserDefaults.GetStringDefault("SmtpDisplayName") == "")) { TUserDefaults.SetDefault("SmtpDisplayName", TAppSettingsManager.GetValue("SmtpDisplayName", "")); } if (!TUserDefaults.HasDefault("SmtpReplyTo")) { TUserDefaults.SetDefault("SmtpReplyTo", TAppSettingsManager.GetValue("SmtpReplyTo", "")); } if (!TUserDefaults.HasDefault("SmtpCcTo")) { TUserDefaults.SetDefault("SmtpCcTo", TAppSettingsManager.GetValue("SmtpCcTo", "")); } if (!TUserDefaults.HasDefault("SmtpEmailBody")) { TUserDefaults.SetDefault("SmtpEmailBody", TAppSettingsManager.GetValue("SmtpEmailBody", "")); } if (!TUserDefaults.HasDefault("SmtpSendAsAttachment")) { TUserDefaults.SetDefault("SmtpSendAsAttachment", TAppSettingsManager.GetValue("SmtpSendAsAttachment", "")); } }
private void RunOnceOnActivationManual() { FPetraUtilsObject.UnhookControl(pnlDetails, true); // I don't want changes in these values to cause SetChangedFlag - I'll set it myself. FPetraUtilsObject.UnhookControl(txtStatus, false); // This control is not to be spied on! txtDetailCostCentreName.TextChanged += new EventHandler(UpdateOnControlChanged); chkDetailCostCentreActiveFlag.CheckedChanged += new EventHandler(UpdateOnControlChanged); cmbDetailCostCentreType.SelectedIndexChanged += new EventHandler(UpdateOnControlChanged); txtDetailCostCentreCode.Validated -= ControlValidatedHandler; // Don't trigger validation on change - I need to do it manually FPetraUtilsObject.ControlChanged += new TValueChangedHandler(FPetraUtilsObject_ControlChanged); FnameForNewCostCentre = Catalog.GetString("NEWCOSTCENTRE"); txtDetailCostCentreCode.TextChanged += new EventHandler(txtDetailCostCentreCode_TextChanged); txtDetailCostCentreCode.Leave += txtDetailCostCentreCode_Leave; FPetraUtilsObject.DataSaved += OnHierarchySaved; mniFilePrint.Click += FilePrint; mniFilePrint.Enabled = true; chkDetailSummaryFlag.CheckedChanged += chkDetailSummaryFlag_CheckedChanged; if (TAppSettingsManager.GetBoolean("OmBuild", false)) // In OM, no-one needs to see the import or export functions: { tbrMain.Items.Remove(tbbImportHierarchy); tbrMain.Items.Remove(tbbExportHierarchy); /* For some reason, this screen never had these menu options! * mnuMain.Items.Remove(mniImportHierarchy); * mnuMain.Items.Remove(mniExportHierarchy); */ } }
public void Init() { //new TLogging("TestServer.log"); TPetraServerConnector.Connect("../../etc/TestServer.config"); FLedgerNumber = TAppSettingsManager.GetInt32("LedgerNumber", 43); TLogging.Log("Ledger Number = " + FLedgerNumber); }
private void ImportGiftBatch(DateTime AEffectiveDate) { TGiftImporting importer = new TGiftImporting(); string testFile = TAppSettingsManager.GetValue("GiftBatch.file", "../../csharp/ICT/Testing/lib/MFinance/SampleData/sampleGiftBatch.csv"); StreamReader sr = new StreamReader(testFile); string FileContent = sr.ReadToEnd(); FileContent = FileContent.Replace("{ledgernumber}", FLedgerNumber.ToString()); FileContent = FileContent.Replace("{thisyear}-01-01", AEffectiveDate.ToString("yyyy-MM-dd")); sr.Close(); Hashtable parameters = new Hashtable(); parameters.Add("Delimiter", ","); parameters.Add("ALedgerNumber", FLedgerNumber); parameters.Add("DateFormatString", "yyyy-MM-dd"); parameters.Add("NumberFormat", "American"); parameters.Add("NewLine", Environment.NewLine); TVerificationResultCollection VerificationResult; GiftBatchTDSAGiftDetailTable NeedRecipientLedgerNumber; importer.ImportGiftBatches(parameters, FileContent, out NeedRecipientLedgerNumber, out VerificationResult); Assert.True(TVerificationHelper.IsNullOrOnlyNonCritical(VerificationResult), "Failed to import the test gift batch. The file contains critical error(s): " + VerificationResult.BuildVerificationResultString()); }
private void PopulateStartupModuleList() { DataTable moduleTable = new DataTable(); moduleTable.Columns.Add("Value", typeof(System.String)); moduleTable.Columns.Add("Display", typeof(System.String)); TYml2Xml parser = new TYml2Xml(TAppSettingsManager.GetValue("UINavigation.File")); XmlDocument UINavigation = parser.ParseYML2XML(); XmlNode OpenPetraNode = UINavigation.FirstChild.NextSibling.FirstChild; XmlNode SearchBoxesNode = OpenPetraNode.FirstChild; XmlNode MainMenuNode = SearchBoxesNode.NextSibling; XmlNodeList modules = MainMenuNode.ChildNodes; foreach (XmlNode n in modules) { string moduleName = n.Name; if ((moduleName != "Settings") && (moduleName != "CrossLedgerSetup")) { bool hasLabelAttribute = n.Attributes["Label"] != null; DataRow row = moduleTable.NewRow(); row["Value"] = n.Name; row["Display"] = hasLabelAttribute ? n.Attributes["Label"].Value.Replace("&", "") : n.Name; moduleTable.Rows.Add(row); } } cmbInitialSelectedModule.ValueMember = "Value"; cmbInitialSelectedModule.DisplayMember = "Display"; cmbInitialSelectedModule.DataSource = moduleTable.DefaultView; }
/// <summary> /// check if a file with this security token exists /// </summary> public static bool CheckServerAdminToken(string AServerAdminToken) { string TokenFilename = TAppSettingsManager.GetValue("Server.PathTemp") + Path.DirectorySeparatorChar + "ServerAdminToken" + AServerAdminToken + ".txt"; if (File.Exists(TokenFilename)) { using (StreamReader sr = new StreamReader(TokenFilename)) { string content = sr.ReadToEnd(); sr.Close(); if (content.Trim() == AServerAdminToken) { TSession.SetVariable("ServerAdminToken", AServerAdminToken); return(true); } } } else { TLogging.Log("cannot find security token file " + TokenFilename); } return(false); }
/// <summary> /// post a request to a website. used for Connectors /// </summary> public static string PostRequest(string url, NameValueCollection parameters) { if (TLogging.DebugLevel > 0) { LogRequest(url, parameters); } try { // config parameter value for how many times a connection should be attempted until the web call fails return(WebClientUploadValues(url, parameters, TAppSettingsManager.GetInt32("HTTPUtils.PostRequests", 10))); } catch (System.Net.WebException e) { TLogging.Log("Trying to download: "); LogRequest(url, parameters); TLogging.Log(e.Message); TLogging.Log("Error message from server:"); TLogging.Log(e.ToString()); if (e.Response != null) { StreamReader sr = new StreamReader(e.Response.GetResponseStream()); TLogging.Log(sr.ReadToEnd()); sr.Close(); } } return(String.Empty); }
/// <summary> /// Use a .NET PrintPreview Dialog to print (or not print) this (possibly multi-page) HTML document. /// </summary> /// <param name="HtmlPages"></param> public static void PreviewOrPrint(String HtmlPages) { System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument(); bool printerInstalled = printDocument.PrinterSettings.IsValid; if (!printerInstalled) { MessageBox.Show(Catalog.GetString("There is no printer, so printing is not possible")); return; } TGfxPrinter GfxPrinter = new TGfxPrinter(printDocument, TGfxPrinter.ePrinterBehaviour.eFormLetter); TPrinterHtml htmlPrinter = new TPrinterHtml(HtmlPages, TAppSettingsManager.GetValue("Formletters.Path"), GfxPrinter); GfxPrinter.Init(eOrientation.ePortrait, htmlPrinter, eMarginType.ePrintableArea); CoolPrintPreviewDialog PrintDlg = new CoolPrintPreviewDialog(); PrintDlg.Document = GfxPrinter.Document; PrintDlg.ClientSize = new System.Drawing.Size(500, 720); try { PrintDlg.ShowDialog(); } catch (Exception) // if the user presses Cancel, an exception may be raised! { } }
/// <summary> /// Calculates the report, which is specified in the parameters table /// /// </summary> /// <returns>void</returns> public void Start(System.Data.DataTable AParameters) { FProgressID = "ReportCalculation" + Guid.NewGuid(); TProgressTracker.InitProgressTracker(FProgressID, string.Empty, -1.0m); FParameterList = new TParameterList(); FParameterList.LoadFromDataTable(AParameters); FSuccess = false; String PathStandardReports = TAppSettingsManager.GetValue("Reporting.PathStandardReports"); String PathCustomReports = TAppSettingsManager.GetValue("Reporting.PathCustomReports"); FDatacalculator = new TRptDataCalculator(PathStandardReports, PathCustomReports); // setup the logging to go to the TProgressTracker TLogging.SetStatusBarProcedure(new TLogging.TStatusCallbackProcedure(WriteToStatusBar)); string session = TSession.GetSessionID(); ThreadStart myThreadStart = delegate { Run(session); }; Thread TheThread = new Thread(myThreadStart); TheThread.CurrentCulture = Thread.CurrentThread.CurrentCulture; TheThread.Name = FProgressID + "_" + UserInfo.GetUserInfo().UserID + "__TReportGeneratorUIConnector.Start_Thread"; TLogging.LogAtLevel(7, TheThread.Name + " starting."); TheThread.Start(); }
/// <summary> /// Helper to run a specific sql file as ExecuteNonQuery() /// </summary> /// <param name="AFileName"></param> private static void RunSQL(string AFileName) { string sql = String.Empty; // Work out the path to the file string TestFile = Path.GetFullPath(TAppSettingsManager.GetValue("Testing.Path") + "/lib/MFinance/ExchangeRates/sql/" + AFileName); Assert.IsTrue(File.Exists(TestFile)); // Read the content using (StreamReader sr = new StreamReader(TestFile)) { sql = sr.ReadToEnd(); sr.Close(); } // Execute the query int nRowsAffected = 0; if (sql != String.Empty) { Boolean IsNewTransaction; TDBTransaction WriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out IsNewTransaction); nRowsAffected = DBAccess.GDBAccessObj.ExecuteNonQuery(sql, WriteTransaction, null, IsNewTransaction); } // Did we do anything? if (!AFileName.Contains("clean.sql")) { // We should have inserted rows (The 'clean' script may have nothing to do if it is run twice) Assert.AreNotEqual(0, nRowsAffected, "Failed to run the SQL insertion script: " + Path.GetFileNameWithoutExtension(AFileName)); } }
public void Init() { new TLogging("../../log/test.log"); new TAppSettingsManager("../../etc/TestServer.config"); FDBType = CommonTypes.ParseDBType(TAppSettingsManager.GetValue("Server.RDBMSType")); EstablishDBConnection(DefaultDBConnName); // Reset some Fields for every Test FTestDBInstance1 = null; FTestDBInstance2 = null; FTestCallDBCommand1 = null; FTestCallDBCommand2 = null; FTestingThread1 = null; FTestingThread2 = null; FTestingThread1NewTransaction = false; FTestingThread2NewTransaction = false; FTestingThread1Exception = null; FTestingThread2Exception = null; FEstablishedDBConnectionSignalDBConn1 = null; FEstablishedDBConnectionSignalDBConn2 = null; FCloseDBConnectionSignalDBConn1 = null; FCloseDBConnectionSignalDBConn2 = null; FDBConnectionClosedSignalDBConn1 = null; FDBConnectionClosedSignalDBConn2 = null; FGotNewOrExistingDBTransactionSignal1 = null; FGotNewOrExistingDBTransactionSignal2 = null; FRollbackDBTransactionSignal1 = null; FRollbackDBTransactionSignal2 = null; FDBTransactionRolledbackSignal1 = null; FDBTransactionRolledbackSignal2 = null; }
/// <summary> /// test for gift batch import /// </summary> public override void Setup() { new TLogging("TestClient.log"); TPetraConnector.Connect("../../etc/TestClient.config"); FLedgerNumber = Convert.ToInt32(TAppSettingsManager.GetValue("LedgerNumber", "43")); }
/// establish a database connection to the alternative sqlite database for the sessions private static TDataBase EstablishDBConnectionSqliteSessionDB(String AConnectionName = "") { TDBType DBType = CommonTypes.ParseDBType(TAppSettingsManager.GetValue("Server.RDBMSType", "postgresql")); if (DBType != TDBType.SQLite) { throw new Exception("EstablishDBConnectionSqliteSessionDB: we should not get here."); } string DatabaseHostOrFile = TAppSettingsManager.GetValue("Server.DBSqliteSession", "localhost"); string DatabasePort = String.Empty; string DatabaseName = TAppSettingsManager.GetValue("Server.DBName", "openpetra"); string DBUsername = TAppSettingsManager.GetValue("Server.DBUserName", "petraserver"); string DBPassword = TAppSettingsManager.GetValue("Server.DBPassword", string.Empty, false); if (!File.Exists(DatabaseHostOrFile)) { // create the sessions database file TLogging.Log("create the sessions database file: " + DatabaseHostOrFile); // sqlite on Windows does not support encryption with a password // System.EntryPointNotFoundException: sqlite3_key DBPassword = string.Empty; SqliteConnection conn = new SqliteConnection("Data Source=" + DatabaseHostOrFile + (DBPassword.Length > 0 ? ";Password="******"")); conn.Open(); string createStmt = @"CREATE TABLE s_session ( s_session_id_c varchar(128) NOT NULL, s_valid_until_d datetime NOT NULL, s_session_values_c text, s_date_created_d date, s_created_by_c varchar(20), s_date_modified_d date, s_modified_by_c varchar(20), s_modification_id_t timestamp, CONSTRAINT s_session_pk PRIMARY KEY (s_session_id_c) )"; SqliteCommand cmd = new SqliteCommand(createStmt, conn); cmd.ExecuteNonQuery(); conn.Close(); } TDataBase DBAccessObj = new TDataBase(); DBAccessObj.EstablishDBConnection(DBType, DatabaseHostOrFile, DatabasePort, DatabaseName, DBUsername, DBPassword, "", true, AConnectionName); return(DBAccessObj); }
/// <summary> /// create the code for validation of a typed table /// </summary> /// <param name="AStore"></param> /// <param name="strGroup"></param> /// <param name="AFilePath"></param> /// <param name="ANamespaceName"></param> /// <param name="AFileName"></param> /// <returns></returns> public static Boolean WriteValidation(TDataDefinitionStore AStore, string strGroup, string AFilePath, string ANamespaceName, string AFileName) { Console.WriteLine("processing validation of Typed Tables " + strGroup.Substring(0, 1).ToUpper() + strGroup.Substring(1)); string templateDir = TAppSettingsManager.GetValue("TemplateDir", true); ProcessTemplate Template = new ProcessTemplate(templateDir + Path.DirectorySeparatorChar + "ORM" + Path.DirectorySeparatorChar + "DataTableValidation.cs"); Template.AddToCodelet("NAMESPACE", ANamespaceName); Template.AddToCodelet("DATATABLENAMESPACE", ANamespaceName.Replace("Validation", "Data")); // load default header with license and copyright Template.SetCodelet("GPLFILEHEADER", ProcessTemplate.LoadEmptyFileComment(templateDir)); foreach (TTable currentTable in AStore.GetTables()) { if (currentTable.strGroup == strGroup) { InsertTableValidation(Template, currentTable, null, "TABLELOOP"); } } if (!Directory.Exists(AFilePath)) { Directory.CreateDirectory(AFilePath); } Template.FinishWriting(AFilePath + AFileName + "-generated.cs", ".cs", true); return(true); }
private static void ClearSecurityToken() { string TokenFilename = TAppSettingsManager.GetValue("Server.PathTemp") + Path.DirectorySeparatorChar + "ServerAdminToken" + SecurityToken + ".txt"; File.Delete(TokenFilename); }
public static string Start(string AReportID, System.Data.DataTable AParameters) { string session = TSession.GetSessionID(); string configfilename = TAppSettingsManager.ConfigFileName; TParameterList ParameterList = new TParameterList(); ParameterList.LoadFromDataTable(AParameters); String PathStandardReports = TAppSettingsManager.GetValue("Reporting.PathStandardReports"); String PathCustomReports = TAppSettingsManager.GetValue("Reporting.PathCustomReports"); TRptDataCalculator Datacalculator = new TRptDataCalculator(PathStandardReports, PathCustomReports); ThreadStart myThreadStart = delegate { Run(configfilename, session, AReportID, Datacalculator, ParameterList); }; Thread TheThread = new Thread(myThreadStart); TheThread.CurrentCulture = Thread.CurrentThread.CurrentCulture; TheThread.Name = AReportID + "_" + UserInfo.GetUserInfo().UserID + "__TReportGeneratorUIConnector.Start_Thread"; TLogging.LogAtLevel(7, TheThread.Name + " starting."); TheThread.Start(); return(AReportID); }
private void RunTestImport(string AFileName, string ACSVSeparator, TVerificationResultCollection AResults, out string AResultText, out string AFirstResultCode) { string TestFile = Path.GetFullPath(TAppSettingsManager.GetValue("Testing.Path") + "/lib/MFinance/ExchangeRates/" + AFileName); Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile); AResults.Clear(); TImportExchangeRates.ImportCurrencyExRates(FMainDS.ACorporateExchangeRate, TestFile, ACSVSeparator, "Corporate", AResults); AResultText = String.Empty; for (int i = 0; i < AResults.Count; i++) { AResultText += String.Format("{0}: {1}{2}", i.ToString(), AResults[i].ResultText, Environment.NewLine); } if (AResultText.Length > 0) { Console.WriteLine(AResultText); } AFirstResultCode = String.Empty; if (AResults.Count > 0) { AFirstResultCode = AResults[0].ResultCode; } }
public void Init() { TPetraServerConnector.Connect("../../etc/TestServer.config"); EventPartnerKey = TAppSettingsManager.GetInt64("ConferenceTool.EventPartnerKey", 1110198); EventCode = TAppSettingsManager.GetValue("ConferenceTool.EventCode", "SC001CNGRSS08"); }
private static WebClientWithSession GetNewWebClient(string url) { CookieContainer CookieCont = new CookieContainer(); TLogging.LogAtLevel(1, "SetWebClient: url argument is: " + url); if (url.StartsWith("Login")) { ResetSession(); } if ((OverallCookie == null) && url.StartsWith(TAppSettingsManager.GetValue("OpenPetra.HTTPServer")) && !(url.Contains("Login") || (url.Contains("/client")) || (url.Contains("serverMServerAdmin.asmx")))) { TLogging.Log("GetNewWebClient: Cannot connect to the server without a cookie! url=" + url); throw new Exception("Cannot connect to the server without a cookie! url=" + url); } if (OverallCookie != null) { TLogging.LogAtLevel(1, "SetWebClient: OverallCookie exists - copying!"); CookieCont = new CookieContainer(); CookieCont.Add(new Cookie(OverallCookie.Name, OverallCookie.Value, OverallCookie.Path, OverallCookie.Domain)); TLogging.LogAtLevel(1, "GetNewWebClient: copying cookie\r\n" + "Name: " + OverallCookie.Name + "\r\n" + "Value: " + OverallCookie.Value + "\r\n" + "Path: " + OverallCookie.Path + "\r\n" + "Domain: " + OverallCookie.Domain); } return(new WebClientWithSession(CookieCont)); }
public void Init() { new TLogging("../../log/TestCommonControls.log"); TPetraConnector.Connect("../../etc/TestClient.config"); FLedgerNumber = Convert.ToInt32(TAppSettingsManager.GetValue("LedgerNumber")); }
protected override WebRequest GetWebRequest(Uri address) { TLogging.LogAtLevel(1, "GetWebRequest: got called for URI: " + address.ToString()); HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address); request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/6.0; OpenPetraFatClient)"; request.Timeout = Convert.ToInt32( TimeSpan.FromMinutes(TAppSettingsManager.GetInt32("WebRequestTimeOutInMinutes", 15)). TotalMilliseconds); // TODO Set HttpWebRequest.KeepAlive property to false to avoid 'The request was aborted: The request was canceled.' when multiple Threads run on one TCP Session ????? // see http://www.jaxidian.org/update/2007/05/05/8/ var castRequest = request as HttpWebRequest; if (castRequest != null) { castRequest.CookieContainer = this.CookieContainer; foreach (Cookie IndivCookie in castRequest.CookieContainer.GetCookies(address)) { TLogging.LogAtLevel(1, "GetWebRequest: castRequest.CookieContainer cookie\r\n" + "Name: " + IndivCookie.Name + "\r\n" + "Value: " + IndivCookie.Value + "\r\n" + "Path: " + IndivCookie.Path + "\r\n" + "Domain: " + IndivCookie.Domain); } } return(request); }
/// <summary> /// generate code for cascading deletions etc /// </summary> /// <param name="AStore"></param> /// <param name="AFilePath"></param> /// <param name="ANamespaceName"></param> /// <param name="AFileName"></param> /// <returns></returns> public static Boolean WriteTypedDataCascading(TDataDefinitionStore AStore, string AFilePath, string ANamespaceName, string AFileName) { Console.WriteLine("writing namespace " + ANamespaceName); string templateDir = TAppSettingsManager.GetValue("TemplateDir", true); ProcessTemplate Template = new ProcessTemplate(templateDir + Path.DirectorySeparatorChar + "ORM" + Path.DirectorySeparatorChar + "DataCascading.cs"); Template.AddToCodelet("NAMESPACE", ANamespaceName); // load default header with license and copyright Template.SetCodelet("GPLFILEHEADER", ProcessTemplate.LoadEmptyFileComment(templateDir)); foreach (TTable currentTable in AStore.GetTables()) { ProcessTemplate snippet = Template.GetSnippet("TABLECASCADING"); if (InsertMainProcedures(AStore, currentTable, Template, snippet)) { Template.AddToCodelet("USINGNAMESPACES", CodeGenerationAccess.GetNamespace(currentTable.strGroup), false); Template.AddToCodelet("USINGNAMESPACES", CodeGenerationAccess.GetNamespace(currentTable.strGroup).Replace( ".Data;", ".Data.Access;"). Replace("Ict.Petra.Shared.", "Ict.Petra.Server."), false); Template.InsertSnippet("TABLECASCADINGLOOP", snippet); } } Template.FinishWriting(AFilePath + AFileName + "-generated.cs", ".cs", true); return(true); }
/// <summary> /// Application and Database should have the same version, otherwise all sorts of things can go wrong. /// this is specific to the OpenPetra database, for all other databases it will just ignore the database version check /// </summary> private static void CheckDatabaseVersion(TDataBase ADataBase) { TDBTransaction ReadTransaction = new TDBTransaction(); DataTable Tbl = null; if (TAppSettingsManager.GetValue("action", string.Empty, false) == "patchDatabase") { // we want to upgrade the database, so don't check for the database version return; } TDataBase db = DBAccess.Connect("CheckDatabaseVersion", ADataBase); db.ReadTransaction(ref ReadTransaction, delegate { // now check if the database is 'up to date'; otherwise run db patch against it Tbl = ReadTransaction.DataBaseObj.SelectDT( "SELECT s_default_value_c FROM PUB_s_system_defaults WHERE s_default_code_c = 'CurrentDatabaseVersion'", "Temp", ReadTransaction, new OdbcParameter[0]); }); if (Tbl.Rows.Count == 0) { return; } }
private static void GetLedgerCurrentYear(string ALedgerNumber, out string ALedgerYearCurrentYear) { // load the file a_ledger.d.gz TTable LedgerTableOld = TDumpProgressToPostgresql.GetStoreOld().GetTable("a_ledger"); TParseProgressCSV Parser = new TParseProgressCSV( TAppSettingsManager.GetValue("fulldumpPath", "fulldump") + Path.DirectorySeparatorChar + "a_ledger.d.gz", LedgerTableOld.grpTableField.Count); StringCollection LedgerColumnNames = GetColumnNames(LedgerTableOld); ALedgerYearCurrentYear = "0"; while (true) { string[] OldRow = Parser.ReadNextRow(); if (OldRow == null) { break; } if (GetValue(LedgerColumnNames, OldRow, "a_ledger_number_i") == ALedgerNumber) { ALedgerYearCurrentYear = GetValue(LedgerColumnNames, OldRow, "a_current_financial_year_i"); break; } } }
/// <summary> /// Load the two icons for the filter button /// </summary> private void LoadFilterIcons() { const string FILENAME_FILTER_ICON = "Filter.ico"; const string FILENAME_FILTER_ACTIVEICON = "FilterActive.ico"; string ResourceDirectory; if (FFilterImages == null) { FFilterImages = new ImageList(); ResourceDirectory = TAppSettingsManager.GetValue("Resource.Dir"); if (System.IO.File.Exists(ResourceDirectory + System.IO.Path.DirectorySeparatorChar + FILENAME_FILTER_ICON)) { FFilterImages.Images.Add(FILENAME_FILTER_ICON, Image.FromFile(ResourceDirectory + System.IO.Path.DirectorySeparatorChar + FILENAME_FILTER_ICON)); } else { MessageBox.Show( "LoadFilterIcons: cannot find file " + ResourceDirectory + System.IO.Path.DirectorySeparatorChar + FILENAME_FILTER_ICON); } if (System.IO.File.Exists(ResourceDirectory + System.IO.Path.DirectorySeparatorChar + FILENAME_FILTER_ACTIVEICON)) { FFilterImages.Images.Add(FILENAME_FILTER_ICON, Image.FromFile(ResourceDirectory + System.IO.Path.DirectorySeparatorChar + FILENAME_FILTER_ACTIVEICON)); } else { MessageBox.Show( "LoadFilterIcons: cannot find file " + ResourceDirectory + System.IO.Path.DirectorySeparatorChar + FILENAME_FILTER_ACTIVEICON); } } }
public void TestGenerateHOSAFiles() { int LedgerNumber = FLedgerNumber; int PeriodNumber = 4; int IchNumber = 1; string CostCentre = "73"; String CurrencySelect = MFinanceConstants.CURRENCY_BASE; string FileName = TAppSettingsManager.GetValue("Server.PathTemp") + Path.DirectorySeparatorChar + "TestGenHOSAFile.csv"; TVerificationResultCollection VerificationResults; TGenHOSAFilesReportsWebConnector.GenerateHOSAFiles(LedgerNumber, PeriodNumber, IchNumber, CostCentre, CurrencySelect, FileName, out VerificationResults); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResults, "HOSA File Generation Failed!"); Assert.IsTrue(File.Exists(FileName), "HOSA File did not create!"); File.Delete(FileName); }
/// <summary> /// build an XML document which includes all ledgers etc. /// </summary> public static XmlNode BuildNavigationXml(bool ADontUseDefaultLedger = false) { string UINavigationFile = TAppSettingsManager.GetValue("UINavigation.File"); if (!File.Exists(UINavigationFile)) { throw new Exception("cannot find file " + UINavigationFile); } TYml2Xml parser = new TYml2Xml(UINavigationFile); XmlDocument UINavigation = parser.ParseYML2XML(); ALedgerTable AvailableLedgers = new ALedgerTable(); if (UserInfo.GUserInfo.IsInModule(SharedConstants.PETRAMODULE_FINANCE1)) { AvailableLedgers = TGLSetupWebConnector.GetAvailableLedgers(); } XmlNode OpenPetraNode = UINavigation.FirstChild.NextSibling.FirstChild; XmlNode MainMenuNode = OpenPetraNode.FirstChild; AddNavigationForEachLedger(MainMenuNode, AvailableLedgers, ADontUseDefaultLedger); return(MainMenuNode); }
public void TestFileHeaderReplace() { string fileName = TAppSettingsManager.GetValue("Server.PathTemp") + Path.DirectorySeparatorChar + "TestGenHOSAFileHeaderReplace.csv"; int PeriodNumber = 4; string StandardCostCentre = "4300"; string CostCentre = "78"; string Currency = "USD"; StreamWriter sw = new StreamWriter(fileName); sw.WriteLine("/** Header **,4,4300,78,18/01/2013,USD"); sw.Close(); TVerificationResultCollection VerificationResults = new TVerificationResultCollection(); string TableForExportHeader = "/** Header **" + "," + PeriodNumber.ToString() + "," + StandardCostCentre + "," + CostCentre + "," + DateTime.Today.ToShortDateString() + "," + Currency; TGenHOSAFilesReportsWebConnector.ReplaceHeaderInFile(fileName, TableForExportHeader, ref VerificationResults); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResults, "Header Replacement in File Failed!"); File.Delete(fileName); }
/// <summary> /// Gets called in regular intervals from a Timer in Class TTimedProcessing. /// </summary> /// <param name="ADBAccessObj">Instantiated DB Access object with opened DB connection.</param> /// <param name="ARunManually">this is true if the process was called manually from the server admin console</param> public static void Process(TDataBase ADBAccessObj, bool ARunManually) { // only check once a day (or as specified in config file), if not manually called if (!ARunManually) { DateTime LastRun = TVariant.DecodeFromString( TSystemDefaults.GetSystemDefault( PROCESSDATACHECK_LAST_RUN, new TVariant(DateTime.MinValue).EncodeToString())).ToDate(); if (LastRun.AddDays(TAppSettingsManager.GetInt16("DataChecks.RunEveryXDays", 1)) > DateTime.Now) { // do not run the data check more than once a day or a week (depending on configuration setting), too many emails TLogging.LogAtLevel(1, "TProcessDataChecks.Process: not running, since last run was at " + LastRun.ToString()); return; } } Errors_SinceDate = DateTime.Today.AddDays(-1 * SENDREPORTFORDAYS_TOUSERS); TLogging.LogAtLevel(1, "TProcessDataChecks.Process: Checking Modules"); CheckModule(ADBAccessObj, "DataCheck.MPartner."); TSystemDefaults.SetSystemDefault(PROCESSDATACHECK_LAST_RUN, new TVariant(DateTime.Now).EncodeToString()); }
/// <summary> /// Calculates the report, which is specified in the parameters table /// /// </summary> /// <returns>void</returns> public void Start(System.Data.DataTable AParameters) { TRptUserFunctionsFinance.FlushSqlCache(); FProgressID = "ReportCalculation" + Guid.NewGuid(); TProgressTracker.InitProgressTracker(FProgressID, string.Empty, -1.0m); FParameterList = new TParameterList(); FParameterList.LoadFromDataTable(AParameters); FSuccess = false; String PathStandardReports = TAppSettingsManager.GetValue("Reporting.PathStandardReports"); String PathCustomReports = TAppSettingsManager.GetValue("Reporting.PathCustomReports"); FDatacalculator = new TRptDataCalculator(DBAccess.GDBAccessObj, PathStandardReports, PathCustomReports); // setup the logging to go to the TProgressTracker TLogging.SetStatusBarProcedure(new TLogging.TStatusCallbackProcedure(WriteToStatusBar)); string session = TSession.GetSessionID(); ThreadStart myThreadStart = delegate { Run(session); }; Thread TheThread = new Thread(myThreadStart); TheThread.Name = FProgressID; TheThread.CurrentCulture = Thread.CurrentThread.CurrentCulture; TheThread.Start(); }