public ContextParser(InformationContext context)
        {
            this.context = context;

            if (!ParseMeta(context))
                Parse(context);
        }
 /// <summary>
 /// Parses the context for known meta informations.
 /// </summary>
 /// <param name="context">The InformationContext to be parsed</param>
 /// <returns>Returns true if a known meta information was parsed, otherwise false.</returns>
 private bool ParseMeta(InformationContext context)
 {
     long numberBuffer;
     if (string.Equals(context.Meta, "Debitorennr", StringComparison.OrdinalIgnoreCase))
     {
         if (long.TryParse(context.Context, out numberBuffer))
         {
             DebitorNumber = numberBuffer;
             return IsDebitorNumber = true;
         }
     }
     if (string.Equals(context.Meta, "Kreditornr", StringComparison.OrdinalIgnoreCase))
     {
         if (long.TryParse(context.Context, out numberBuffer))
         {
             KreditorNumber = numberBuffer;
             return IsKreditorNumber = true;
         }
     }
     if (string.Equals(context.Meta, "Email", StringComparison.OrdinalIgnoreCase))
     {
         Ilc.Linguistic.EmailAddress email;
         if (Ilc.Linguistic.EmailAddress.TryParse(context.Context, out email))
         {
             EmailAddress = email;
             return IsEmailAddress = true;
         }
     }
     return false;
 }
예제 #3
0
        /// <summary>
        /// Parses the context for known meta informations.
        /// </summary>
        /// <param name="context">The InformationContext to be parsed</param>
        /// <returns>Returns true if a known meta information was parsed, otherwise false.</returns>
        private bool ParseMeta(InformationContext context)
        {
            long numberBuffer;

            if (string.Equals(context.Meta, "Debitorennr", StringComparison.OrdinalIgnoreCase))
            {
                if (long.TryParse(context.Context, out numberBuffer))
                {
                    DebitorNumber = numberBuffer;
                    return(IsDebitorNumber = true);
                }
            }
            if (string.Equals(context.Meta, "Kreditornr", StringComparison.OrdinalIgnoreCase))
            {
                if (long.TryParse(context.Context, out numberBuffer))
                {
                    KreditorNumber = numberBuffer;
                    return(IsKreditorNumber = true);
                }
            }
            if (string.Equals(context.Meta, "Email", StringComparison.OrdinalIgnoreCase))
            {
                Ilc.Linguistic.EmailAddress email;
                if (Ilc.Linguistic.EmailAddress.TryParse(context.Context, out email))
                {
                    EmailAddress = email;
                    return(IsEmailAddress = true);
                }
            }
            return(false);
        }
예제 #4
0
 public DescriptionKeyGroupsController(DeterminationContext detContext, InformationContext infContext, ObservationContext obsContext, MappingContext mapContext)
 {
     _detContext = detContext;
     _infContext = infContext;
     _obsContext = obsContext;
     _mapContext = mapContext;
 }
예제 #5
0
        private async Task GetData()
        {
            using (InformationContext entity = new InformationContext())
            {
                List <InformationReport> reports = new List <InformationReport>();
                reports = entity.InformationReport.ToList();
                Uri       uri    = new Uri("https://data.dublinked.ie/cgi-bin/rtpi/realtimebusinformation?stopid=103381&format=xml");
                WebClient client = new WebClient();
                string    xmlStr = await client.DownloadStringTaskAsync(uri);

                var xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xmlStr);

                DataSet ds = new DataSet();
                ds.ReadXml(new XmlNodeReader(xmlDoc));

                if (reports.Count == 0)
                {
                    await FillData(ds, entity, reports);
                }
                else
                {
                    reports.ForEach(x => entity.InformationReport.Remove(x));
                    await FillData(ds, entity, reports);
                }
            }
        }
예제 #6
0
 public TaxonsController(DeterminationContext detContext, InformationContext infContext, ObservationContext obsContext, MappingContext mapContext)
 {
     _detContext = detContext;
     _infContext = infContext;
     _obsContext = obsContext;
     _mapContext = mapContext;
 }
