Example #1
0
        /// <summary>
        /// Фильтровать
        /// </summary>
        /// <param name="items">Элементы для фильтрации</param>
        /// <param name="filterList">Какой список фильтруется</param>
        public ListViewItem[] FilterOut(List <ListViewItem> items,
                                        FilterList filterList)
        {
            var filteredList   = new List <ListViewItem>();
            var allowedDevices = new string[0];

            if (filterList == FilterList.CurrentProject)
            {
                allowedDevices = CurrentProjectSelectedDevices;
            }
            else
            {
                allowedDevices = AdvancedProjectSelectedDevices;
            }

            if (allowedDevices.Length != 0)
            {
                filteredList = items
                               .Where(x => allowedDevices.Contains(x.Tag.ToString()))
                               .ToList();
                return(filteredList.ToArray());
            }
            else
            {
                return(items.ToArray());
            }
        }
Example #2
0
        public static void DeleteAll()
        {
            DeleteToolObject();
            App.LockAndExecute(() =>
            {
                ClearHighlighted();
                var layerTable = HostApplicationServices.WorkingDatabase.LayerTableId.QOpenForRead <SymbolTable>();
                HostApplicationServices.WorkingDatabase.Clayer = layerTable["0"];
                DeleteByLayer(layerTable, ProcessLayerName);
                DeleteByLayer(layerTable, HatchLayerName);
                DeleteByLayer(layerTable, GashLayerName);
                DeleteByLayer(layerTable, ExtraObjectsLayerName);
            });

            void DeleteByLayer(SymbolTable layerTable, string layerName)
            {
                if (layerTable.Has(layerName))
                {
                    var ids = QuickSelection.SelectAll(FilterList.Create().Layer(layerName));
                    if (ids.Any())
                    {
                        ids.QForEach(entity => entity.Erase());
                    }
                    layerTable[layerName].Erase();
                }
            }
        }
        public ActionResult Landing(FilterList <PropertyShortDisplay> filter)
        {
            InitSearchLookups();
            var rows = new BLayer().GetAllPropertiesLanding(filter, PropertiesDisplayType.AllBrokers);

            return(View(rows));
        }
Example #4
0
    private ShadowTransform[] BlendController(
        ShadowController controller,
        ShadowTransform[] input,
        Slider weight,
        FilterList <string> filter = null)
    {
        if (weight.IsMin == true)
        {
            return(input);
        }

        // Update the target controller from that blend
        if (filter == null)
        {
            controller.Decode(input);
        }
        else
        {
            controller.Decode(input, filter);
        }
        controller.ControlledUpdate();
        ShadowTransform[] result
            = controller.Encode(this.NewTransformArray());

        return(BlendSystem.Blend(
                   this.NewTransformArray(),
                   new BlendPair(input, weight.Inverse),
                   new BlendPair(result, weight.Value)));
    }
Example #5
0
        public void CanFilterBufferToOdbInBareRepository()
        {
            var id    = new ObjectId("799770d1cff46753a57db7a066159b5610da6e3a");
            var flags = FilterFlags.NoSystemAttributes | FilterFlags.AttributesFromHead;

            var blobFilterOptions = new BlobFilterOptions();

            blobFilterOptions.Flags = BlobFilterFlags.NoSystemAttributes | BlobFilterFlags.AttributesFromHead;

            using (Repository repo = SandboxRepository("crlf.git"))
                using (Blob b = repo.Objects.Lookup <Blob>(id))
                    using (FilterList cleanFilter = repo.LoadFilterList(b, "file.crlf", FilterMode.ToObjectDatabase, flags))
                    {
                        using (GitBuffer inputBuffer = b.GetFilteredContent("file.crlf", blobFilterOptions))
                        {
                            Assert.Equal(20, inputBuffer.Length);
                            Assert.True(inputBuffer.Content.SequenceEqual(new ReadOnlySpan <byte>(new byte[] { 0x6c, 0x66, 0x0d, 0x0a, 0x6c, 0x66, 0x0d, 0x0a, 0x6c, 0x66, 0x0d, 0x0a, 0x6c, 0x66, 0x0d, 0x0a, 0x6c, 0x66, 0x0d, 0x0a })));
                            Assert.Equal(20, inputBuffer.Content.Length);

                            // No filtering is configured
                            using (GitBuffer outputBuffer = cleanFilter.Apply(inputBuffer))
                            {
                                Assert.Equal(15, outputBuffer.Length);
                                Assert.True(outputBuffer.Content.SequenceEqual(new ReadOnlySpan <byte>(new byte[] { 0x6c, 0x66, 0x0a, 0x6c, 0x66, 0x0a, 0x6c, 0x66, 0x0a, 0x6c, 0x66, 0x0a, 0x6c, 0x66, 0x0a })));
                                Assert.Equal(15, outputBuffer.Content.Length);
                            }
                        }
                    }
        }
Example #6
0
 public void ClearFilters_ListWith2Filters_FilterListWithOnlyCategoryFilterCollection()
 {
     FilterList.AddFilter(new DateFilter(DateTime));
     FilterList.AddFilter(new DateFilter(DateTime));
     FilterList.ClearFilters();
     Assert.AreEqual(1, FilterList.GetFilters().Count);
 }
