예제 #1
0
        public void SetUnusedDataListItems(IList <IDataListVerifyPart> parts)
        {
            foreach (IDataListItemModel dataListItemModel in ScalarCollection)
            {
                dataListItemModel.IsUsed = true;
            }

            foreach (IDataListItemModel dataListItemModel in RecsetCollection)
            {
                dataListItemModel.IsUsed = true;
                foreach (IDataListItemModel listItemModel in dataListItemModel.Children)
                {
                    listItemModel.IsUsed = true;
                }
            }

            IList <IDataListItemModel> tmpRecsets = new List <IDataListItemModel>();

            foreach (IDataListVerifyPart part in parts)
            {
                if (part.IsScalar)
                {
                    IDataListItemModel scalarToRemove = ScalarCollection.FirstOrDefault(c => c.Name == part.Field);
                    if (scalarToRemove != null)
                    {
                        scalarToRemove.IsUsed = false;
                    }
                }
                else
                {
                    IDataListItemModel recsetToRemove = RecsetCollection.FirstOrDefault(c => c.Name == part.Recordset && c.IsRecordset);
                    if (string.IsNullOrEmpty(part.Field))
                    {
                        if (recsetToRemove != null)
                        {
                            recsetToRemove.IsUsed = false;
                        }
                    }
                    else
                    {
                        if (recsetToRemove != null)
                        {
                            IDataListItemModel childToRemove = recsetToRemove.Children.FirstOrDefault(c => c.Name == part.Field && c.IsField);
                            if (childToRemove != null)
                            {
                                childToRemove.IsUsed = false;
                            }
                        }
                    }
                }
            }

            foreach (IDataListItemModel item in tmpRecsets)
            {
                RecsetCollection.Remove(item);
                Validator.Remove(item);
            }
            WriteToResourceModel();
            Mediator.SendMessage(MediatorMessages.UpdateIntelisense, this);
        }
예제 #2
0
        public void AddMissingDataListItems(IList <IDataListVerifyPart> parts, bool async)
        {
            IList <IDataListItemModel> tmpRecsetList = new List <IDataListItemModel>();

            foreach (var part in parts)
            {
                if (part.IsScalar)
                {
                    if (ScalarCollection.FirstOrDefault(c => c.Name == part.Field) == null)
                    {
                        IDataListItemModel scalar = DataListItemModelFactory.CreateDataListModel(part.Field,
                                                                                                 part.Description,
                                                                                                 enDev2ColumnArgumentDirection
                                                                                                 .None);
                        if (ScalarCollection.Count > ScalarCollection.Count - 1)
                        {
                            ScalarCollection.Insert(ScalarCollection.Count - 1, scalar);
                        }
                        else
                        {
                            ScalarCollection.Insert(ScalarCollection.Count, scalar);
                        }
                    }
                }
                else
                {
                    IDataListItemModel recsetToAddTo = RecsetCollection.
                                                       FirstOrDefault(c => c.Name == part.Recordset && c.IsRecordset);

                    IDataListItemModel tmpRecset = tmpRecsetList.FirstOrDefault(c => c.Name == part.Recordset);

                    if (recsetToAddTo != null)
                    {
                        if (recsetToAddTo.Children.FirstOrDefault(c => c.Name == part.Field) == null)
                        {
                            IDataListItemModel child = DataListItemModelFactory.CreateDataListModel(part.Field,
                                                                                                    part.Description,
                                                                                                    recsetToAddTo);
                            if (recsetToAddTo.Children.Count > 0)
                            {
                                recsetToAddTo.Children.Insert(recsetToAddTo.Children.Count - 1, child);
                            }
                            else
                            {
                                recsetToAddTo.Children.Add(child);
                            }
                        }
                    }
                    else if (tmpRecset != null)
                    {
                        IDataListItemModel child = DataListItemModelFactory.CreateDataListModel
                                                       (part.Field, part.Description, tmpRecset);
                        child.Name = part.Recordset + "()." + part.Field;
                        tmpRecset.Children.Add(child);
                    }
                    else
                    {
                        IDataListItemModel recset = DataListItemModelFactory.CreateDataListModel
                                                        (part.Recordset, part.Description, enDev2ColumnArgumentDirection.None);

                        tmpRecsetList.Add(recset);
                    }
                }
            }

            foreach (var item in tmpRecsetList)
            {
                if (item.Children.Count == 0)
                {
                    item.Children.Add(DataListItemModelFactory.CreateDataListModel(string.Empty, string.Empty, item));
                }
                if (RecsetCollection.Count > 0)
                {
                    RecsetCollection.Insert(RecsetCollection.Count - 1, item);
                }
                else
                {
                    RecsetCollection.Add(item);
                }
            }

            WriteToResourceModel();
            EventPublisher.Publish(new UpdateIntellisenseMessage());
            RemoveBlankScalars();
            RemoveBlankRecordsets();
            RemoveBlankRecordsetFields();

            if (parts.Count > 0)
            {
                AddBlankRow(null);
            }
        }