private static void InitCouchBase()
        {
            NetDesktop.Activate();

            // Get the database (and create it if it doesn't exist)
            _database = new Database("db");

            // Create replicator to push and pull changes to and from the cloud
            var targetEndpoint = new URLEndpoint(new Uri("ws://localhost:4984/db"));
            var replConfig     = new ReplicatorConfiguration(_database, targetEndpoint);

            // Add authentication
            replConfig.Authenticator  = new BasicAuthenticator("sync_gateway", "password");
            replConfig.ReplicatorType = ReplicatorType.PushAndPull;
            replConfig.Continuous     = true;

            // Create replicator (make sure to add an instance or static variable
            // named _Replicator)
            _Replicator = new Replicator(replConfig);
            _Replicator.AddChangeListener((sender, args) =>
            {
                Instance.DataChanged.Invoke(sender, args);
                _log.Debug($"status={args.Status.Activity}");
                _log.Debug($"progress={args.Status.Progress.Completed}/{args.Status.Progress.Total}");
                _log.Debug($"error={args.Status.Error}");
                if (args.Status.Error != null)
                {
                    _log.Error($"Error :: {args.Status.Error}");
                }
            });

            _Replicator.Start();
        }
        static Native()
        {
            var version = typeof(Native).GetTypeInfo().Assembly
                          .GetCustomAttribute <AssemblyInformationalVersionAttribute>();

#if NEEDS_LITECORE_LOAD
            NetDesktop.LoadLiteCore();
#endif
        }
Example #3
0
        static void Main(string[] args)
        {
            CouchbaseLite P = new CouchbaseLite();



            Database db;
            Database dbproducts;
            Database dborders;

            try
            {
                NetDesktop.Activate();


                /*This part of code is used for bulk loading data from a File into CBL
                 * DataTable dtcustmaster = new DataTable();
                 *
                 * /dtcustmaster = P.showDataFromTextLogFiles(@"C:\Personal\09106684\Desktop\Orders.txt");
                 * DatabaseConfiguration config = new DatabaseConfiguration() { Directory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) };
                 *
                 * dborders = new Database("Ordersdb", config);
                 *
                 * foreach (DataRow drr in dtcustmaster.Rows)
                 * {
                 *
                 *  using (var CustomerDoc = new MutableDocument(drr["DOC_NBR"].ToString()))
                 *  {
                 *
                 *      CustomerDoc.SetString("DOC_NBR", drr["DOC_NBR"].ToString());
                 *      CustomerDoc.SetString("CUST_NBR", drr["CUST_NBR"].ToString());
                 *      CustomerDoc.SetString("ORDER_CREATED_DT", drr["ORDER_CREATED_DT"].ToString());
                 *      CustomerDoc.SetString("ITEM_ID", drr["ITEM_ID"].ToString());
                 *      CustomerDoc.SetString("ORD_QTY", drr["ORD_QTY"].ToString());
                 *      CustomerDoc.SetString("RETL_AMT", drr["RETL_AMT"].ToString());
                 *
                 *      dborders.Save(CustomerDoc);
                 *
                 *  }
                 * }
                 *
                 * P.runselectOrders(dborders); */

                db = P.OpenCustDB();

                dbproducts = P.OpenProdDB();

                dborders = P.OpenOrderDB();

                P.PromptMaster(db, dbproducts, dborders);
            }

            catch (Exception ex)
            {
                Console.WriteLine("Error Unable to connect : " + ex.ToString());
            }
        }