Exemplo n.º 1
0
        public bool IsNeedNewCell(GroupDataHolder holder, InsertOption nlOption, int currentColIndex, int currentRowIndex, System.Data.DataTable table,
                                  int valueRowIndex)
        {
            if (align == GroupAlign.always)
            {
                return(true);
            }

            if (align == GroupAlign.none)
            {
                return((nlOption & InsertOption.always) != 0);
            }

            object value = GetGroupValue(holder, table, valueRowIndex);

            switch (align)
            {
            case GroupAlign.vGroup:
            case GroupAlign.hGroup:
                if ((nlOption & InsertOption.BeforeChange) != 0)
                {
                    if (valueRowIndex + 1 >= table.Rows.Count)
                    {
                        // last line
                        return(true);
                    }

                    object value1 = GetGroupValue(holder, table, valueRowIndex);

                    object value2 = GetGroupValue(holder, table, valueRowIndex + 1);
                    return(!Equals(value1, value2));
                }
                else
                {
                    if (lastGroupedValue == null || !lastGroupedValue.Equals(value))
                    {
                        lastGroupedValue = value;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

            /*case GroupAlign.hGroup:
             *      // todo: check hGroup Cells. dose need a New Row.
             *      if (value == null)
             *              return true;
             *      bool flag;
             *      if (lastValueMap.TryGetValue(value, out flag))
             *              return false;
             *      else
             *              lastValueMap.Add(value, true);
             *      return true;*/
            default:
                break;
            }
            return(false);
        }
Exemplo n.º 2
0
        public ICommandExecution Create(ICommand cmd, object targetModel, InsertOption insertOption = InsertOption.Default)
        {
            lock (oLockCachedAnswers)
            {
                CachedDropTarget proposition = new CachedDropTarget(targetModel, insertOption);

                //typically user might start a drag and then drag it all over the place so cache answers to avoid hammering database/loading donuts
                if (_cachedAnswers.ContainsKey(cmd))
                {
                    //if we already have a cached execution for the command and the target
                    if (_cachedAnswers[cmd].ContainsKey(proposition))
                    {
                        return(_cachedAnswers[cmd][proposition]);//return from cache
                    }
                }
                else
                {
                    _cachedAnswers.Add(cmd, new Dictionary <CachedDropTarget, ICommandExecution>()); //novel command
                }
                var result = CreateNoCache(cmd, targetModel, insertOption);
                _cachedAnswers[cmd].Add(new CachedDropTarget(targetModel, insertOption), result);

                return(result);
            }
        }
Exemplo n.º 3
0
        public ICommandExecution ProposeExecution(ICommand cmd, object target, InsertOption insertOption = InsertOption.Default)
        {
            if (IsCompatibleTarget(target))
            {
                return(ProposeExecution(cmd, (T)target, insertOption));
            }

            return(null);
        }
Exemplo n.º 4
0
        private ICommandExecution CreateNoCache(ICommand cmd, object targetModel, InsertOption insertOption = InsertOption.Default)
        {
            ///////////////Catalogue or ambiguous Drop Targets ////////////////////////
            var targetCatalogueFolder = targetModel as CatalogueFolder;

            if (targetCatalogueFolder != null)
            {
                return(CreateWhenTargetIsFolder(cmd, targetCatalogueFolder));
            }

            /////////////Table Info Drop Targets///////////////////////////////////
            var targetTableInfo = targetModel as TableInfo;

            if (targetTableInfo != null)
            {
                return(CreateWhenTargetIsATableInfo(cmd, targetTableInfo));
            }

            //////////////////////Cohort Drop Targets//////////////////

            var targetJoinableCollectionNode = targetModel as JoinableCollectionNode;

            if (targetJoinableCollectionNode != null)
            {
                return(CreateWhenTargetIsJoinableCollectionNode(cmd, targetJoinableCollectionNode));
            }

            ///////////////Data Loading Drop Targets ///////////////////

            var targetProcessTask = targetModel as ProcessTask;

            if (targetProcessTask != null)
            {
                return(CreateWhenTargetIsProcessTask(cmd, targetProcessTask, insertOption));
            }

            /////////////Table Info Collection Drop Targets////////////////////

            var targetPreLoadDiscardedColumnsNode = targetModel as PreLoadDiscardedColumnsNode;

            if (targetPreLoadDiscardedColumnsNode != null)
            {
                return(CreateWhenTargetIsPreLoadDiscardedColumnsNode(cmd, targetPreLoadDiscardedColumnsNode));
            }

            foreach (ICommandExecutionProposal proposals in _proposers.Where(p => p.IsCompatibleTarget(targetModel)))
            {
                var ce = proposals.ProposeExecution(cmd, targetModel, insertOption);
                if (ce != null)
                {
                    return(ce);
                }
            }

            //no valid combinations
            return(null);
        }
        private ExecuteCommandReOrderAggregate(IActivateItems activator, IOrderable target, InsertOption insertOption) : base(activator)
        {
            _targetOrder  = target;
            _insertOption = insertOption;

            if (target is IMightBeReadOnly ro && ro.ShouldBeReadOnly(out string reason))
            {
                SetImpossible(reason);
            }
        }
Exemplo n.º 6
0
        public override ICommandExecution ProposeExecution(ICommand cmd, ProjectCohortIdentificationConfigurationAssociationsNode target,
                                                           InsertOption insertOption = InsertOption.Default)
        {
            var cicCommand = cmd as CohortIdentificationConfigurationCommand;

            if (cicCommand != null)
            {
                return(new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(ItemActivator).SetTarget(cicCommand.CohortIdentificationConfiguration).SetTarget(target.Project));
            }

            return(null);
        }
        public ExecuteCommandReOrderProcessTask(IActivateItems activator, ProcessTaskCommand sourceProcessTaskCommand, ProcessTask targetProcessTask, InsertOption insertOption) : base(activator)
        {
            _targetProcessTask = targetProcessTask;
            _insertOption      = insertOption;
            _sourceProcessTask = sourceProcessTaskCommand.ProcessTask;

            if (_sourceProcessTask.LoadMetadata_ID != targetProcessTask.LoadMetadata_ID)
            {
                SetImpossible("ProcessTasks must belong to the same Load");
            }
            else
            if (_sourceProcessTask.LoadStage != targetProcessTask.LoadStage)
            {
                SetImpossible("ProcessTasks must belong in the same LoadStage to be ReOrdered");
            }
            else
            if (_insertOption == InsertOption.Default)
            {
                SetImpossible("Drag above or below to ReOrder");
            }
        }
Exemplo n.º 8
0
        public bool IsNeedNewCell(GroupDataHolder holder, InsertOption insertOption, int currentColIndex,
                                  int currentRowIndex, DataTable table, int valueRowIndex)
        {
            if (GroupAlign == GroupAlign.Always)
            {
                return(true);
            }
            if (GroupAlign == GroupAlign.None)
            {
                //无分组时,行添加方式为all时才新增单元格
                return((insertOption & InsertOption.Always) != InsertOption.Never);
            }
            var currentGroupValue = GetGroupValue(holder, table, valueRowIndex);

            switch (GroupAlign)
            {
            case GroupAlign.Vertical:
            case GroupAlign.Horizontal:
                if ((insertOption & InsertOption.BeforeChange) == InsertOption.Never)
                {
                    //行添加方式不为before时,判断与上一分组值是否相等(不相等则新增)
                    if ((LastGroupedValue != null) && LastGroupedValue.Equals(currentGroupValue))
                    {
                        return(false);
                    }
                    LastGroupedValue = currentGroupValue;
                    return(true);
                }
                if ((valueRowIndex + 1) < table.Rows.Count)
                {
                    //before时(非数据源最后一行),判断与下一行单元格值是否相等(不相等则新增)
                    var nextGroupValue = GetGroupValue(holder, table, valueRowIndex + 1);
                    return(!Equals(currentGroupValue, nextGroupValue));
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 9
0
        public ExecuteCommandReOrderAggregateContainer(IActivateItems activator, CohortAggregateContainerCombineable sourceCohortAggregateContainerCombineable, CohortAggregateContainer targetCohortAggregateContainer, InsertOption insertOption) : this(activator, targetCohortAggregateContainer, insertOption)
        {
            _sourceCohortAggregateContainerCombineable = sourceCohortAggregateContainerCombineable;

            _targetParent = targetCohortAggregateContainer.GetParentContainerIfAny();

            //reorder is only possible within a container
            if (!_sourceCohortAggregateContainerCombineable.ParentContainerIfAny.Equals(_targetParent))
            {
                SetImpossible("First move containers to share the same parent container");
            }

            if (_insertOption == InsertOption.Default)
            {
                SetImpossible("Insert must be above/below");
            }

            if (_targetParent.ShouldBeReadOnly(out string reason))
            {
                SetImpossible(reason);
            }
        }
Exemplo n.º 10
0
 public long LInsert(string key, InsertOption option, string pivot, string value)
 {
     return this.LInsert(key, option.ToString(), pivot, value);
 }
        public override ICommandExecution ProposeExecution(ICombineToMakeCommand cmd, StandardPipelineUseCaseNode target, InsertOption insertOption = InsertOption.Default)
        {
            var sourcePipelineCommand = cmd as PipelineCombineable;

            if (sourcePipelineCommand != null)
            {
                return(new ExecuteCommandEditPipelineWithUseCase(ItemActivator, sourcePipelineCommand.Pipeline, target.UseCase));
            }

            return(null);
        }
 public override ICommandExecution ProposeExecution(ICommand cmd, WindowLayout target, InsertOption insertOption = InsertOption.Default)
 {
     return(null);
 }
Exemplo n.º 13
0
        public ExecuteCommandReOrderAggregate(IActivateItems activator, AggregateConfigurationCombineable sourceAggregateCommand, CohortAggregateContainer targetCohortAggregateContainer, InsertOption insertOption) : this(activator, targetCohortAggregateContainer, insertOption)
        {
            _sourceAggregateCommand = sourceAggregateCommand;
            _parentContainer        = targetCohortAggregateContainer.GetParentContainerIfAny();

            if (!sourceAggregateCommand.ContainerIfAny.Equals(_parentContainer))
            {
                SetImpossible("Cannot ReOrder, you should first move both objects into the same container (UNION / EXCEPT / INTERSECT)");
                return;
            }
        }
Exemplo n.º 14
0
        public override ICommandExecution ProposeExecution(ICombineToMakeCommand cmd, Catalogue targetCatalogue, InsertOption insertOption = InsertOption.Default)
        {
            var sourceFileCollection = cmd as FileCollectionCombineable;

            if (sourceFileCollection != null)
            {
                if (sourceFileCollection.IsShareDefinition)
                {
                    return(new ExecuteCommandImportCatalogueDescriptionsFromShare(ItemActivator, sourceFileCollection, targetCatalogue));
                }
                else
                {
                    return(new ExecuteCommandAddNewSupportingDocument(ItemActivator, sourceFileCollection, targetCatalogue));
                }
            }

            return(null);
        }
Exemplo n.º 15
0
        public override ICommandExecution ProposeExecution(ICommand cmd, Project project, InsertOption insertOption = InsertOption.Default)
        {
            //drop a cic on a Project to associate it with that project
            var cicCommand = cmd as CohortIdentificationConfigurationCommand;

            if (cicCommand != null)
            {
                return(new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(ItemActivator).SetTarget(cicCommand.CohortIdentificationConfiguration).SetTarget(project));
            }

            var cataCommand = cmd as CatalogueCommand;

            if (cataCommand != null)
            {
                return(new ExecuteCommandMakeCatalogueProjectSpecific(ItemActivator).SetTarget(cataCommand.Catalogue).SetTarget(project));
            }

            var file = cmd as FileCollectionCommand;

            if (file != null)
            {
                return(new ExecuteCommandCreateNewCatalogueByImportingFile(ItemActivator, file).SetTarget(project));
            }

            var aggCommand = cmd as AggregateConfigurationCommand;

            if (aggCommand != null)
            {
                return(new ExecuteCommandCreateNewCatalogueByExecutingAnAggregateConfiguration(ItemActivator).SetTarget(project).SetTarget(aggCommand.Aggregate));
            }


            return(null);
        }
Exemplo n.º 16
0
 public override ICommandExecution ProposeExecution(ICommand cmd, GovernanceDocument target, InsertOption insertOption = InsertOption.Default)
 {
     return(null);
 }
Exemplo n.º 17
0
        public ExecuteCommandReOrderAggregateContainer(IActivateItems activator, CohortAggregateContainerCombineable sourceCohortAggregateContainerCombineable, AggregateConfiguration targetAggregate, InsertOption insertOption) : this(activator, targetAggregate, insertOption)
        {
            _sourceCohortAggregateContainerCombineable = sourceCohortAggregateContainerCombineable;
            _targetParent = targetAggregate.GetCohortAggregateContainerIfAny();

            //if they do not share the same parent container
            if (!_sourceCohortAggregateContainerCombineable.ParentContainerIfAny.Equals(_targetParent))
            {
                SetImpossible("First move objects into the same parent container");
            }
        }
Exemplo n.º 18
0
 private ExecuteCommandReOrderAggregateContainer(IActivateItems activator, IOrderable orderable, InsertOption insertOption) : base(activator)
 {
     _targetOrderable = orderable;
     _insertOption    = insertOption;
 }
Exemplo n.º 19
0
 public override ICommandExecution ProposeExecution(ICommand cmd, PermissionWindowUsedByCacheProgressNode target, InsertOption insertOption = InsertOption.Default)
 {
     //no drag and drop
     return(null);
 }
Exemplo n.º 20
0
        public override ICommandExecution ProposeExecution(ICombineToMakeCommand cmd, AggregateConfiguration targetAggregateConfiguration, InsertOption insertOption = InsertOption.Default)
        {
            if (cmd is ContainerCombineable cc)
            {
                return(new ExecuteCommandImportFilterContainerTree(ItemActivator, targetAggregateConfiguration, cc.Container));
            }

            var sourceAggregateCommand = cmd as AggregateConfigurationCombineable;

            //if it is an aggregate being dragged
            if (sourceAggregateCommand != null)
            {
                //source and target are the same
                if (sourceAggregateCommand.Aggregate.Equals(targetAggregateConfiguration))
                {
                    return(null);
                }

                //that is part of cohort identification already and being dragged above/below the current aggregate
                if (sourceAggregateCommand.ContainerIfAny != null && insertOption != InsertOption.Default)
                {
                    return(new ExecuteCommandReOrderAggregate(ItemActivator, sourceAggregateCommand, targetAggregateConfiguration, insertOption));
                }
            }

            var sourceCohortAggregateContainerCommand = cmd as CohortAggregateContainerCombineable;

            if (sourceCohortAggregateContainerCommand != null)
            {
                //can never drag the root container elsewhere
                if (sourceCohortAggregateContainerCommand.ParentContainerIfAny == null)
                {
                    return(null);
                }

                //above or below
                if (insertOption != InsertOption.Default)
                {
                    return(new ExecuteCommandReOrderAggregateContainer(ItemActivator, sourceCohortAggregateContainerCommand, targetAggregateConfiguration, insertOption));
                }
            }
            return(null);
        }
Exemplo n.º 21
0
 public override ICommandExecution ProposeExecution(ICommand cmd, ConnectionStringKeyword target, InsertOption insertOption = InsertOption.Default)
 {
     //no drag and drop
     return(null);
 }
Exemplo n.º 22
0
 public override ICommandExecution ProposeExecution(ICombineToMakeCommand cmd, TableInfo target, InsertOption insertOption = InsertOption.Default)
 {
     return(null);
 }
Exemplo n.º 23
0
        public ExecuteCommandReOrderAggregate(IActivateItems activator, AggregateConfigurationCommand sourceAggregateCommand, AggregateConfiguration targetAggregateConfiguration, InsertOption insertOption) : this(activator, targetAggregateConfiguration, insertOption)
        {
            _sourceAggregateCommand = sourceAggregateCommand;
            _parentContainer        = targetAggregateConfiguration.GetCohortAggregateContainerIfAny();

            if (_parentContainer == null)
            {
                SetImpossible("Target Aggregate " + targetAggregateConfiguration + " is not part of any cohort identification set containers");
                return;
            }

            if (!sourceAggregateCommand.ContainerIfAny.Equals(_parentContainer))
            {
                SetImpossible("Cannot ReOrder, you should first move both objects into the same container (UNION / EXCEPT / INTERSECT)");
                return;
            }
        }
 public override ICommandExecution ProposeExecution(ICombineToMakeCommand cmd, DataAccessCredentialUsageNode target,
                                                    InsertOption insertOption = InsertOption.Default)
 {
     return(null);
 }
        public override ICommandExecution ProposeExecution(ICommand cmd, LoadStageNode targetStage, InsertOption insertOption = InsertOption.Default)
        {
            var sourceProcessTaskCommand = cmd as ProcessTaskCommand;
            var sourceFileTaskCommand    = cmd as FileCollectionCommand;

            if (sourceProcessTaskCommand != null)
            {
                return(new ExecuteCommandChangeLoadStage(ItemActivator, sourceProcessTaskCommand, targetStage));
            }

            if (sourceFileTaskCommand != null && sourceFileTaskCommand.Files.Length == 1)
            {
                var f = sourceFileTaskCommand.Files.Single();

                if (f.Extension == ".sql")
                {
                    return(new ExecuteCommandCreateNewProcessTask(ItemActivator, ProcessTaskType.SQLFile, targetStage.LoadMetadata, targetStage.LoadStage, f));
                }


                if (f.Extension == ".exe")
                {
                    return(new ExecuteCommandCreateNewProcessTask(ItemActivator, ProcessTaskType.Executable, targetStage.LoadMetadata, targetStage.LoadStage, f));
                }
            }


            return(null);
        }
Exemplo n.º 26
0
 private ExecuteCommandReOrderAggregate(IActivateItems activator, IOrderable target, InsertOption insertOption) : base(activator)
 {
     _targetOrder  = target;
     _insertOption = insertOption;
 }
        public override ICommandExecution ProposeExecution(ICommand cmd, GovernancePeriod target, InsertOption insertOption = InsertOption.Default)
        {
            if (cmd is FileCollectionCommand files && files.Files.Length == 1)
            {
                return(new ExecuteCommandAddNewGovernanceDocument(ItemActivator, target, files.Files[0]));
            }

            if (cmd is CatalogueCommand c)
            {
                return(new ExecuteCommandAddCatalogueToGovernancePeriod(ItemActivator, target, c.Catalogue));
            }

            if (cmd is ManyCataloguesCommand mcat)
            {
                return(new ExecuteCommandAddCatalogueToGovernancePeriod(ItemActivator, target, mcat.Catalogues));
            }

            //no drag and drop support
            return(null);
        }
Exemplo n.º 28
0
 public override ICommandExecution ProposeExecution(ICommand cmd, ParametersNode target, InsertOption insertOption = InsertOption.Default)
 {
     return(null);
 }
Exemplo n.º 29
0
 public void Insert(InsertOption option = InsertOption.Row)
 {
     this.mCache.Add(new Dictionary <string, object>());
     this.mIsWrite = true;
 }
Exemplo n.º 30
0
 public override ICommandExecution ProposeExecution(ICombineToMakeCommand cmd, IDirectoryInfoNode target, InsertOption insertOption = InsertOption.Default)
 {
     //no drag and drop support
     return(null);
 }
        public override ICommandExecution ProposeExecution(ICombineToMakeCommand cmd, ProjectCataloguesNode target, InsertOption insertOption = InsertOption.Default)
        {
            //use the same drop options as Project except for this one

            if (cmd is CohortIdentificationConfigurationCommand)
            {
                return(null);
            }


            return(_projectFunctionality.ProposeExecution(cmd, target.Project, insertOption));
        }