private void LoadOperationProjectCompleted(LoadOperation<ProductManager.Web.Model.project> aLoadOperation)
 {
     ProjectEntityList.Clear();
     foreach (ProductManager.Web.Model.project project in aLoadOperation.Entities)
     {
         ProjectEntity projectEntity = new ProjectEntity();
         projectEntity.Project = project;
         projectEntity.Update();
         ProjectEntityList.Add(projectEntity);
     }
     IsBusy = false;
 }
        private void loadOperationProject_Completed(object sender, EventArgs e)
        {
            ProjectEntityDictionary.Clear();
            LoadOperation loadOperation = sender as LoadOperation;
            foreach (ProductManager.Web.Model.project project in loadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.Update();
                ProjectEntityDictionary.Add(projectEntity.ManufactureNumber, projectEntity);
            }

            this.productSource = new EntityList<ProductManager.Web.Model.product>(this.ProductDomainContext.products);
            this.productLoader = new DomainCollectionViewLoader<ProductManager.Web.Model.product>(
                this.LoadProductEntities,
                this.LoadOperationProductCompleted);
            this.productView = new DomainCollectionView<ProductManager.Web.Model.product>(this.productLoader, this.productSource);
            using (this.productView.DeferRefresh())
            {
                this.productView.MoveToFirstPage();
            }
        }
        void loadOperationProject_Completed(object sender, EventArgs e)
        {
            ProjectEntityDictionary.Clear();
            LoadOperation loadOperation = sender as LoadOperation;

            foreach (ProductManager.Web.Model.project project in loadOperation.Entities)
            {
                ProjectEntity projectEnttiy = new ProjectEntity();
                projectEnttiy.Project = project;
                projectEnttiy.Update();
                ProjectEntityDictionary.Add(projectEnttiy.ManufactureNumber, projectEnttiy);
            }

            LoadOperation<ProductManager.Web.Model.department> loadOperationDepartment =
                SystemManageDomainContext.Load<ProductManager.Web.Model.department>(SystemManageDomainContext.GetDepartmentQuery());
            loadOperationDepartment.Completed += loadOperationDepartment_Completed_Dictionary;
        }
 private void LoadOperationProjectCompleted(LoadOperation<ProductManager.Web.Model.project> aLoadOperation)
 {
     ProjectEntityList.Clear();
     ProjectFilesEntityList.Clear();
     foreach (ProductManager.Web.Model.project project in aLoadOperation.Entities)
     {
         ProjectEntity projectEntity = new ProjectEntity();
         projectEntity.Project = project;
         projectEntity.Update();
         ProjectEntityList.Add(projectEntity);
     }
     if (aLoadOperation.TotalEntityCount != -1)
     {
         this.projectView.SetTotalItemCount(aLoadOperation.TotalEntityCount);
     }
     UpdateChanged("ProjectEntityList");
     UpdateChanged("CollectionProjectView");
     UpdateChanged("ProjectFilesEntityList");
     UpdateChanged("RecorderCount");
     this.IsBusy = false;
 }
        private void LoadOperationPlanCompleted(LoadOperation<plan> aLoadOperation)
        {
            planRemindList.Clear();
            App app = Application.Current as App;
            planRemindList = new ObservableCollection<PlanEntity>();
            if (null != app.UserInfo)
            {
                string userName = app.UserInfo.UserName;

                IEnumerable<string> project_responsibles_MN =
                                                      from c in productDomainContext.project_responsibles
                                                      where c.responsible_persionName == app.UserInfo.UserName
                                                      || (app.UserInfo.IsManager ? c.department_id == app.UserInfo.DepartmentID : false)
                                                      select c.manufacture_number;

                if (0 != project_responsibles_MN.Count())
                {
                    foreach (string itemMN in project_responsibles_MN)
                    {
                        IEnumerable<project> projects =
                                                      from c in planManagerDomainContext.projects
                                                      where c.manufacture_number == itemMN
                                                      select c;
                        if (0 == projects.Count())
                        {
                            continue;
                        }

                        project projectInfo = projects.First<project>();
                        if (string.IsNullOrEmpty(projectInfo.plan_version_id)
                            || (projectInfo.isdelete.HasValue && projectInfo.isdelete.Value))
                        {
                            continue;
                        }
                        ProjectEntity projectDetail = new ProjectEntity();
                        projectDetail.Project = projectInfo;
                        projectDetail.Update();

                        UserRemindEntity lUserRemindEntity;
                        if (UserRemindEntityDicationary.TryGetValue(projectDetail.ManufactureNumber, out lUserRemindEntity))
                        {
                            projectDetail.UserRemindEntity = lUserRemindEntity;
                        }

                        IEnumerable<string> respUserName = from c in productDomainContext.project_responsibles
                                                           where c.manufacture_number == itemMN && c.department_id == app.UserInfo.DepartmentID
                                                           select c.responsible_persionName;

                        String respUserNameString = respUserName.First();

                        IEnumerable<plan> plans;
                        if (app.UserInfo.DepartmentID != 1000)
                        {
                            plans = from c in planManagerDomainContext.plans
                                    where c.manufacture_number == itemMN && c.department_id == app.UserInfo.DepartmentID
                                              && c.version_id == projectInfo.plan_version_id
                                    select c;
                        }
                        else
                        {
                            plans = from c in planManagerDomainContext.plans
                                    where c.manufacture_number == itemMN && c.version_id == projectInfo.plan_version_id
                                    select c;
                        }
                        //IEnumerable<plan> plans = from c in planManagerDomainContext.plans
                        //                          where c.manufacture_number == itemMN && c.department_id == app.UserInfo.DepartmentID
                        //                                    && c.version_id == projectInfo.plan_version_id
                        //                          select c;
                        foreach (plan planItem in plans)
                        {
                            if (planItem.accomplish_date.HasValue)
                            {
                                continue;
                            }

                            int remindDay = ("设计节点" == planItem.sheet_name) ? projectDetail.RemindDayDesign :
                                (("采购节点" == planItem.sheet_name) ? projectDetail.RemindDayPurchase : projectDetail.RemindDayProduce);

                            Nullable<DateTime> targetDateTime = planItem.target_date_adjustment2.HasValue ? planItem.target_date_adjustment2.Value :
                                                (planItem.target_date_adjustment1.HasValue ? planItem.target_date_adjustment1.Value : planItem.target_date);

                            if (!targetDateTime.HasValue)
                            {
                                continue;
                            }

                            DateTime currentDateTime = DateTime.Now;
                            TimeSpan difference = targetDateTime.Value - currentDateTime;

                            if (difference.Days > remindDay)
                            {
                                continue;
                            }

                            PlanEntity planEntity = new PlanEntity();
                            planEntity.Plan = planItem;
                            planEntity.Update();
                            planEntity.Plan = null;
                            planEntity.PlanRemindDay = remindDay;
                            planEntity.ProjectName = projectInfo.project_name;
                            planEntity.TargetDate = targetDateTime.Value;
                            planEntity.RespUserName = respUserNameString;
                            string getDepartmentName;
                            if (departmentIdNameDictionary.TryGetValue(planEntity.DepartmentId, out getDepartmentName))
                            {
                                planEntity.DepartmentName = getDepartmentName;
                            }
                            planRemindList.Add(planEntity);
                        }
                    }
                }
            }
            UpdateChanged("planRemindList");
            IsBusy = false;
        }
        private void LoadOperationProjectCompleted(LoadOperation<project> aLoadOperation)
        {
            projectRecentUpdateList.Clear();
            DateTime currentDateTime = DateTime.Now;
            foreach (project projectItem in aLoadOperation.Entities)
            {
                if (!projectItem.plan_update_date.HasValue)
                {
                    continue;
                }

                TimeSpan difference = projectItem.plan_update_date.Value - currentDateTime;
                if (difference.Days >= 7)
                {
                    continue;
                }

                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = projectItem;
                projectEntity.Update();
                projectEntity.Project = null;
                projectRecentUpdateList.Add(projectEntity);
            }

            planManagerDomainContext.plans.Clear();

            planSource = new EntityList<plan>(planManagerDomainContext.plans);
            planLoader = new DomainCollectionViewLoader<plan>(
                LoadPlanEntities,
                LoadOperationPlanCompleted);
            planView = new DomainCollectionView<plan>(planLoader, planSource);
            using (planView.DeferRefresh())
            {
                planView.MoveToFirstPage();
            }
        }
        private void LoadOperationProjectCompleted(LoadOperation<project> aLoadOperation)
        {
            ProjectList.Clear();
            foreach (project project in aLoadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.Update();
                if (!String.IsNullOrEmpty(projectEntity.PlanVersionID))
                {
                    IEnumerable<plan_extra> plan_extras = from c in planManagerDomainContext.plan_extras
                                                          where c.version_id == projectEntity.PlanVersionID
                                                            && c.manufacture_number == projectEntity.ManufactureNumber
                                                          select c;
                    if (0 != plan_extras.Count())
                    {
                        plan_extra planExtra = plan_extras.First<plan_extra>();
                        projectEntity.CompileUserName = planExtra.compile_user_name;
                        projectEntity.CompileDate = planExtra.compile_date;
                    }

            //                     IEnumerable<string> planVersions = from c in planManagerDomainContext.plans
            //                                                           where c.manufacture_number == projectEntity.ManufactureNumber
            //                                                           select c.version_id;
                    if (!string.IsNullOrEmpty(project.plan_version_id))
                    {
            //                         projectEntity.PlanVersionDictionary = new Dictionary<string, string>();
            //                         foreach (string item in planVersions)
            //                         {
            //                             if (projectEntity.PlanVersionDictionary.ContainsKey(item))
            //                             {
            //                                 continue;
            //                             }
            //                             projectEntity.PlanVersionDictionary.Add(item, item);
            //                         }
                        projectEntity.HasHistory = true;
                    }
                }

                UserProjectEntity lUserProjectEntity;
                if (UserProjectEntityDictionary.TryGetValue(projectEntity.ManufactureNumber, out lUserProjectEntity))
                {
                    projectEntity.UserProjectEntity = lUserProjectEntity;
                    projectEntity.SetIsUserProject(true);
                }

                projectEntity.UserProjectEntityDictionary = UserProjectEntityDictionary;
                if (IsUserProject && !projectEntity.IsUserProject)
                {
                    continue;
                }

                UserRemindEntity lUserRemindEntity;
                if (UserRemindEntityDicationary.TryGetValue(projectEntity.ManufactureNumber, out lUserRemindEntity))
                {
                    projectEntity.UserRemindEntity = lUserRemindEntity;
                }

                projectEntity.PlanManagerDomainContext = planManagerDomainContext;

                ProjectList.Add(projectEntity);
            }
            if (aLoadOperation.TotalEntityCount != -1)
            {
                this.projectView.SetTotalItemCount(aLoadOperation.TotalEntityCount);
            }
            UpdateChanged("ProjectList");
            this.IsBusy = false;
        }
        void loadOperationProject_Completed(object sender, EventArgs e)
        {
            ProjectList.Clear();
            LoadOperation loadOperation = sender as LoadOperation;
            foreach (ProductManager.Web.Model.project project in loadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.Update();
                ProjectList.Add(projectEntity);
            }

            UpdateChanged("ProjectList");
            IsBusy = false;
        }
        private void loadOperationProject_Completed(object sender, EventArgs e)
        {
            ProjectEntityDictionary.Clear();

            LoadOperation loadOperation = sender as LoadOperation;
            foreach (ProductManager.Web.Model.project project in loadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.Update();
                ProjectEntityDictionary.Add(projectEntity.ManufactureNumber, projectEntity);
            }

            LoadOperation<ProductManager.Web.Model.user> loadOperationUser =
                SystemManageDomainContext.Load<ProductManager.Web.Model.user>(SystemManageDomainContext.GetUserQuery());
            loadOperationUser.Completed += loadOperationUser_Completed;
        }
        private void LoadOperationProjectCompleted(LoadOperation<ProductManager.Web.Model.project> aLoadOperation)
        {
            ProjectEntityList.Clear();
            UserProjectCount = 0;
            foreach (ProductManager.Web.Model.project project in aLoadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.ProjectEntityDictionary = ProjectEntityDictionary;
                projectEntity.Update();

                UserProjectEntity lUserProjectEntity;
                if (UserProjectEntityDictionary.TryGetValue(projectEntity.ManufactureNumber, out lUserProjectEntity))
                {
                    projectEntity.UserProjectEntity = lUserProjectEntity;
                    projectEntity.SetIsUserProject(true);
                }

                projectEntity.UserProjectEntityDictionary = UserProjectEntityDictionary;
                projectEntity.ProductManagersViewModel = this;
                projectEntity.ProductDomainContext = ProductDomainContext;
                if (IsUserProject && !projectEntity.IsUserProject)
                {
                    continue;
                }
                ProjectEntityList.Add(projectEntity);
                UserProjectCount++;
            }
            if (aLoadOperation.TotalEntityCount != -1)
            {
                this.projectView.SetTotalItemCount(aLoadOperation.TotalEntityCount);
            }
            UpdateChanged("ProjectEntityList");
            UpdateChanged("RecorderCount");
            this.IsBusy = false;
        }
        private void LoadOperationProjectCompleted(LoadOperation<ProductManager.Web.Model.project> aLoadOperation)
        {
            ResponsiblePersonEntityList.Clear();
            ProjectEntityDictionary.Clear();

            foreach (ProductManager.Web.Model.project project in aLoadOperation.Entities)
            {
                ProjectEntity lProjectEntity = new ProjectEntity();
                lProjectEntity.Project = project;
                lProjectEntity.Update();
                ProjectEntityDictionary.Add(lProjectEntity.ManufactureNumber, lProjectEntity);
            }

            using (projectResponsibleView.DeferRefresh())
            {
                projectResponsibleView.MoveToFirstPage();
            }
        }