public void Add(List<HeartbeatBody> heartbeatBodys, Guid machineId)
        {
            var oldHeartbeatIDs = heartbeatBodys.Select(x => x.LogTime);

            using (var monitorContext = new DefaultContext())
            {
                var oldHeartbeats = monitorContext.Heartbeats.Where(x => oldHeartbeatIDs.Contains(x.LogTime) && x.MachineId == machineId);
                if (oldHeartbeats.Any())
                {
                    monitorContext.Heartbeats.RemoveRange(oldHeartbeats);
                }

                foreach (var heartbeatBody in heartbeatBodys)
                {
                    var heartbeat = new Heartbeat();
                    heartbeat.ID = Guid.NewGuid();
                    heartbeat.CreateTime = DateTime.Now;
                    heartbeat.LogTime = heartbeatBody.LogTime;
                    heartbeat.MachineId = machineId;
                    heartbeat.AvgNum = heartbeatBody.AvgNum;
                    heartbeat.MaxNum = heartbeatBody.MaxNum;
                    heartbeat.HourTime = heartbeatBody.HourTime;
                    heartbeat.AvgMemory = heartbeatBody.AvgMemory;
                    heartbeat.MaxMemory = heartbeatBody.MaxMemory;
                    monitorContext.Heartbeats.Add(heartbeat);
                }
                monitorContext.SaveChanges();
            }
            Flag = true;
        }
Example #2
0
        public void SendLetter(UpdateLetter updateLetter)
        {
            var letter = updateLetter.CreateLetter();
            letter.ReplyTime = SqlDateTime.MinValue.Value;
            using (var content = new DefaultContext())
            {
                content.Letters.Add(letter);
                content.SaveChanges();
            }
            var dic = new Dictionary<string, string>();
            dic.Add("ActionName", "Reply");
            dic.Add("letter", letter.ToJson());

            var resString = HttpWebResponseUtility.CreatePostHttpResponse("http://second.eagle.com/api/Message", dic.ToJson(), 30000);
            if (string.IsNullOrEmpty(resString) || resString == "0")
            {
                Flag = false;
                Message = "消息无响应";
                return;
            }
            var result = resString.ToDeserialize<Cells>();
            if (!result.Flag)
            {
                Flag = false;
                Message = result.Message;
                return;
            }
            Flag = true;
        }
        public void Execution()
        {
            var letter = updateLetter.CreateLetter();
            letter.CreateTime = ReceiveTime;
            letter.ReplyTime = DateTime.Now;
            using (var content = new DefaultContext())
            {
                content.Letters.Add(letter);
                content.SaveChanges();
            }
            updateLetter.Message = $"CreateTime:{letter.CreateTime},ReplyTime:{letter.ReplyTime}";


            var resString = HttpWebResponseUtility.CreatePostHttpResponse(string.Format("http://{0}/Message/Letter/Reply", SystemConst.PirateAddress), updateLetter.ToJson(), 30000);

            var result = resString.ToDeserialize<Cells>();
            if (!result.Flag)
            {
                Flag = false;
                Message = result.Message;
                return;
            }
            Flag = true;

        }
 /// <summary>
 /// 分配页面权限
 /// </summary>
 /// <param name="accountId"></param>
 /// <param name="addList"></param>
 /// <param name="delList"></param>
 public void Distribution(Guid accountId, List<Guid> addList, List<Guid> delList)
 {
     using (var defaultContent = new DefaultContext())
     {
         var account = defaultContent.Accounts.FirstOrDefault(x => x.ID == accountId);
         if (account.Null())
         {
             Message = "分配账号不存在";
             return;
         }
         if (delList.Any())
         {
             var delBranch = defaultContent.Jurisdictions.Where(x => delList.Contains(x.BranchId) && x.AccountID == accountId).ToList();
             defaultContent.Jurisdictions.RemoveRange(delBranch);
         }
         if (addList.Any())
         {
             foreach (var guid in addList)
             {
                 var jurisdiction = new Jurisdiction();
                 jurisdiction.ID = Guid.NewGuid();
                 jurisdiction.AccountID = accountId;
                 jurisdiction.BranchId = guid;
                 defaultContent.Jurisdictions.Add(jurisdiction);
             }
         }
         defaultContent.SaveChanges();
         Flag = true;
     }
 }
        private void Add(UpdateTrackPlan updateTrackPlan)
        {
            using (var defaultContext = new DefaultContext())
            {
                defaultContext.TrackPlans.Add(updateTrackPlan.Create());
                defaultContext.SaveChanges();
            }

            Flag = true;
        }
