예제 #1
0
 public NotifyUsersAboutEndingOfReservationBackgroundTask(ResourcesContext context,
                                                          INotificationService notificator,
                                                          NotificationOptions options)
 {
     _context     = context;
     _notificator = notificator;
     _options     = options;
 }
 public static bool UpdateAnalyseDetails(string projectId, ResourcesContext resources)
 {
     try
     {
         return(MongoHelper.UpdateTheAnalyseStageDetailsInDB(projectId, resources));
     }
     catch (Exception ex)
     {
         Log.Error(ex, $"Error updating Analyse Details for ProjectId : {projectId}");
         return(false);
     }
 }
예제 #3
0
        public ResourcesController(ResourcesContext context)
        {
            _context = context;
            if (_context.BuildingsItems.Count() == 0)
            {
                // Create a new BuildingItemObtained if collection is empty,
                // which means you can't delete all BuildingItemObtaineds.
                _context.BuildingsItems.Add(new BuildingItem {
                    Name = "Choza", Resource = "gold"
                });

                _context.SaveChanges();
            }
        }
예제 #4
0
        public static string CheckUrlPresentInAssetOrNot(Uri absoluteUrl, ResourcesContext resourcesContext)
        {
            try
            {
                if (resourcesContext.UniqueAssetsDictionary.ContainsKey(absoluteUrl.AbsoluteUri))
                {
                    return(resourcesContext.UniqueAssetsDictionary[absoluteUrl.AbsoluteUri].PlaceHolder);
                }
                else if (resourcesContext.UniqueScriptsDictionary.ContainsKey(absoluteUrl.AbsoluteUri))
                {
                    return(resourcesContext.UniqueScriptsDictionary[absoluteUrl.AbsoluteUri].PlaceHolder);
                }
                else if (resourcesContext.UniqueStylesDictionary.ContainsKey(absoluteUrl.AbsoluteUri))
                {
                    return(resourcesContext.UniqueStylesDictionary[absoluteUrl.AbsoluteUri].PlaceHolder);
                }
                else if (resourcesContext.UniqueWebpagesDictionary.ContainsKey(absoluteUrl.AbsoluteUri))
                {
                    return(resourcesContext.UniqueWebpagesDictionary[absoluteUrl.AbsoluteUri].PlaceHolder);
                }
                else if (!String.IsNullOrEmpty(resourcesContext.IncludeFilesRegex))
                {
                    Regex regex = new Regex(resourcesContext.IncludeFilesRegex, RegexOptions.IgnoreCase);
                    if (regex.IsMatch(absoluteUrl.PathAndQuery))
                    {
                        return(null);
                    }
                }
                if (!String.IsNullOrEmpty(resourcesContext.ExcludeFilesRegex))
                {
                    Regex regex = new Regex(resourcesContext.ExcludeFilesRegex, RegexOptions.IgnoreCase);
                    if (regex.IsMatch(absoluteUrl.PathAndQuery))
                    {
                        return("IGNORE");
                    }
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw new Exception("Error while checking if the url present or not", ex);
            }
        }
예제 #5
0
        /// <summary>
        /// Update the Resources Details to KitsuneProjects DB
        /// </summary>
        /// <param name="crawlId"></param>
        /// <param name="resources"></param>
        /// <returns></returns>
        public static bool UpdateTheAnalyseStageDetailsInDB(string crawlId, ResourcesContext resources)
        {
            try
            {
                if (_server == null)
                {
                    InitiateConnection();
                }

                var urlCollection = _kitsuneDB.GetCollection <KitsuneKrawlerStats>(EnvironmentConstants.ApplicationConfiguration.MongoDBCollections.KitsuneKrawlStatsCollection);

                //Filter Defination
                var fdb    = new FilterDefinitionBuilder <KitsuneKrawlerStats>();
                var filter = fdb.Where(x => x.ProjectId == crawlId);


                //Update Defination
                var udb    = new UpdateDefinitionBuilder <KitsuneKrawlerStats>();
                var update = udb.Set(x => x.Links, resources.UniqueWebpagesDictionary.Values.ToList())
                             .Set(x => x.Scripts, resources.UniqueScriptsDictionary.Values.ToList())
                             .Set(x => x.Styles, resources.UniqueStylesDictionary.Values.ToList())
                             .Set(x => x.Assets, resources.UniqueAssetsDictionary.Values.ToList())
                             .Set(x => x.DomainsFound, resources.ExternalDomains.ToList())
                             .Set(x => x.LinksFound, resources.UniqueWebpagesDictionary.Values.Count())
                             .Set(x => x.StylesFound, resources.UniqueStylesDictionary.Values.Count())
                             .Set(x => x.ScriptsFound, resources.UniqueScriptsDictionary.Values.Count())
                             .Set(x => x.AssetsFound, resources.UniqueAssetsDictionary.Values.Count());

                //Process
                var result = urlCollection.UpdateOne(filter, update, new UpdateOptions {
                    IsUpsert = true
                });


                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
        public KHtmlParser(Uri rootUri, KHtmlDocument htmlDocument)
        {
            try
            {
                if (rootUri == null)
                {
                    throw new Exception("Root Uri cannot be null");
                }
                if (htmlDocument == null)
                {
                    throw new Exception("HtmlDocument cannot be null");             //TODO: also check if htmlDocument is loaded with content
                }
                UniqueWebPageQueue = new ConcurrentQueue <string>();
                Resources          = new ResourcesContext();
                ErrorLogMethod     = (LOGTYPE x, string y, Exception z) => Console.WriteLine("Type: {0} , Message: {1} ,Exception: {2}", x, y, z == null ? "No InnerException" : z.Message);

                _rootUrl = rootUri;
                KHtml    = htmlDocument;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #7
0
 public RemoveResourceCommandHandler(ResourcesContext context)
 {
     _context = context;
 }
 public BookResourceCommandHandler(ResourcesContext context)
 {
     _context = context;
 }
예제 #9
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 public ContactService()
 {
     _context = new ResourcesContext();
 }
예제 #10
0
 public DetailsModel(ResourcesContext context, IMediator mediator, BookingOptions _options)
 {
     _context  = context;
     _mediator = mediator;
     Options   = _options;
 }
 public EditResourcePostProcessor(ResourcesContext context, IHttpContextAccessor httpContextAccessor)
 {
     _context             = context;
     _httpContextAccessor = httpContextAccessor;
 }
예제 #12
0
 public BookModel(ResourcesContext context, IMediator mediator, BookingOptions bookingOptions)
 {
     _context        = context;
     _mediator       = mediator;
     _bookingOptions = bookingOptions;
 }
 public ResourcesController(ResourcesContext context)
 {
     _context = context;
 }
예제 #14
0
 public AddModel(ResourcesContext context, IMediator mediator)
 {
     _context  = context;
     _mediator = mediator;
 }
 public TebexController(ResourcesContext context, ILogger <TebexController> logger)
 {
     _logger  = logger;
     _context = context;
 }
예제 #16
0
 public IndexModel(ResourcesContext context) => _context = context;
 public ReleaseResourcePostProcessor(ResourcesContext context)
 {
     _context = context;
 }
 public ReleaseExpiredReservationsBackgroundTask(IMediator mediator, ResourcesContext context)
 {
     _mediator = mediator;
     _context  = context;
 }
	public ResourcesContext resources() {
		ResourcesContext _localctx = new ResourcesContext(Context, State);
		EnterRule(_localctx, 94, RULE_resources);
		int _la;
		try {
			EnterOuterAlt(_localctx, 1);
			{
			State = 1366; k_resources();
			State = 1370;
			ErrorHandler.Sync(this);
			_la = TokenStream.La(1);
			while (_la==SCOL) {
				{
				{
				State = 1367; resrcparam();
				}
				}
				State = 1372;
				ErrorHandler.Sync(this);
				_la = TokenStream.La(1);
			}
			State = 1373; Match(COL);
			State = 1374; text();
			State = 1379;
			ErrorHandler.Sync(this);
			_la = TokenStream.La(1);
			while (_la==COMMA) {
				{
				{
				State = 1375; Match(COMMA);
				State = 1376; text();
				}
				}
				State = 1381;
				ErrorHandler.Sync(this);
				_la = TokenStream.La(1);
			}
			State = 1382; Match(CRLF);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}
 public BookResourcePostProcessor(ResourcesContext context)
 {
     _context = context;
 }
 public UnitOfWorkPipelineBehavior(ResourcesContext context)
 {
     _context = context;
 }
 public ResourcesRepository(ResourcesContext context)
 {
     this.context = context;
 }
 public EditResourceCommandHandler(ResourcesContext context)
 {
     _context = context;
 }
 public DownloadController(ResourcesContext _context)
 {
     context = _context;
 }