protected virtual IStatementReader CreateReader() { IStatementReader processor = null; bool importToSingleAccount = this.CASetup.Current.ImportToSingleAccount ?? false; string typeName = this.CASetup.Current.StatementImportTypeName; if (importToSingleAccount) { CashAccount acct = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Optional <CABankTranHeader.cashAccountID> > > > .Select(this); if (acct != null) { typeName = acct.StatementImportTypeName; } } if (string.IsNullOrEmpty(typeName)) { return(processor); } try { Type processorType = System.Web.Compilation.PXBuildManager.GetType(typeName, true); processor = (IStatementReader)Activator.CreateInstance(processorType); } catch (Exception e) { throw new PXException(e, Messages.StatementServiceReaderCreationError, typeName); } return(processor); }
public virtual void ImportStatement(PX.SM.FileInfo aFileInfo, bool doRedirect) { bool isFormatRecognized = false; IStatementReader reader = this.CreateReader(); if (reader != null && reader.IsValidInput(aFileInfo.BinData)) { reader.Read(aFileInfo.BinData); List <CABankTranHeader> imported; reader.ExportToNew(aFileInfo, this, out imported); if (imported != null && doRedirect) { CABankTranHeader last = (imported != null && imported.Count > 0) ? imported[imported.Count - 1] : null; if (this.Header.Current == null || (last != null && (this.Header.Current.CashAccountID != last.CashAccountID || this.Header.Current.RefNbr != last.RefNbr))) { this.Header.Current = this.Header.Search <CABankTranHeader.cashAccountID, CABankTranHeader.refNbr>(last.CashAccountID, last.RefNbr); throw new PXRedirectRequiredException(this, "Navigate to the uploaded record"); } } isFormatRecognized = true; } if (!isFormatRecognized) { throw new PXException(Messages.UploadFileHasUnrecognizedBankStatementFormat); } }
private static void Run(IStatementReader statementReader) { CassandraSharpConfig cassandraSharpConfig = new CassandraSharpConfig(); cassandraSharpConfig.Logger = typeof(ConsoleDebugLogger).AssemblyQualifiedName; cassandraSharpConfig.Instrumentation = typeof(ConsoleInstrumentation).AssemblyQualifiedName; ClusterManager.Configure(cassandraSharpConfig); ClusterConfig clusterConfig = new ClusterConfig { Transport = new TransportConfig { User = _cliArgs.User, Password = _cliArgs.Password }, Endpoints = new EndpointsConfig { Servers = new[] {_cliArgs.Hostname}, Discovery = "Null", } }; using (ICluster cluster = ClusterManager.GetCluster(clusterConfig)) { CommandContext.Cluster = cluster; if (_cliArgs.CheckConnection) { Console.WriteLine("Connecting to {0}:{1}...", _cliArgs.Hostname, _cliArgs.Port); const string checkStatement = "select cluster_name, data_center, rack, release_version from system.local"; new Exec {Statement = checkStatement}.Execute(); if (CommandContext.LastCommandFailed) { return; } } if (! _cliArgs.NoHelp) { new Exec {Statement = "!help"}.Execute(); } foreach (string statement in statementReader.Read()) { new Exec {Statement = statement}.Execute(); if (CommandContext.Exit) { return; } } } }
public StatementSplitter(IStatementReader statementReader) { _statementReader = statementReader; }
private static void Run(IStatementReader statementReader) { CassandraSharpConfig cassandraSharpConfig = new CassandraSharpConfig { Logger = new LoggerConfig { Type = typeof(ConsoleDebugLogger).AssemblyQualifiedName }, Instrumentation = new InstrumentationConfig { Type = typeof(ConsoleInstrumentation).AssemblyQualifiedName } }; ClusterManager.Configure(cassandraSharpConfig); ClusterConfig clusterConfig = new ClusterConfig { Transport = new TransportConfig { User = _cliArgs.User, Password = _cliArgs.Password }, Endpoints = new EndpointsConfig { Servers = new[] { _cliArgs.Hostname }, } }; if (!_cliArgs.Discovery) { clusterConfig.Endpoints.Discovery = new DiscoveryConfig { Type = "Null" }; } using (ICluster cluster = ClusterManager.GetCluster(clusterConfig)) { CommandContext.Cluster = cluster; if (_cliArgs.CheckConnection) { Console.WriteLine("Connecting to {0}:{1}...", _cliArgs.Hostname, _cliArgs.Port); const string checkStatement = "select cluster_name, data_center, rack, release_version from system.local"; new Exec { Statement = checkStatement }.Execute(); if (CommandContext.LastCommandFailed) { return; } Console.WriteLine(); Console.WriteLine("Querying ring state..."); const string peersStatement = "select rpc_address,tokens,release_version from system.peers"; new Exec { Statement = peersStatement }.Execute(); Console.WriteLine(); if (CommandContext.LastCommandFailed) { return; } } if (!_cliArgs.NoHelp) { new Exec { Statement = "!help" }.Execute(); } foreach (string statement in statementReader.Read()) { new Exec { Statement = statement }.Execute(); if (CommandContext.Exit) { return; } } } }
public BlankParser(IStatementReader expressionReader) : base(expressionReader, @char => @char == ' ') { }
public ReservedWordParser(IStatementReader expressionReader) : base(expressionReader, char.IsLetter) { }
public QuotationParser(IStatementReader expressionReader) : base(expressionReader, (@char) => @char == '"') { }
public AccountBalanceController(IStatementReader statementReader) { _statementReader = statementReader; }
public ParamParser(IStatementReader expressionReader) : base(expressionReader, (@char) => @char == '[') { }
public StatementParser(IStatementReader expressionReader, Func <char, bool> parseCondition) { this._expressionReader = expressionReader; this._parseCondition = parseCondition; }
private static void Run(string hostname, IStatementReader statementReader) { CassandraSharpConfig cassandraSharpConfig = new CassandraSharpConfig(); cassandraSharpConfig.Logger = typeof(ConsoleDebugLogger).AssemblyQualifiedName; ClusterManager.Configure(cassandraSharpConfig); ClusterConfig clusterConfig = new ClusterConfig { Transport = new TransportConfig { User = _cliArgs.User, Password = _cliArgs.Password, }, Endpoints = new EndpointsConfig { Servers = new[] {hostname}, } }; using (ICluster cluster = ClusterManager.GetCluster(clusterConfig)) { CommandContext.Cluster = cluster; if (_cliArgs.CheckConnection) { Console.WriteLine("Connecting to {0}:", hostname); const string checkStatement = "select cluster_name, data_center, rack, release_version from system.local"; if (!ExecuteCommand(checkStatement)) { return; } } if (_cliArgs.Banner) { ExecuteCommand("!help"); } foreach (string statement in statementReader.Read()) { ExecuteCommand(statement); if (CommandContext.Exit) { return; } } } }
public NumericParser(IStatementReader expressionReader) : base(expressionReader, char.IsDigit) { }