public List<ShowRestPace> Get(int pageNum)
        {
            List<ShowRestPace> showRestPace;
            using (var restContext = new DefaultContext())
            {
                var restPaces = from restPace in restContext.RestPaces
                                let rest = restContext.MonitorRestaurants.FirstOrDefault(x => x.ID == restPace.RestaurantId)
                                orderby rest.Name
                                select new
                                {
                                    restPace,
                                    rest
                                };
                showRestPace =
                    restPaces.AsNoTracking().Pageing(pageNum, PageSize, ref _pageCount).ToList().Select(x => new ShowRestPace()
                    {
                        ID = x.restPace.ID,
                        RestaurantName = x.rest.Name,
                        SqlCommand = x.restPace.SqlCommand,
                        SendTime = x.restPace.SendTime,
                        ReceiptText = x.restPace.ReceiptText,
                        ReceiveTime = x.restPace.ReceiveTime,
                    }).ToList();
            }

            return showRestPace;
        }
Example #2
0
 public List<IShowBranch> GetBranches()
 {
     Dictionary<Guid, List<Branch>> allBranch;
     using (var context = new DefaultContext())
     {
         allBranch = context.Branches.AsNoTracking().Where(x => x.Enble).GroupBy(x => x.PreBranch).ToDictionary(x => x.Key, x => x.OrderBy(y => y.SortID).ToList());
     }
     if (!allBranch.Any() || !allBranch.ContainsKey(Guid.Empty))
     {
         return new List<IShowBranch>();
     }
     var firstBranch = allBranch[Guid.Empty].ToList();
     var resultBranch = new List<IShowBranch>();
     foreach (var branch in firstBranch)
     {
         var dataBranch = ShowBranch.CreateShowBranch(branch);
         if (allBranch.ContainsKey(branch.ID))
         {
             dataBranch.Branches = new List<ShowBranch>();
             foreach (var branch1 in allBranch[branch.ID])
             {
                 dataBranch.Branches.Add(ShowBranch.CreateShowBranch(branch1));
             }
         }
         else
         {
             dataBranch.Branches = new List<ShowBranch>();
         }
         resultBranch.Add(dataBranch);
     }
     Flag = true;
     return resultBranch;
 }
        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;

        }
        public List<ShowWorkRecord> GetAllRecords(DateTime selectTime, Guid departmentId)
        {
            var showWorkRecords = new List<ShowWorkRecord>();

            using (var workContext = new DefaultContext())
            {
                var beginTime = selectTime.Date;
                var endTime = selectTime.Date.AddDays(1);
                var workRecords = (
                                from workRecord in workContext.WorkRecords.Where(x => x.CreateTime > beginTime && x.CreateTime < endTime)
                                join account1 in workContext.Accounts on workRecord.AccountId equals account1.ID
                                join workCard in workContext.WorkCards on workRecord.AccountId equals workCard.AccountId
                                where departmentId == Guid.Empty || workCard.DepartmentId == departmentId
                                orderby workRecord.CreateTime descending
                                select new
                                {
                                    workRecord,
                                    account1
                                }).AsNoTracking();

                showWorkRecords.AddRange(workRecords.ToList().Select(x => ShowWorkRecord.CreateWorkRecord(x.workRecord, x.account1)));

            }
            return showWorkRecords;
        }
Example #5
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 List<ShowRestaurant> GetAll(Guid cityId, string restName, int pageNum)
        {
            Expression<Func<MonitorRestaurant, bool>> restaurantExpression = x => true;
            Expression<Func<MonitorRestaurant, bool>> restaurantNameExpression = x => true;
            if (Guid.Empty != cityId)
            {
                restaurantExpression = x => x.City == cityId;
            }
            Guid restaurant;
            if (!string.IsNullOrEmpty(restName))
            {
                if (Guid.TryParse(restName, out restaurant))
                {
                    restaurantNameExpression = x => x.ID == restaurant;
                }
                else
                {
                    restaurantNameExpression = x => x.Name.Contains(restName) || x.SubName.Contains(restName);
                }
            }
            var showRests = new List<ShowRestaurant>();
            using (var restContext = new DefaultContext())
            {
                var restLists =
                    (from monitorRestaurant in restContext.MonitorRestaurants
                        .Where(restaurantExpression).Where(restaurantNameExpression)
                     orderby monitorRestaurant.SubName
                     orderby monitorRestaurant.Name
                     select monitorRestaurant).AsNoTracking().Pageing(pageNum, PageSize, ref _pageCount).ToList();

                showRests.AddRange(restLists.Select(ShowRestaurant.CreateShowRestaurant));

            }
            return showRests;
        }
