Exemplo n.º 1
0
        public async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Pills.Clear();
                var pills = await MongoRepo.GetAllPills();

                foreach (var pill in pills)
                {
                    Pills.Add(pill);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 2
0
        public async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Reminders.Clear();
                if (MongoRepo.LoggedUser != null)
                {
                    var pills = await MongoRepo.GetAllRemindersAsync(MongoRepo.LoggedUser.Username);

                    foreach (var pill in pills)
                    {
                        Reminders.Add(pill);
                    }
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Reminders", "You should login to see reminders!", "OK");
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 3
0
        public ActionResult Index(long?id)
        {
            var db = new MongoRepo();
            var d  = new ApplicationDbContext();
            //var class1 = new Class2();
            //var class2 = new SDHCRoot();
            //ContentManager.CreateContent(class1);
            //ContentManager.CreateContent(class2);
            var list  = ContentManager.GetAllChildContent(null).ToList();
            var types = list.Select(b => b.GetType()).ToList();

            return(Content($""));
        }
Exemplo n.º 4
0
        public ItemsViewModel()
        {
            Title            = "Pills";
            Pills            = new ObservableCollection <Pill>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, Pill>(this, "AddItem", (obj, item) =>
            {
                var newItem = item as Pill;
                Pills.Add(newItem);
                MongoRepo.AddPill(newItem);
            });
        }
Exemplo n.º 5
0
        public RemindersViewModel()
        {
            Title            = "Reminders";
            Reminders        = new ObservableCollection <Reminder>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewReminderPage, Reminder>(this, "AddReminder", (obj, reminder) =>
            {
                var newReminder = reminder as Reminder;
                Reminders.Add(newReminder);
                MongoRepo.AddReminder(newReminder);
            });
        }
 public UserService()
 {
     _repo = new MongoRepo <User>("users");
 }
 public TaskModelController(MongoRepo<TaskModel> taskmodel_repo, MongoRepo<Site> site_repo)
 {
     this.taskModelCollection = taskmodel_repo.Collection;
     this.siteCollection = site_repo.Collection;
 }
Exemplo n.º 8
0
 public void Configuration(IAppBuilder app)
 {
     G.MongoDbIuserStore = () => null;
     SDHCStartup2.Init <MongoRepo, SDHCRoot, SDHCBascSelect, UserMongo>(
         app, () => MongoRepo.Create(), HostingEnvironment.MapPath("/"));
 }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            MongoRepo mongoRepo = new MongoRepo();

            mongoRepo.Connect();

            Parser.Default.ParseArguments <CmdOptions>(args)
            .WithParsed <CmdOptions>(o =>
            {
                Console.WriteLine(o.Seconds);
                if (o.Seconds > 0)
                {
                    mongoRepo.Get(o.Seconds);
                }
                else if (o.InsSeconds > 0)
                {
                    mongoRepo.Create(o.InsSeconds);
                }
                else if (o.IsUpdate)
                {
                    Console.WriteLine("Enter the number of batches: ");
                    int NoOfBatches = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Enter the number of records per batch: ");
                    int NoOfRecordsPerBatch = Convert.ToInt32(Console.ReadLine());
                    for (int i = 0; i < NoOfBatches; i++)
                    {
                        bool updateRes = mongoRepo.Update(NoOfRecordsPerBatch);
                        if (updateRes)
                        {
                            Console.WriteLine("Batch " + (i + 1) + " updated successfully");
                        }
                    }
                }
                else if (o.IsBulkUpdate)
                {
                    Console.WriteLine("Enter the number of batches: ");
                    int NoOfBatches = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Enter the number of records per batch: ");
                    int NoOfRecordsPerBatch = Convert.ToInt32(Console.ReadLine());
                    for (int i = 0; i < NoOfBatches; i++)
                    {
                        bool updateRes = mongoRepo.UpdateBulk(NoOfRecordsPerBatch);
                        if (updateRes)
                        {
                            Console.WriteLine("Batch " + (i + 1) + " updated successfully");
                        }
                    }
                }
                else if (o.IsBulkReplace)
                {
                    Console.WriteLine("Enter the number of batches: ");
                    int NoOfBatches = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Enter the number of records per batch: ");
                    int NoOfRecordsPerBatch = Convert.ToInt32(Console.ReadLine());
                    for (int i = 0; i < NoOfBatches; i++)
                    {
                        bool updateRes = mongoRepo.ReplaceBulk(NoOfRecordsPerBatch);
                        if (updateRes)
                        {
                            Console.WriteLine("Batch " + (i + 1) + " updated successfully");
                        }
                    }
                }
                else if (o.Verbose)
                {
                    Console.WriteLine("--h Help");
                    Console.WriteLine("--g Get Records per second");
                    Console.WriteLine("--i Insert Records per second");
                }
                else
                {
                    Console.WriteLine("--h Help");
                }
            });
        }