public string Logout() { string clientName = "unknown"; if (DomainManager.CurrentClient != null) { clientName = DomainManager.CurrentClient.ClientName; } TLogging.Log("Logout from session: ClientName=" + clientName, TLoggingType.ToLogfile | TLoggingType.ToConsole); if (DomainManager.CurrentClient == null) { TSession.CloseSession(); } else { DomainManager.CurrentClient.EndSession(); } Dictionary <string, object> result = new Dictionary <string, object>(); result.Add("resultcode", "success"); return(JsonConvert.SerializeObject(result)); }
/// <summary> /// Executes the query. Always call this method in a separate Thread to execute the query asynchronously! /// </summary> /// <param name="ASessionID">the id of the current session</param> /// <param name="AContext">Context in which this quite generic Method gets called (e.g. 'Partner Find'). This is /// optional but should be specified to aid in debugging as it gets logged in case Exceptions happen when the /// DB Transaction is taken out and the Query gets executed.</param> /// <param name="ADataBase">An instantiated <see cref="TDataBase" /> object, or null (default = null). If null /// gets passed then the Method executes DB commands with a new Database connection</param> /// <remarks>An instance of TAsyncFindParameters with set up Properties must exist before this procedure can get /// called! /// </remarks> public void ExecuteQuery(string ASessionID, string AContext = null, TDataBase ADataBase = null) { // need to initialize the database session TSession.InitThread(ASessionID); TDataBase db = DBAccess.Connect("ExecuteQuery", ADataBase); try { FProgressID = Guid.NewGuid().ToString(); TProgressTracker.InitProgressTracker(FProgressID, "Executing Query...", 100.0m); // Create SQL statement and execute it to return all records ExecuteFullQuery(AContext, db); } catch (Exception exp) { TLogging.Log(this.GetType().FullName + ".ExecuteQuery" + (AContext == null ? "" : " (Context: " + AContext + ")") + ": Exception occured: " + exp.ToString()); // Inform the caller that something has gone wrong... TProgressTracker.CancelJob(FProgressID); /* * WE MUST 'SWALLOW' ANY EXCEPTION HERE, OTHERWISE THE WHOLE * PETRASERVER WILL GO DOWN!!! (THIS BEHAVIOUR IS NEW WITH .NET 2.0.) * * --> ANY EXCEPTION THAT WOULD LEAVE THIS METHOD WOULD BE SEEN AS AN <-- * --> UNHANDLED EXCEPTION IN A THREAD, AND THE .NET/MONO RUNTIME <-- * --> WOULD BRING DOWN THE WHOLE PETRASERVER PROCESS AS A CONSEQUENCE! <-- * */ } }
/// <summary> /// the client can cancel the job /// </summary> /// <param name="AClientID"></param> static public bool CancelJob(string AClientID) { if (TSession.HasVariable(PROGRESSTRACKER + AClientID)) { TProgressState state = ((JObject)TSession.GetVariable(PROGRESSTRACKER + AClientID)).ToObject <TProgressState>(); TLogging.SetStatusBarProcedure(null); if (state.JobFinished == true) { if (TLogging.DebugLevel >= DEBUG_PROGRESS) { TLogging.Log("Cannot cancel the job for " + AClientID + " because the job has already finished"); } } else { state.CancelJob = true; if (TLogging.DebugLevel >= DEBUG_PROGRESS) { TLogging.Log("Cancelled the job for " + AClientID); } TSession.SetVariable(PROGRESSTRACKER + AClientID, state); return(true); } } return(false); }
} // Select Gift Recipients /// <summary> /// Find all the gifts for a worker, presenting the results in four year columns. /// NOTE - the user can select the field of the donor. /// /// All the DB work was previously done by the Select Gift Recipients function above. /// I only need to filter the table by recipientKey. /// </summary> /// <returns></returns> public static DataTable SelectGiftDonors(TParameterList AParameters, TResultList AResults) { Int64 recipientKey = AParameters.Get("RecipientKey").ToInt64(); // TotalGiftsPerRecipient must not be static. DataTable TotalGiftsPerRecipient = null; TDBTransaction Transaction = new TDBTransaction(); TDataBase db = DBAccess.Connect("SelectGiftDonors"); string SqlQuery = TSession.GetVariable("QueryFinanceReport_SelectGiftRecipients").ToString(); SqlQuery = SqlQuery.Replace("GROUP by ", "AND recipient.p_partner_key_n = " + recipientKey + " GROUP by "); db.ReadTransaction( ref Transaction, delegate { TotalGiftsPerRecipient = db.SelectDT(SqlQuery, "result", Transaction); }); TotalGiftsPerRecipient.DefaultView.RowFilter = "RecipientKey = " + recipientKey.ToString(); DataTable resultTable = TotalGiftsPerRecipient.DefaultView.ToTable(true, new String[] { "DonorKey", "DonorName", "DonorClass", "YearTotal0", "YearTotal1", "YearTotal2", "YearTotal3" }); return(resultTable); }
/// <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(); }
/// <inheritdoc /> public void addSession(String handlePartner, TSession sessionType) { Invoke((MethodInvoker)delegate { this.listCalls.Items.Add(new ListViewItem(new String[] { handlePartner, "" + sessionType, INSECURE, NO_FINGERPRINT })); }); }
/// <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(); }
private eLoginEnum LoginInternal(string username, string password, Version AClientVersion, out Int32 AClientID, out string AWelcomeMessage, out Boolean ASystemEnabled, out IPrincipal AUserInfo, out Boolean AMustChangePassword) { AUserInfo = null; ASystemEnabled = true; AWelcomeMessage = string.Empty; AClientID = -1; AMustChangePassword = false; if (DBAccess.GDBAccessObj == null) { TServerManager.TheCastedServerManager.EstablishDBConnection(); } try { TConnectedClient CurrentClient = TClientManager.ConnectClient( username.ToUpper(), password.Trim(), HttpContext.Current.Request.UserHostName, HttpContext.Current.Request.UserHostAddress, AClientVersion, TClientServerConnectionType.csctRemote, out AClientID, out AWelcomeMessage, out ASystemEnabled, out AUserInfo); TSession.SetVariable("LoggedIn", true); // the following values are stored in the session object DomainManager.GClientID = AClientID; DomainManager.CurrentClient = CurrentClient; UserInfo.GUserInfo = (TPetraPrincipal)AUserInfo; DBAccess.GDBAccessObj.UserID = username.ToUpper(); TServerManager.TheCastedServerManager.AddDBConnection(DBAccess.GDBAccessObj); AMustChangePassword = (((TPetraPrincipal)AUserInfo).LoginMessage == SharedConstants.LOGINMUSTCHANGEPASSWORD); return(eLoginEnum.eLoginSucceeded); } catch (Exception e) { TLogging.Log(e.Message); TLogging.Log(e.StackTrace); TSession.SetVariable("LoggedIn", false); if (DBAccess.GDBAccessObj != null) { DBAccess.GDBAccessObj.CloseDBConnection(); } TSession.Clear(); return(TClientManager.LoginErrorFromException(e)); } }
public static bool LoginServerAdmin() { string WelcomeMessage; bool SystemEnabled; Int32 ClientID; Int64 SiteKey; TConnectedClient CurrentClient = TClientManager.ConnectClient( "SYSADMIN", string.Empty, HttpContext.Current.Request.UserHostName, HttpContext.Current.Request.UserHostAddress, TFileVersionInfo.GetApplicationVersion().ToVersion(), TClientServerConnectionType.csctRemote, out ClientID, out WelcomeMessage, out SystemEnabled, out SiteKey); TSession.SetVariable("LoggedIn", true); // the following values are stored in the session object DomainManager.GClientID = ClientID; DomainManager.CurrentClient = CurrentClient; DomainManager.GSiteKey = SiteKey; return(true); }
/// <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> /// end the session, and release all resources /// </summary> public void EndSession() { if (FAppDomainStatus == TSessionStatus.adsStopped) { TLogging.Log("EndSession (for client '" + this.ClientName + "'): Session has been stopped already!"); return; } TLogging.Log("EndSession (for client '" + this.ClientName + "'): Session is about to getting stopped!"); // TODORemoting // release all UIConnector objects TLogging.Log("EndSession (for client '" + this.ClientName + "'): Checking whether there is a HttpSession.Current object"); // clear the session object if (HttpContext.Current != null) { TLogging.Log("EndSession (for client '" + this.ClientName + "'): Clearing Session"); TSession.CloseSession(); } FClientDisconnectionFinishedTime = DateTime.Now; FAppDomainStatus = TSessionStatus.adsStopped; TLogging.LogAtLevel(1, "Session for client " + this.ClientName + " has been destroyed successfully!"); }
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); }
/// <summary> /// run the report /// </summary> private void Run(string ASessionID) { // need to initialize the database session TSession.InitThread(ASessionID); IsolationLevel Level; if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "readuncommitted") { // for long reports, that should not take out locks; // the data does not need to be consistent or will most likely not be changed during the generation of the report Level = IsolationLevel.ReadUncommitted; } else if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "repeatableread") { // for financial reports: it is important to have consistent data; e.g. for totals Level = IsolationLevel.RepeatableRead; } else if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "serializable") { // for creating extracts: we need to write to the database Level = IsolationLevel.Serializable; } else { // default behaviour for normal reports Level = IsolationLevel.ReadCommitted; } FSuccess = false; TDBTransaction Transaction = null; bool SubmissionOK = false; try { DBAccess.GDBAccessObj.BeginAutoTransaction(Level, ref Transaction, ref SubmissionOK, delegate { if (FDatacalculator.GenerateResult(ref FParameterList, ref FResultList, ref FErrorMessage)) { FSuccess = true; SubmissionOK = true; } else { TLogging.Log(FErrorMessage); } }); } catch (Exception e) { TLogging.Log("problem calculating report: " + e.Message); TLogging.Log(e.StackTrace, TLoggingType.ToLogfile); } TProgressTracker.FinishJob(FProgressID); }
/// main method public static void Main(string[] args) { new TAppSettingsManager(); new TLogging(); if (!TAppSettingsManager.HasValue("YmlGzFile") || !TAppSettingsManager.HasValue("Action")) { TLogging.Log("sample call: -C:../../etc/TestServer.config -Action:dump -YmlGzFile:test.yml.gz"); TLogging.Log("sample call: -C:../../etc/TestServer.config -Action:load -YmlGzFile:test.yml.gz"); Environment.Exit(-1); } string YmlFile = TAppSettingsManager.GetValue("YmlGzFile"); string Action = TAppSettingsManager.GetValue("Action"); TLogging.DebugLevel = TAppSettingsManager.GetInt32("Server.DebugLevel", 0); TSession.InitThread(); TServerManager.TheServerManager = new TServerManager(); bool ExitWithError = false; try { if (Action == "dump") { if (!DumpYmlGz(YmlFile)) { ExitWithError = true; } } else if (Action == "load") { if (!LoadYmlGz(YmlFile)) { ExitWithError = true; } } } catch (Exception e) { TLogging.Log(e.ToString()); ExitWithError = true; } TServerManager.TheServerManager.StopServer(); if (TAppSettingsManager.GetValue("interactive", "true") == "true") { Console.WriteLine("Please press Enter to continue..."); Console.ReadLine(); } if (ExitWithError) { Environment.Exit(-1); } }
static private void SetDatabaseForSession(TDataBase database) { if (Thread.CurrentThread.Name == null) { // TLogging.Log("there is a new thread for session " + HttpContext.Current.Session.SessionID); System.Threading.Thread.CurrentThread.Name = "MainThread" + Guid.NewGuid().ToString();; } TSession.SetVariable("DBAccessObj", database); }
public static string Create() { string session = TSession.GetSessionID(); string ReportID = "ReportCalculation" + session + Guid.NewGuid(); TProgressTracker.InitProgressTracker(ReportID, string.Empty, -1.0m); return(ReportID); }
static private TDataBase GetDatabaseFromSession(bool AOpenConnection = true) { // if another thread gets called, then the session object is null if (HttpContext.Current == null) { if (Thread.CurrentThread.Name == null) { throw new Exception( "TOpenPetraOrgSessionManager.GetDatabaseFromSession: we do need a name for the thread for managing the database connection"); } if (!FDatabaseObjects.ContainsKey(Thread.CurrentThread.Name)) { TDataBase db = new TDataBase(); if (AOpenConnection) { db.EstablishDBConnection(TSrvSetting.RDMBSType, TSrvSetting.PostgreSQLServer, TSrvSetting.PostgreSQLServerPort, TSrvSetting.PostgreSQLDatabaseName, TSrvSetting.DBUsername, TSrvSetting.DBPassword, ""); } FDatabaseObjects.Add(Thread.CurrentThread.Name, db); } return(FDatabaseObjects[Thread.CurrentThread.Name]); } if (TSession.GetVariable("DBAccessObj") == null) { if (TServerManager.TheServerManager == null) { TLogging.Log("GetDatabaseFromSession : TheServerManager is null"); } else { // disconnect web user after 2 minutes of inactivity. should disconnect itself already earlier TServerManager.TheCastedServerManager.DisconnectTimedoutDatabaseConnections(2 * 60, "ANONYMOUS"); // disconnect normal users after 3 hours of inactivity TServerManager.TheCastedServerManager.DisconnectTimedoutDatabaseConnections(3 * 60 * 60, ""); if (AOpenConnection) { TServerManager.TheCastedServerManager.EstablishDBConnection(); } } } return((TDataBase)TSession.GetVariable("DBAccessObj")); }
/// <summary> /// add or reuse a tracker for the given clientID /// </summary> /// <param name="AClientID"></param> /// <param name="ACaption"></param> /// <param name="AAbsoluteOverallAmount"></param> /// <returns></returns> static public TProgressState InitProgressTracker(string AClientID, string ACaption, decimal AAbsoluteOverallAmount = 100.0m) { TProgressState state = new TProgressState(); state.AbsoluteOverallAmount = AAbsoluteOverallAmount; state.Caption = ACaption; TSession.SetVariable(PROGRESSTRACKER + AClientID, state); return(state); }
private static bool TrainBankStatementsLastMonthThread(String ASessionID, Int32 AClientID, Int32 ALedgerNumber, DateTime AToday) { TSession.InitThread(ASessionID); DomainManager.GClientID = AClientID; string MyClientID = DomainManager.GClientID.ToString(); TProgressTracker.InitProgressTracker(MyClientID, Catalog.GetString("Training last months bank statements"), 30); DateTime startDateThisMonth = new DateTime(AToday.Year, AToday.Month, 1); DateTime endDateLastMonth = startDateThisMonth.AddDays(-1); DateTime startDateLastMonth = new DateTime(endDateLastMonth.Year, endDateLastMonth.Month, 1); // get all bank accounts TCacheable CachePopulator = new TCacheable(); Type typeofTable; GLSetupTDSAAccountTable accounts = (GLSetupTDSAAccountTable)CachePopulator.GetCacheableTable( TCacheableFinanceTablesEnum.AccountList, "", false, ALedgerNumber, out typeofTable); foreach (GLSetupTDSAAccountRow account in accounts.Rows) { // at OM Germany we don't have the bank account flags set if ((!account.IsBankAccountFlagNull() && (account.BankAccountFlag == true)) || (!account.IsCashAccountFlagNull() && (account.CashAccountFlag == true)) ) { string BankAccountCode = account.AccountCode; DateTime counter = startDateLastMonth; while (!counter.Equals(startDateThisMonth)) { TProgressTracker.SetCurrentState( MyClientID, String.Format(Catalog.GetString("Training {0} {1}"), BankAccountCode, counter.ToShortDateString()), counter.Day); // TODO: train only one bank statement per date and bank account? TrainBankStatement(ALedgerNumber, counter, BankAccountCode); counter = counter.AddDays(1); } } } TProgressTracker.FinishJob(MyClientID); return(true); }
public string GetVersion() { object loggedIn = TSession.GetVariable("LoggedIn"); if ((null != loggedIn) && ((bool)loggedIn == true)) { return(TFileVersionInfo.GetApplicationVersion().ToVersion().ToString()); } return("0.0.0.0"); }
public bool IsUserLoggedIn() { object loggedIn = TSession.GetVariable("LoggedIn"); if ((null != loggedIn) && ((bool)loggedIn == true)) { return(true); } return(false); }
public string SetNewPassword(string AUserID, string AToken, string ANewPassword) { // make sure we are logged out. especially SYSADMIN could be logged in when a new user is created. Logout(); TSession.InitThread("SetNewPassword", TAppSettingsManager.ConfigFileName); TVerificationResultCollection VerificationResult; bool Result = TMaintenanceWebConnector.SetNewPassword(AUserID, AToken, ANewPassword, out VerificationResult); return("{" + "\"AVerificationResult\": " + THttpBinarySerializer.SerializeObject(VerificationResult) + "," + "\"result\": " + THttpBinarySerializer.SerializeObject(Result) + "}"); }
/// <summary> /// Executes the query. Call this method in a separate Thread to execute the /// query asynchronously! /// </summary> /// <remarks>An instance of TAsyncFindParameters with set up Properties must /// exist before this procedure can get called! /// </remarks> /// <returns>void</returns> public void ExecuteQuery(string ASessionID) { bool ownDatabaseConnection = false; // need to initialize the database session TSession.InitThread(ASessionID); if (!DBAccess.GDBAccessObj.ConnectionOK) { // we need a separate database object for this thread, since we cannot access the session object DBAccess.GDBAccessObj.EstablishDBConnection(TSrvSetting.RDMBSType, TSrvSetting.PostgreSQLServer, TSrvSetting.PostgreSQLServerPort, TSrvSetting.PostgreSQLDatabaseName, TSrvSetting.DBUsername, TSrvSetting.DBPassword, ""); ownDatabaseConnection = true; } try { FProgressID = Guid.NewGuid().ToString(); TProgressTracker.InitProgressTracker(FProgressID, "Executing Query...", 100.0m); // Create SQL statement and execute it to return all records ExecuteFullQuery(); } catch (Exception exp) { TLogging.Log(this.GetType().FullName + ".ExecuteQuery: Exception occured: " + exp.ToString()); // Inform the caller that something has gone wrong... TProgressTracker.CancelJob(FProgressID); /* * WE MUST 'SWALLOW' ANY EXCEPTION HERE, OTHERWISE THE WHOLE * PETRASERVER WILL GO DOWN!!! (THIS BEHAVIOUR IS NEW WITH .NET 2.0.) * * --> ANY EXCEPTION THAT WOULD LEAVE THIS METHOD WOULD BE SEEN AS AN <-- * --> UNHANDLED EXCEPTION IN A THREAD, AND THE .NET/MONO RUNTIME <-- * --> WOULD BRING DOWN THE WHOLE PETRASERVER PROCESS AS A CONSEQUENCE! <-- * */ } if (ownDatabaseConnection) { DBAccess.GDBAccessObj.CloseDBConnection(); } }
private eLoginEnum LoginInternal(string username, string password, Version AClientVersion, out Int32 AClientID, out string AWelcomeMessage, out Boolean ASystemEnabled, out Boolean AMustChangePassword) { ASystemEnabled = true; AWelcomeMessage = string.Empty; AClientID = -1; AMustChangePassword = false; Int64 SiteKey; try { if (username.ToUpper() == "SELFSERVICE") { throw new Exception("Login with user SELFSERVICE is not permitted"); } TConnectedClient CurrentClient = TClientManager.ConnectClient( username.ToUpper(), password.Trim(), HttpContext.Current.Request.UserHostName, HttpContext.Current.Request.UserHostAddress, AClientVersion, TClientServerConnectionType.csctRemote, out AClientID, out AWelcomeMessage, out ASystemEnabled, out SiteKey); TSession.SetVariable("LoggedIn", true); // the following values are stored in the session object DomainManager.GClientID = AClientID; DomainManager.CurrentClient = CurrentClient; DomainManager.GSiteKey = SiteKey; AMustChangePassword = (UserInfo.GetUserInfo().LoginMessage == SharedConstants.LOGINMUSTCHANGEPASSWORD); return(eLoginEnum.eLoginSucceeded); } catch (Exception e) { TLogging.Log(e.Message); TLogging.Log(e.StackTrace); TSession.SetVariable("LoggedIn", false); TSession.CloseSession(); return(TClientManager.LoginErrorFromException(e)); } }
public static bool TrainBankStatementsLastMonth(Int32 ALedgerNumber, DateTime AToday) { string sessionID = TSession.GetSessionID(); Int32 clientID = DomainManager.GClientID; Thread t = new Thread(() => TrainBankStatementsLastMonthThread( sessionID, clientID, ALedgerNumber, AToday)); t.Name = Guid.NewGuid().ToString(); t.Start(); return(true); }
/// <summary> /// add or reuse a tracker for the given clientID /// </summary> /// <param name="AClientID"></param> /// <param name="ACaption"></param> /// <param name="AAbsoluteOverallAmount"></param> /// <returns></returns> static public TProgressState InitProgressTracker(string AClientID, string ACaption, decimal AAbsoluteOverallAmount = 100.0m) { TProgressState state = new TProgressState(); state.AbsoluteOverallAmount = AAbsoluteOverallAmount; state.Caption = ACaption; // First clear all progress trackers. We cannot have too many variables in the session. We only work with one progress tracker per session. TSession.ClearVariables(PROGRESSTRACKER); TSession.SetVariable(PROGRESSTRACKER + AClientID, state); return(state); }
public bool Logout() { TLogging.Log("Logout from session: ClientName=" + DomainManager.CurrentClient.ClientName, TLoggingType.ToLogfile | TLoggingType.ToConsole); if (DomainManager.CurrentClient == null) { TSession.Clear(); } else { DomainManager.CurrentClient.EndSession(); } return(true); }
public string IsUserLoggedIn() { Dictionary <string, object> result = new Dictionary <string, object>(); object loggedIn = TSession.GetVariable("LoggedIn"); if ((null != loggedIn) && ((bool)loggedIn == true)) { result.Add("resultcode", "success"); } else { result.Add("resultcode", "error"); } return(JsonConvert.SerializeObject(result)); }
/// <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); // First check whether the 'globally available' DB Connection isn't busy - we must not allow the start of a // Report Calculation when that is the case (as this would lead to a nested DB Transaction exception, // EDBTransactionBusyException). if (DBAccess.GDBAccessObj.Transaction != null) { FErrorMessage = Catalog.GetString(SharedConstants.NO_PARALLEL_EXECUTION_OF_XML_REPORTS_PREFIX + "The OpenPetra Server is currently too busy to prepare this Report. " + "Please retry once other running tasks (eg. a Report) are finished!"); TProgressTracker.FinishJob(FProgressID); FSuccess = false; // Return to the Client immediately! return; } TRptUserFunctionsFinance.FlushSqlCache(); 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.CurrentCulture = Thread.CurrentThread.CurrentCulture; TheThread.Name = FProgressID + "_" + UserInfo.GUserInfo.UserID + "__TReportGeneratorUIConnector.Start_Thread"; TLogging.LogAtLevel(7, TheThread.Name + " starting."); TheThread.Start(); }
public static TSession ResolveSession <TSession>() where TSession : SessionBase { var type = typeof(TSession); string name = type.Name; TSession session = _resolver.ResolveSession <TSession>(); //Activator.CreateInstance(proxyAssemblyNamespace, //string.Format("{0}.{1}", proxyAssemblyNamespace, name)).Unwrap(); if (SessionCreated != null) { SessionCreated(typeof(SessionManager), new SessionCreatedEventArgs(session)); } return(session); }
public string IsUserLoggedIn() { Dictionary <string, object> result = new Dictionary <string, object>(); object loggedIn = TSession.GetVariable("LoggedIn"); if ((null != loggedIn) && ((bool)loggedIn == true)) { result.Add("resultcode", "success"); } else { result.Add("selfsignupEnabled", TMaintenanceWebConnector.SignUpSelfServiceEnabled()?"true":"false"); result.Add("resultcode", "error"); } return(JsonConvert.SerializeObject(result)); }
/// <summary> /// The public constructor. /// </summary> /// <param name="handleParticipant">The unique handle of the other participant in the communication session.</param> /// <param name="type">The type of the communication sesison.</param> /// <param name="surfaceComm">An interface to a communication service provider.</param> /// <param name="kryptonite">An interface to a Kryptonite module.</param> /// <param name="bottom">An interface to a Bottom module.</param> public Session(string handleParticipant, TSession type, ISurfaceCommunicationSpecific surfaceComm, IKryptoniteExternalCommunicationSpecific kryptonite, IBottomExternalCommunicationSpecific bottom) { this._handleParticipant = handleParticipant; this.kryptonite = kryptonite; this.bottom = bottom; this.surfaceComm = surfaceComm; this.type = type; //set-up send message call-backs bottom.sendMessage = this.sendBottomMessage; kryptonite.sendMessage = this.sendKryptoniteMessage; this._deployBtm2Btm = false; this._deployKrypt2Krypt = false; this._encrypted = false; //set-up surface message received call-back surfaceComm.surfaceSpecificMessageHandler = this.surfaceMessageReceived; }
/// <inheritdoc /> public void goneSecure(String handlePartner, TSession sessionType) { Invoke((MethodInvoker)delegate { if (sessionType != TSession.call) { //we currently only explicitly support calls return; } string str2nd = "" + TSession.call; foreach (ListViewItem item in listCalls.Items) { if ((item.SubItems[0].Text == handlePartner) && (item.SubItems[1].Text == str2nd)) { item.SubItems[2].Text = SECURE; System.Threading.Thread t = new System.Threading.Thread(playSoundSecure); t.Start(); break; } } }); }
/// <inheritdoc /> public void goneInsecure(String handlePartner, TSession sessionType) { Invoke((MethodInvoker)delegate { string str2nd = "" + TSession.call; foreach (ListViewItem item in listCalls.Items) { if ((item.SubItems[0].Text == handlePartner) && (item.SubItems[1].Text == str2nd)) { item.SubItems[2].Text = INSECURE; System.Threading.Thread t = new System.Threading.Thread(playSoundInsecure); t.Start(); break; } } }); }
/// <inheritdoc /> public void removeSession(String handlePartner, TSession sessionType) { Invoke((MethodInvoker)delegate { //todo: does this work out? string str2nd = "" + sessionType; foreach (ListViewItem item in listCalls.Items) { if ((item.SubItems[0].Text == handlePartner) && (item.SubItems[1].Text == str2nd)) { listCalls.Items.Remove(item); break; } } }); }
/// <inheritdoc /> public bool encrypt(int sessionId, TSession toEncrypt, CryptoKey key, bool primaryActor) { if (toEncrypt != TSession.call) { Logger.log(TLogLevel.logUser, "Error: Currently only the encryption of calls is explicitely supported."); return false; } //check strength of key if ((key.bitStrength != BIT_STRENGTH_KEY) || (key.algorithm != SYMMETRIC_ALGORITHM)) { return false; } sessionKey = key; gotSessionKey = true; //start the Bottom protocol if (primaryActor == true) { start(); } return true; //TODO: think about return value }