Example #7
0
        public List<ShowAccount> GetAccounts(int pageNum, Guid accountId)
        {
            var accounts = new List<ShowAccount>();
            using (var defaultContent = new DefaultContext())
            {
                var account = defaultContent.Accounts.SingleOrDefault(x => x.ID == accountId);
                if (account.Null())
                {
                    return new List<ShowAccount>();
                }
                var accountList = new List<Account>();
                if ((account.AccountType & AccountType.Admin) != 0)
                {
                    accountList = defaultContent.Accounts.OrderByDescending(x => x.CreateTime)
                        .Pageing(pageNum, PageSize, ref _pageCount).ToList();
                }
                else
                {
                    accountList = defaultContent.Accounts.Where(x => (x.AccountType & AccountType.Admin) == 0).OrderByDescending(x => x.CreateTime)
                        .Pageing(pageNum, PageSize, ref _pageCount).ToList();
                }

                accounts.AddRange(accountList.Select(ShowAccount.CreateShowAccount));
            }
            return accounts;
        }
 /// <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;
     }
 }
        public List<ShowWeeklyPlan> Get(Guid accountId, int pageNum)
        {
            var showWeeklyPlans = new List<ShowWeeklyPlan>();
            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 List<ShowWeeklyPlan>();
                }

                var preWeeklyPalns = (from target in workContext.WeekTargets
                                      let summ = workContext.WeekSummaries.FirstOrDefault(x => x.ID == target.ID)
                                      where target.DepartmentId == workCard.card.DepartmentId
                                      orderby target.WeekNum descending
                                      select new
                                      {
                                          target,
                                          summ
                                      }).Pageing(pageNum, PageSize, ref _pageCount);
                showWeeklyPlans.AddRange(preWeeklyPalns.Select(x => ShowWeeklyPlan.CreateShowWeeklyPlan(x?.summ, x?.target, workCard?.department)));
            }
            return showWeeklyPlans;
        }
        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;
        }
        public UpdateTrackPlan Get(Guid trackPlanId)
        {
            using (var defaultContext = new DefaultContext())
            {
                var trackPlan = defaultContext.TrackPlans.SingleOrDefault(x => x.ID == trackPlanId);

                return UpdateTrackPlan.CreateUpdateTrackPlan(trackPlan);
            }
        }
 /// <summary>
 /// 获取用户的权限
 /// </summary>
 /// <param name="accountId"></param>
 /// <returns></returns>
 public List<Guid> GetJurisdiction(Guid accountId)
 {
     Flag = true;
     using (var defaultContext = new DefaultContext())
     {
         var jurisdictions = defaultContext.Jurisdictions.Where(x => x.AccountID == accountId).AsNoTracking().ToList();
         return jurisdictions.Select(x => x.BranchId).ToList();
     }
 }
        public UpdateTrackTarget Get(Guid trackTargetId)
        {
            using (var defaultContext = new DefaultContext())
            {
                var trackTarget = defaultContext.TrackTargets.SingleOrDefault(x => x.ID == trackTargetId);

                return UpdateTrackTarget.CreateUpdateTrackTarget(trackTarget);
            }
        }
        private void Add(UpdateTrackPlan updateTrackPlan)
        {
            using (var defaultContext = new DefaultContext())
            {
                defaultContext.TrackPlans.Add(updateTrackPlan.Create());
                defaultContext.SaveChanges();
            }

            Flag = true;
        }
Example #15
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;
        }
 public List<ShowDepartment> Get()
 {
     var showDepartments = new List<ShowDepartment>();
     using (var accountContext = new DefaultContext())
     {
         var departments = accountContext.Departments.OrderByDescending(x => x.CreateTime).ToList();
         showDepartments.AddRange(departments.Select(ShowDepartment.CreateShowDepartment));
     }
     Flag = true;
     return showDepartments;
 }
 public void Execution()
 {
     using (var content = new DefaultContext())
     {
         var letterList = content.Letters.Where(x => x.CreateTime >= BeginTime && x.CreateTime < EndTime).AsNoTracking().ToList();
         foreach (var letter in letterList)
         {
             showLetters.Add(ShowLetter.CreateShowLetter(letter));
         }
     }
     Flag = true;
 }
        public List<ISelectTrackPlan> Get()
        {
            var showTrackPlans = new List<ISelectTrackPlan>();
            using (var defaultContext = new DefaultContext())
            {
                //.Where(x => x.BeginTime < DateTime.Now && x.EndTime > DateTime.Now)
                var trackPlans = defaultContext.TrackPlans.OrderByDescending(x => x.CreateTime).AsNoTracking();

                showTrackPlans.AddRange(trackPlans.Select(ShowTrackPlan.CreateShowTrackPlan));
            }
            return showTrackPlans;
        }
        public List<ShowTrackPlan> Get(int pageNum)
        {
            var showTrackPlans = new List<ShowTrackPlan>();
            using (var defaultContext = new DefaultContext())
            {
                var trackPlans = defaultContext.TrackPlans.OrderByDescending(x => x.CreateTime).AsNoTracking()
                    .Pageing(pageNum, PageSize, ref _pageCount);

                showTrackPlans.AddRange(trackPlans.Select(ShowTrackPlan.CreateShowTrackPlan));
            }
            return showTrackPlans;
        }
        public int Clear()
        {
            int result = 0;
            using (var defaultContext = new DefaultContext())
            {
                var monitorDbName = defaultContext.Database.Connection.Database;
                string sql = $"DELETE [{monitorDbName}].dbo.MonitorRestaurants";
                result = defaultContext.Database.ExecuteSqlCommand(sql);

            }
            Flag = true;
            return result;
        }
