예제 #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var parameterID = -1;
            var visible     = Visibility.Collapsed;

            if (value != null && Int32.TryParse(value.ToString(), out parameterID) && parameterID > 0)
            {
                var valueType = ParameterRepository.GetParameterValueType(parameterID);
                switch ((string)parameter)
                {
                case "Number":
                    visible = (valueType == EParameterValueType.Int32 || valueType == EParameterValueType.Decimal) ? Visibility.Visible : Visibility.Collapsed;
                    break;

                case "String":
                    visible = (valueType == EParameterValueType.String) ? Visibility.Visible : Visibility.Collapsed;
                    break;

                case "DateTime":
                    visible = (valueType == EParameterValueType.DateTIme) ? Visibility.Visible : Visibility.Collapsed;
                    break;

                case "Path":
                    visible = (valueType == EParameterValueType.Path) ? Visibility.Visible : Visibility.Collapsed;
                    break;

                case "Enum":
                    visible = (valueType == EParameterValueType.Enum) ? Visibility.Visible : Visibility.Collapsed;
                    break;
                }
                ;
            }
            ;
            return(visible);
        }
예제 #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var mask        = String.Empty;
            var parameterID = -1;

            if (value != null && Int32.TryParse(value.ToString(), out parameterID) && parameterID > 0)
            {
                var valueType = ParameterRepository.GetParameterValueType(parameterID);
                switch (valueType)
                {
                case EParameterValueType.Int32:
                    mask = @"n0";
                    break;

                case EParameterValueType.Decimal:
                    mask = @"n";
                    break;
                }
                ;
            }
            return(mask);
        }
