コード例 #1
0
        static void Main(string[] args)
        {
            EventPersister ep = PersisterFactory.CreatePersister();

            //ep.Connect("USER", "_SYSTEM", "SYS");
            ep.Connect("localhost", 1972, "USER", "_SYSTEM", "SYS");
            Object returnvalue = ep.CallClassMethod("%SYSTEM.Version", "GetVersion");

            Console.Write("ReturnValue = " + returnvalue.ToString());

            ep.Close();
        }
        protected override void Given()
        {
            Context += () =>
                           {
                               _httpWebResponse = new Mock<IHttpWebResponse>(MockBehavior.Loose);
                               _httpWebResponse.Setup(r => r.StatusCode).Returns(HttpStatusCode.BadRequest);
                               _gateway = new Mock<IAmAGatewayForWebRequests>(MockBehavior.Loose);
                               _gateway.Setup(g => g.SafelyMakeRequest(It.IsAny<HttpWebRequest>()))
                                   .Returns(new CouchDbResponse(_httpWebResponse.Object));

                               _sut = new EventPersister(_gateway.Object, new CouchDbDatabaseDetailsBuilder("TestDatabase", "http://127.0.0.1/", "Foo", "Bar").Build());
                               _aggregateId = AggregateIdGenerator.Generate();
                               _eventsSpy = new EventsSpy(new AggregateEvent(_aggregateId),
                                                          new AggregateEvent(_aggregateId),
                                                          new AggregateEvent(_aggregateId));
                           };
        }
コード例 #3
0
        static void Main(String[] args)
        {
            // If you are using a remote instance, update IP and password here
            String user     = "******";
            String password = "******";
            String IP       = "localhost";
            int    port     = 51773;

            try
            {
                // Connect to database using EventPersister, which is based on IRISDataSource
                // For more details on EventPersister, visit
                // https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=BNETXEP_xep
                EventPersister xepPersister = PersisterFactory.CreatePersister();
                xepPersister.Connect(IP, port, "User", user, password);

                Console.WriteLine("Connected to InterSystems IRIS");
                xepPersister.DeleteExtent("Demo.Airport");     // Remove old test data
                xepPersister.ImportSchemaFull("Demo.Airport"); // Import flat schema
                // Create XEP Event for object access
                Event xepEvent = xepPersister.GetEvent("Demo.Airport");
                // Create IRIS Native object
                IRISADOConnection connection = (IRISADOConnection)xepPersister.GetAdoNetConnection();
                IRIS irisNative = IRIS.CreateIRIS(connection);

                Console.WriteLine("Generating airport table...");

                // Populate 5 airport objects and save to the database using XEP
                populateAirports(xepEvent);

                // Get all airports using ADO.NET
                getAirports(connection);

                // Store natively - Uncomment the following line for task 3
                // StoreAirfare(irisNative);
                Console.ReadLine();
                // Close everything
                xepEvent.Close();
                xepPersister.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error creating airport listing: " + e);
            }
        }
コード例 #4
0
    static void Main(string[] args)
    {
        JsonObject jso = new JsonObject();

        jso.Add("Grade", 1);
        jso.Add("Class", 2);
        jso.Add("Name", "クライアントさん");

        JsonObject otherJO1 = new JsonObject();

        otherJO1.Add("Subject", "数学");
        otherJO1.Add("Score", 64);

        JsonObject otherJO2 = new JsonObject();

        otherJO2.Add("Subject", "理科");
        otherJO2.Add("Score", 70);

        JsonObject otherJO3 = new JsonObject();

        otherJO3.Add("Subject", "英語");
        otherJO3.Add("Score", 80);

        // Json array

        JsonArray ja = new JsonArray();

        ja.Add(otherJO1);
        ja.Add(otherJO2);
        ja.Add(otherJO3);

        jso.Add("Results", ja);

        Console.WriteLine(jso.ToString());

        EventPersister ep = PersisterFactory.CreatePersister();

        ep.Connect("USER", "_SYSTEM", "SYS");
        //ep.Connect("localhost",1972,"USER", "_SYSTEM", "SYS");

        Object returnvalue = ep.CallClassMethod("REST.JSON", "SendJSON", jso.ToString());

        ep.Close();
    }
コード例 #5
0
        // Task 4: Generate trades and save it to database using ADO.NET.
        public static void Task4(Trade[] sampleArray, EventPersister xepPersister)
        {
            Console.WriteLine("How many items to generate using ADO.NET? ");
            String inputNum = Console.ReadLine();
            int    numberADO;

            Int32.TryParse(inputNum, out numberADO);
            if (numberADO <= 0)
            {
                Console.WriteLine("Number of items has to bigger than 0");
            }
            //Get sample generated array to store
            sampleArray = Trade.generateSampleData(numberADO);

            //Save generated trades using ADO
            long totalADOStore = StoreUsingADO(xepPersister, sampleArray);

            Console.WriteLine("Execution time: " + totalADOStore + " ms");
        }
