Exemplo n.º 1
0
        private bool findCluster(Report report)
        {
            if (exist(report))
            {
                return(true);
            }

            using (var context = new DB14())
            {
                var studentAndCourseList = context.C.ToList();
                if (studentAndCourseList.Count == 0)
                {
                    return(false);
                }

                foreach (Cluster c in studentAndCourseList)
                {
                    c.list = context.R.Where(l => l.ClusterId == c.Id).ToList();
                    if (c.Belong(report))
                    {
                        c.push(report);
                        CalcAvgLoc(c); /// get real location by algo

                        context.SaveChanges();
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        public async Task labelDataAsync(string s, string token)
        {
            using (var context = new DB14())
            {
                var a = context.A.ToList();
                List = context.C.ToList();

                LogEvent task = log.LogMessege("labeld data", true);

                foreach (Cluster c in List)
                {
                    var d = context.R.ToList();
                    c.list = context.R.Where(l => l.ClusterId == c.Id).ToList();

                    foreach (Report r in c)
                    {
                        if (r.needAttr())
                        {
                            await FindLocAsync(r, s, token, task);
                        }
                    }
                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 3
0
 private void createNewCluster(Report report)
 {
     using (var context = new DB14())
     {
         log.LogMessege("create new");
         var nr = new Cluster(report);
         //context.R.Add(report);
         context.C.Add(nr);
         log.LogMessege("try save the new one");
         context.SaveChanges();
         //list.Add();
         log.LogMessege("create new Clusters at " + report.GetDateTime().ToString(), false);
     }
 }
Exemplo n.º 4
0
 public void Save()
 {
     using (var ctx = new DB14())
     {
         var t1 = ctx.R.ToList();
         var t2 = ctx.C.ToList();
         var t3 = ctx.A.ToList();
         foreach (var l in List)
         {
             var resToUpdate = ctx.C.AsNoTracking().Select(x => x.Id == l.Id);
             if (resToUpdate != null)
             {
                 ctx.C.Attach(l);
                 ctx.Entry(l).State = System.Data.Entity.EntityState.Modified;
             }
             else
             {
                 ctx.C.Add(l);
             }
         }
         log.LogMessege("saveing");
         ctx.SaveChanges();
     }
 }