Example #6
0
 private void Add(UpdateCard updateCard)
 {
     var systemCard = updateCard.CreateSystemCard();
     using (var defaultContext = new DefaultContext())
     {
         defaultContext.SystemCards.Add(systemCard);
         defaultContext.SaveChanges();
     }
     Flag = true;
 }
        private void Add(UpdateTrackTarget updateTrackTarget)
        {
            using (var defaultContext = new DefaultContext())
            {
                defaultContext.TrackTargets.Add(updateTrackTarget.Create());
                defaultContext.SaveChanges();
            }

            Flag = true;
        }
Example #8
0
 private void Add(UpdateJournal updateJournal)
 {
     var journal = new Journal();
     journal.ID = Guid.NewGuid();
     journal.ProjectName = updateJournal.ProjectName;
     journal.Path = updateJournal.Path;
     journal.CreateTime = DateTime.Now;
     using (var monitorContext = new DefaultContext())
     {
         monitorContext.Journals.Add(journal);
         monitorContext.SaveChanges();
     }
     Flag = true;
 }
 private void Edit(UpdateTrackPlan updateTrackPlan)
 {
     using (var defaultContext = new DefaultContext())
     {
         var trackPlan = defaultContext.TrackPlans.SingleOrDefault(x => x.ID == updateTrackPlan.ID);
         if (trackPlan.Null())
         {
             return;
         }
         defaultContext.TrackPlans.Add(updateTrackPlan.Create());
         defaultContext.SaveChanges();
     }
     Flag = true;
 }
Example #10
0
 private void Edit(UpdateJournal updateJournal)
 {
     using (var monitorContext = new DefaultContext())
     {
         var journal = monitorContext.Journals.FirstOrDefault(x => x.ID == updateJournal.ID);
         if (journal.Null())
         {
             Message = "请选择要修改的日志";
             return;
         }
         journal.ProjectName = updateJournal.ProjectName;
         journal.Path = updateJournal.Path;
         monitorContext.ModifiedModel(journal);
         monitorContext.SaveChanges();
     }
     Flag = true;
 }
Example #11
0
 private void Edit(UpdateCard updateCard)
 {
     using (var defaultContext = new DefaultContext())
     {
         var systemCard = defaultContext.SystemCards.FirstOrDefault(x => x.ID == updateCard.ID);
         if (systemCard.Null())
         {
             Message = "请选择要修改的服务器";
             return;
         }
         systemCard.Action = updateCard.Action;
         systemCard.CardName = updateCard.CardName;
         systemCard.BranchId = updateCard.BranchId;
         defaultContext.ModifiedModel(systemCard);
         defaultContext.SaveChanges();
     }
     Flag = true;
 }
Example #12
0
 private void Edit(UpdateTree updateTree)
 {
     using (var monitorContext = new DefaultContext())
     {
         var tree = monitorContext.Trees.FirstOrDefault(x => x.ID == updateTree.ID);
         if (tree.Null())
         {
             Message = "请选择要修改的服务器";
             return;
         }
         tree.Name = updateTree.Name;
         tree.Description = updateTree.Description;
         tree.IpAddr = updateTree.IpAddr;
         monitorContext.ModifiedModel(tree);
         monitorContext.SaveChanges();
     }
     Flag = true;
 }
        public ShowWeeklyPlan GetLastWeekPlan(Guid accountId)
        {
            var weekNum = DateTimeUtility.GetWeekOfYear(DateTime.Now);
            using (var workContext = new DefaultContext())
            {
                var workCard = (
                    from card in workContext.WorkCards
                    join department in workContext.Departments on card.DepartmentId equals department.ID
                    where card.AccountId == accountId
                    select new
                    {
                        card,
                        department
                    }).FirstOrDefault();

                if (workCard.Null())
                {
                    return new ShowWeeklyPlan();
                }
                var weeklyPaln = (
                    from target in workContext.WeekTargets
                    let summ = workContext.WeekSummaries.FirstOrDefault(x => x.ID == target.ID)
                    where target.DepartmentId == workCard.card.DepartmentId && target.WeekNum == weekNum
                    select new
                    {
                        target,
                        summ
                    }).FirstOrDefault();
                if (weeklyPaln.Null())
                {
                    var target = new WeekTarget();
                    target.ID = Guid.NewGuid();
                    target.CreateTime = DateTime.Now;
                    target.DepartmentId = (Guid)workCard?.department.ID;
                    target.WeekNum = weekNum;
                    target.Target = "本周日志还没写!!!";
                    target.Progress = 100;
                    workContext.WeekTargets.Add(target);
                    workContext.SaveChanges();
                }
                return ShowWeeklyPlan.CreateShowWeeklyPlan(weeklyPaln?.summ, weeklyPaln?.target,
                    workCard?.department);
            }
        }