コード例 #6
0
        static void Main(string[] args)
        {
            String ip = "localhost";
            int port = 51773;
            String username = "******";
            String password = "******";
            String Namespace = "USER";
            String className = "myApp.StockInfo";
            
            try {
                // Connect to database using EventPersister
                EventPersister xepPersister = PersisterFactory.CreatePersister();
                xepPersister.Connect(ip, port, Namespace, username, password);
                Console.WriteLine("Connected to InterSystems IRIS.");
                xepPersister.DeleteExtent(className);   // remove old test data
                xepPersister.ImportSchema(className);   // import flat schema
            
                // Create Event
                Event xepEvent = xepPersister.GetEvent(className);
                IRISADOConnection connection = (IRISADOConnection) xepPersister.GetAdoNetConnection();
                IRIS native = IRIS.CreateIRIS(connection);

                // Task 2
                // Uncomment the line below to run task 2
                // Task2(connection);

                // Task 3
                // Uncomment the line below to run task 3
                // Task3(connection, xepEvent);

                // Task 4
                // Comment out Task 2, Task 3 and uncomment the line below to run task 4
                // Task4(connection, native, xepEvent);

                xepEvent.Close();
                xepPersister.Close();

            
            } catch (Exception e) { 
                Console.WriteLine("Interactive prompt failed:\n" + e); 
            }
        }
コード例 #7
0
 public RoutingSlipCompletedConsumer(EventPersister persister)
 {
     _persister = persister;
 }
コード例 #8
0
 public RoutingSlipFaultedConsumer(EventPersister persister)
 {
     _persister = persister;
 }
コード例 #9
0
        public IPersisterDaemon BuildDefaultPersisterDaemon(IStreamIngestorConfiguration streamIngestorConfiguration = null, 
            IPersistenceConfiguration persistenceConfiguration = null)
        {
            if(streamIngestorConfiguration == null)
                streamIngestorConfiguration = new StreamIngestorConfiguration();

            if(persistenceConfiguration == null)
                persistenceConfiguration = new PersistenceConfiguration();

            var eventPersister = new EventPersister(persistenceConfiguration,
                new DataExtractor(persistenceConfiguration,
                    new FingerprintReader(persistenceConfiguration),
                    new ServerReader(persistenceConfiguration),
                    new ServerWriter(persistenceConfiguration)),
                new ErrorDefinitionWriter(persistenceConfiguration),
                new TimelineWriter(persistenceConfiguration));

            if (_eventDiscarder == null)
                _eventDiscarder = new NullEventDiscarder();

            return new PersisterDaemon(streamIngestorConfiguration, eventPersister, _eventDiscarder);
        }
コード例 #10
0
 public SicknessEpisodeEventManager(EventPersister persister)
 {
     _persister = persister;
 }
コード例 #11
0
 public void Setup()
 {
     _persister = MockRepository.GenerateStub<EventPersister>();
     Event = new SicknessEpisodeEventManager(_persister).Create(e => BuilderAction(e));
 }
コード例 #12
0
 public SicknessEpisodeEventCreationContext()
 {
     _persister = MockRepository.GenerateStub<EventPersister>();
     _manager = new SicknessEpisodeEventManager(_persister);
 }
