public IEnumerable <string> GetAllUsers(int pageIndex, int pageSize)
        {
            var all = (from e in NewContext.AllDelegations(DefaultPartitionKey)
                       select e.UserName);

            return(all.Distinct().ToList());
        }
Example #2
0
        public void Update(Weather weather)
        {
            try
            {
                using (var context = new NewContext())
                {
                    var q = from w in context.Weathers
                            where w.Timestamp == weather.Timestamp
                            select w;
                    if (q.Count() > 0)
                    {
                        return;
                    }

                    context.Weathers.Add(weather);
                    context.SaveChanges();
                }
            }
            catch (DbUpdateException e)
            {
                MySqlException innerException = e.InnerException.InnerException as MySqlException;
                if (innerException == null || innerException.Number != 1062)
                {
                    throw;
                }
            }
        }
Example #3
0
 public void MigrateSite()
 {
     using (var context = new NewContext())
     {
         SiteService.ResolveSite(context, Number);
     }
     SiteService.UpdateSite(Number, Name, Latitude, Longitude);
 }
Example #4
0
 public UnitOfWork(NewContext dbContext)
 {
     if (dbContext == null)
     {
         throw new ArgumentNullException("DbContext");
     }
     DbContext = dbContext;
 }
        public IEnumerable <string> List(int pageIndex, int pageSize)
        {
            var all = NewContext.AllClientCertificates(DefaultPartitionKey);

            return((from cc in all
                    select cc.UserName)
                   .Distinct().ToList());
        }
        public override ASTN VisitNew([NotNull] NewContext context)
        {
            NewNode node = new NewNode(context)
            {
                Type = new TypeNode(context, context.TYPE().GetText())
            };

            return(node);
        }
Example #7
0
        public DateTime GetLastTimestamp()
        {
            using (var context = new NewContext())
            {
                var q = from w in context.Weathers
                        orderby w.Timestamp descending
                        select w.Timestamp;

                return(q.FirstOrDefault());
            }
        }
        public void Delete(DelegationSetting setting)
        {
            var entity = (from e in NewContext.Delegation
                          where e.PartitionKey == DefaultPartitionKey &&
                          e.UserName.Equals(setting.UserName, StringComparison.OrdinalIgnoreCase) &&
                          e.Realm.Equals(setting.Realm.AbsoluteUri, StringComparison.OrdinalIgnoreCase)
                          select e)
                         .Single();

            NewContext.DeleteDelegation(entity.PartitionKey, entity.RowKey);
        }
Example #9
0
 void DeleteAndCreateNewDatabase(bool delete)
 {
     using (var context = new NewContext())
     {
         if (delete)
         {
             context.Database.Delete();
         }
         context.Database.CreateIfNotExists();
     }
 }
Example #10
0
        public DateTime GetLastTimestamp(int number)
        {
            using (var context = new NewContext())
            {
                long siteId = ResolveSite(context, number);
                var  q      = from log in context.Logs
                              where log.Sensor.Site.Id == siteId
                              orderby log.Timestamp descending
                              select log.Timestamp;

                return(q.FirstOrDefault());
            }
        }
Example #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Context context = new Context(new ConcreteStrategyA());

            context.AlgorithmInvoke();


            NewContext newContext = new NewContext();

            newContext.AlgorithmInvoke(new ConcreteStrategyB());

            Console.ReadKey();
        }
Example #12
0
 public override void ExitNew([NotNull] NewContext context)
 {
     base.ExitNew(context);
     Log("ExitNew");
     if (phase == Phase.Building)
     {
         symbolTableCreator.ExitNew(context);
     }
     else
     {
         symbolTableTraverser.ExitNew(context);
         semanticErrorChecker.ExitNew(context);
     }
 }
Example #13
0
 public void UpdateSite(int number, string name, double latitude, double longitude)
 {
     using (var context = new NewContext())
     {
         long siteId = ResolveSite(context, number);
         var  q      = from s in context.Sites
                       where s.Id == siteId
                       select s;
         Site site = q.First();
         site.Name      = name;
         site.Latitude  = latitude;
         site.Longitude = longitude;
         context.SaveChanges();
     }
 }