예제 #7
0
        private static void PatchBlogsAndActivitiesSelectedCollections()
        {
            var ownerLocations = GetAllOwnerLocations();
            int totalCount     = ownerLocations.Length;
            int currIX         = 0;

            foreach (var ownerLocation in ownerLocations)
            {
                Console.WriteLine("Updating number " + (++currIX) + " out of " + totalCount);
                VirtualOwner owner = VirtualOwner.FigureOwner(ownerLocation);
                var          informationObjects = StorageSupport.CurrActiveContainer.
                                                  GetInformationObjects(ownerLocation, null,
                                                                        iObj =>
                                                                        iObj is Blog ||
                                                                        iObj is Activity).ToArray();
                foreach (var iObj in informationObjects)
                {
                    try
                    {
                        //StorageSupport.StoreInformationMasterFirst(iObj, owner, true);
                        StorageSupport.StoreInformationMasterFirst(iObj, owner, false);
                    }
                    catch (Exception ex)
                    {
                        bool letThrow = false;
                        if (letThrow)
                        {
                            throw;
                        }
                    }
                }
            }
            InformationContext.ProcessAndClearCurrent();
            InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName);
        }
예제 #8
0
 public QuestionController(IMapper mapper, InformationContext context, IUnitOfWork unitOfWork, IQuestionRepository questionRepository)
 {
     _context            = context;
     _unitOfWork         = unitOfWork;
     _mapper             = mapper;
     _questionRepository = questionRepository;
 }
예제 #9
0
        /// <summary>
        /// Method for handeling the scraping a site.
        /// </summary>
        public void WebScraping()
        {
            runWebScraping = true;

            Person person = new InformationContext()
                            .Persons.OrderByDescending(u => u.UrlIndex)
                            .ThenByDescending(u => u.PageNumber)
                            .FirstOrDefault();

            if (person == null)
            {
                person = new Person()
                {
                    UrlIndex = 0, PageNumber = 1
                };
            }

            personListInformationHandler.PostalNumber = person.UrlIndex;
            personListInformationHandler.PageNumber   = person.PageNumber;

            using (var context = new InformationContext())
            {
                context.Addresses.ToList().ForEach(a => populationenRendering.AddCoordinate(new Point(a.XCoord, a.YCoord)));
                Dispatcher.Invoke(() => { lblNumberOfRecords.Content = context.Persons.Count().ToString(); });

                Task.Run(() =>
                {
                    Dispatcher.Invoke(() => mapPixelProgressBar.Visibility = Visibility.Visible);
                    while (populationenRendering.QueueCount() > 0)
                    {
                        Dispatcher.Invoke(() =>
                        {
                            populationenRendering.QueueCount();
                            mapPixelProgressBar.Value++;
                        });
                        Thread.Sleep(250);
                    }
                    Dispatcher.Invoke(() => mapPixelProgressBar.Visibility = Visibility.Hidden);
                });
            }

            while (runWebScraping && Dispatcher.Thread.IsAlive)
            {
                List <string> personList = personListInformationHandler.GetNextList(USER_LIST_REGEX);
                Dispatcher.Invoke(() =>
                {
                    lblUrlId.Content            = personListInformationHandler.PostalNumber;
                    lblIdDataAddress.Content    = personListInformationHandler.Url;
                    idBufferProgressBar.Maximum = personList.Count;
                    idBufferProgressBar.Value   = personList.Count;
                });

                personList.ForEach(id => HandleUserInformation(
                                       siteInformationHandler,
                                       personListInformationHandler.PostalNumber,
                                       personListInformationHandler.PageNumber,
                                       int.Parse(id)));
            }
        }
예제 #10
0
 public ValuesController(DeterminationContext detContext, InformationContext infContext, ObservationContext obsContext, MappingContext mapContext, IConfiguration smtpConfiguration)
 {
     _detContext = detContext;
     _infContext = infContext;
     _obsContext = obsContext;
     _mapContext = mapContext;
     _smtpConfig = smtpConfiguration;
 }
예제 #11
0
 /***
 ** Advice = Event + Observation
 ** Event = Fundort
 ** Observation = Fund
 ** Observation = ObservationInfo + optional List of Images
 ***/
 public AdviceController(UserManager <ApplicationUser> userManager, DeterminationContext detContext, InformationContext infContext, ObservationContext obsContext, MappingContext mapContext, LocationContext locContext, PublicContext idoContext)
 {
     _userManager = userManager;
     _obsContext  = obsContext;
     _locContext  = locContext;
     _idoContext  = idoContext;
     _infContext  = infContext;
 }
예제 #12
0
        public ContextParser(InformationContext context)
        {
            this.context = context;

            if (!ParseMeta(context))
            {
                Parse(context);
            }
        }