예제 #3
0
        private bool UploadFiles()
        {
            bool result = true;

            foreach (var stg in StageTileView.Stages)
            {
                foreach (var par in stg.StageParameter.Where(x => !String.IsNullOrEmpty(x.OriginalFilePath)))
                {
                    if (ParameterRepository.GetParameterValueType(par.ParameterID) == EParameterValueType.Path)
                    {
                        var stageFolder = String.Empty;
                        if (checkDirectory(stg, out stageFolder))
                        {
                            var filePath = System.IO.Path.Combine(stageFolder, par.StringValue);
                            try
                            {
                                if (!System.IO.File.Exists(filePath))
                                {
                                    System.IO.File.Copy(par.OriginalFilePath, filePath);
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(String.Format("При копировании файла {0} в файловое хранилище возникла ошибка:\n{1}", par.StringValue, ex.Message), "Ошибка копированияы", MessageBoxButton.OK, MessageBoxImage.Error);
                                result = false;
                            };
                        }
                        else
                        {
                            result = false;
                        }
                    }
                    ;
                }
                ;
            }
            ;
            return(result);
        }
예제 #4
0
        private void WizardApplyButton_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateWizard())
            {
                var saveData     = true;
                var newProjectID = -1;
                using (var dc = new ORM.FPMDataContext())
                {
                    #region ProjectInfo changes
                    var         findProject = new Func <ORM.Project, bool>(x => x.ID == _project.ID);
                    ORM.Project project     = null;
                    if (dc.Project.Any(findProject))
                    {
                        project      = dc.Project.Single(findProject);
                        newProjectID = project.ID;
                    }
                    else
                    {
                        project = new ORM.Project();
                    };
                    project.Type = _project.Type;
                    project.ResponsiblePerson = _project.ResponsiblePerson;
                    project.Progress          = getProjectProgress();
                    project.Priority          = _project.Priority;
                    project.Note      = _project.Note;
                    project.IsInWork  = _project.IsInWork;
                    project.ContactID = _project.ContactID;
                    project.Caption   = _project.Caption;
                    project.CrtDate   = _project.CrtDate;
                    project.RowState  = _project.RowState;
                    #endregion
                    if (_project.ID <= 0)
                    {
                        dc.Project.InsertOnSubmit(project);
                    }
                    else
                    {
                        #region ProjectStage changes
                        var stages = dc.ProjectStage.Where(x => x.ProjectID == _project.ID);
                        foreach (var itm in stages)
                        {
                            if (!saveData)
                            {
                                break;
                            }
                            ;
                            if (StageTileView.Stages.Any(x => x.ID == itm.ID))
                            {
                                /*измененные стадии*/
                                var stg = StageTileView.Stages.Single(x => x.ID == itm.ID);
                                itm.IsPublic        = stg.IsPublic;
                                itm.SortIndex       = stg.SortIndex;
                                itm.Name            = stg.Name;
                                itm.Note            = stg.Note;
                                itm.ResponsibleRole = stg.ResponsibleRole;
                                itm.StageState      = stg.StageState;

                                /*Изменение параметров стадии*/
                                var parameters = dc.StageParameter.Where(x => x.ProjectStageID == itm.ID);
                                foreach (var par in parameters)
                                {
                                    if (stg.StageParameter.Any(x => x.ID == par.ID))
                                    {
                                        var srcPar = stg.StageParameter.Single(x => x.ID == par.ID);
                                        par.NumberValue   = srcPar.NumberValue;
                                        par.StringValue   = srcPar.StringValue;
                                        par.DateTimeValue = srcPar.DateTimeValue;
                                    }
                                    else
                                    {
                                        dc.StageParameter.DeleteOnSubmit(par);
                                        if (ParameterRepository.GetParameterValueType(par.ParameterID) == EParameterValueType.Path)
                                        {
                                            if (!stg.StageParameter.Any(x => x.StringValue == par.StringValue))
                                            {
                                                saveData = deleteFile(par);
                                            }
                                            ;
                                        }
                                        ;
                                    };
                                }
                                ;
                                if (saveData)
                                {
                                    /*Новые параметры*/
                                    foreach (var nStg in stg.StageParameter.Where(x => x.ID < 0))
                                    {
                                        var newParameter = new ORM.StageParameter()
                                        {
                                            CrtDate        = nStg.CrtDate,
                                            DateTimeValue  = nStg.DateTimeValue,
                                            NumberValue    = nStg.NumberValue,
                                            StringValue    = nStg.StringValue,
                                            ParameterID    = nStg.ParameterID,
                                            ProjectStageID = nStg.ProjectStageID
                                        };
                                        dc.StageParameter.InsertOnSubmit(newParameter);
                                    }
                                    ;
                                }
                                ;
                            }
                            else
                            {
                                /*удаленные стадии*/
                                itm.RowState = Convert.ToInt16(ERowState.Deleted);
                            };
                        }
                        ;
                        #endregion
                    };
                    if (saveData)
                    {
                        if (StageTileView.Stages.Any(x => x.ID == 0))
                        {
                            /*новые стадии*/
                            foreach (var itm in StageTileView.Stages.Where(x => x.ID == 0))
                            {
                                var stage = new ORM.ProjectStage()
                                {
                                    CrtDate         = itm.CrtDate,
                                    IsPublic        = itm.IsPublic,
                                    Name            = itm.Name,
                                    Note            = itm.Note,
                                    Project         = project,
                                    ResponsibleRole = itm.ResponsibleRole,
                                    RowState        = 1,
                                    SortIndex       = itm.SortIndex,
                                    StageState      = itm.StageState,
                                    StageParameter  = itm.StageParameter
                                };
                                dc.ProjectStage.InsertOnSubmit(stage);
                            }
                            ;
                        }
                        ;
                    }
                    ;
                    #region Upload Files
                    if (project.ID > 0)
                    {
                        saveData = UploadFiles();
                        if (saveData)
                        {
                            dc.SubmitChanges();
                        }
                        ;
                    }
                    else
                    {
                        dc.SubmitChanges();
                        newProjectID = project.ID;
                        UploadFiles();
                    };
                    #endregion
                };
                if (saveData)
                {
                    var focusedStage = StageTileView.Stages.Single(x => x.IsFocused);
                    Load(newProjectID);
                    StageTileView.FocusedStage = focusedStage;
                }
                ;
                ProjectWasChanged = !saveData;
                _changesWasSaved  = saveData;

                OnPropertyChanged("AllowDeleteAndArchieveProject");
            }
            ;
        }