コード例 #13
0
        // Save trade into database using ADO.NET - which is slower than using XEP
        public static long StoreUsingADO(EventPersister persist, Trade[] sampleArray)
        {
            long totalTime = new long();
            long startTime = DateTime.Now.Ticks;

            // Loop through objects to insert
            try
            {
                IRISDataAdapter da        = new IRISDataAdapter();
                String          ClassName = "myApp.Trade";

                IRISADOConnection con = (IRISADOConnection)persist.GetAdoNetConnection();

                String SQL = "select purchaseDate, purchasePrice, stockName, shares, traderName from " + ClassName;
                da.SelectCommand             = con.CreateCommand();
                da.SelectCommand.CommandText = SQL;

                SQL = "INSERT INTO myApp.Trade (purchaseDate, purchasePrice, stockName, shares, traderName) VALUES (?,?,?,?,?)";

                IRISCommand cmd = con.CreateCommand();
                cmd.CommandText  = SQL;
                da.InsertCommand = cmd;

                IRISParameter date_param = new IRISParameter("purchaseDate", IRISDbType.DateTime);
                cmd.Parameters.Add(date_param);
                date_param.SourceColumn = "purchaseDate";

                IRISParameter price_param = new IRISParameter("purchasePrice", IRISDbType.Double);
                cmd.Parameters.Add(price_param);
                price_param.SourceColumn = "purchasePrice";

                IRISParameter name_param = new IRISParameter("stockName", IRISDbType.NVarChar);
                cmd.Parameters.Add(name_param);
                name_param.SourceColumn = "stockName";

                IRISParameter shares_param = new IRISParameter("shares", IRISDbType.Int);
                cmd.Parameters.Add(shares_param);
                shares_param.SourceColumn = "shares";

                IRISParameter trader_param = new IRISParameter("traderName", IRISDbType.NVarChar);
                cmd.Parameters.Add(trader_param);
                trader_param.SourceColumn = "traderName";

                da.TableMappings.Add("Table", ClassName);

                DataSet ds = new DataSet();
                da.Fill(ds);

                for (int i = 0; i < sampleArray.Length; i++)
                {
                    DataRow newRow = ds.Tables[0].NewRow();
                    newRow["purchaseDate"]  = sampleArray[i].purchaseDate;
                    newRow["purchasePrice"] = sampleArray[i].purchasePrice;
                    newRow["stockName"]     = sampleArray[i].stockName;
                    newRow["shares"]        = sampleArray[i].shares;
                    newRow["traderName"]    = sampleArray[i].traderName;
                    ds.Tables[0].Rows.Add(newRow);
                }


                da.Update(ds);
                Console.WriteLine("Inserted " + sampleArray.Length + " item(s) via ADO.NET successfully.");
                totalTime = DateTime.Now.Ticks - startTime;
            }
            catch (Exception e)
            {
                Console.WriteLine("There was a problem storing items using ADO.NET.\n" + e);
            }
            return(totalTime / TimeSpan.TicksPerMillisecond);
        }
コード例 #14
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Trade[] sampleArray = null;

            // Initialize dictionary to store connection details from config.txt
            IDictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary = generateConfig("..\\..\\..\\config.txt");

            // Retrieve connection information from configuration file
            string ip        = dictionary["ip"];
            int    port      = Convert.ToInt32(dictionary["port"]);
            string Namespace = dictionary["namespace"];
            string username  = dictionary["username"];
            string password  = dictionary["password"];
            String className = "myApp.Trade";

            try
            {
                // Connect to database using EventPersister
                EventPersister xepPersister = PersisterFactory.CreatePersister();
                xepPersister.Connect(ip, port, Namespace, username, password);
                Console.WriteLine("Connected to InterSystems IRIS.");
                xepPersister.DeleteExtent(className);   // remove old test data
                xepPersister.ImportSchema(className);   // import flat schema

                // Create Event
                Event xepEvent = xepPersister.GetEvent(className);

                // Starting interactive prompt
                bool always = true;
                while (always)
                {
                    Console.WriteLine("1. Make a trade (do not save)");
                    Console.WriteLine("2. Confirm all trades");
                    Console.WriteLine("3. Generate and save multiple trades");
                    Console.WriteLine("4. Retrieve all trades; show execution statistics");
                    Console.WriteLine("5. ADO.NET Comparison - Create and save multiple trades");
                    Console.WriteLine("6. Update all trades; show execution statistics");
                    Console.WriteLine("7. Quit");
                    Console.WriteLine("What would you like to do? ");

                    String option = Console.ReadLine();
                    switch (option)
                    {
                    // Task 2
                    case "1":
                        sampleArray = Task2CreateTrade(sampleArray);
                        break;

                    case "2":
                        Task2SaveTrade(sampleArray, xepEvent);
                        sampleArray = null;
                        break;

                    // Task 3
                    case "3":
                        Task3(sampleArray, xepEvent);
                        break;

                    // Task 5
                    case "4":
                        Task5(xepEvent);
                        break;

                    // Task 4
                    case "5":
                        Task4(sampleArray, xepPersister);
                        break;

                    // Task 6
                    case "6":
                        Task6(xepEvent);
                        break;

                    case "7":
                        Console.WriteLine("Exited.");
                        always = false;
                        break;

                    default:
                        Console.WriteLine("Invalid option. Try again!");
                        break;
                    }
                }
                xepEvent.Close();
                xepPersister.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Interactive prompt failed:\n" + e);
            }
        }
