Пример #1
0
        static void Main(string[] args)
        {
            SanitizerService Sanitizer = new SanitizerService();

            string[]            CheckedArgs   = Sanitizer.SanitizeArgs(args);
            SearchEngineGroup   EngineGroup   = new SearchEngineGroup();
            SearchStatsService  SearchResults = new SearchStatsService(CheckedArgs, EngineGroup.SearchEngines);
            OutputFormatService Output        = new OutputFormatService();

            if (CheckedArgs.Length < 1)
            {
                Console.WriteLine("SearchFight | error: You must enter at least 1 language");
                return;
            }

            Parallel.ForEach(EngineGroup.SearchEngines, engine =>
            {
                foreach (string language in CheckedArgs)
                {
                    SearchResults.UpdateStat(engine.Search(language));
                }
            });

            Output.Format(SearchResults);
        }
 public ConfigurationAdminManager(
     SanitizerService sanitizerService,
     ICategoriesCache categoriesCache,
     DataBaseConnection db) : base(db)
 {
     this.sanitizerService = sanitizerService;
     this.categoriesCache  = categoriesCache;
 }
Пример #3
0
 public PersonalManager(
     DataBaseConnection db,
     JweBlackListService jweBlackListService,
     SanitizerService sanitizerService) : base(db)
 {
     this.sanitizerService    = sanitizerService;
     this.jweBlackListService = jweBlackListService;
 }
Пример #4
0
 public CategoriesAdminManager(
     DataBaseConnection db,
     IOptions <MaterialsOptions> materialOptions,
     ICategoriesCache categoriesCache,
     SanitizerService sanitizerService) : base(db)
 {
     this.sanitizerService = sanitizerService;
     this.categoriesCache  = categoriesCache;
     this.materialOptions  = materialOptions.Value;
 }
Пример #5
0
 public ProfileManager(
     DataBaseConnection db,
     IEmailSenderService emailSenderService,
     IOptionsMonitor <GlobalOptions> globalOptions,
     SanitizerService sanitizerService
     ) : base(db)
 {
     this.emailSenderService = emailSenderService;
     this.sanitizerService   = sanitizerService;
     this.globalOptions      = globalOptions;
 }
Пример #6
0
 public MaterialsManager(
     DataBaseConnection db,
     SanitizerService sanitizerService,
     ICategoriesCache categoriesCache,
     ITagsManager tagsManager,
     IOptions <MaterialsOptions> materialsOptions) : base(db)
 {
     this.tagsManager      = tagsManager;
     this.sanitizerService = sanitizerService;
     this.materialsOptions = materialsOptions.Value;
     this.categoriesCache  = categoriesCache;
 }
Пример #7
0
        public ResultService Search(string language)
        {
            StreamReader     reader;
            ParserService    ps = new ParserService();
            SanitizerService ss = new SanitizerService();
            string           queryURL = string.Format(URL, ss.SanitizeInput(language));
            string           html, numResultsStr;
            long             numResults;

            try
            {
                HttpWebRequest request = HttpWebRequest.CreateHttp(queryURL);
                request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; .NET CLR 1.0.3705;)";
                request.Timeout   = 60000;
                request.Method    = "GET";
                WebResponse response = request.GetResponse();

                using (Stream dataStream = response.GetResponseStream())
                {
                    reader        = new StreamReader(dataStream, Encoding.ASCII);
                    html          = reader.ReadToEnd();
                    numResultsStr = ps.Parse(html, RegexPattern);
                }
                reader.Close();
                response.Close();

                numResults = ss.SanitizeOutput(numResultsStr);

                if (numResults == -1)
                {
                    throw new System.InvalidCastException();
                }
                return(new ResultService {
                    EngineName = Name, Language = language, NumResults = numResults
                });
            }
            catch (WebException e)
            {
                Console.WriteLine("SearchFight | error: {0} on {1} search: \"{2}\". Please try again.", e.Status, Name, language);
                return(new ResultService {
                    EngineName = Name, Language = language, NumResults = -1
                });
            }
            catch (InvalidCastException e)
            {
                Console.WriteLine("SearchFight | error: Result could not be parsed. The term entered had 0 results or check App.config for configuration of engine {0}", Name);
                return(new ResultService {
                    EngineName = Name, Language = language, NumResults = -1
                });
            }
        }
Пример #8
0
 public CacheAdminController(
     ISectionsCache sectionsCache,
     ICategoriesCache categoriesCache,
     IMenuCache menuCache,
     SpamProtectionCache spamProtectionCache,
     IMailTemplatesCache mailTemplatesCache,
     IConfigurationRoot configurationRoot,
     IDynamicConfigCache dynamicConfigCache,
     SanitizerService sanitizerService,
     IServiceProvider serviceProvider) : base(serviceProvider)
 {
     this.sectionsCache       = sectionsCache;
     this.categoriesCache     = categoriesCache;
     this.menuCache           = menuCache;
     this.spamProtectionCache = spamProtectionCache;
     this.mailTemplatesCache  = mailTemplatesCache;
     this.configurationRoot   = configurationRoot;
     this.dynamicConfigCache  = dynamicConfigCache;
     this.sanitizerService    = sanitizerService;
 }
Пример #9
0
        public void AddResources(IEnumerable <Resource> resources)
        {
            bool containsDirtyInputs = resources.Any(
                resource => SanitizerService.InputsNeedSanitizing(new[]
            {
                resource.Name,
                resource.Description
            })
                );

            if (containsDirtyInputs)
            {
                return;
            }
            using (var db = new dotRDbEntities())
            {
                db.Resources.AddRange(resources);
                db.SaveChanges();
            }
        }
Пример #10
0
        public void AddResource(Resource resource)
        {
            if (resource.Name == null)
            {
                return;
            }
            var myNode = new Node
            {
                NodeTypeId = NodeTypes.Resource
            };

            _db.Nodes.Add(myNode);
            var savedResource = new Resource
            {
                Name        = SanitizerService.SanitizeForSql(resource.Name),
                Description = SanitizerService.SanitizeForSql(resource.Description),
                Node        = myNode
            };

            _db.Resources.Add(savedResource);
            _db.SaveChanges();
        }
 public CategoriesAdminManager(
     DataBaseConnection db,
     SanitizerService sanitizerService) : base(db)
 {
     this.sanitizerService = sanitizerService;
 }
Пример #12
0
 public Demo()
 {
     _sanitizerService = new SanitizerService(new [] { typeof(Demo).Assembly });
 }