예제 #13
0
 private static void RemoveMemberFromGroup(string groupID, string memberEmail)
 {
     AaltoGlobalImpact.OIP.RemoveMemberFromGroup.Execute(new RemoveMemberFromGroupParameters()
     {
         GroupID      = groupID,
         EmailAddress = memberEmail
     });
     InformationContext.ProcessAndClearCurrent();
     InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName);
 }
        private void InitContexts()
        {
            var optionsBuilderInf = new DbContextOptionsBuilder <InformationContext>();

            optionsBuilderInf.UseNpgsql(Program.Configuration.GetConnectionString("DatabaseConnection"));
            _contextInf = new InformationContext(optionsBuilderInf.Options);

            var optionsBuilderObs = new DbContextOptionsBuilder <ObservationContext>();

            optionsBuilderObs.UseNpgsql(Program.Configuration.GetConnectionString("DatabaseConnection"));
            _contextObs = new ObservationContext(optionsBuilderObs.Options);
        }
예제 #15
0
        private static void DoCustomCleanup(string groupLoc)
        {
            var defaultBlogToDelete = StorageSupport.CurrActiveContainer.
                                      GetInformationObjects(groupLoc, null,
                                                            item => item is Blog && item.RelativeLocation.EndsWith("/default")).ToArray();

            foreach (Blog blog in defaultBlogToDelete)
            {
                StorageSupport.DeleteInformationObject(blog);
            }
            InformationContext.ProcessAndClearCurrent();
            InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName);
        }
예제 #16
0
        private static void FinishDeviceNegotiation(InformationContext iCtx, INegotiationProtocolMember protocolParty, string remainingDetails)
        {
            var result = CreateDeviceMembership.Execute(new CreateDeviceMembershipParameters
            {
                Owner = iCtx.Owner,
                ActiveSymmetricAESKey = protocolParty.NegotiationResults[0],
                DeviceDescription     = remainingDetails
            });

            CreateAndSendEmailValidationForDeviceJoinConfirmation.Execute(new CreateAndSendEmailValidationForDeviceJoinConfirmationParameters
            {
                DeviceMembership = result.DeviceMembership,
                OwningAccount    = iCtx.Owner as TBAccount,
                OwningGroup      = iCtx.Owner as TBCollaboratingGroup,
            });
        }
예제 #17
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest request = context.Request;

            WebSupport.InitializeContextStorage(context.Request);
            try
            {
                if (request.Path.StartsWith(AuthEmailValidation))
                {
                    HandleEmailValidation(context);
                }
            } finally
            {
                InformationContext.ProcessAndClearCurrent();
            }
        }
예제 #18
0
        public async Task <IHttpActionResult> GetInformations()
        {
            List <InformationReport> reports = new List <InformationReport>();

            try
            {
                using (InformationContext entity = new InformationContext())
                {
                    reports = entity.InformationReport.ToList();
                }
            }
            catch (Exception ex)
            {
            }
            return(await Task.FromResult(Ok(reports)));
        }
예제 #19
0
        private static void UpdateAccountAndGroups(string accountEmail)
        {
            string         emailID     = TBREmailRoot.GetIDFromEmailAddress(accountEmail);
            TBREmailRoot   emailRoot   = TBREmailRoot.RetrieveFromDefaultLocation(emailID);
            TBRAccountRoot accountRoot = TBRAccountRoot.RetrieveFromDefaultLocation(emailRoot.Account.ID);

            foreach (var groupRole in accountRoot.Account.GroupRoleCollection.CollectionContent)
            {
                TBRGroupRoot groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(groupRole.GroupID);
                RefreshAccountGroupMemberships.Execute(new RefreshAccountGroupMembershipsParameters
                {
                    AccountID = accountRoot.Account.ID,
                    GroupRoot = groupRoot
                });
                InformationContext.ProcessAndClearCurrent();
                InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName);
            }
        }
예제 #20
0
        public void ProcessRequest(HttpContext context)
        {
            string user            = context.User.Identity.Name;
            bool   isAuthenticated = String.IsNullOrEmpty(user) == false;
            var    request         = context.Request;
            var    response        = context.Response;

            WebSupport.InitializeContextStorage(context.Request);
            if (request.Path.StartsWith(AboutPrefix))
            {
                if (request.Path.EndsWith("/oip-layout-register.phtml"))
                {
                    ProcessDynamicRegisterRequest(request, response);
                }
                else
                {
                    HandleAboutGetRequest(context, request.Path);
                }
                return;
            }

            if (isAuthenticated == false)
            {
                return;
            }
            try
            {
                if (request.Path.StartsWith(AuthPersonalPrefix))
                {
                    HandlePersonalRequest(context);
                }
                else if (request.Path.StartsWith(AuthGroupPrefix))
                {
                    HandleGroupRequest(context);
                }
                else if (request.Path.StartsWith(AuthAccountPrefix))
                {
                    HandleAccountRequest(context);
                }
            } finally
            {
                InformationContext.ProcessAndClearCurrent();
            }
        }
