Пример #1
0
        public ActionResult AddCompanySponzoring(
            string ico,
            string strana, string rok, string castka, string udalost
            )
        {
            var apires = Framework.ApiAuth.IsApiAuth(this);

            if (apires.Authentificated &&
                (apires.ApiCall.User == "*****@*****.**" ||
                 apires.ApiCall.User == "*****@*****.**"
                )
                )
            {
                Firma f = Firma.FromIco(ico, true);
                if (f == null)
                {
                    HlidacStatu.Util.Consts.Logger.Error("API AddCompanySponzoring: ICO " + ico + " not found");
                    return(new HttpStatusCodeResult(500, "ICO not found."));
                }

                f.AddSponsoring(strana, Convert.ToInt32(rok), ParseTools.ToDecimal(castka).Value, "https://udhpsh.cz/5290-2/", this.User.Identity.Name, checkDuplicates: false);
                return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { ok = true }), "application/json"));
            }
            else
            {
                return(new HttpStatusCodeResult(401));
            }
        }
Пример #2
0
        private FirmaSocialDTO TransformEventsToFirmaSocial(IGrouping <string, OsobaEvent> groupedEvents)
        {
            var firma = Firma.FromIco(groupedEvents.Key);

            if (firma is null || !firma.Valid)
            {
                return(null);
            }

            return(new FirmaSocialDTO(firma, groupedEvents.ToList()));
        }
Пример #3
0
        /// <summary>
        /// Uploads new donations to FirmaEvent table
        /// </summary>
        /// <param name="donations"></param>
        public static void UploadCompanyDonations(Donations donations)
        {
            foreach (var companyDonations in donations.GetDonations())
            {
                var donor = companyDonations.Key;

                Firma firma = null;
                try
                {
                    firma = Firma.FromIco(donor.CompanyId);
                }
                catch (Exception)
                {
                }

                if (firma is null)
                {
                    Console.WriteLine($"Chybějící firma v db - ICO: {donor.CompanyId}, nazev: {donor.Name}");
                    continue;
                }

                var firmaEvents = firma.Events(ev => ev.Type == (int)FirmaEvent.Types.Sponzor).ToList();

                foreach (var donation in companyDonations.Value)
                {
                    var eventToRemove = firmaEvents.Where(oe => oe.AddInfoNum == donation.Amount &&
                                                          oe.Description == donation.ICO &&
                                                          oe.DatumOd.HasValue &&
                                                          oe.DatumOd.Value.Year == donation.Date.Year).FirstOrDefault();
                    if (eventToRemove is null)
                    {
                        // add event
                        var newEvent = new FirmaEvent()
                        {
                            AddInfo     = NormalizePartyName(donation.Party, donation.ICO),
                            DatumOd     = donation.Date,
                            AddInfoNum  = donation.Amount,
                            Description = donation.ICO,
                            Zdroj       = _zdroj,
                            Note        = donation.Description,
                            Type        = (int)FirmaEvent.Types.Sponzor
                        };
                        firma.AddOrUpdateEvent(newEvent, _user, checkDuplicates: false);
                    }
                    else
                    {
                        firmaEvents.Remove(eventToRemove);
                    }
                }
            }
        }
Пример #4
0
 public SubjectExport(Subject s)
 {
     if (s != null)
     {
         this.ICO   = s.ICO;
         this.Jmeno = s.Jmeno;
     }
     if (!string.IsNullOrEmpty(s?.ICO))
     {
         var f = Firma.FromIco(s.ICO);
         if (f != null && f.Valid)
         {
             this.KrajId  = f.KrajId;
             this.OkresId = f.OkresId;
         }
     }
 }
Пример #5
0
        public ActionResult CompanyDetail(string ico, string columOrdering, int?descending)
        {
            if (string.IsNullOrWhiteSpace(ico))
            {
                return(NotFound());
            }

            Firma firma = Firma.FromIco(ico);

            if (firma is null || !firma.Valid)
            {
                return(NotFound());
            }


            return(View(firma));
        }
Пример #6
0
        public void Save()
        {
            if (string.IsNullOrWhiteSpace(Id))
            {
                this.Id = Guid.NewGuid().ToString();
            }
            if (string.IsNullOrWhiteSpace(Company))
            {
                var firma = Firma.FromIco(Ico);
                Company = firma.Jmeno;
            }
            var res = ES.Manager.GetESClient_KindexFeedback().IndexDocument(this); //druhy parametr musi byt pole, ktere je unikatni

            if (!res.IsValid)
            {
                throw new ApplicationException(res.ServerError?.ToString());
            }
        }
