Beispiel #1
0
 private static async Task PiracyCheckAsync(string line, LogParseState state)
 {
     if (await ContentFilter.FindTriggerAsync(FilterContext.Log, line).ConfigureAwait(false) is Piracystring match &&
         match.Actions.HasFlag(FilterAction.RemoveContent))
     {
         var m = match;
         if (line.Contains("not valid, removing from") || line.Contains("Invalid disc path registered"))
         {
             m = new Piracystring
             {
                 Id              = match.Id,
                 Actions         = match.Actions & ~FilterAction.IssueWarning,
                 Context         = match.Context,
                 CustomMessage   = match.CustomMessage,
                 Disabled        = match.Disabled,
                 ExplainTerm     = match.ExplainTerm,
                 String          = match.String,
                 ValidatingRegex = match.ValidatingRegex,
             }
         }
         ;
         if (state.FilterTriggers.TryGetValue(m.Id, out var fh))
         {
             var updatedActions = fh.filter.Actions | m.Actions;
             if (fh.context.Length > line.Length)
             {
                 m.Actions = updatedActions;
                 state.FilterTriggers[m.Id] = (m, line.ToUtf8());
             }
             else
             {
                 fh.filter.Actions = updatedActions;
             }
             if (updatedActions.HasFlag(FilterAction.IssueWarning))
             {
                 state.Error = LogParseState.ErrorCode.PiracyDetected;
             }
         }
         else
         {
             var utf8line = line.ToUtf8();
             state.FilterTriggers[m.Id] = (m, utf8line);
             if (m.Actions.HasFlag(FilterAction.IssueWarning))
             {
                 state.Error = LogParseState.ErrorCode.PiracyDetected;
             }
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Updates the control with a new filter.
        /// </summary>
        private void Update(ContentFilter filter)
        {
            BeginUpdate();

            int index = 0;

            foreach (ContentFilterElement element in filter.Elements)
            {
                AddItem(element, "Property", index++);
            }

            EndUpdate();

            AdjustColumns();
        }
Beispiel #3
0
        private void CopyDirectory(string sourcePath, string destPath)
        {
            var filter = new ContentFilter {
                SourceDirectory      = sourcePath,
                DestinationDirectory = destPath,
                DirectoryAction      = (src, dest) => Directory.CreateDirectory(dest),
                FileAction           = File.Copy,
                IgnoredDirectories   =
                {
                    ".git",
                },
            };

            filter.Run();
        }
Beispiel #4
0
        private GetChunkedFileRequestMessage CreateGetChunkedFileRequestMessage()
        {
            GetChunkedFileRequestMessage request = new GetChunkedFileRequestMessage();

            request.ContentPropertiesToReturn = new string[] { "prop1", "lastocssave" };
            ContentFilter filter = new ContentFilter();

            filter.ChunkingScheme     = ChunkingScheme.FullFile.ToString();
            filter.StreamId           = "MainContent";
            filter.ChunksToReturn     = ChunksToReturn.All.ToString();
            filter.AlreadyKnownChunks = new string[] { "ChunkId1" };
            request.ContentFilters    = new ContentFilter[] { filter };

            return(request);
        }
Beispiel #5
0
        public ActionResult ContentList(int page = 1, int pageSize = 20, string sortby = "")
        {
            ContentFilter filter = (ContentFilter)Session["ContentFilter"];

            if (filter == null)
            {
                filter = new ContentFilter();
                Session["ContentFilter"] = filter;
            }
            var model = _contentRepo.GetContentPaging(filter, page, pageSize, sortby);

            ViewBag.PageNumber = page;
            ViewBag.Title      = "Danh sách bài viết";
            return(View(model));
        }
        public async Task Can_Filter()
        {
            var filter = new ContentFilter("product",
                                           new[] { new ContentFilterProperties("productName", "Jacket", ContentFilterMatch.Contains) });

            var service = new ContentDeliveryService(_configuration,
                                                     GetMockedHttpClient(HttpMethod.Post, $"{_contentBaseUrl}/filter", ContentDeliveryJson.Search));//result is the same as with search so reusing the json
            var result = await service.Content.Filter(filter);

            Assert.NotNull(result);
            Assert.NotNull(result.Content);
            Assert.NotEmpty(result.Content.Items);
            Assert.Equal(1, result.TotalPages);
            Assert.Equal(1, result.TotalItems);
        }
Beispiel #7
0
        private void EditValueMI_Click(object sender, EventArgs e)
        {
            try {
                ContentFilterElement element = SelectedTag as ContentFilterElement;

                if (element == null)
                {
                    return;
                }

                List <FilterOperand> operands = element.GetOperands();

                if (operands.Count != 2)
                {
                    return;
                }

                LiteralOperand literal = operands[1] as LiteralOperand;

                if (literal == null)
                {
                    return;
                }

                // get the current value.
                object currentValue = literal.Value.Value;

                if (currentValue == null)
                {
                    currentValue = String.Empty;
                }

                // edit the value.
                object value = new SimpleValueEditDlg().ShowDialog(currentValue, currentValue.GetType());

                if (value == null)
                {
                    return;
                }

                // update value.
                literal.Value = new Variant(value);
                ContentFilter filter = GetFilter();
                Update(filter);
            } catch (Exception exception) {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
Beispiel #8
0
        public void Test003_CheckWordsDontAppearTwice()
        {
            //dictionary
            contentFilter = new ContentFilter();

            //create project
            project = new Splitter(contentFilter);

            //process sentence le path est bypassé de toute facon
            var r = project.Process("my tailor is my tailor.", new Processor());

            Assert.AreEqual(new List <string>()
            {
                "my", "tailor", "is"
            }, r);
        }
Beispiel #9
0
        /// <summary>
        /// Returns the filter in the control.
        /// </summary>
        public ContentFilter GetFilter()
        {
            ContentFilter filter = new ContentFilter();

            for (int ii = 0; ii < ItemsLV.Items.Count; ii++)
            {
                ContentFilterElement element = ItemsLV.Items[ii].Tag as ContentFilterElement;

                if (element != null)
                {
                    filter.Elements.Add(element);
                }
            }

            return(filter);
        }
Beispiel #10
0
        private void FiddlerApplicationAfterSessionComplete(Session oSession)
        {
            if (string.IsNullOrEmpty(URLFilter) == false)
            {
                URLFilter = URLFilter.Replace("http://", "");
                if (URLFilter.Split(' ').Any(item => oSession.url.Contains(item) == false))
                {
                    return;
                }
            }

            var httpitem = new HttpItem {
                Parameters = oSession.oRequest.headers.ToString()
            };


            if ((oSession.BitFlags & SessionFlags.IsHTTPS) != 0)
            {
                httpitem.URL = "https://" + oSession.url;
            }
            else
            {
                httpitem.URL = "http://" + oSession.url;
            }


            httpitem.Postdata = Encoding.Default.GetString(oSession.RequestBody);
            if (string.IsNullOrEmpty(httpitem.Postdata) == false)
            {
                httpitem.Method = MethodType.POST;
                ControlExtended.UIInvoke(() => Documents.Add(httpitem));
            }


            if (string.IsNullOrEmpty(ContentFilter) == false)
            {
                if (ContentFilter.Split(' ').Any(item => oSession.GetResponseBodyAsString().Contains(item) == false))
                {
                    return;
                }
            }


            httpitem.DictCopyTo(Http);
            XLogSys.Print.Info("已经成功获取嗅探字段" + oSession.url);
        }
Beispiel #11
0
        public void Test001a_Filter_AllDifferentKeepsTheSame()
        {
            //Arrange
            var source = new ContentFilter();

            //Act
            var r = source.Filter(new List <string>()
            {
                "a", "b"
            });

            //Assert
            Assert.AreEqual(new List <string>()
            {
                "a", "b"
            }, r);
        }
Beispiel #12
0
        public void Test001b_Filter_FilterDuplicates()
        {
            //Arrange
            var source = new ContentFilter();

            //Act
            var r = source.Filter(new List <string>()
            {
                "caca", "b", "caca"
            });

            //Assert
            Assert.AreEqual(new List <string>()
            {
                "caca", "b"
            }, r);
        }
 public ActionResult GetList(bool?isMatched, ContentFilter filter)
 {
     return(List(unit => (from c in unit.Service <ProductMatch>().GetAll()
                          join matchProduct in unit.Service <ProductMatch>().GetAll() on c.ProductMatchID equals matchProduct.ProductMatchID
                          let pMedia = c.Product.ProductMedias.Where(m => m.MediaType.Type == "Image").FirstOrDefault()
                                       let cMedia = matchProduct.Product.ProductMedias.Where(x => x.MediaType.Type == "Image").FirstOrDefault()
                                                    let productName = c.Product != null ?
                                                                      c.Product.ProductDescriptions.FirstOrDefault(x => x.LanguageID == Client.User.LanguageID) ??
                                                                      c.Product.ProductDescriptions.FirstOrDefault() : null
                                                                      let productMatchName = matchProduct.Product != null ?
                                                                                             matchProduct.Product.ProductDescriptions.FirstOrDefault(x => x.LanguageID == Client.User.LanguageID) ??
                                                                                             matchProduct.Product.ProductDescriptions.FirstOrDefault() : null
                                                                                             where (isMatched.HasValue ? c.isMatched == isMatched : true) &&
                                                                                             (c.ProductID != matchProduct.ProductID) &&
                                                                                             ((filter.MatchedProduct.HasValue ? c.isMatched == true : true) ||
                                                                                              (filter.UnmatchedProduct.HasValue ? c.isMatched == false : false))
                                                                                             select new
     {
         c.ProductMatchID,
         c.ProductID,
         ProductBarcode = c.Product.ProductBarcodes.Count > 0 ? c.Product.ProductBarcodes.FirstOrDefault().Barcode : string.Empty,
         Description = productName != null ? (productName.ProductName ?? productName.ShortContentDescription) :
                       c.Product != null ? c.Product.VendorItemNumber : string.Empty,
         VendorItemNumber = c.Product.VendorItemNumber,
         Brand = c.Product.BrandID,
         BrandName = c.Product.Brand.Name,
         CorrespondingProductID = matchProduct.ProductID,
         CorrespondingProductBarcode = matchProduct.Product.ProductBarcodes.Count > 0 ? matchProduct.Product.ProductBarcodes.FirstOrDefault().Barcode : string.Empty,
         CorrespondingDescription = productMatchName != null ? (productMatchName.ProductName ?? productMatchName.ShortContentDescription) :
                                    matchProduct.Product != null ? matchProduct.Product.VendorItemNumber : string.Empty,
         CorrespondingBrand = matchProduct.Product.BrandID,
         CorrespondingBrandName = matchProduct.Product.Brand.Name,
         CorrespondingVendorItemNumber = matchProduct.Product.VendorItemNumber,
         c.isMatched,
         MatchPercentage = c.MatchPercentage.HasValue ? c.MatchPercentage.Value : 0,
         //ConnectorID = c.Product.Contents.Select(e => e.ConnectorID).FirstOrDefault() != null ? c.Product.Contents.Select(e => e.ConnectorID).FirstOrDefault() : int.Parse(ConfigurationManager.AppSettings["ConcentratorVendorID"].ToString()),
         ConnectorID = c.Product.Contents.Select(e => e.ConnectorID).FirstOrDefault(),
         VendorID = c.Product.SourceVendorID,
         MediaUrl = pMedia != null ? pMedia.MediaUrl : String.Empty,
         MediaPath = pMedia != null ? pMedia.MediaUrl : String.Empty,
         CorrespondingMediaUrl = cMedia != null ? cMedia.MediaUrl : String.Empty,
         CorrespondingMediaPath = cMedia != null ? cMedia.MediaPath : String.Empty,
         MatchStatus = c.MatchStatus
     })));
 }
        public static async Task OnReaction(MessageReactionAddEventArgs e)
        {
            if (e.User.IsBotSafeCheck())
            {
                return;
            }

            var emoji = e.Client.GetEmoji(":piratethink:", Config.Reactions.PiracyCheck);

            if (e.Emoji != emoji)
            {
                return;
            }

            var message = await e.Channel.GetMessageAsync(e.Message.Id).ConfigureAwait(false);

            await ContentFilter.IsClean(e.Client, message).ConfigureAwait(false);
        }
Beispiel #15
0
        private void CreateElementNotMI_Click(object sender, EventArgs e)
        {
            try {
                if (ItemsLV.SelectedItems.Count != 1)
                {
                    return;
                }

                ContentFilterElement element1 = ItemsLV.SelectedItems[0].Tag as ContentFilterElement;

                ContentFilter filter = GetFilter();
                filter.Push(FilterOperator.Not, element1);

                Update(filter);
            } catch (Exception exception) {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
Beispiel #16
0
        /// <summary>
        /// get list view content và paging sort filter
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="sortby"></param>
        /// <returns></returns>
        public IEnumerable <v_Content> GetContentPaging(ContentFilter filter, int pageIndex = 1, int pageSize = 20, string sortby = "")
        {
            IQueryable <v_Content> model = entities.v_Content;

            try
            {
                if (!string.IsNullOrEmpty(filter.SearchString))
                {
                    string searchString = filter.SearchString.Trim();
                    model = model.Where(x => x.Name.Contains(searchString));
                }

                if (filter.CatalogueId > 0)
                {
                    model = model.Where(x => x.CatalogueId == filter.CatalogueId);
                }

                if (filter.CategoryID > 0)
                {
                    model = model.Where(x => x.CategoryID == filter.CategoryID);
                }

                if (filter.Status.Count() > 0)
                {
                    model = model.Where(w => filter.Status.Contains(w.Status));
                }

                if (!String.IsNullOrWhiteSpace(sortby))
                {
                    model = model.OrderByDescending(x => x.CreatedDate);
                }
                else
                {
                    model = model.OrderByDescending(x => x.CreatedDate);
                }
            }
            catch (Exception ex)
            {
                string subject = "Error " + SiteSetting.SiteName + " at GetContentPaging at ContentRepo at Model.Repository";
                string message = StringHelper.Parameters2ErrorString(ex, conn);
                MailHelper.SendMail(SiteSetting.EmailAdmin, subject, message);
            }
            return(model.ToPagedList(pageIndex, pageSize));
        }
Beispiel #17
0
 public ActionResult GetList(ContentFilter filter)
 {
     return(List(unit => (from e in unit.Service <EdiOrderListener>().GetAll()
                          where (filter.ProcessedOrder.HasValue ? e.Processed == true : true) ||
                          (filter.UnprocessedOrder.HasValue ? e.Processed == false : true)
                          select new
     {
         e.EdiRequestID,
         e.CustomerName,
         e.CustomerIP,
         e.CustomerHostName,
         e.RequestDocument,
         e.ReceivedDate,
         e.Processed,
         e.ResponseRemark,
         e.ResponseTime,
         e.ErrorMessage
     }).OrderByDescending(x => x.ReceivedDate)));
 }
Beispiel #18
0
        void CreateTextContentValue()
        {
            contentStore = manager.GetContentStore(repositoryId);
            var contentItem = new StringContentItem()
            {
                Id           = Guid.NewGuid(),
                DefinitionId = definitionId,
                Data         = contentName
            };
            var contentFilter = new ContentFilter()
            {
                FilterDefinitionId = textFilterId
            };

            contentFilter.Values.Add("MyCoolCard");
            contentItem.Filters.Add(contentFilter);
            contentStore.Items.Add(contentItem);
            contentStore.Save();
        }
Beispiel #19
0
        /// <summary>
        /// Create expression from string
        /// </summary>
        public FilterExpression(string filterStatement)
        {
            // Parse
            var lexer = new FilterLexer(new AntlrInputStream(filterStatement));

            lexer.RemoveErrorListeners();
            lexer.AddErrorListener(new RaiseException <int>());
            var parser = new FilterParser(new CommonTokenStream(lexer));

            parser.RemoveErrorListeners();
            parser.AddErrorListener(new RaiseException <IToken>());
            var context = parser.parse();

            // Fill in select and where clause
            SelectClause = new SimpleAttributeOperandCollection();
            WhereClause  = new ContentFilter();

            if (context.selectList().STAR() != null)
            {
                // Select all / default
            }
            else
            {
                foreach (var expr in context.selectList().selectexpr())
                {
                    expr.attr_op().GetText();

                    var nodeId          = expr.attr_op().nodeId().STRING_LITERAL().GetText();
                    var browsePathElems = expr.attr_op().nodeId().browsePathElement();
                    var attributeId     = Enum.Parse <NodeAttribute>(expr.attr_op().attributeId().GetText(), true);

                    var operand = new SimpleAttributeOperand {
                        // TypeDefinitionId = expr.attr_op()
                        // AttributeId = (field.InstanceDeclaration.NodeClass == NodeClass.Object) ? Attributes.NodeId : Attributes.Value,
                        // BrowsePath = field.InstanceDeclaration.BrowsePath
                    };
                    SelectClause.Add(operand);
                }
            }

            Evaluate(context.elem_op());
        }
Beispiel #20
0
        public async Task Can_Retrieve_Filtered_Content_As_Typed_Object(string alias, string value, ContentFilterMatch match)
        {
            var service = new ContentDeliveryService(_configuration, GetMockedHttpClient($"{_contentBaseUrl}/filter", ContentDeliveryJson.Filter));
            var filters = new List <ContentFilterProperties>();

            filters.Add(new ContentFilterProperties(alias, value, match));
            var contentFilter = new ContentFilter(filters.ToArray());
            var pagedContent  = await service.Content.Filter <Product>(contentFilter);

            Assert.NotNull(pagedContent);
            Assert.NotNull(pagedContent.Content);
            Assert.NotEmpty(pagedContent.Content.Items);
            Assert.Equal(1, pagedContent.TotalPages);
            Assert.Equal(1, pagedContent.TotalItems);
            foreach (var contentItem in pagedContent.Content.Items)
            {
                Assert.NotNull(contentItem);
                Assert.False(string.IsNullOrEmpty(contentItem.ProductName));
            }
        }
Beispiel #21
0
 public static GenericContentDirectoryFilter GetContentFilter(ContentFilter Filter)
 {
     if (Filter == ContentFilter.SamsungContentFilter)
     {
         return(new SamsungContentDirectoryFilter());
     }
     else if (Filter == ContentFilter.XBoxContentFilter)
     {
         return(new XBoxContentDirectoryFilter());
     }
     else if (Filter == ContentFilter.WMPContentFilter)
     {
         return(new WMPContentDirectoryFilter());
     }
     else if (Filter == ContentFilter.SimpleContentFilter)
     {
         return(new SimpleContentDirectoryFilter());
     }
     return(new GenericContentDirectoryFilter());
 }
Beispiel #22
0
        public void Add(uint key, uint[] resourceList, ContentFilter filter)
        {
            AddInternal(key, () =>
            {
                var l = new List<Resource>();

                foreach (var resourceKey in resourceList)
                {
                    if (!resources.ContainsKey(resourceKey))
                    {
                        throw new InvalidOperationException(
                            "members of composite resources must be added to the repository first");
                    }

                    l.Add(resources[resourceKey]);
                }

                resources.Add(key, new CompositeResource { Resources = l.ToArray(), Filter = filter });
            });
        }
        void CreateTextContentValue()
        {
            contentStore = manager.GetContentStore(repositoryId);
            var contentItem = new StringContentItem()
            {
                Id           = Guid.NewGuid(),
                DefinitionId = definitionId,
                Data         = contentName
            };
            var contentFilter = new ContentFilter()
            {
                FilterDefinitionId = datetimeFilterId
            };

            contentFilter.Values.Add(DateTime.Today.AddDays(-10));
            contentFilter.Values.Add(DateTime.Today.AddDays(10));
            contentItem.Filters.Add(contentFilter);
            contentStore.Items.Add(contentItem);
            contentStore.Save();
        }
Beispiel #24
0
        /// <summary>
        /// 打开章节内容页面
        /// </summary>
        /// <param name="r"></param>
        /// <param name="url"></param>
        public void OpenChapterPage(BookRule r, string url)
        {
            int errorCount = 0;

begin:
            try
            {
                Console.WriteLine(string.Format("打开章节:{0}", url));
                string html   = Url.GetHtml(url, r.CharSet);
                var    result = (ChapterContent)SetMatchResult(typeof(ChapterContent), html, r.ContentRule).FirstOrDefault();

                string        chapterContent = GetChapterContent(r, html);
                ContentFilter f = new ContentFilter();
                chapterContent = f.Filter(chapterContent);

                chapterContent = chapterContent.HtmlDeCode();

                SaveChapter(result, chapterContent);

                //判断是否翻页
                if (r.NextChapterUrlRule.IsNullOrEmpty() == false &&
                    html.GetMatchGroup(r.NextChapterUrlRule).Groups.Count > 0
                    )
                {
                    //处理下一页
                    OpenChapterPage(r, html.GetMatch(r.NextChapterUrlRule).FirstOrDefault().AppendToDomain(RootUrl));
                }
            }
            catch
            {
                errorCount++;
                if (errorCount < 3)
                {
                    goto begin;
                }
                else
                {
                    throw new Exception("章节打开分析失败。");
                }
            }
        }
Beispiel #25
0
        public void FindsEverything()
        {
            var directoriesFound = new List <string>();
            var filesFound       = new List <string>();

            var filter = new ContentFilter {
                SourceDirectory      = "C:\\Test\\Source",
                DestinationDirectory = "C:\\Test\\Destination",
                DirectoryAction      = (src, dest) => directoriesFound.Add(src),
                FileAction           = (src, dest) => filesFound.Add(src),
                Provider             = CreateMockProvider(),
            };

            filter.Run();

            Assert.That(directoriesFound, Contains.Item("C:\\Test\\Source\\A"));
            Assert.That(directoriesFound, Contains.Item("C:\\Test\\Source\\ignore"));
            Assert.That(filesFound, Contains.Item("C:\\Test\\Source\\rootFile.txt"));
            Assert.That(filesFound, Contains.Item("C:\\Test\\Source\\A\\B.zip"));
            Assert.That(filesFound, Contains.Item("C:\\Test\\Source\\ignore\\donotfind"));
        }
Beispiel #26
0
 public ActionResult GetList(ContentFilter filter)
 {
     return(List(unit => (from e in unit.Service <EdiOrderResponse>().GetAll()
                          where filter.ResponseType.HasValue ? filter.ResponseType == e.ResponseType : true
                          select new
     {
         e.EdiOrderResponseID,
         e.ResponseType,
         e.VendorDocument,
         e.AdministrationCost,
         e.DropShipmentCost,
         e.ShipmentCost,
         e.OrderDate,
         e.PartialDelivery,
         e.VendorDocumentNumber,
         e.VendorDocumentDate,
         e.VatPercentage,
         e.VatAmount,
         e.TotalGoods,
         e.TotalExVat,
         e.TotalAmount,
         e.PaymentConditionDays,
         e.PaymentConditionCode,
         e.PaymentConditionDiscount,
         e.PaymentConditionDiscountDescription,
         e.TrackAndTrace,
         e.InvoiceDocumentNumber,
         e.ShippingNumber,
         e.ReqDeliveryDate,
         e.InvoiceDate,
         e.Currency,
         e.DespAdvice,
         e.ShipToCustomerID,
         e.SoldToCustomerID,
         e.ReceiveDate,
         e.TrackAndTraceLink,
         e.VendorDocumentReference,
         e.EdiOrderID
     }).OrderByDescending(x => x.ReceiveDate)));
 }
Beispiel #27
0
        private static void QueryFirstCall(Session session)
        {
            ViewDescription vd = new ViewDescription();

            vd.ViewId      = 5000;
            vd.ViewVersion = 0;
            NodeTypeDescriptionCollection nt  = new NodeTypeDescriptionCollection();
            NodeTypeDescription           ntd = new NodeTypeDescription();

            ExpandedNodeId enid = new ExpandedNodeId("ns=3;s=AirConditioner_1");

            ntd.TypeDefinitionNode = enid;
            nt.Add(ntd);

            ContentFilterElement           cfe  = new ContentFilterElement();
            ContentFilterElementCollection cfec = new ContentFilterElementCollection();


            cfec.Add(cfe);
            ContentFilter cf = new ContentFilter();

            cf.Elements = cfec;

            QueryDataSetCollection qdsc = new QueryDataSetCollection();

            byte[] cp = new byte[100];
            ParsingResultCollection  prc = new ParsingResultCollection();
            DiagnosticInfoCollection dic = new DiagnosticInfoCollection();
            ContentFilterResult      cfr = new ContentFilterResult();

            try
            {
                var rs = session.QueryFirst(null, vd, nt, cf, 1000, 1000, out qdsc, out cp, out prc, out dic, out cfr);
            }
            catch (Exception eX)
            {
                Console.WriteLine("EXCEPTION:  QueryFirst  :  {0}", eX.Message);
            }
        }
        /// <summary>
        /// Sets the nodes in the control.
        /// </summary>
        public void Initialize(Session session, ContentFilter filter)
        {
            if (session == null) throw new ArgumentNullException("session");
            
            Clear();
            
            m_session = session;
            m_browser = new Browser(session);
            m_filter  = filter;

            if (m_filter == null)
            {
                return;                
            }

            foreach (ContentFilterElement element in filter.Elements)
            {
                AddItem(element);
            }

            AdjustColumns();
        }
Beispiel #29
0
        public DataTable sp_ExecuteProcedure(string procedure, int brief, string startDate, string endDate, string[] filters)
        {
            var ci = new System.Globalization.CultureInfo("en-GB");

            ContentFilter cf            = new ContentFilter(brief, filters);
            var           parameterList = ConvertContentFilterToSqlParameterList(cf);

            if (!string.IsNullOrEmpty(startDate))
            {
                parameterList.Add(new SqlParameter("@hasStartDate", 1));
                DateTime dtStart = Convert.ToDateTime(startDate, ci);
                parameterList.Add(new SqlParameter("@startDate", dtStart));
            }
            if (!string.IsNullOrEmpty(endDate))
            {
                parameterList.Add(new SqlParameter("@hasEndDate", 1));
                DateTime dtEnd = Convert.ToDateTime(endDate, ci);
                parameterList.Add(new SqlParameter("@endDate", dtEnd));
            }

            return(util.QuerytoDataTable(procedure, parameterList, CS_MAIN));
        }
 internal ContentRestrictionData(StoreSession storeSession, ContentFilter contentFilter)
 {
     this.Flags       = (int)base.GetContentFlags(contentFilter.MatchFlags, contentFilter.MatchOptions);
     this.PropTag     = base.GetPropTagFromDefinition(storeSession, contentFilter.Property);
     this.MultiValued = ((PropTag)this.PropTag).IsMultiValued();
     if (contentFilter is TextFilter)
     {
         TextFilter textFilter = (TextFilter)contentFilter;
         this.Value = new PropValueData(((PropTag)this.PropTag).ChangePropType(PropType.String), textFilter.Text);
         return;
     }
     if (contentFilter is BinaryFilter)
     {
         BinaryFilter binaryFilter = (BinaryFilter)contentFilter;
         this.Value = new PropValueData(((PropTag)this.PropTag).ChangePropType(PropType.Binary), binaryFilter.BinaryData);
         return;
     }
     MrsTracer.Common.Error("Unknown content filter type '{0}' in content restriction data constructor", new object[]
     {
         contentFilter.GetType()
     });
     throw new CorruptRestrictionDataException();
 }
Beispiel #31
0
        public ActionResult GetList(ContentFilter filter)
        {
            var query = new QueryBuilder()
                        .From("[dbo].[ContentPrice] AS [CP]")
                        .Join(JoinType.OuterLeft, "[dbo].[Brand] AS [B]", "[CP].[BrandID] = [B].[BrandID]")
                        .Join(JoinType.OuterLeft, "[dbo].[Product] AS [P]", "[CP].[ProductID] = [P].[ProductID]")
                        .Join(JoinType.OuterLeft, "[dbo].[ProductAttributeMetaData] as [A]", "[CP].AttributeID = [A].AttributeID")
                        .Join(JoinType.OuterLeft, "[dbo].[ProductGroupLanguage] AS [PGL]", "[CP].[ProductGroupID] = [PGL].[ProductGroupID]")
                        .Join(JoinType.OuterLeft, "[dbo].[ProductAttributeName] AS [PAN]", "[A].[AttributeID] = [PAN].[AttributeID] AND" + string.Format("[PAN].LanguageID = {0}", Client.User.LanguageID))
                        .Select("[CP].*")
                        .Column("A.AttributeID")
                        .Column("CASE WHEN [PAN].Name IS NULL THEN A.AttributeCode ELSE [PAN].Name END as AttributeName")
                        .Column("CP.AttributeValue")
                        .Column("[B].[Name] AS [BrandName]")
                        .Column("[P].[VendorItemNumber] AS [ProductDescription]")
                        .Column("[PGL].[Name] AS [ProductGroupName]")
                        .OrderBy("[CP].[ContentPriceRuleIndex]");

            using (var database = new Database(Environments.Current.Connection, Database.MsSqlClientProvider))
            {
                return(List(database.Query <ContentPriceModel>(query).AsQueryable()));
            }
        }
Beispiel #32
0
        public async Task <IActionResult> Test(string page, string rule = null)
        {
            if (string.IsNullOrWhiteSpace(page))
            {
                return(BadRequest($"The '{nameof(page)}' parameter is mandatory."));
            }

            if (string.IsNullOrWhiteSpace(rule))
            {
                rule = _ruleRepository.GetRule(page);

                if (rule == null)
                {
                    return(NotFound($"Rule for site '{page}' not found."));
                }
            }

            var pageContent = await _agent.GetContent($"http://{page}");

            var textResult = ContentFilter.Apply(pageContent, rule);

            return(new OkObjectResult(textResult));
        }
        /// <summary>
        /// Updates the control with a new filter.
        /// </summary>
        private void Update(ContentFilter filter)
        {              
            BeginUpdate();

            int index = 0;

            foreach (ContentFilterElement element in filter.Elements)
            {
                AddItem(element, "Property", index++);
            }
            
            EndUpdate();

            AdjustColumns();
        }
        /// <summary>
        /// Returns the filter in the control.
        /// </summary>
        public ContentFilter GetFilter()
        {
            ContentFilter filter = new ContentFilter();
                    
            for (int ii = 0; ii < ItemsLV.Items.Count; ii++)
            {
                ContentFilterElement element = ItemsLV.Items[ii].Tag as ContentFilterElement;

                if (element != null)
                {
                    filter.Elements.Add(element);
                }
            }

            return filter;
        }
Beispiel #35
0
		private ContentFilter createContentFilter(string expression, string mapTo, bool isRegularExpression)
		{
			ContentFilter contentFilter = new ContentFilter(expression, mapTo);
			contentFilter.IsRegEx = isRegularExpression;
			return contentFilter;
		}