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);
            }
        }
Пример #2
0
        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;
                    }
                }
            }
        }
Пример #3
0
 public IEnumerable <string> Read()
 {
     return(_statementReader.Read());
 }
Пример #4
0
        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;
                    }
                }
            }
        }
Пример #5
0
        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;
                    }
                }
            }
        }