Example #14
0
 public void Work(string sqlText)
 {
     var restPace = new RestPace();
     restPace.ID = Guid.NewGuid();
     restPace.SqlCommand = sqlText;
     restPace.SendTime = DateTime.Now;
     restPace.ReceiveTime = SqlDateTime.MinValue.Value;
     restPace.RestaurantId = RestaurantId;
     restPace.ReceiptText = new List<List<string>>().ToJson();
     using (var restContext = new DefaultContext())
     {
         restContext.RestPaces.Add(restPace);
         restContext.SaveChanges();
     }
     var dic = new Dictionary<string, string>();
     dic.Add("messageID", restPace.ID.ToString());
     dic.Add("text", sqlText);
     PushCommandToRest(dic.ToJson());
 }
Example #15
0
        public void Delete(List<Guid> letterIdList)
        {

            using (var context = new DefaultContext())
            {
                var letterList = context.Letters.Where(x => letterIdList.Contains(x.ID)).ToList();
                if (!letterList.Any())
                {
                    Message = "请选择正确的数据";
                    return;
                }
                context.Letters.RemoveRange(letterList);
                context.SaveChanges();
            }
            Flag = true;
        }
Example #16
0
 private void Add(UpdateTree updateTree)
 {
     var tree = new Tree();
     tree.ID = Guid.NewGuid();
     tree.Name = updateTree.Name;
     tree.Description = updateTree.Description;
     tree.IpAddr = updateTree.IpAddr;
     tree.CreateTime = DateTime.Now;
     using (var monitorContext = new DefaultContext())
     {
         monitorContext.Trees.Add(tree);
         monitorContext.SaveChanges();
     }
     Flag = true;
 }
Example #17
0
 public void Delete(List<Guid> treeIdList)
 {
     using (var defalutContent = new DefaultContext())
     {
         var trees = defalutContent.Trees.Where(x => treeIdList.Contains(x.ID));
         if (!trees.Any())
         {
             Message = "请选择要删除的数据";
             return;
         }
         defalutContent.Trees.RemoveRange(trees);
         defalutContent.SaveChanges();
         Flag = true;
     }
 }
        private void Edit(UpdateDepartment updateDepartment)
        {
            using (var accountContext = new DefaultContext())
            {
                var department = accountContext.Departments.SingleOrDefault(x => x.ID == updateDepartment.ID);
                if (department.Null())
                {
                    return;
                }
                department = updateDepartment.UpdateShowDepartment(department);
                accountContext.ModifiedModel(department);
                var workCard =
                    accountContext.WorkCards.FirstOrDefault(x => x.Owner && x.DepartmentId == updateDepartment.ID);

                if (!workCard.Null())
                {
                    if (workCard.AccountId != updateDepartment.ID)
                    {
                        workCard.Owner = false;
                        accountContext.ModifiedModel(workCard);
                    }
                }
                var newWorkCard =
                        accountContext.WorkCards.FirstOrDefault(x => x.AccountId == updateDepartment.OwnerId && x.DepartmentId == updateDepartment.ID);
                if (!newWorkCard.Null())
                {
                    newWorkCard.Owner = true;
                    accountContext.ModifiedModel(newWorkCard);
                }



                accountContext.SaveChanges();
                Flag = true;
            }
        }
 private void EditComment(UpdateWorkComment updateWorkComment)
 {
     using (var workContext = new DefaultContext())
     {
         var workComment = workContext.WorkComments.FirstOrDefault(x => x.ID == updateWorkComment.ID);
         workComment = updateWorkComment.Update(workComment);
         workContext.ModifiedModel(workComment);
         workContext.SaveChanges();
         Flag = true;
     }
 }
 private void Add(UpdateDepartment updateDepartment)
 {
     using (var accountContext = new DefaultContext())
     {
         var department = accountContext.Departments.SingleOrDefault(x => x.Name == updateDepartment.Name);
         if (!department.Null())
         {
             Message = "创建部门已经存在";
             return;
         }
         department = updateDepartment.CreateShowDepartment();
         accountContext.Departments.Add(department);
         accountContext.SaveChanges();
         Flag = true;
     }
 }
Example #21
0
        public void Delete(List<Guid> branchIdList)
        {

            using (var context = new DefaultContext())
            {
                var branchList = context.Branches.Where(x => branchIdList.Contains(x.ID)).ToList();
                if (!branchList.Any())
                {
                    Message = "请选择正确的数据";
                    return;
                }
                context.Branches.RemoveRange(branchList);
                context.SaveChanges();
            }
            Flag = true;
        }