Пример #7
0
        /// <summary>
        /// Uploads new donations to FirmaEvent table
        /// </summary>
        public static void UploadCompanyDonations(Donations donations)
        {
            foreach (var companyDonations in donations.GetDonations())
            {
                var donor = companyDonations.Key;

                Firma firma = null;
                try
                {
                    firma = Firma.FromIco(donor.CompanyId);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                if (firma is null)
                {
                    Console.WriteLine($"Chybějící firma v db - ICO: {donor.CompanyId}, nazev: {donor.Name}");
                    continue;
                }

                foreach (var donation in companyDonations.Value)
                {
                    // add event
                    var sponzoring = new Sponzoring()
                    {
                        DarovanoDne = donation.Date,
                        Hodnota     = donation.Amount,
                        IcoPrijemce = donation.ICO,
                        Zdroj       = _zdroj,
                        Popis       = donation.Description,
                        Typ         = (int)donation.GiftType
                    };
                    firma.AddSponsoring(sponzoring, _user);
                }
            }
        }
        public ActionResult NasiPolitici_GetData(string _id)
        {
            string id = _id;

            if (!Framework.ApiAuth.IsApiAuth(this,
                                             parameters: new Framework.ApiCall.CallParameter[] {
                new Framework.ApiCall.CallParameter("id", id),
            })
                .Authentificated)
            {
                Response.StatusCode = 401;
                return(Json(ApiResponseStatus.ApiUnauthorizedAccess, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var o = Osoba.GetByNameId(id);
                if (o == null)
                {
                    Response.StatusCode = 404;
                    return(Json(ApiResponseStatus.Error(404, "Politik not found"), JsonRequestBehavior.AllowGet));
                }
                if (o.StatusOsoby() != Osoba.StatusOsobyEnum.Politik)
                {
                    Response.StatusCode = 404;
                    return(Json(ApiResponseStatus.Error(404, "Person is not marked as politician"), JsonRequestBehavior.AllowGet));
                }

                var vazby = o.AktualniVazby(Relation.AktualnostType.Nedavny)
                            .Where(v => v.Distance == 1 && v.To?.Type == Graph.Node.NodeType.Company)
                            .Take(10)
                            .Select(v => new
                {
                    company     = Firma.FromIco(v.To.Id).Jmeno,
                    ico         = v.To.Id,
                    since       = v.RelFrom,
                    until       = v.RelTo,
                    description = v.Descr
                }).ToList();


                var statDescription =
                    InfoFact.RenderInfoFacts(
                        o.InfoFacts().Where(i => i.Level != InfoFact.ImportanceLevel.Stat).ToArray()
                        , 4, true, true, "", "{0}");

                var angazovanost =
                    InfoFact.RenderInfoFacts(
                        o.InfoFacts().Where(m => m.Level == InfoFact.ImportanceLevel.Stat).ToArray()
                        , 4, true, true, "", "{0}");


                int[] types =
                {
                    (int)OsobaEvent.Types.VolenaFunkce,
                    (int)OsobaEvent.Types.PolitickaPracovni,
                    (int)OsobaEvent.Types.Politicka,
                    (int)OsobaEvent.Types.VerejnaSpravaJine,
                    (int)OsobaEvent.Types.VerejnaSpravaPracovni,
                };
                //var funkceOsoba = o.Description(true,
                //        m => types.Contains(m.Type),
                //        20);

                var roleOsoba = o.Events(m =>
                                         types.Contains(m.Type) &&
                                         m.Status != (int)OsobaEvent.Statuses.NasiPoliticiSkryte)
                                .Select(e => new {
                    role         = e.AddInfo,
                    dateFrom     = e.DatumOd,
                    dateTo       = e.DatumDo,
                    organisation = e.Organizace
                })
                                .ToArray();

                string registrOznameni = o.Events(m =>
                                                  m.Type == (int)OsobaEvent.Types.CentralniRegistrOznameni &&
                                                  m.Status != (int)OsobaEvent.Statuses.NasiPoliticiSkryte)
                                         .Select(m => m.AddInfo).FirstOrDefault();

                List <StatementDTO> statements = null;
                if (!string.IsNullOrWhiteSpace(registrOznameni))
                {
                    var ds    = DataSet.CachedDatasets.Get("centralniregistroznameni");
                    var value = ds.GetDataObj(registrOznameni);


                    //StatementDTO[] statements = (StatementDTO[])value.statements;
                    statements = value?.statements?.ToObject <List <StatementDTO> >();
                }

                string osobaInsQuery = $"{{0}}.osobaId:{o.NameId}";
                //var oinsRes = HlidacStatu.Lib.Data.Insolvence.Insolvence.SimpleSearch("osobaid:" + Model.NameId, 1, 5, (int)HlidacStatu.Lib.Searching.InsolvenceSearchResult.InsolvenceOrderResult.LatestUpdateDesc, false, false);
                //query: dluznici.osobaId:{o.NameId}
                var oinsDluznik = Lib.Data.Insolvence.Insolvence.SimpleSearch(string.Format(osobaInsQuery, "dluznici"), 1, 1, (int)Lib.Searching.InsolvenceSearchResult.InsolvenceOrderResult.FastestForScroll, false, true);
                //query: veritele.osobaId:{o.NameId}
                var oinsVeritel = Lib.Data.Insolvence.Insolvence.SimpleSearch(string.Format(osobaInsQuery, "veritele"), 1, 1, (int)Lib.Searching.InsolvenceSearchResult.InsolvenceOrderResult.FastestForScroll, false, true);
                //query: spravci.osobaId:{o.NameId}
                var oinsSpravce = Lib.Data.Insolvence.Insolvence.SimpleSearch(string.Format(osobaInsQuery, "spravci"), 1, 1, (int)Lib.Searching.InsolvenceSearchResult.InsolvenceOrderResult.FastestForScroll, false, true);

                Dictionary <string, long> oinsolv = new Dictionary <string, long>();
                oinsolv.Add("dluznici|dlužník|dlužníka|dlužníkem", oinsDluznik.Total);
                oinsolv.Add("veritele|věřitel|věřitele|veřitelem", oinsVeritel.Total);
                oinsolv.Add("spravci|insolvenční správce|insolvenčního správce|insolvenčním správcem", oinsSpravce.Total);

                var insRes     = Lib.Data.Insolvence.Insolvence.SimpleSearch("osobaid:" + o.NameId, 1, 5, (int)Lib.Searching.InsolvenceSearchResult.InsolvenceOrderResult.LatestUpdateDesc, false, true);
                var insDluznik = Lib.Data.Insolvence.Insolvence.SimpleSearch("osobaiddluznik:" + o.NameId, 1, 1, (int)Lib.Searching.InsolvenceSearchResult.InsolvenceOrderResult.FastestForScroll, false, true);
                var insVeritel = Lib.Data.Insolvence.Insolvence.SimpleSearch("osobaidveritel:" + o.NameId, 1, 1, (int)Lib.Searching.InsolvenceSearchResult.InsolvenceOrderResult.FastestForScroll, false, true);
                var insSpravce = Lib.Data.Insolvence.Insolvence.SimpleSearch("osobaidspravce:" + o.NameId, 1, 1, (int)Lib.Searching.InsolvenceSearchResult.InsolvenceOrderResult.FastestForScroll, false, true);

                Dictionary <string, long> insolv = new Dictionary <string, long>();
                insolv.Add("dluznik|dlužník|dlužníka|dlužníkem", insDluznik.Total);
                insolv.Add("veritel|věřitel|věřitele|veřitelem", insVeritel.Total);
                insolv.Add("spravce|insolvenční správce|insolvenčního správce|insolvenčním správcem", insSpravce.Total);

                var photo = o.GetPhotoUrl(false) + "?utm_source=nasipolitici&utm_medium=detail&utm_campaign=photo";

                var sponzorstvi = o.Events(m =>
                                           m.Type == (int)OsobaEvent.Types.Sponzor &&
                                           m.Status != (int)OsobaEvent.Statuses.NasiPoliticiSkryte)
                                  .Select(m => new
                {
                    party         = m.Organizace,
                    donatedAmount = m.AddInfoNum,
                    year          = m.DatumOd?.Year,
                    source        = m.Zdroj
                }
                                          ).ToArray();

                var insPerson = new
                {
                    debtorCount = oinsDluznik.Total,
                    debtorLink  = $"https://www.hlidacstatu.cz/insolvence/hledat?Q=dluznici.osobaId:{o.NameId}"
                                  + "&utm_source=nasipolitici&utm_medium=detail&utm_campaign=dluznikosoba",
                    creditorCount = oinsVeritel.Total,
                    creditorLink  = $"https://www.hlidacstatu.cz/insolvence/hledat?Q=veritele.osobaId:{o.NameId}"
                                    + "&utm_source=nasipolitici&utm_medium=detail&utm_campaign=veritelosoba",
                    bailiffCount = oinsSpravce.Total,
                    bailiffLink  = $"https://www.hlidacstatu.cz/insolvence/hledat?Q=spravci.osobaId:{o.NameId}"
                                   + "&utm_source=nasipolitici&utm_medium=detail&utm_campaign=spravceosoba",
                };

                var insCompany = new
                {
                    debtorCount = insDluznik.Total,
                    debtorLink  = $"https://www.hlidacstatu.cz/insolvence/hledat?Q=osobaiddluznik:{o.NameId}"
                                  + "&utm_source=nasipolitici&utm_medium=detail&utm_campaign=dluznikfirma",
                    creditorCount = insVeritel.Total,
                    creditorLink  = $"https://www.hlidacstatu.cz/insolvence/hledat?Q=osobaidveritel:{o.NameId}"
                                    + "&utm_source=nasipolitici&utm_medium=detail&utm_campaign=veritelfirma",

                    bailiffCount = insSpravce.Total,
                    bailiffLink  = $"https://www.hlidacstatu.cz/insolvence/hledat?Q=osobaidspravce:{o.NameId}"
                                   + "&utm_source=nasipolitici&utm_medium=detail&utm_campaign=spravcefirma",
                };

                var lastUpdate = o.Events(m => true)
                                 .OrderByDescending(e => e.Created)
                                 .Select(e => e.Created)
                                 .FirstOrDefault();


                var result = new
                {
                    id                             = o.NameId,
                    lastUpdate                     = lastUpdate,
                    lastManualUpdate               = o.ManuallyUpdated,
                    namePrefix                     = o.TitulPred,
                    nameSuffix                     = o.TitulPo,
                    name                           = o.Jmeno,
                    surname                        = o.Prijmeni,
                    birthDate                      = o.Narozeni,
                    deathDate                      = o.Umrti,
                    status                         = o.StatusOsoby().ToString(),
                    hasPhoto                       = o.HasPhoto(),
                    photo                          = photo,
                    description                    = statDescription,
                    companyConnection              = angazovanost,
                    notificationRegisterId         = registrOznameni,
                    notificationRegisterStatements = statements,
                    //funkce = funkceOsoba,
                    roles             = roleOsoba,
                    insolvencyPerson  = insPerson,
                    insolvencyCompany = insCompany,
                    source            = o.GetUrl(false),
                    sponsor           = sponzorstvi,
                    currentParty      = o.CurrentPoliticalParty(),
                    contacts          = o.GetSocialContact(),
                    connections       = vazby,
                    wikiId            = o.WikiId,
                    //sources
                    sourceInsolvency = $"https://www.hlidacstatu.cz/insolvence/hledat?Q=osobaid:{o.NameId}"
                                       + "&utm_source=nasipolitici&utm_medium=detail&utm_campaign=osoba",
                    sourceSponzor = $"https://www.hlidacstatu.cz/osoba/{o.NameId}"
                                    + "?utm_source=nasipolitici&utm_medium=detail&utm_campaign=osoba",
                    sourceRegisterStatements = string.IsNullOrWhiteSpace(registrOznameni)
                            ? "https://www.hlidacstatu.cz" + "?utm_source=nasipolitici&utm_medium=detail&utm_campaign=osoba"
                            : $"https://www.hlidacstatu.cz/data/Detail/centralniregistroznameni/{registrOznameni}" + "?utm_source=nasipolitici&utm_medium=detail&utm_campaign=osoba",
                    sourceRoles = $"https://www.hlidacstatu.cz/osoba/{o.NameId}" + "?utm_source=nasipolitici&utm_medium=detail&utm_campaign=osoba",
                };

                return(Content(JsonConvert.SerializeObject(result), "application/json"));
                // return Json(result, JsonRequestBehavior.AllowGet);
            }
        }