コード例 #15
0
        static void Main(string[] args)
        {
            Trade[] sampleArray = null;
            Console.WriteLine("Hello World!");

            String ip        = "localhost";
            int    port      = 51773;
            String username  = "******";
            String password  = "******";
            String Namespace = "USER";
            String className = "myApp.Trade";

            try {
                // Connect to database using EventPersister
                EventPersister xepPersister = PersisterFactory.CreatePersister();
                xepPersister.Connect(ip, port, Namespace, username, password);
                Console.WriteLine("Connected to InterSystems IRIS.");
                xepPersister.DeleteExtent(className);   // Remove old test data
                xepPersister.ImportSchema(className);   // Import flat schema

                // Create Event
                Event xepEvent = xepPersister.GetEvent(className);

                // Starting interactive prompt
                bool always = true;
                while (always)
                {
                    Console.WriteLine("1. Make a trade (do not save)");
                    Console.WriteLine("2. Confirm all trades");
                    Console.WriteLine("3. Generate and save multiple trades");
                    Console.WriteLine("4. Retrieve all trades; show execution statistics");
                    Console.WriteLine("5. ADO.NET Comparison - Create and save multiple trades");
                    Console.WriteLine("6. Quit");
                    Console.WriteLine("What would you like to do? ");

                    String option = Console.ReadLine();

                    switch (option)
                    {
                    // Task 2
                    case "1":
                        // Uncomment below line to run Task 2 - Create Trade
                        // sampleArray = Task2CreateTrade(sampleArray);
                        break;

                    case "2":
                        // Uncomment below line to run Task 2 - Save Trade
                        // Task2SaveTrade(sampleArray, xepEvent);
                        sampleArray = null;
                        break;

                    // Task 3
                    case "3":
                        // Uncomment below line to run Task 3
                        //Task3(sampleArray, xepEvent);
                        break;

                    // Task 5 + Task 6
                    case "4":
                        // Uncomment below line to run Task 5
                        // Task5(xepEvent);
                        // Uncomment below line to run Task 6
                        // Task6(xepEvent);
                        break;

                    // Task 4
                    case "5":
                        // Uncomment below line to run Task 4
                        // Task4(sampleArray, xepPersister);
                        break;

                    case "6":
                        Console.WriteLine("Exited.");
                        always = false;
                        break;

                    default:
                        Console.WriteLine("Invalid option. Try again!");
                        break;
                    }
                }
                xepEvent.Close();
                xepPersister.Close();
            } catch (Exception e) {
                Console.WriteLine("Interactive prompt failed:\n" + e);
            }
        }
コード例 #16
0
 public void Setup()
 {
     _persister = MockRepository.GenerateStub <EventPersister>();
     Event      = new SicknessEpisodeEventManager(_persister).Create(e => BuilderAction(e));
 }
コード例 #17
0
 public SicknessEpisodeEventCreationContext()
 {
     _persister = MockRepository.GenerateStub <EventPersister>();
     _manager   = new SicknessEpisodeEventManager(_persister);
 }
コード例 #18
0
 public RoutingSlipActivityCompensationFailedConsumer(EventPersister persister)
 {
     _persister = persister;
 }
コード例 #19
0
 public SicknessEpisodeEventManager(EventPersister persister)
 {
     _persister = persister;
 }
コード例 #20
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            // Initialize dictionary to store connection details from config.txt
            IDictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary = generateConfig("..\\..\\..\\config.txt");

            // Retrieve connection information from configuration file
            string ip        = dictionary["ip"];
            int    port      = Convert.ToInt32(dictionary["port"]);
            string Namespace = dictionary["namespace"];
            string username  = dictionary["username"];
            string password  = dictionary["password"];
            String className = "myApp.StockInfo";

            try
            {
                // Connect to database using EventPersister
                EventPersister xepPersister = PersisterFactory.CreatePersister();
                xepPersister.Connect(ip, port, Namespace, username, password);
                Console.WriteLine("Connected to InterSystems IRIS.");
                xepPersister.DeleteExtent(className);   // Remove old test data
                xepPersister.ImportSchema(className);   // Import flat schema

                // Create Event
                Event             xepEvent   = xepPersister.GetEvent(className);
                IRISADOConnection connection = (IRISADOConnection)xepPersister.GetAdoNetConnection();
                IRIS native = IRIS.CreateIRIS(connection);

                // Starting interactive prompt
                bool always = true;
                while (always)
                {
                    Console.WriteLine("1. Retrieve all stock names");
                    Console.WriteLine("2. Create objects");
                    Console.WriteLine("3. Populate properties");
                    Console.WriteLine("4. Quit");
                    Console.WriteLine("What would you like to do? ");

                    String option = Console.ReadLine();
                    switch (option)
                    {
                    // Task 2
                    case "1":
                        Task2(connection);
                        break;

                    // Task 3
                    case "2":
                        Task3(connection, xepEvent);
                        break;

                    // Task 4
                    case "3":
                        Task4(connection, native, xepEvent);
                        break;

                    case "4":
                        Console.WriteLine("Exited.");
                        always = false;
                        break;

                    default:
                        Console.WriteLine("Invalid option. Try again!");
                        break;
                    }
                }

                xepEvent.Close();
                xepPersister.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Interactive prompt failed:\n" + e);
            }
        }