Example #22
0
 public ShowLetter GetLetter(Guid id)
 {
     Flag = true;
     using (var content = new DefaultContext())
     {
         var letter = content.Letters.AsNoTracking().FirstOrDefault(x => x.ID == id);
         if (letter == null)
         {
             return new ShowLetter();
         }
         return ShowLetter.CreateShowLetter(letter);
     }
 }
 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 #24
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;
 }
Example #25
0
        public List<ShowJournal> GetJournals(int pageNum)
        {
            var showJournals = new List<ShowJournal>();
            using (var content = new DefaultContext())
            {
                var journals = content.Journals.AsNoTracking().OrderByDescending(x => x.CreateTime).Pageing(pageNum, PageSize, ref _pageCount).ToList();

                foreach (var journal in journals)
                {
                    showJournals.Add(ShowJournal.CreateShowJournal(journal));
                }
            }
            return showJournals;
        }
        public List<ShowTrackTarget> Get(int pageNum)
        {
            var showTrackPlans = new List<ShowTrackTarget>();
            using (var defaultContext = new DefaultContext())
            {
                var trackTargets = defaultContext.TrackTargets.OrderByDescending(x => x.PlanId).ThenByDescending(x => x.CreateTime).AsNoTracking()
                    .Pageing(pageNum, PageSize, ref _pageCount);
                var trackPlanIds = trackTargets.Select(x => x.PlanId).Distinct().ToList();
                var trackPlan = defaultContext.TrackPlans.Where(x => trackPlanIds.Contains(x.ID));


                showTrackPlans.AddRange(trackTargets.Select(x => ShowTrackTarget.CreateShowTrackTarget(x, trackPlan.ToList())));
            }
            return showTrackPlans;
        }
Example #27
0
        public List<ShowAccount> GetAccountsByDepartment(Guid departmentId)
        {
            var showAccounts = new List<ShowAccount>();

            using (var defaultContent = new DefaultContext())
            {
                var accountList = from account in defaultContent.Accounts
                                  join workCard in defaultContent.WorkCards on account.ID equals workCard.AccountId
                                  where workCard.DepartmentId == departmentId
                                  select account;

                showAccounts.AddRange(accountList.ToList().Select(ShowAccount.CreateShowAccount));
            }
            return showAccounts;
        }
Example #28
0
        public void Init()
        {
            var monitorDbName = string.Empty;
            int result = 0;
            using (var restContext = new DefaultContext())
            {
                monitorDbName = restContext.Database.Connection.Database;
                string sql = string.Format("DELETE [{0}].dbo.MonitorCities", monitorDbName);
                result = restContext.Database.ExecuteSqlCommand(sql);

                sql = string.Format("INSERT INTO [{1}].dbo.MonitorCities (ID,Name) SELECT a.ID,a.Name from {0}.dbo.Cities a ", AuspiciousCache.MonitorDatabase, monitorDbName);
                result = restContext.Database.ExecuteSqlCommand(sql);
            }
            Flag = true;
        }
        public ShowDepartment Get(Guid departmentId)
        {
            using (var accountContext = new DefaultContext())
            {
                var department = accountContext.Departments.SingleOrDefault(x => x.ID == departmentId);
                if (department == null)
                {
                    return null;
                }
                var showDepartments = ShowDepartment.CreateShowDepartment(department);

                Flag = true;
                return showDepartments;
            }
        }
Example #30
0
 public UpdateCard GetCard(int cardId)
 {
     var updateCard = new UpdateCard();
     using (var defaultContext = new DefaultContext())
     {
         var systemCard = defaultContext.SystemCards.FirstOrDefault(x => x.ID == cardId);
         if (systemCard.Null())
         {
             Message = "未找到要修改的配置";
             return updateCard;
         }
         updateCard = UpdateCard.CreateUpdateCard(systemCard);
         Flag = true;
         return updateCard;
     }
 }