예제 #21
0
        private async Task FillData(DataSet ds, InformationContext entity, List <InformationReport> reports)
        {
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                InformationReport report = new InformationReport();
                report.ErrorCode = item["errorcode"] != null?Convert.ToInt32(item["errorcode"]) : 0;

                report.ErrorMessage    = item["errormessage"].ToString();
                report.NumberOfResults = item["numberofresults"].ToString();
                report.Results         = item["results"].ToString();
                report.StopID          = item["stopid"] != null?Convert.ToInt32(item["stopid"]) : 0;

                report.TimeStamp = item["timestamp"] != null?Convert.ToDateTime(item["timestamp"]) : DateTime.Now;

                reports.Add(report);
                entity.InformationReport.Add(report);
            }
            entity.SaveChanges();
        }
예제 #22
0
        public void InitInformationContext()
        {
            try
            {
                var optionsBuilderInf = new DbContextOptionsBuilder <InformationContext>();
                optionsBuilderInf.UseNpgsql(Program.Configuration.GetConnectionString("DatabaseConnection"));
                _infContext = new InformationContext(optionsBuilderInf.Options);
                Logger.Debug("Init InformationContext successful");

                var optionsBuilderDet = new DbContextOptionsBuilder <Kbs.IdoWeb.Data.Determination.DeterminationContext>();
                optionsBuilderDet.UseNpgsql(Program.Configuration.GetConnectionString("DatabaseConnection"));
                _detContext = new Kbs.IdoWeb.Data.Determination.DeterminationContext(optionsBuilderDet.Options);
                Logger.Debug("Init DetContext successful");
            }
            catch (Exception e)
            {
                Logger.Error(e, "Could not init InformationContext");
            }
        }
 /// <summary>
 /// Parses the context value for known formats and trys to categorize them. If no categorization could be done it defaults to companyname.
 /// </summary>
 /// <param name="context">The InformationContext to be parsed</param>
 private void Parse(InformationContext context)
 {
     long numberBuffer;
     Ilc.Linguistic.EmailAddress email;
     if (Ilc.Linguistic.EmailAddress.TryParse(context.Context, out email))
     {
         IsEmailAddress = true;
         EmailAddress = email;
     }
     else if (long.TryParse(context.Context, out numberBuffer))
     {
         IsDebitorNumber = IsKreditorNumber = true;
         DebitorNumber = KreditorNumber = numberBuffer;
     }
     else
     {
         IsCompanyName = true;
         CompanyName = context.Context;
     }
 }
예제 #24
0
        private static void ClearEmptyLocations()
        {
            var locations =
                GetAllInformationObjects(null, io => io is AddressAndLocation).Cast <AddressAndLocation>().ToArray();

            foreach (var loc in locations)
            {
                if (String.IsNullOrEmpty(loc.Location.LocationName))
                {
                    try
                    {
                        StorageSupport.DeleteInformationObject(loc);
                    } finally
                    {
                        InformationContext.ProcessAndClearCurrent();
                        InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName);
                    }
                }
            }
        }
예제 #25
0
        private static void InitBlogProfileAndIconOnce()
        {
            var blogs = GetAllInformationObjects(name => name.Contains("/Blog/"), io => io is Blog).Cast <Blog>().ToArray();

            try
            {
                foreach (var blog in blogs)
                {
                    blog.IconImage    = Image.CreateDefault();
                    blog.ProfileImage = Image.CreateDefault();
                    VirtualOwner owner = VirtualOwner.FigureOwner(blog);
                    blog.StoreInformationMasterFirst(owner, false);
                }
            }
            finally
            {
                InformationContext.ProcessAndClearCurrent();
                InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName);
            }
        }
예제 #26
0
        /// <summary>
        /// Parses the context value for known formats and trys to categorize them. If no categorization could be done it defaults to companyname.
        /// </summary>
        /// <param name="context">The InformationContext to be parsed</param>
        private void Parse(InformationContext context)
        {
            long numberBuffer;

            Ilc.Linguistic.EmailAddress email;
            if (Ilc.Linguistic.EmailAddress.TryParse(context.Context, out email))
            {
                IsEmailAddress = true;
                EmailAddress   = email;
            }
            else if (long.TryParse(context.Context, out numberBuffer))
            {
                IsDebitorNumber = IsKreditorNumber = true;
                DebitorNumber   = KreditorNumber = numberBuffer;
            }
            else
            {
                IsCompanyName = true;
                CompanyName   = context.Context;
            }
        }