Example #7
0
        static async Task Main(string[] args)
        {
            try
            {
                var hangmanServer  = HangmanServer();
                var filter         = new FilterList();
                var makeMoveAction = new PlayMoveOnServerAction(hangmanServer);
                var newGameAction  = new StartNewGameOnServerAction(hangmanServer);

                var registerUserAction = new RegisterUserOnServerAction(hangmanServer);
                var x_access_token     = await registerUserAction.Execute(username : "******", password : "******");

                Login(hangmanServer, x_access_token);

                while (true)
                {
                    await PlayGame(makeMoveAction, filter, newGameAction);

                    Console.WriteLine("");
                    Console.WriteLine("------------------------------------");
                    Console.WriteLine("");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return;
            }
        }
Example #8
0
        private void SetDiffTerTabFilters(FilterList list)
        {
            bool atLeastOne = false;

            if (list.Contains(FilterList.KEY_TERRAIN_VAL))
            {
                atLeastOne = true;
                difficultyPage.TerrValue    = list.GetCriteria(FilterList.KEY_TERRAIN_VAL) as string;
                difficultyPage.TerrOperator = list.GetCriteria(FilterList.KEY_TERRAIN_OP) as string;
            }
            if (list.Contains(FilterList.KEY_DIFF_VAL))
            {
                atLeastOne = true;
                difficultyPage.DifficultyValue    = list.GetCriteria(FilterList.KEY_DIFF_VAL) as string;
                difficultyPage.DifficultyOperator = list.GetCriteria(FilterList.KEY_DIFF_OP) as string;
            }
            if (list.Contains(FilterList.KEY_CACHETYPE))
            {
                atLeastOne = true;
                difficultyPage.SelectedCacheTypes = list.GetCriteria(FilterList.KEY_CACHETYPE) as List <string>;
            }
            if (list.Contains(FilterList.KEY_CACHE_SOURCE))
            {
                atLeastOne = true;
                difficultyPage.CacheSources = list.GetCriteria(FilterList.KEY_CACHE_SOURCE) as List <String>;
            }
            if (atLeastOne)
            {
                diffLabel.Markup = "<b>" + Catalog.GetString("Difficulty/Terrain/Type") + "</b>";
            }
        }
Example #9
0
 private void GetDateFilter(FilterList filter)
 {
     if (placementPage.PlaceBefore != DateTime.MinValue)
     {
         filter.AddFilterCriteria(FilterList.KEY_PLACEBEFORE, placementPage.PlaceBefore);
     }
     else
     {
         filter.RemoveCriteria(FilterList.KEY_PLACEBEFORE);
     }
     if (placementPage.PlaceAfter != DateTime.MinValue)
     {
         filter.AddFilterCriteria(FilterList.KEY_PLACEAFTER, placementPage.PlaceAfter);
     }
     else
     {
         filter.RemoveCriteria(FilterList.KEY_PLACEAFTER);
     }
     if (updatedPage.InfoBefore != DateTime.MinValue)
     {
         filter.AddFilterCriteria(FilterList.KEY_INFOBEFORE, updatedPage.InfoBefore);
     }
     else
     {
         filter.RemoveCriteria(FilterList.KEY_INFOBEFORE);
     }
     if (updatedPage.InfoAfter != DateTime.MinValue)
     {
         filter.AddFilterCriteria(FilterList.KEY_INFOAFTER, updatedPage.InfoAfter);
     }
     else
     {
         filter.RemoveCriteria(FilterList.KEY_INFOAFTER);
     }
 }
Example #10
0
        public FilterList <PropertyShortDisplay> GetAllPropertiesRequests(FilterList <PropertyShortDisplay> filter)
        {
            filter.DataType = FilterListDataType.Requests;
            var query = db.PropertyRequests.Where(x => !x.IsDeleted && x.IsActive);

            if (filter.ByUserID > 0)
            {
                query = query.Where(x => x.ByUserID == filter.ByUserID);
            }
            query = query.OrderByDescending(x => x.RequestID).Skip(filter.PageSize * (filter.PageNum - 1)).Take(filter.PageSize);

            filter.Data = query.Select(x => new PropertyShortDisplay()
            {
                EntryDate        = x.EntryDate,
                FloorTypeTitle   = x.PropertyFloorType.FloorTypeTitle,
                Title            = x.Title,
                LocationName     = x.Location.LocationName,
                OwnerShipTitle   = x.OwnerShipType.OwnerShipTitle,
                PropertyID       = x.RequestID,
                PropPurposeTitle = x.PropertyPurpose.PropPurposeTitle,
                PropTypeTitle    = x.PropertyType.PropTypeTitle,
                AddressDetails   = x.AddressDetails,
                UserID           = x.ByUserID,
            }).OrderByDescending(x => x.PropertyID).ToList();

            return(filter);
        }
Example #11
0
        private void SetAttributeTabFilters(FilterList list)
        {
            bool atLeastOne = false;

            if (list.Contains(FilterList.KEY_INCATTRS))
            {
                atLeastOne = true;
                attributePage.IncludeAttributes = (List <String>)list.GetCriteria(FilterList.KEY_INCATTRS);
            }
            if (list.Contains(FilterList.KEY_EXCATTRS))
            {
                atLeastOne = true;
                attributePage.MustHaveNegAttributes = (List <String>)list.GetCriteria(FilterList.KEY_EXCATTRS);
            }
            if (list.Contains(FilterList.KEY_INCNOATTRS))
            {
                atLeastOne = true;
                attributePage.MustNotHaveIncludeAttributes = (List <String>)list.GetCriteria(FilterList.KEY_INCNOATTRS);
            }
            if (list.Contains(FilterList.KEY_EXCNOATTRS))
            {
                atLeastOne = true;
                attributePage.MustNotHaveNegAttributes = (List <String>)list.GetCriteria(FilterList.KEY_EXCNOATTRS);
            }
            if (atLeastOne)
            {
                attrPageLabel.Markup = "<b>" + Catalog.GetString("Attributes") + "</b>";
            }
        }
Example #12
0
 /// <summary>
 /// Merges QuickFilter
 /// </summary>
 /// <param name="tbl">
 /// A <see cref="System.Collections.Hashtable"/>
 /// </param>
 /// <param name="condition">
 /// A <see cref="FilterList"/>
 /// </param>
 private static void MergeFilterConditions(System.Collections.Hashtable tbl, FilterList condition)
 {
     foreach (object key in tbl.Keys)
     {
         condition.AddFilterCriteria(key as string, tbl[key]);
     }
 }
Example #13
0
 private static void RenderUserData(FilterList list, StringBuilder builder)
 {
     if (list.Contains(FilterList.KEY_U1))
     {
         builder.Append(Catalog.GetString("<b>User 1 contains: </b>"));
         builder.Append(list.GetCriteria(FilterList.KEY_U1) as string);
         builder.Append("\n");
     }
     if (list.Contains(FilterList.KEY_U2))
     {
         builder.Append(Catalog.GetString("<b>User 2 contains: </b>"));
         builder.Append(list.GetCriteria(FilterList.KEY_U2) as string);
         builder.Append("\n");
     }
     if (list.Contains(FilterList.KEY_U3))
     {
         builder.Append(Catalog.GetString("<b>User 3 contains: </b>"));
         builder.Append(list.GetCriteria(FilterList.KEY_U3) as string);
         builder.Append("\n");
     }
     if (list.Contains(FilterList.KEY_U4))
     {
         builder.Append(Catalog.GetString("<b>User 4 contains: </b>"));
         builder.Append(list.GetCriteria(FilterList.KEY_U4) as string);
         builder.Append("\n");
     }
 }
Example #14
0
 private static void RenderStatus(FilterList list, StringBuilder builder)
 {
     if (list.Contains(FilterList.KEY_STATUS))
     {
         builder.Append(Catalog.GetString("<b>Status: </b>"));
         bool[] status = (bool[])list.GetCriteria(FilterList.KEY_STATUS);
         if (status[0])
         {
             builder.Append(Catalog.GetString("Found "));
         }
         if (status[1])
         {
             builder.Append(Catalog.GetString("Unfound "));
         }
         if (status[2])
         {
             builder.Append(Catalog.GetString("Mine "));
         }
         if (status[3])
         {
             builder.Append(Catalog.GetString("Available "));
         }
         if (status[4])
         {
             builder.Append(Catalog.GetString("Disabled "));
         }
         if (status[5])
         {
             builder.Append(Catalog.GetString("Archived "));
         }
         builder.Append("\n");
     }
 }
Example #15
0
        private void ApplyQuickFilterPressed(QuickFilter quickFilter)
        {
            FilterList.ApplyQuickFilter(quickFilter);

            IPreviewBeatmapLevel[] unfilteredLevels = null;
            if (_lastPack == null)
            {
                _lastPack = LevelSelectionNavigationController.GetPrivateField <IBeatmapLevelPack>("_levelPack");
            }
            if (_lastPack == null)
            {
                unfilteredLevels = _levelCollectionTableView.GetPrivateField <IPreviewBeatmapLevel[]>("_previewBeatmapLevels");
            }
            else
            {
                unfilteredLevels = _lastPack.beatmapLevelCollection.beatmapLevels;
            }

            if (unfilteredLevels == null)
            {
                Logger.log.Warn("Unable to apply quick filter (could not find songs to filter)");
                return;
            }

            _filteredLevelPack.SetupFromUnfilteredLevels(unfilteredLevels);
            LevelSelectionNavigationController.SetData(
                _filteredLevelPack,
                true,
                LevelSelectionNavigationController.GetPrivateField <bool>("_showPlayerStatsInDetailView"),
                LevelSelectionNavigationController.GetPrivateField <bool>("_showPracticeButtonInDetailView"));

            ButtonPanel.instance.SetFilterStatus(true);
        }
Example #16
0
 protected bool ItemsFilter(object e)
 {
     if (e is T entity && FilterList.Any(f => f.Key == FilterType) && !string.IsNullOrEmpty(FilterText))
     {
         var value = entity.GetType().GetProperty(FilterType).GetValue(entity, null);
         return(value == null || value.ToString().ToUpper().Contains(FilterText.ToUpper()));
     }
Example #17
0
        public void AddFilter_AddDateFilterToEmptyList_AddsFilterToList()
        {
            DateFilter dateFilter = new DateFilter(DateTime);

            FilterList.AddFilter(dateFilter);
            Assert.Contains(dateFilter, FilterList.GetFilters());
        }
Example #18
0
        /// <summary>
        /// Удаление уже привязанных сигналов из списка сигналов
        /// </summary>
        /// <param name="items">Пары уже связанных сигналов</param>
        /// <param name="filterList">Какой проект проверяется</param>
        /// <returns></returns>
        private IEnumerable <ListViewItem> RemoveBindedSignals(
            IEnumerable <ListViewItem> items, FilterList filterList)
        {
            Dictionary <string, List <string[]> > allSignals =
                InterprojectExchange.GetInstance().GetBindedSignals();

            var projectSignals = new List <string>();

            foreach (var signalGroup in allSignals.Keys)
            {
                foreach (var signalPair in allSignals[signalGroup])
                {
                    var signal = signalPair[(int)filterList];
                    projectSignals.Add(signal);
                }
            }

            var filteredSignals = new List <ListViewItem>();
            int subItemIndex    = filterList == FilterList.CurrentProject ? 1 : 0;

            foreach (var item in items)
            {
                string itemName = item.SubItems[subItemIndex].Text;
                if (!projectSignals.Contains(itemName))
                {
                    filteredSignals.Add(item);
                }
            }

            return(filteredSignals);
        }
Example #19
0
 public void UpdateChoosers(FilterList <FilterCategory> categories)
 {
     foreach (var category in categories)
     {
         UpdateChooser(category);
     }
 }
Example #20
0
 public CompareSyncWorker(string leftPath, string rightPath)
 {
     LeftCompareRootPath  = leftPath;
     RightCompareRootPath = rightPath;
     Exclusions           = new FilterList();
     _syncBehavior        = new NoopBehavior(this);
 }
Example #21
0
 public SearchStartingEventArgs(SearchStartingReason reason, string searchText,
                                FilterList <FilterCategory> filters)
 {
     Reason     = reason;
     SearchText = searchText;
     Filters    = filters;
 }
Example #22
0
 public void LoadFilterData()
 {
     foreach (string filter in Properties.Settings.Default.Filters)
     {
         FilterList.Add(new FilterData(filter));
     }
 }
        public void When_I_Scan_with_a_FilterList_with_OR_logic_I_get_the_expected_results()
        {
            List <FilterTestRecord> expectedRecords = (from r in _allExpectedRecords where r.LineNumber <= 2 select r).ToList();

            var client  = new HBaseClient(_credentials);
            var scanner = new Scanner();

            Filter f0 = new SingleColumnValueFilter(
                Encoding.UTF8.GetBytes(ColumnFamilyName1),
                Encoding.UTF8.GetBytes(LineNumberColumnName),
                CompareFilter.CompareOp.Equal,
                BitConverter.GetBytes(1));

            Filter f1 = new SingleColumnValueFilter(
                Encoding.UTF8.GetBytes(ColumnFamilyName1),
                Encoding.UTF8.GetBytes(LineNumberColumnName),
                CompareFilter.CompareOp.LessThanOrEqualTo,
                BitConverter.GetBytes(2));

            var filter = new FilterList(FilterList.Operator.MustPassOne, f0, f1);

            scanner.filter = filter.ToEncodedString();

            ScannerInformation      scanInfo      = client.CreateScanner(_tableName, scanner);
            List <FilterTestRecord> actualRecords = RetrieveResults(scanInfo).ToList();

            actualRecords.ShouldContainOnly(expectedRecords);
        }
Example #24
0
    /// <summary>
    /// Recursively applies an encoded skeleton, or part of it, to the shadow
    /// </summary>
    /// <param name="data">The encoded skeleton data</param>
    /// <param name="t">The current transform to apply to</param>
    /// <param name="nameFilter">The filter for names</param>
    /// <param name="bypass">Used for whitelists to take children of
    /// whitelisted transforms</param>
    public static void ReadShadowData(
        ShadowTransform[] data,
        Transform t,
        ShadowCoordinator coordinator,
        FilterList <string> nameFilter,
        bool bypass = false)
    {
        bool allowed   = (bypass == true || nameFilter.Allowed(t.name) == true);
        bool whitelist = (nameFilter.IsWhitelist() == true);

        bypass = (allowed == true && whitelist == true);

        // If this is a valid bone, and is allowed, read it to the skeleton
        int key = coordinator.GetBoneKey(t.name);

        if (allowed == true && ShadowTransform.IsValid(data[key]) == true)
        {
            data[key].WriteTo(t);
        }

        // See if we need to keep searching
        if (whitelist == true || allowed == true)
        {
            foreach (Transform child in t)
            {
                ReadShadowData(data, child, coordinator, nameFilter, bypass);
            }
        }
    }
Example #25
0
        public void CanFilterFileToOdb()
        {
            var id    = new ObjectId("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
            var flags = FilterFlags.NoSystemAttributes;

            using (Repository repo = SandboxRepository("testrepo"))
            {
                string attributesPath = string.Format("{0}/.gitattributes", repo.Workdir);
                File.WriteAllLines(attributesPath, new string[] { "* text eol=crlf" });

                string filePath = string.Format("{0}/foo.txt", repo.Workdir);
                File.WriteAllBytes(filePath, new byte[] { 0x68, 0x65, 0x79, 0x20, 0x74, 0x68, 0x65, 0x72, 0x65, 0x0d, 0x0a });

                using (Blob b = repo.Objects.Lookup <Blob>(id))
                    using (FilterList cleanFilter = repo.LoadFilterList(b, "foo.txt", FilterMode.ToObjectDatabase, flags))
                    {
                        using (GitBuffer outputBuffer = cleanFilter.Apply("foo.txt"))
                        {
                            Assert.Equal(10, outputBuffer.Length);
                            Assert.True(outputBuffer.Content.SequenceEqual(new ReadOnlySpan <byte>(new byte[] { 0x68, 0x65, 0x79, 0x20, 0x74, 0x68, 0x65, 0x72, 0x65, 0x0a })));
                            Assert.Equal(10, outputBuffer.Content.Length);
                        }
                    }
            }
        }
Example #26
0
        public async Task ApplyRotationFilterAsync(double value)
        {
            RotationFilterModel f = new RotationFilterModel(value);

            IsChanged = true;
            FilterList.Add(f);
            foreach (var item in f.Components)
            {
                _filters.Add(item);
            }

            int h = Math.Max(OriginalBitmap.PixelHeight, OriginalBitmap.PixelWidth);
            int w = Math.Min(OriginalBitmap.PixelHeight, OriginalBitmap.PixelWidth);

            OriginalBitmap = new WriteableBitmap(w, h);

            using (FilterEffect effect = new FilterEffect(ImageSource)
            {
                Filters = _filters
            })
                using (WriteableBitmapRenderer renderer = new WriteableBitmapRenderer(effect, OriginalBitmap))
                {
                    await renderer.RenderAsync();

                    OriginalBitmap.Invalidate();
                }
        }
Example #27
0
    /// <summary>
    /// Recursively populates a transform data array from this shadow, with
    /// a potential whitelist or blacklist
    /// </summary>
    /// <param name="data">The array to populate</param>
    /// <param name="t">The current subtree root</param>
    /// <param name="coordinator">The coordinator</param>
    /// <param name="nameFilter">The filter for names</param>
    /// <param name="bypass">Used for whitelists to take children of
    /// whitelisted transforms</param>
    public static void WriteShadowData(
        ShadowTransform[] data,
        Transform t,
        ShadowCoordinator coordinator,
        FilterList <string> nameFilter,
        bool bypass = false)
    {
        bool allowed   = (bypass == true || nameFilter.Allowed(t.name) == true);
        bool whitelist = (nameFilter.IsWhitelist() == true);

        bypass = (allowed == true && whitelist == true);

        // If we're permitting this bone through the filter
        if (allowed == true)
        {
            data[coordinator.GetBoneKey(t.name)].ReadFrom(t);
        }

        // See if we need to keep searching
        if (whitelist == true || allowed == true)
        {
            foreach (Transform child in t)
            {
                WriteShadowData(data, child, coordinator, nameFilter, bypass);
            }
        }
    }
        public FilterList <Order> ReadAllOrders(Filter filter)
        {
            IQueryable <Order> orders = ctx.Orders.Include(order => order.Customer).AsQueryable();

            if (filter.OrderFinished)
            {
                orders = from x in orders where x.OrderFinished select x;
            }
            if (!filter.OrderFinished)
            {
                orders = from x in orders where !x.OrderFinished select x;
            }

            int totalItems = orders.Count();

            if (filter.CurrentPage > 0)
            {
                orders = orders.Skip((filter.CurrentPage - 1) * filter.ItemsPrPage).Take(filter.ItemsPrPage);
                if (orders.Count() == 0 && filter.CurrentPage > 1)
                {
                    throw new InvalidDataException("Index out of bounds");
                }
            }

            FilterList <Order> filterList = new FilterList <Order> {
                totalItems = totalItems, List = orders.ToList()
            };

            return(filterList);
        }
        /// <summary>
        /// Filters from post.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <returns>CustomerFilters.</returns>
        private CustomerFilters FilterFromPost(dynamic obj)
        {
            var result = new CustomerFilters();

            result.UserName = obj.name;
            result.UserFilterListCollection.Clear();
            foreach (var filter in obj.filters)
            {
                var list  = new FilterList();
                var array = ((string)filter).Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var val in array)
                {
                    if (!string.IsNullOrEmpty(val))
                    {
                        list.Filters.Add(new Filter {
                            Name = "Keywords", Value = val
                        });
                    }
                }

                if (list.Filters.Count > 0)
                {
                    result.UserFilterListCollection.Add(list);
                }
            }

            return(result);
        }
Example #30
0
 private static void RenderCacheDiff(FilterList list, StringBuilder builder)
 {
     if (list.Contains(FilterList.KEY_DIFF_VAL))
     {
         builder.Append(Catalog.GetString("<b>Difficulty: </b>"));
         string op = list.GetCriteria(FilterList.KEY_DIFF_OP) as String;
         if (op == "==")
         {
             builder.Append(Catalog.GetString("Equal to"));
         }
         else if (op == ">")
         {
             builder.Append(Catalog.GetString("Greater Than"));
         }
         else if (op == ">=")
         {
             builder.Append(Catalog.GetString("Greater Than or Equal To"));
         }
         else if (op == "<=")
         {
             builder.Append(Catalog.GetString("Less Than or Equal To"));
         }
         else if (op == "<")
         {
             builder.Append(Catalog.GetString("Less Than"));
         }
         builder.Append(" ");
         builder.Append(list.GetCriteria(FilterList.KEY_DIFF_VAL));
         builder.Append("\n");
     }
 }
Example #31
0
 /// <summary>
 /// Copy property values between two filter lists
 /// </summary>
 /// <param name="from">The filter list to read properties from</param>
 /// <param name="to">The filter list to copy properties to</param>
 public void CopyPropertyValues(FilterList from, FilterList to)
 {
     for (int i = 0; i < from.Count; ++i) {
     if (!Object.ReferenceEquals(from[i], to[i])) {
       CopyPropertyValues(from[i], to[i]);
     }
       }
 }
Example #32
0
        public UdpFilterViewModel(FilterValue filterValue, FilterFormatType type, string crProcess, DynamicTypeManager theDynamicTypeManager, string name, string crFieldName, FilterList filterList)
        {
            if (theDynamicTypeManager == null)
            {
                throw new ArgumentNullException("theDynamicTypeManager");
            }

            Name = name;
            Type = type != null ? GetTypeForView(type.MemberType.Name != "Nullable`1" ? type.MemberType : type.MemberType.GenericTypeArguments[0]) : "Text";

            if (crProcess != null)
            {
                //Type itemType = theDynamicTypeManager.GetInfoType<IInfoClass>(crProcess);
                //PropertyInfo guidProperty = itemType.GetPropertyByName("Guid");
               // PropertyInfo crFieldProperty = itemType.GetPropertyByName(crFieldName);

                if (crProcess == Constants.StateProcessName)
                {
                    Values = theDynamicTypeManager.GetList<IInfoList>(crProcess, string.Empty, 0, int.MaxValue, null, filterList)
                            .Cast<IStateInfo>()
                            .Select(x => new IdValuePair
                            {
                                Id = x.Id.ToString(CultureInfo.InvariantCulture),//guidProperty.With(v => v.GetValue(x)).Return(v => v.ToString(), string.Empty),
                                //Value = crFieldProperty.GetValue(x)
                                Value = x.GetValueByPropertyName(crFieldName)

                            })
                            .ToList();
                }
                else
                {
                    Values = theDynamicTypeManager.GetList<IInfoList>(crProcess, string.Empty, 0, int.MaxValue)
                        .Cast<IInfoClass>()
                        .Select(x => new IdValuePair
                        {
                            Id = x.Id.ToString(CultureInfo.InvariantCulture),
                            Value = x.GetValueByPropertyName(crFieldName)
                        })
                        .ToList();
                }
            }
            else
            {
                if (Type == "Approval")
                {
                    Values = Enum.GetValues(typeof(ApprovalStates)).Cast<ApprovalStates>().Select(x => new IdValuePair { Id = x.ToString(), Value = x.GetDescription() }).ToList();
                }
                else
                {
                    Values = null;
                }
            }

            DefaultValue = filterValue != null && filterValue.DefaultValue != null ? Convert.ToString(filterValue.DefaultValue, CultureInfo.InvariantCulture) : string.Empty;
        }
Example #33
0
        private bool LoadFilters(string path)
        {
            if (!File.Exists(path))
                return false;

            var serializer = new XmlSerializer(_Filters.GetType());
            using (TextReader textReader = new StreamReader(path))
            {
                _Filters = (FilterList)serializer.Deserialize(textReader);
            }
            return true;
        }
Example #34
0
        public FilterListTests()
        {
            XDocument filterDoc = new XDocument(
                new XElement("response",
                    new XElement("filters",
                        new XElement("filter",
                                        new XAttribute("type", "builtin"),
                                        new XAttribute("sFilter", "ex349"),
                                        "My Cases"),
                        new XElement("filter",
                                        new XAttribute("type", "saved"),
                                        new XAttribute("sFilter", "304"),
                                        new XAttribute("status", "current"),
                                        "Cases I should have closed months ago"))));

            this.list = new FilterList(filterDoc);
        }
Example #35
0
    public static void TestCount()
    {
      for (var i = 0; i < 100; i++)
      {
        var items = MonteCarlo.Unordered().ToList();
        var keys = MonteCarlo.Keys(items.Count).AsIntervals().ToList();

        var filteredItems = new FilterList<int>(items, keys);

        Console.WriteLine("   {0}", items.ToCSV(100));
        Console.WriteLine(" [ {0} ]", keys);
        Console.WriteLine(" = {0}", filteredItems);
        Console.WriteLine();

        Assert.That(filteredItems.Count, Is.EqualTo(keys.IntervalsCount()));
      }
    }
        public void TestGlitchFilterOverCreation()
        {
            List<FilterList> inputs = new List<FilterList>();

            try
            {


                for (int i = 0; i < 3; i++)
                {
                    DigitalInput input = new DigitalInput(i);
                    DigitalGlitchFilter filter = new DigitalGlitchFilter();
                    filter.Add(input);

                    FilterList list = new FilterList
                    {
                        input = input,
                        filter = filter,
                        index = i
                    };

                    inputs.Add(list);

                    Assert.That(SimData.DIO[i].FilterIndex, Is.EqualTo(i));
                }

                Assert.Throws<AllocationException>(() =>
                {
                    DigitalGlitchFilter filter = new DigitalGlitchFilter();
                });

            }
            finally
            {
                foreach (var filterList in inputs)
                {
                    filterList.filter.Remove(filterList.input);
                    filterList.filter.Dispose();
                    filterList.input.Dispose();

                    Assert.That(SimData.DIO[filterList.index].FilterIndex, Is.EqualTo(-1));
                }
            }
        }
Example #37
0
        /// <summary>
        /// Creates a new filter list from an existing one.
        /// </summary>
        /// <remarks>If the filter is not found in the addin host or
        /// the type hasn't changed, the old filter is copied by reference to the new
        /// filter list. Otherwise, a new instance of the new type is initialized and
        /// added to the new filter list</remarks>
        /// <param name="fl">Current filter list</param>
        /// <param name="h">List of available addins</param>
        /// <returns>The new filter list</returns>
        public FilterList Update(FilterList fl, AddinHost h)
        {
            FilterList fl_new = new FilterList();
              foreach (IFilter f in fl) {
            Type t = f.GetType();
            Type addin = h.FindAddins(
              typeof(IFilter),
              (ai) => { return ai.IsDefaultConstructible() && ai.FullName == t.FullName; }).FirstOrDefault();

            if (addin == null || t == addin) {
              // Just move filter over
              fl_new.Add(f);
            } else {
              // Create a new instance
              fl_new.Add(h.CreateInstance(addin) as IFilter);
            }
              }

              return fl_new;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //To get the string to search in depfilter table
            string departmentID = Request.QueryString["DepartmentID"];

            var sqlFilList = new FilterList();
            sqlFilList.Filters = new List<FilterObject>();

            using (var db = new KioskContext())
            {
                //selects only from departmentfilter where department ID  = SIT [Querystring]
                var depfilters = from df in db.DepartmentFilters
                                where df.Department.DepartmentID == departmentID

                                orderby df.FilterName
                                select new
                                {
                                    df.DepartmentFilterID,
                                    df.DepartmentID,
                                    df.FilterName,
                                    df.Block,
                                    df.Level,
                                    df.Name,
                                };

                foreach (var fil in depfilters)
                {
                    FilterObject filobject = new FilterObject(fil.DepartmentFilterID, fil.DepartmentID, fil.FilterName, fil.Block, fil.Level,
                        fil.Name);

                    sqlFilList.Filters.Add(filobject);
                }
            }

            //Serialize into json format output (string)
            string json = JsonConvert.SerializeObject(sqlFilList, Formatting.Indented);

            //codes to pass back the json string to the iPad
            Response.Write(json);
            Response.End();
        }
        public SpecificationForm()
        {
            InitializeComponent();
              try
              {
            current = Program.StartForm.current;
            if (current == null)
            {
              Functions.CloseApplication();
              return;
            }
            FM = new FlexCellManager(Book);
            FM.InitBook(1, 1, "Tahoma", 8, true);

            StatusSplash.Create(MainStatusStrip);
            StatusSplash.Message("Настройка источника данных...");
            current.Parameters.Add("ConnectionString", 0, "User id=qmmoscow;password=qmmoscow;Data Source=msk-lims-01.corp.tnk-bp.ru;SID=limsmsk;Direct=true;Max Pool Size=30;Connection Lifetime=1200");
            DataConnection.ConnectionString = current.Parameters["ConnectionString"].StringValue;
            DataConnection.Open();

            // фильтры
            StatusSplash.Message("Обновление фильтров...");
            FL = new FilterList(current);
            FL.Add(PlantsCheck, null);
            FL.Add(PlantsCombo, UpdatePlants);
            FL.Add(UNCCheck, null);
            FL.Add(UNCCombo, UpdateUNCProducts);
            FL.Add(ProductsCheck, null);
            FL.Add(ProductsCombo, UpdateProducts);
            FL.Start();

            IntegralCheck_CheckedChanged(this, new EventArgs());
              }
              finally
              {
            StatusSplash.Close();
              }
        }
Example #40
0
        public static Filter[] getFilters(FilterList list)
        {
            if (list.count == 0)
                return new Filter[0];
            List<Filter> ret = new List<Filter>();
            string result = exec("show filterlist name=\"" + list.name + "\" level=verbose format=table wide=no");
            result = result.Substring(result.IndexOf("-------\r\n") + "-------\r\n".Length);
            string[] parts = result.Replace("\r", "").Split('\n');

            for (int i = 0; i < parts.Length - 2; i += 2)
            {
                string part = parts[i];
                string[] cells = part.Split('\t');
                Filter filter = new Filter();
                filter.address = IPAddress.Parse(cells[1].Trim());
                ret.Add(filter);
            }
            return hideDuplicates(ret);
        }
        private void ExecuteUnlink(IEditableRoot source, IEditableRoot destination)
        {
            var crList = (ICrossRefItemList)destination.GetValueByPropertyName(Property.Name);
            if (crList == null)
            {
                throw new InvalidOperationException("Destination field is null.");
            }

            var filterList = new FilterList();
            if (crList.Count > 0)
            {
                // Include only items that are linked to MCR.
                filterList.Add(CreateLinkedItemsFilter(FilterOperator.In, crList.Cast<ICrossRefItemInfo>().Select(x => x.Id)));
            }

            if (!string.IsNullOrEmpty(SourceDataFilterDefinition))
            {
                filterList.Add(CreateSourceDataFilter(source));
            }

            foreach (var infoItem in GetSourceItems(filterList))
            {
                var ancestor = infoItem.GetAncestorByProcessName(ReferencedProcessName);
                if (ancestor == null)
                    continue;

                crList.Remove(ancestor.Id);
            }
        }
Example #42
0
 public virtual FilterList VisitFilterList(FilterList filters){
   if (filters == null) return null;
   for (int i = 0, n = filters.Count; i < n; i++)
     filters[i] = (Filter)this.VisitFilter(filters[i]);
   return filters;
 }
Example #43
0
        /// <summary>
        /// Schedules the items.
        /// </summary>
        /// <param name="scheduleEdit">The schedule edit.</param>
        /// <param name="finalState">The final state.</param>
        public void ScheduleItems(ISupportScheduling scheduleEdit, Guid finalState)
        {
            using (new BypassPropertyCheckContext())
            {
                if (scheduleEdit == null)
                {
                    return;
                }

                if (scheduleEdit.ProcessingScheduling)
                {
                    return;
                }

                if (!scheduleEdit.ScheduleBasedOnDate.HasValue && !scheduleEdit.ScheduleDisplayDate.HasValue)
                {
                    return;
                }

                if (scheduleEdit.IsScheduleDateChangedForOnlyItem)
                {
                    return;
                }

                var fp = TheDynamicTypeManager.GetEditableRoot<IFrequencyPattern>(Constants.FrequencyPatternProcessName, scheduleEdit.SchedulingFrequencyPatternId);
                if (fp == null)
                {
                    return;
                }

                var supportStateEdit = scheduleEdit as ISupportStates;
                if (supportStateEdit == null)
                {
                    return;
                }

                var isFinalState = finalState == supportStateEdit.CurrentStateGuid;
                if (!isFinalState && !scheduleEdit.IsNew)
                {
                    return;
                }

                if (scheduleEdit.SchedulingEndOption == SchedulingEndOption.EndAfterOccurrences.ToString())
                {
                    if (scheduleEdit.SchedulingEndAfterOccurrencesIndex >= scheduleEdit.SchedulingEndAfterOccurrences)
                    {
                        return;
                    }

                    scheduleEdit.SchedulingEndAfterOccurrencesIndex++;
                }

                DateTime dateOfScheduleEdit = scheduleEdit.ScheduleBasedOnDate ?? scheduleEdit.ScheduleDisplayDate.Value;

                ICalendar calendar = null;
                var userCalendar = scheduleEdit.GetCalendar();

                var tmpCalendar = userCalendar as ICalendar;
                if (tmpCalendar != null)
                {
                    calendar = tmpCalendar;
                }

                if (userCalendar is int)
                {
                    calendar = TheDynamicTypeManager.GetEditableRoot<ICalendar>(Constants.CalendarProcessName, (int)userCalendar);
                }

                if (userCalendar == null)
                {
                    var calendars = TheDynamicTypeManager.GetInfoList<IInfoClass>(Constants.CalendarProcessName, pageSize: 1);
                    if (calendars.Count > 0)
                    {
                        calendar = TheDynamicTypeManager.GetEditableRoot<ICalendar>(Constants.CalendarProcessName, calendars[0].Id);
                    }
                }

                var filter = new FilterList
                                 {
                                     new FilterDescriptor(
                                         LogicalOperators.And,
                                         new MobileObservableCollection<IFilterDescriptor>
                                             {
                                                 new FilterDescriptor(
                                                     Constants.SchedulingSeriesGuid,
                                                     FilterOperator.IsEqualTo,
                                                     scheduleEdit.SchedulingSeriesGuid,
                                                     typeof(string)),
//ELMTDEV-2250
//                                                 new FilterDescriptor(
//                                                     Constants.SchedulingSeriesItemNumber,
//                                                     FilterOperator.IsGreaterThan,
//                                                     scheduleEdit.SchedulingSeriesItemNumber,
//                                                     typeof(int)),
                                                 new FilterDescriptor(
                                                     Constants.IdColumnName,
                                                     FilterOperator.IsNotEqualTo,
                                                     scheduleEdit.Id,
                                                     typeof(int)),
                                                 new FilterDescriptor(
                                                     Constants.CurrentStateIdColumnName,
                                                     FilterOperator.IsNotEqualTo,
                                                     scheduleEdit.ScheduleStartStateId,
                                                     typeof(int))
                                             })
                                 };

                if (!string.IsNullOrEmpty(scheduleEdit.ScheduleFilter))
                {
                    var scheduleFilterList = FilterDescriptor.GetFilterList(scheduleEdit.ScheduleFilter);
                    if (scheduleFilterList != null)
                    {
                        foreach (var filterDescriptor in scheduleFilterList)
                            filter.Add(filterDescriptor);
                    }
                }

                var sortList = new SortList { new SortDescriptor(Constants.SchedulingSeriesItemNumber, SortDirection.Ascending) };

                var infoList = TheDynamicTypeManager.GetInfoList<IInfoClass>(
                    scheduleEdit.ProcessName,
                    pageSize: 100,
                    filterDescriptors: filter,
                    sortDescriptors: sortList);

                var lenght = isFinalState ? scheduleEdit.ScheduledItemsCount : scheduleEdit.ScheduledItemsCount - 1;

                _scheduledList.Clear();
                _scheduledList.Add(dateOfScheduleEdit.Date);
                _previousScheduleDate = dateOfScheduleEdit.Date;
                for (var i = 0; i < lenght; i++)
                {
                    CalculateAndSave(ref dateOfScheduleEdit, infoList.ElementAtOrDefault(i), scheduleEdit, fp, calendar);
                }
             }
        }
Example #44
0
 public static FilterList[] getFilterLists()
 {
     List<FilterList> ret = new List<FilterList>();
     string result = exec("show filterlist all format=table");
     if (result.Contains("IPsec[05067]"))
         return new FilterList[0];
     string[] parts = result.Replace("\r", "").Split('\n');
     for (int i = 2; i < parts.Length - 5; i++)
     {
         string part = parts[i];
         string[] cells = part.Split('\t');
         FilterList filterList = new FilterList();
         filterList.name = cells[0].Trim();
         filterList.count = int.Parse(cells[1].Trim());
         ret.Add(filterList);
     }
     return ret.ToArray();
 }
Example #45
0
 public static void deleteFilter(FilterList list, string src, string dst = "Me")
 {
     exec("delete filter filterlist=\"" + list.name + "\" srcaddr=\"" + src + "\" dstaddr=\"" + dst + "\"");
 }
Example #46
0
 public static void addFilterRule(string name, FilterPolicy policy, FilterList list, FilterAction action)
 {
     string s = exec("add rule name=\"" + name + "\" policy=\"" + policy.name + "\" filterlist=\"" + list.name + "\" filteraction=\"" + action.name + "\"");
 }
Example #47
0
 public static void addFilterPolicy(FilterList list, string name, string description="", bool assign = true, int pollinginterval = 30)
 {
     exec("add policy name=\"" + name + "\" description=\"" + description + "\" assign=\"" + (assign ? "yes" : "no") + "\" pollinginterval=\"" + pollinginterval + "\"");
 }
        /// <summary>
        /// Links items to destination field.
        /// </summary>
        /// <param name="source">
        /// The source item.
        /// </param>
        /// <param name="destination">
        /// The destination item.
        /// </param>
        private void ExecuteLink(IEditableRoot source, IEditableRoot destination)
        {
            var crList = (ICrossRefItemList)destination.GetValueByPropertyName(Property.Name);
            if (crList == null)
            {
                throw new InvalidOperationException("Destination field is null.");
            }

            var filterList = new FilterList();
            if (crList.Count > 0)
            {
                // Exclude items that are already linked.
                filterList.Add(CreateLinkedItemsFilter(FilterOperator.NotIn, crList.Cast<ICrossRefItemInfo>().Select(x => x.Id)));
            }

            if (!string.IsNullOrEmpty(SourceDataFilterDefinition))
            {
                filterList.Add(CreateSourceDataFilter(source));
            }

            foreach (var infoItem in GetSourceItems(filterList))
            {
                var ancestor = infoItem.GetAncestorByProcessName(ReferencedProcessName);
                if (ancestor == null || crList.Contains(ancestor.Id))
                    continue;

                crList.Assign(ancestor.Id);

                if (FieldUpdaters.Count == 0)
                    continue;

                var criteria = new DetailCriteria(infoItem.Id) { AllowLazyLoading = true };
                var editItem = DynamicTypeManager.GetEditableRoot<IEditableRoot>(SourceDataProcessName, criteria);
                if (editItem == null || editItem.Id <= 0)
                    continue;

                var sourceData = new DataTriggerSourceData();
                sourceData.SourceItems[DataTriggerFieldMappingExpressionNames.SourceDataProcess] = editItem;

                UpdateFieldValues(sourceData, editItem);

                ((ISavable)editItem).Save();
            }
        }
        private IInfoList<IInfoClass> GetSourceItems(FilterList filters)
        {
            var criteria = new PagedCriteria
                               {
                                   ProcessName = SourceDataProcessName,
                                   FilterDefinition = FilterDescriptor.GetFilterExpression(filters),
                                   PageNumber = 0,
                                   PageSize = int.MaxValue,
                                   LimitResultColumns = true,
                                   ResultColumns = new MobileList<string> { Constants.IdColumnName },
                                   NotCalculateAccessDeniedList = true
                               };

            return DynamicTypeManager.GetInfoList<IInfoClass>(criteria);
        }
Example #50
0
 public virtual FilterList VisitFilterList(FilterList filters1, FilterList filters2)
 {
     if (filters1 == null) return null;
     for (int i = 0, n = filters1.Count, m = filters2 == null ? 0 : filters2.Count; i < n; i++)
     {
         //^ assert filters2 != null;
         if (i >= m)
             filters1[i] = (Filter)this.VisitFilter(filters1[i], null);
         else
             filters1[i] = (Filter)this.VisitFilter(filters1[i], filters2[i]);
     }
     return filters1;
 }
 public virtual Filter GetClosestMatch(Filter/*!*/ nd1, FilterList/*!*/ list1, FilterList list2, int list1pos, ref int list2start,
   TrivialHashtable matchedNodes, out Differences closestDifferences, out int list2pos){
   closestDifferences = null; list2pos = -1;
   if (list2 == null) return null;
   if (nd1 == null || list1 == null || matchedNodes == null || list1pos < 0 || list1pos >= list1.Count || list2start < 0 || list2start >= list2.Count) {
     Debug.Assert(false); return null;
   }
   Filter closest = null;
   Differences winnerSoFar = null;
   for (int j = list2start, m = list2.Count; j < m; j++){
     Filter nd2 = list2[j];
     if (list2start == j) list2start++;
     if (nd2 == null) continue;
     if (matchedNodes[nd2.UniqueKey] != null) continue;
     Differences diff = this.GetDifferences(nd1, nd2);
     if (diff == null){Debug.Assert(false); continue;}
     if (diff.Similarity <= 0.5){
       //Not a good enough match
       if (list2start == j+1) list2start--; //The next call to GetClosestMatch will start looking at list2start, so this node will be considered then
       continue; //ignore it for the rest of this call
     }
     if (winnerSoFar != null && winnerSoFar.Similarity >= diff.Similarity) continue;
     winnerSoFar = closestDifferences = diff;
     closest = nd2;
     list2pos = j;
     if (diff.NumberOfDifferences == 0) return closest; //Perfect match, no need to look for other matches
   }
   if (closest != null){
     //^ assert winnerSoFar != null;
     //closest is closer to nd1 than any other node in list2, but this is no good if some other node in list1 has a better claim on closest
     for (int i = list1pos+1, n = list1.Count; i < n; i++){
       Filter nd1alt = list1[i];
       if (nd1alt == null) continue;
       if (matchedNodes[nd1alt.UniqueKey] != null) continue;
       Differences diff = this.GetDifferences(nd1alt, closest);
       if (diff == null){Debug.Assert(false); continue;}
       if (diff.Similarity <= winnerSoFar.Similarity) continue;
       //nd1alt has a better claim on closest. See if it wants closest.
       Differences diff2;
       int j, k = list2start;
       Filter nd2alt = this.GetClosestMatch(nd1alt, list1, list2, i, ref k,  matchedNodes, out diff2, out j);
       if (nd2alt != closest){
         Debug.Assert(nd2alt != null && diff2 != null && diff2.Similarity >= diff.Similarity);
         continue; //nd1alt prefers nd2alt to closest, so closest is still available
       }
       //nd1alt wants closest, take it out of the running
       matchedNodes[closest.UniqueKey] = nd1alt;
       //Now that closest is out of the running, try again
       k = list2start;
       Filter newClosest = this.GetClosestMatch(nd1, list1, list2, i, ref k, matchedNodes, out winnerSoFar, out list2pos);
       //put closest back in the running so that the next call to this routine will pick it up
       matchedNodes[closest.UniqueKey] = closest;
       closest = newClosest;
       break;
     }
   }
   closestDifferences = winnerSoFar;
   return closest;
 }
Example #52
0
 public virtual void VisitFilterList(FilterList filters)
 {
   if (filters == null) return;
   for (int i = 0, n = filters.Count; i < n; i++)
     this.VisitFilter(filters[i]);
 }
Example #53
0
 public override FilterList VisitFilterList(FilterList filters)
 {
     if (filters == null) return null;
     return base.VisitFilterList(filters.Clone());
 }
Example #54
0
 public static void addFilter(FilterList list, string src, string dst = "Me")
 {
     string s = exec("add filter filterlist=\"" + list.name + "\" srcaddr=\"" + src + "\" dstaddr=\"" + dst + "\"");
 }
 public virtual Differences VisitFilterList(FilterList list1, FilterList list2,
   out FilterList changes, out FilterList deletions, out FilterList insertions){
   changes = list1 == null ? null : list1.Clone();
   deletions = list1 == null ? null : list1.Clone();
   insertions = list1 == null ? new FilterList() : list1.Clone();
   //^ assert insertions != null;
   Differences differences = new Differences();
   for (int j = 0, n = list2 == null ? 0 : list2.Count; j < n; j++){
     //^ assert list2 != null;
     Filter nd2 = list2[j];
     if (nd2 == null) continue;
     insertions.Add(null);
   }
   TrivialHashtable savedDifferencesMapFor = this.differencesMapFor;
   this.differencesMapFor = null;
   TrivialHashtable matchedNodes = new TrivialHashtable();
   for (int i = 0, k = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
     //^ assert list1 != null && changes != null && deletions != null;
     Filter nd1 = list1[i]; 
     if (nd1 == null) continue;
     Differences diff;
     int j;
     Filter nd2 = this.GetClosestMatch(nd1, list1, list2, i, ref k, matchedNodes, out diff, out j);
     if (nd2 == null || diff == null){Debug.Assert(nd2 == null && diff == null); continue;}
     matchedNodes[nd1.UniqueKey] = nd1;
     matchedNodes[nd2.UniqueKey] = nd2;
     changes[i] = diff.Changes as Filter;
     deletions[i] = diff.Deletions as Filter;
     insertions[i] = diff.Insertions as Filter;
     insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
     Debug.Assert(diff.Changes == changes[i] && diff.Deletions == deletions[i] && diff.Insertions == insertions[i]);
     differences.NumberOfDifferences += diff.NumberOfDifferences;
     differences.NumberOfSimilarities += diff.NumberOfSimilarities;
   }
   //Find deletions
   for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
     //^ assert list1 != null && changes != null && deletions != null;
     Filter nd1 = list1[i]; 
     if (nd1 == null) continue;
     if (matchedNodes[nd1.UniqueKey] != null) continue;
     changes[i] = null;
     deletions[i] = nd1;
     insertions[i] = null;
     differences.NumberOfDifferences += 1;
   }
   //Find insertions
   for (int j = 0, n = list1 == null ? 0 : list1.Count, m = list2 == null ? 0 : list2.Count; j < m; j++){
     //^ assert list2 != null;
     Filter nd2 = list2[j]; 
     if (nd2 == null) continue;
     if (matchedNodes[nd2.UniqueKey] != null) continue;
     insertions[n+j] = nd2;  //Records nd2 as an insertion into list1, along with its position in list2
     differences.NumberOfDifferences += 1; //REVIEW: put the size of the tree here?
   }
   if (differences.NumberOfDifferences == 0){
     changes = null;
     deletions = null;
     insertions = null;
   }
   this.differencesMapFor = savedDifferencesMapFor;
   return differences;
 }
Example #56
0
        /// <summary>
        /// Gets the last successful session.
        /// </summary>
        /// <param name="synchronizer">The synchronizer.</param>
        /// <returns>IESyncSessionInfo.</returns>
        private IESyncSessionInfo GetLastSuccessfulSession(IProcessSynchronizer synchronizer)
        {
            try
            {
                var filterList = new FilterList
                                     {
                                         new FilterDescriptor("SynchronizedProcessName", FilterOperator.IsEqualTo, synchronizer.ProcessName),
                                         new FilterDescriptor(Constants.ESyncSessionSyncProcessGuidColumnName, FilterOperator.IsEqualTo, synchronizer.Guid.ToString()),
                                         new FilterDescriptor(Constants.ESyncSessionIsSuccessfulColumnName, FilterOperator.IsEqualTo, 1),
                                     };

                var sortList = new SortList
                               {
                                   new SortDescriptor(Constants.ESyncSessionEndTimeColumnName, SortDirection.Descending)
                               };

                var list = DynamicTypeManager.GetList<IInfoList>(Constants.ESyncSessionProcessName, string.Empty, 0, 1, sortList, filterList);

                if (list != null && list.Count > 0)
                    return list.Cast<IESyncSessionInfo>().First();
            }
            catch (Exception ex)
            {
                Logger.Log(LogSeverity.Error, "ESYNC", ex);
            }

            return null;
        }
        public CertTankForm()
        {
            InitializeComponent();
              StatusSplash.Create(MainStatusStrip);
              StatusSplash.Message("�����������...");
              current = Program.StartForm.current;
              if (current == null)
              {
            Functions.CloseApplication();
            return;
              }

              StatusSplash.Message("��������� ��������� ������...");
              current.Parameters.Add("ConnectionString", 0, "User id=qmmoscow;password=qmmoscow;Data Source=msk-lims-01.corp.tnk-bp.ru;SID=limsmsk;Direct=true;Max Pool Size=30;Connection Lifetime=1200");
              DataConnection.ConnectionString = current.Parameters["ConnectionString"].StringValue;
              DataConnection.Open();

              StatusSplash.Message("������...");
              // ������� FlexCell
              FM = new FlexCellManager(Book);
              FM.InitBook(1, 1, "Arial", 8, true);
              FM.EnableCalculateStatistical(StatusLabel);

              // ������������� ����
              Date1.Value = Functions.FirstDateInMonth(DateTime.Now.AddDays(-3));
              Date1.MaxDate = DateTime.Now;
              Date2.Value = Functions.LastDateInMonth(DateTime.Now.AddDays(-3));
              Date2.MaxDate = Date2.Value;

              this.WindowState = FormWindowState.Maximized;

              StatusSplash.Message("��������� ������ �����������...");
              UpdatePlants(); // ��������� ������ ������ �������

              StatusSplash.Message("���������� �������� ������...");
              // ��������� �������� ��������, ������� ������ �� ������� �������� � ��� ��������� �� ���������� �
              // �����������, �� ��������� �������� "�������" ��������
              FL = new FilterList(current);
              FL.Add(new Filter(null, Date1, null));
              FL.Add(new Filter(null, Date2, null));
              FL.Add(PlantCombo, UpdateCertTankPlants);
              FL.Add(ControlTypeCombo, UpdateCertTankControlTypes);
              FL.Add(ProductCombo, UpdateCertTankProducts);
              FL.Start();

              StatusSplash.Close();
        }
Example #58
0
 public void Decode(
     ShadowTransform[] data,
     FilterList<string> nameFilter)
 {
     this.shadow.Decode(data, nameFilter);
 }
Example #59
0
 public virtual FilterList VisitFilterList(FilterList filters, FilterList changes, FilterList deletions, FilterList insertions){
   if (filters == null) return changes;
   if (changes != null){
     if (deletions == null || insertions == null)
       Debug.Assert(false);
     else{
     }
   }else if (deletions != null)
     return null;
   return filters;
 }
Example #60
0
 public ShadowTransform[] Encode(
     ShadowTransform[] buffer,
     FilterList<string> nameFilter)
 {
     return this.shadow.Encode(buffer, nameFilter);
 }