Example #22
0
 private void Edit(UpdateBranch updateBranch)
 {
     using (var context = new DefaultContext())
     {
         var editBranch = context.Branches.FirstOrDefault(x => x.ID == updateBranch.ID);
         if (editBranch.Null())
         {
             Message = "修改菜单不存在";
             return;
         }
         editBranch.Title = updateBranch.Title;
         editBranch.Level = updateBranch.Level;
         editBranch.PreBranch = updateBranch.PreBranch;
         editBranch.SortID = updateBranch.SortID;
         editBranch.Logo = updateBranch.Logo;
         editBranch.ActionName = updateBranch.ActionName;
         editBranch.AreaName = updateBranch.AreaName;
         editBranch.Description = updateBranch.Description;
         context.ModifiedModel(editBranch);
         context.SaveChanges();
     }
 }
 private void Add(UpdateWorkRecord updateWorkRecord, Guid accountId)
 {
     using (var workContext = new DefaultContext())
     {
         var account = workContext.Accounts.FirstOrDefault(x => x.ID == accountId);
         if (account.Null())
         {
             Message = "登录过期,清重新登陆";
             return;
         }
         var workRecord = updateWorkRecord.CreateWorkRecord(account.ID);
         workContext.WorkRecords.Add(workRecord);
         workContext.SaveChanges();
         Flag = true;
     }
 }
 private void Edit(UpdateWorkRecord updateWorkRecord)
 {
     using (var workContext = new DefaultContext())
     {
         var workRecord = workContext.WorkRecords.FirstOrDefault(x => x.ID == updateWorkRecord.ID);
         if (workRecord.Null())
         {
             Message = "被修改日志不存在!";
             return;
         }
         if (workRecord.CreateTime.Date.AddHours(27) < DateTime.Now)
         {
             Message = "日志已经被锁定无法修改!";
             return;
         }
         workRecord = updateWorkRecord.Update(workRecord);
         workContext.ModifiedModel(workRecord);
         workContext.SaveChanges();
         Flag = true;
     }
 }
 public void Delete(UpdateWorkRecord updateWorkRecord)
 {
     using (var workContext = new DefaultContext())
     {
         var workRecord = workContext.WorkRecords.FirstOrDefault(x => x.ID == updateWorkRecord.ID);
         workContext.WorkRecords.Remove(workRecord);
         workContext.SaveChanges();
         Flag = true;
     }
 }
Example #26
0
 public void ReplyLetter(UpdateLetter updateLetter)
 {
     using (var content = new DefaultContext())
     {
         var letter = content.Letters.AsNoTracking().FirstOrDefault(x => x.ID == updateLetter.ID);
         if (letter == null)
         {
             return;
         }
         letter.ReplyTime = DateTime.Now;
         letter.Reply = updateLetter.Message;
         content.ModifiedModel(letter);
         content.SaveChanges();
     }
     Flag = true;
 }
 public void Delete(List<Guid> departmentsList)
 {
     using (var accountContext = new DefaultContext())
     {
         var departmenst = accountContext.Departments.Where(x => departmentsList.Contains(x.ID));
         if (!departmenst.Any())
         {
             Message = "创建部门已经存在";
             return;
         }
         accountContext.Departments.RemoveRange(departmenst);
         accountContext.SaveChanges();
         Flag = true;
     }
 }
 private void AddComment(UpdateWorkComment updateWorkComment, Guid accountId)
 {
     using (var workContext = new DefaultContext())
     {
         var workRecord = workContext.WorkRecords.FirstOrDefault(x => x.ID == updateWorkComment.RecordId);
         if (workRecord.Null())
         {
             Message = "评论日志不存在";
             return;
         }
         var workComment = updateWorkComment.Create(accountId, workRecord.AccountId);
         workContext.WorkComments.Add(workComment);
         workContext.SaveChanges();
         Flag = true;
     }
 }
Example #29
0
 public void Delete(List<Guid> journalList)
 {
     using (var defalutContent = new DefaultContext())
     {
         var journals = defalutContent.Journals.Where(x => journalList.Contains(x.ID));
         if (!journals.Any())
         {
             Message = "请选择要删除的数据";
             return;
         }
         defalutContent.Journals.RemoveRange(journals);
         defalutContent.SaveChanges();
         Flag = true;
     }
 }
Example #30
0
 private void Add(UpdateBranch updateBranch)
 {
     var branch = new Branch();
     branch.ID = Guid.NewGuid();
     branch.Title = updateBranch.Title;
     branch.Enble = true;
     branch.Level = updateBranch.Level;
     branch.PreBranch = updateBranch.PreBranch;
     branch.SortID = updateBranch.SortID;
     branch.Logo = updateBranch.Logo;
     branch.ActionName = updateBranch.ActionName;
     branch.AreaName = updateBranch.AreaName;
     branch.Description = updateBranch.Description;
     using (var context = new DefaultContext())
     {
         branch.SortID = context.Branches.Max(x => x.SortID) + 1;
         context.Branches.Add(branch);
         context.SaveChanges();
     }
 }