Example #14
0
        static void Main(string[] args)
        {
            using (var db = new NewContext())
            {
                Console.WriteLine("请输入Name:");
                var name = Console.ReadLine();

                var newType = new NewType {
                    Name = name
                };
                db.NewTypes.Add(newType);
                db.SaveChanges();

                Console.WriteLine("Save successfully");
                Console.Read();
            }
        }
Example #15
0
        // GET: /Customers/

        public JsonResult GetCustomers(string sidx, string sort, int page, int rows)
        {
            NewContext db = new NewContext();

            sort = (sort == null) ? "" : sort;
            int pageIndex = Convert.ToInt32(page) - 1;
            int pageSize  = rows;

            var CustomerList = db.Customers.Select(
                t => new
            {
                t.CustomerId,
                t.CustomerName,
                t.Address,
                t.MobileNo,
                //   t.PhoneNo,
                t.City,
                //   t.District,
                t.State
            });
            int totalRecords = CustomerList.Count();
            var totalPages   = (int)Math.Ceiling((float)totalRecords / (float)rows);

            if (sort.ToUpper() == "DESC")
            {
                CustomerList = CustomerList.OrderByDescending(t => t.CustomerName);
                CustomerList = CustomerList.Skip(pageIndex * pageSize).Take(pageSize);
            }
            else
            {
                CustomerList = CustomerList.OrderBy(t => t.CustomerName);
                CustomerList = CustomerList.Skip(pageIndex * pageSize).Take(pageSize);
            }
            var jsonData = new
            {
                total = totalPages,
                page,
                records = totalRecords,
                rows    = CustomerList
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
        Task MigrateSite <T>(Func <LegacyContext, DateTime, IEnumerable <T> > query)
            where T : ISiteRecord
        {
            Console.WriteLine(typeof(T).ToString());
            SiteMigrator <T> migrator = Container.Resolve <SiteMigrator <T> >();

            migrator.MigrateSite();

            DateTime last = SiteService.GetLastTimestamp(migrator.Number);

            if (last != DateTime.MinValue)
            {
                last -= new TimeSpan(0, 2, 0, 0);
            }

            IEnumerable <T> legacyData;

            using (var legacyContext = new LegacyContext())
            {
                legacyData = query(legacyContext, last).ToList();
            }

            return(Task.Run(() =>
            {
                foreach (var l in legacyData)
                {
                    using (var context = new NewContext())
                    {
                        context.Configuration.AutoDetectChangesEnabled = false;
                        migrator.MigrateLogs(context, l);
                        context.ChangeTracker.DetectChanges();
                        context.SaveChanges();
                    }
                }
            }));
        }
 public void Add(ClientCertificate certificate)
 {
     NewContext.AddClientCertificate(certificate.ToEntity());
 }
Example #18
0
 public StudentsController(NewContext context)
 {
     _context = context;
 }
 public AccountsController(NewContext context, ILogger <AccountsController> logger)
 {
     _context = context;
     _logger  = logger;
 }
Example #20
0
 public GenericRepository(NewContext context, IUnitOfWorkFactory uowFactory)
 {
     this.context    = context;
     this.uowFactory = uowFactory;
 }
Example #21
0
 public void Delete(string id)
 {
     NewContext.DeleteRelyingParty(DefaultPartitionKey, id);
 }
Example #22
0
 public void Update(RelyingParty relyingParty)
 {
     NewContext.UpdateRelyingParty(relyingParty.ToEntity(relyingParty.Id));
 }
Example #23
0
 public void Add(RelyingParty relyingParty)
 {
     NewContext.AddRelyingParty(relyingParty.ToEntity());
 }
Example #24
0
 public ArrayFixture()
 {
     NewContext.GenerateAndRegisterArrayConverter <ImageInfo>();
 }
Example #25
0
 public NewController(NewContext context)
 {
     _context = context;
 }
Example #26
0
        static void Main(string[] args)
        {
            Context db = new Context();

            Console.WriteLine(db.Database.CanConnect());

            NewContext db2 = new NewContext();

            Messurement current = new Messurement();

            Stopwatch watch = new Stopwatch();

            watch.Start();



            List <User> users2 = db.Users.Include("Contents.Entries").Include("Contents").Include("Contents").ToList();

            List <User> user3 = db2.Users.ToList();

            db2.Users.RemoveRange(user3.Take(2));
            db2.SaveChanges();


            db.Users.RemoveRange(db.Users.Skip(40));
            db.SaveChanges();

            List <User> users = db.Users.Include(x => x.Contents).ThenInclude(x => x.Entries).Include(x => x.Settings).ToList(); //db.Users.Include(x => x.Contents).Include(x => x.Settings).ToList();

            List <Content> contents = db.Contents.Include(x => x.User).ToList();

            watch.Stop();
            current.TimeRead   = watch.Elapsed;
            current.EntryCount = users.Count + contents.Count;
            Console.WriteLine((users.Count + contents.Count) + " Werte in " + watch.ElapsedMilliseconds + " ms gelesen");

            watch.Restart();

            User us = new User()
            {
                Name     = "Morris Janatzek",
                Username = "",
                Type     = User.UserType.Manager,
                Test     = 2
            };

            db.Users.Add(us);

            User us3 = new User()
            {
                Name     = "Morris Janatzek",
                Username = ""
            };

            db2.Users.Add(us3);

            db2.SaveChanges();

            db.SaveChanges();

            db.Users.Remove(db.Users.FirstOrDefault());

            db.SaveChanges();

            Content c = new Content()
            {
                Text   = "Test",
                UserId = us.Id
            };

            db.Contents.Add(c);

            db.ContentEntries.Add(new ContentEntry()
            {
                Text      = "das ist in set",
                ContentId = c.Id
            });

            db.Users.Add(new User()
            {
                Username = "******",
                Name     = "Test Test"
            });

            db.Users.Add(new User()
            {
                Username = "******",
                Name     = "Test Test 2"
            });

            db.Users.Add(new User()
            {
                Username = "******",
                Name     = "Test Test 3"
            });

            db.SaveChanges();

            watch.Stop();
            current.TimeWrite = watch.Elapsed;
            Console.WriteLine("Werte in " + watch.ElapsedMilliseconds + " ms geschrieben");

            db.Messurements.Add(current);
            db.SaveChanges();

            db.Generics.Add(new GenericTest <int>()
            {
                Value = 1
            });

            db.Generics.Add(new GenericTest <int>()
            {
                Value = 2
            });


            db.SaveChanges();

            Console.WriteLine(db.Generics.Count());

            while (true)
            {
                string result = Console.ReadLine();

                if (result != "q")
                {
                    db.Users.Add(new User()
                    {
                        Username = "******",
                        Name     = "Test User"
                    });

                    db.SaveChanges();

                    continue;
                }

                break;
            }

            Context db3 = new Context();
            Context db4 = new Context();

            List <User> users3 = db3.Users.ToList();

            db4.Users.Add(new User()
            {
                Name     = "Morris Janatzek",
                Username = "******"
            });

            db4.SaveChanges();

            users3 = db3.Users.ToList();

            Console.WriteLine(db.Users.Count());

            db.Users.Add(new User()
            {
                Name     = "Test",
                Username = "******"
            });
            db.SaveChanges();

            Console.WriteLine(db.Users.Count());

            Console.ReadKey();
        }
Example #27
0
 public UsersController(NewContext context)
 {
     _context = context;
 }
 public void Delete(ClientCertificate certificate)
 {
     NewContext.DeleteClientCertificate(certificate.ToEntity());
 }
Example #29
0
 public PostsController(NewContext context)
 {
     _context = context;
 }
Example #30
0
 public MapFixture()
 {
     NewContext.GenerateAndRegisterMapConverter <ImageInfo>();
 }