public UpdateFileWindowViewModel(ChildWindow aChildWindow, ObservableCollection<FileTypeEntity> aFileTypeEntityList, ObservableCollection<ProjectFilesEntity> aProjectFilesEntityList, ProjectFilesEntity aProjectFileEntity)
        {
            UserFile = new FileUploader.UserFile();
            ProjectFilesEntity = aProjectFileEntity;
            ProjectFilesEntityList = aProjectFilesEntityList;
            FileTypeEntityList = aFileTypeEntityList;
            childWindow = aChildWindow;
            FileTypes = new List<String>();
            App app = Application.Current as App;
            bool lIsPermis;
            if (app.UserInfo.UserAction.TryGetValue(2020100, out lIsPermis))
            {
                if (lIsPermis)
                {
                    FileTypes.Add("合同协议文件");
                    ProjectFilesEntity.fileType = "合同协议文件";
                }
            }

            if (app.UserInfo.UserAction.TryGetValue(2020200, out lIsPermis))
            {
                if (lIsPermis)
                {
                    FileTypes.Add("配置文件");
                    ProjectFilesEntity.fileType = "配置文件";
                }
            }

            Title = "上传文件 生产令号:" + ProjectFilesEntity.ManufactureNumber;

            OnOpenFile = new DelegateCommand(OnOpenFileCommand);
            OnUpdate = new DelegateCommand(OnUpdateCommand, CanUpdateCommand);
            OnCancel = new DelegateCommand(OnCancelCommand);
        }
        public DeleteFileViewWindowViewModel(ChildWindow aChildWindow, ProjectFilesEntity aProjectFileEntity)
        {
            childWindow = aChildWindow;
            ProjectFileEntity = aProjectFileEntity;
            Title = "已删除文件:" + ProjectFileEntity.FileName;

            OnOK = new DelegateCommand(OnOKCommand);
            OnCancel = new DelegateCommand(OnCancelCommand);
        }
        public ModifyFileWindowViewModel(ChildWindow aChildWindow, ObservableCollection<FileTypeEntity> aFileTypeEntityList, ProjectFilesEntity aProjectFileEntity)
        {
            childWindow = aChildWindow;
            FileTypeEntityList = aFileTypeEntityList;

            ProjectFilesEntity = aProjectFileEntity;

            OnOK = new DelegateCommand(OnOKCommand);
            OnCancel = new DelegateCommand(OnCancelCommand);
        }
 private void loadOperationProjectFiles_Completed(LoadOperation<ProductManager.Web.Model.project_files> aLoadOperation)
 {
     ProjectFilesEntityList.Clear();
     //LoadOperation<ProductManager.Web.Model.project_files> loadOperation = sender as LoadOperation<ProductManager.Web.Model.project_files>;
     foreach (ProductManager.Web.Model.project_files project_files in aLoadOperation.Entities)
     {
         ProjectFilesEntity projectFilesEntity = new ProjectFilesEntity();
         projectFilesEntity.ProjectFiles = project_files;
         projectFilesEntity.Update();
         DepartmentEntity lDepartmentEntity;
         if (DepartmentDictionary.TryGetValue(projectFilesEntity.DepartmentID, out lDepartmentEntity))
         {
             projectFilesEntity.DepartmentName = lDepartmentEntity.DepartmentName;
         }
         UserEntity lUserEntity;
         if (UserEntityDictionary.TryGetValue(projectFilesEntity.UserID, out lUserEntity))
         {
             projectFilesEntity.UserName = lUserEntity.CUserName;
         }
         if (UserEntityDictionary.TryGetValue(projectFilesEntity.FileDeletePersionID, out lUserEntity))
         {
             projectFilesEntity.FileDeletePersionName = lUserEntity.CUserName;
         }
         FileTypeEntity lFileTypeEntity;
         if (FileTypeEntityDictionary.TryGetValue(projectFilesEntity.FileTypeID, out lFileTypeEntity))
         {
             projectFilesEntity.FileTypeName = lFileTypeEntity.FileTypeName;
         }
         ProjectFilesEntityList.Add(projectFilesEntity);
     }
     UpdateChanged("ProjectFilesEntityList");
     canConfirm = isLinkProject ? (ProjectFilesEntityList.Count > 0) : (null != SelectProjectFilesEntity);
     UpdateChanged("CanConfirm");
     IsBusy = false;
 }
 private void loadOperationProjectFiles_Completed(object sender, EventArgs e)
 {
     ProjectFilesEntityList.Clear();
     LoadOperation<ProductManager.Web.Model.project_files> loadOperation = sender as LoadOperation<ProductManager.Web.Model.project_files>;
     foreach (ProductManager.Web.Model.project_files project_files in loadOperation.Entities)
     {
         ProjectFilesEntity projectFilesEntity = new ProjectFilesEntity();
         projectFilesEntity.ProjectFiles = project_files;
         projectFilesEntity.Update();
         projectFilesEntity.FileUrl = CustomUri.GetAbsoluteUrl(projectFilesEntity.ManufactureNumber + "/" + projectFilesEntity.FileName);
         DepartmentEntity lDepartmentEntity;
         if (DepartmentEntityDictionary.TryGetValue(projectFilesEntity.DepartmentID, out lDepartmentEntity))
         {
             projectFilesEntity.DepartmentName = lDepartmentEntity.DepartmentName;
         }
         UserEntity lUserEntity;
         if (UserEntityDictionary.TryGetValue(projectFilesEntity.UserID, out lUserEntity))
         {
             projectFilesEntity.UserName = lUserEntity.CUserName;
         }
         FileTypeEntity lFileTypeEntity;
         if (FileTypeEntityDictionary.TryGetValue(projectFilesEntity.FileTypeID, out lFileTypeEntity))
         {
             projectFilesEntity.FileTypeName = lFileTypeEntity.FileTypeName;
         }
         ProjectFilesEntityList.Add(projectFilesEntity);
     }
     IsBusy = false;
 }
 public DeleteFileViewWindow(ProjectFilesEntity aProjectFilesEntity)
 {
     InitializeComponent();
     this.DataContext = new DeleteFileViewWindowViewModel(this, aProjectFilesEntity);
 }
 public UpdateFileWindow(ObservableCollection<FileTypeEntity> aFileTypeEntityList, ObservableCollection<ProjectFilesEntity> aProjectFilesEntityList, ProjectFilesEntity aProjectFileEntity)
 {
     InitializeComponent();
     this.DataContext = new UpdateFileWindowViewModel(this, aFileTypeEntityList, aProjectFilesEntityList, aProjectFileEntity);
 }
 private void OnUpdateFileCommand()
 {
     AddProjectFilesEntity = new ProjectFilesEntity();
     App app = Application.Current as App;
     AddProjectFilesEntity.UserID = app.UserInfo.UserID;
     AddProjectFilesEntity.DepartmentID = app.UserInfo.DepartmentID;
     AddProjectFilesEntity.DepartmentName = app.UserInfo.UserDepartment;
     AddProjectFilesEntity.UserName = app.UserInfo.UserName;
     AddProjectFilesEntity.ManufactureNumber = SelectProjectEntity.ManufactureNumber;
     AddProjectFilesEntity.FileTypeID = 1;
     AddProjectFilesEntity.ProjectFiles = new ProductManager.Web.Model.project_files();
     UpdateFileWindow updateFileWindow = new UpdateFileWindow(FileTypeEntityList, ProjectFilesEntityList, AddProjectFilesEntity);
     updateFileWindow.Closed += updateFileWindow_Closed;
     updateFileWindow.Show();
 }
        void loadOperationAllProjectFiles_Completed(object sender, EventArgs e)
        {
            ProjectFilesEntityList.Clear();
            LoadOperation<ProductManager.Web.Model.project_files> loadOperation = sender as LoadOperation<ProductManager.Web.Model.project_files>;
            foreach (ProductManager.Web.Model.project_files project_files in loadOperation.Entities)
            {
                ProjectFilesEntity projectFilesEntity = new ProjectFilesEntity();
                projectFilesEntity.ProjectFiles = project_files;
                projectFilesEntity.Update();

                Dictionary<String, ProjectFilesEntity> lTempDictionary;
                if (!FilesDictionarys.TryGetValue(projectFilesEntity.manufactureNumber, out lTempDictionary))
                {
                    lTempDictionary = new Dictionary<string, ProjectFilesEntity>();
                    FilesDictionarys.Add(projectFilesEntity.manufactureNumber, lTempDictionary);
                }

                if (lTempDictionary != null)
                {
                    ProjectFilesEntity lFileEntityTemp;
                    if (!lTempDictionary.TryGetValue(projectFilesEntity.FileName, out lFileEntityTemp))
                    {
                        lTempDictionary.Add(projectFilesEntity.FileName, projectFilesEntity);
                    }
                }

            }
            IsBusy = false;
        }
        void linkFileWindow_Closed(object sender, EventArgs e)
        {
            LinkFileWindow linkFileWindow = sender as LinkFileWindow;
            if (linkFileWindow.DialogResult == true)
            {
                App app = Application.Current as App;
                if (linkFileWindow.linkFileViewModel.IsLinkFile)
                {
                    string rManufactureNumber = String.IsNullOrEmpty(linkFileWindow.linkFileViewModel.SelectProjectFilesEntity.RManufactureNumber) ?
                                                    linkFileWindow.linkFileViewModel.SelectProjectFilesEntity.ManufactureNumber :
                                                    linkFileWindow.linkFileViewModel.SelectProjectFilesEntity.RManufactureNumber;
                    foreach (ProjectEntity projectEntity in linkFileWindow.linkFileViewModel.ProjectLinkEntityList)
                    {
                        foreach (ProjectFilesEntity lEntity in linkFileWindow.projectFilesDataGrid.SelectedItems)
                        {
                            if (rManufactureNumber == projectEntity.ManufactureNumber)
                            {
                                continue;
                            }

                            if (IsDuplicate(projectEntity.ManufactureNumber, lEntity))
                            {
                                continue;
                            }

                            AddProjectFilesEntity = new ProjectFilesEntity();
                            AddProjectFilesEntity.DepartmentID = app.UserInfo.DepartmentID;
                            AddProjectFilesEntity.FileDiscript = lEntity.FileDiscript;
                            AddProjectFilesEntity.FileName = lEntity.FileName;
                            AddProjectFilesEntity.FileType = lEntity.FileType;
                            AddProjectFilesEntity.ManufactureNumber = projectEntity.ManufactureNumber;
                            AddProjectFilesEntity.RManufactureNumber = rManufactureNumber;
                            AddProjectFilesEntity.UserID = app.UserInfo.UserID;
                            AddProjectFilesEntity.FileUpdateTime = lEntity.FileUpdateTime;
                            AddProjectFilesEntity.FileTypeID = lEntity.FileTypeID;
                            AddProjectFilesEntity.FileBytes = lEntity.FileBytes;

                            AddProjectFilesEntity.DepartmentName = lEntity.DepartmentName;
                            AddProjectFilesEntity.UserName = lEntity.UserName;
                            AddProjectFilesEntity.FileDeletePersionName = lEntity.FileDeletePersionName;
                            AddProjectFilesEntity.FileTypeName = lEntity.FileTypeName;

                            AddProjectFilesEntity.ProjectFiles = new ProductManager.Web.Model.project_files();
                            ProjectFilesEntityList.Add(AddProjectFilesEntity);
                            AddProjectFilesEntity.DUpdate();
                            ProductDomainContextForFile.project_files.Add(AddProjectFilesEntity.ProjectFiles);
                        }

                    }
                }
                else
                {
                    foreach (ProjectEntity projectEntity in linkFileWindow.linkFileViewModel.ProjectLinkEntityList)
                    {
                        foreach (ProjectFilesEntity entity in linkFileWindow.linkFileViewModel.ProjectFilesEntityList)
                        {
                            string rManufactureNumber = String.IsNullOrEmpty(entity.RManufactureNumber) ? entity.ManufactureNumber : entity.RManufactureNumber;
                            if (rManufactureNumber == projectEntity.ManufactureNumber)
                            {
                                continue;
                            }
                            if (IsDuplicate(projectEntity.ManufactureNumber, linkFileWindow.linkFileViewModel.SelectProjectFilesEntity))
                            {
                                continue;
                            }
                            AddProjectFilesEntity = new ProjectFilesEntity();
                            AddProjectFilesEntity.DepartmentID = app.UserInfo.DepartmentID;
                            AddProjectFilesEntity.FileDiscript = entity.FileDiscript;
                            AddProjectFilesEntity.FileName = entity.FileName;
                            AddProjectFilesEntity.FileType = entity.FileType;
                            AddProjectFilesEntity.ManufactureNumber = projectEntity.ManufactureNumber;
                            AddProjectFilesEntity.RManufactureNumber = rManufactureNumber;
                            AddProjectFilesEntity.UserID = app.UserInfo.UserID;
                            AddProjectFilesEntity.FileUpdateTime = entity.FileUpdateTime;
                            AddProjectFilesEntity.FileTypeID = entity.FileTypeID;
                            AddProjectFilesEntity.FileBytes = entity.FileBytes;

                            AddProjectFilesEntity.DepartmentName = entity.DepartmentName;
                            AddProjectFilesEntity.UserName = entity.UserName;
                            AddProjectFilesEntity.FileDeletePersionName = entity.FileDeletePersionName;
                            AddProjectFilesEntity.FileTypeName = entity.FileTypeName;

                            AddProjectFilesEntity.ProjectFiles = new ProductManager.Web.Model.project_files();
                            ProjectFilesEntityList.Add(AddProjectFilesEntity);
                            AddProjectFilesEntity.DUpdate();
                            ProductDomainContextForFile.project_files.Add(AddProjectFilesEntity.ProjectFiles);
                        }
                    }
                }
                IsBusy = true;
                SubmitOperation subOperation = ProductDomainContextForFile.SubmitChanges();
                subOperation.Completed += SubOperationCommpleted;
            }
        }
        bool IsDuplicate(String aManufactureNumber, ProjectFilesEntity aProjectFiles)
        {
            bool lRes = false;
            if (FilesDictionarys != null)
            {
                Dictionary<String, ProjectFilesEntity> lTempDictionary;
                if (FilesDictionarys.TryGetValue(aManufactureNumber, out lTempDictionary))
                {
                    ProjectFilesEntity lFileEntityTemp;
                    if (lTempDictionary.TryGetValue(aProjectFiles.FileName, out lFileEntityTemp))
                    {
                        lRes = true;
                    }
                }

            }
            return lRes;
        }