예제 #27
0
        private static void UpdateAllImageFormatsCustomGroup()
        {
            //var images =
            //    GetAllInformationObjects(name => name.Contains("/Image/") && name.Contains("/9798daca-"), io => io is Image).Cast<Image>().ToArray();
            var ownerLocations = GetAllOwnerLocations();
            var ownerLocation  = ownerLocations.Where(loc => loc.Contains("/9798daca-")).SingleOrDefault();
            var images         = StorageSupport.CurrActiveContainer.GetInformationObjects(ownerLocation, name => name.Contains("/Image/"), io => io is Image).Cast <Image>().ToArray();
            int currImageIndex = 0;

            foreach (var image in images)
            {
                if (image.ImageData.ID.Contains("a25982") == false)
                {
                    continue;
                }
                image.ImageData.UpdateAdditionalMediaFormats();
                Console.WriteLine("Processed Image: " + ++currImageIndex + " out of " + images.Length);
            }
            InformationContext.ProcessAndClearCurrent();
            InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName);
        }
예제 #28
0
        /// <summary>
        /// Method for populating the database with address data.
        /// </summary>
        /// <param name="staticMapData">The staticdata object.</param>
        private void UpdateDatabase(StaticMapData staticMapData)
        {
            using (var context = new InformationContext())
            {
                Dispatcher.Invoke(() => { lblNumberOfRecords.Content = context.Persons.Count().ToString(); });

                Postal postal = context.Postals.Where(x =>
                                                      x.PostalCode == staticMapData.PostalCode &&
                                                      x.City == staticMapData.City).FirstOrDefault();

                if (postal == null)
                {
                    context.Postals.Add(staticMapData.GetPostal());
                    context.SaveChanges();
                    return;
                }

                Address address = context.Addresses.Where(x =>
                                                          x.Street == staticMapData.Addr1 &&
                                                          x.PostalCode == staticMapData.PostalCode).FirstOrDefault();

                if (address == null)
                {
                    postal.Addresses.Add(staticMapData.GetAddress(postal));
                    context.SaveChanges();
                    return;
                }

                Person person = context.Persons.Where(x =>
                                                      x.DataId.ToString() == staticMapData.Id).FirstOrDefault();

                if (person == null)
                {
                    address.Persons.Add(staticMapData.GetPerson(address));
                    context.SaveChanges();
                }
            }
        }
예제 #29
0
        private void Init()
        {
            try
            {
                Logger.Info("Initializing AppData ..");
                var optionsBuilderDet = new DbContextOptionsBuilder <DeterminationContext>();
                optionsBuilderDet.UseNpgsql(Program.Configuration.GetConnectionString("DatabaseConnection"));
                _detContext = new DeterminationContext(optionsBuilderDet.Options);

                var optionsBuilderInf = new DbContextOptionsBuilder <InformationContext>();
                optionsBuilderInf.UseNpgsql(Program.Configuration.GetConnectionString("DatabaseConnection"));
                _infContext = new InformationContext(optionsBuilderInf.Options);

                var optionsBuilderObs = new DbContextOptionsBuilder <ObservationContext>();
                optionsBuilderObs.UseNpgsql(Program.Configuration.GetConnectionString("DatabaseConnection"));
                _obsContext = new ObservationContext(optionsBuilderObs.Options);

                Logger.Info(".. Success");
            }
            catch (Exception e)
            {
                Logger.Error(e, "Init Import Meta failed");
            }
        }
예제 #30
0
파일: WorkerRole.cs 프로젝트: michlG/Caloom
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            CurrWorkerID = DateTime.Now.ToString();
            ServicePointManager.DefaultConnectionLimit = 12;
            ServicePointManager.UseNagleAlgorithm      = false;
            string       connStr;
            const string ConnStrFileName = @"C:\Users\Michael\Documents\theballconnstr.txt";

            if (File.Exists(ConnStrFileName))
            {
                connStr = File.ReadAllText(ConnStrFileName);
            }
            else
            {
                connStr = CloudConfigurationManager.GetSetting("StorageConnectionString");
            }
            StorageSupport.InitializeWithConnectionString(connStr);
            InformationContext.InitializeFunctionality(3, allowStatic: true);
            InformationContext.Current.InitializeCloudStorageAccess(CURRENT_HARDCODED_CONTAINER_NAME);
            CurrQueue = QueueSupport.CurrDefaultQueue;
            IsStopped = false;
            return(base.OnStart());
        }
예제 #31
0
 public VideosController(InformationContext context)
 {
     _context = context;
 }
예제 #32
0
 public ImagesController(ObservationContext obsContext, InformationContext infContext)
 {
     _obsContext = obsContext;
     _infContext = infContext;
 }
예제 #33
0
 public UnitOfWork(InformationContext context)
 {
     _context = context;
 }