public static BankovniUcet Get(string cisloUctu) { lock (lockObj) { if (uctyWithExpiration.ContainsKey(cisloUctu)) { var kv = uctyWithExpiration[cisloUctu]; if (kv.Expiration > DateTime.Now) { return(kv.BU); } else { uctyWithExpiration.Remove(cisloUctu); } } BankovniUcet bu = BankovniUcet.Get(cisloUctu); //ulozit vcetne neexistujicich uctu, obrana proti utoku pres fake ucty uctyWithExpiration.Add(cisloUctu, new UcetWithExpiration() { BU = bu }); return(bu); } }
public BankovniUcet GetBankovniUcet() { if (_bu == null) { _bu = BankovniUcet.Get(this.CisloUctu); } return(_bu); }
public static Nest.ISearchResponse <BankovniPolozka> SearchPolozkyForOsoba(int osobaInternalId, BankovniUcet bu = null, int size = 500, AggregationContainerDescriptor <BankovniPolozka> anyAggregation = null) { return(SearchPolozkyRaw( string.Format("comments.valueInt:{0} AND comments.typeId:1", osobaInternalId), bu, size)); }
public static Nest.ISearchResponse <BankovniPolozka> SearchPolozkyForOsoba(string nameId, BankovniUcet bu = null, int size = 500, AggregationContainerDescriptor <BankovniPolozka> anyAggregation = null) { HlidacStatu.Lib.Data.Osoba o = HlidacStatu.Lib.Data.Osoby.GetByNameId.Get(nameId); if (o == null) { return(null); } return(SearchPolozkyForOsoba(o.InternalId)); }
public static Nest.ISearchResponse <BankovniPolozka> SearchPolozkyRaw(string queryString, BankovniUcet bu = null, int size = 500, AggregationContainerDescriptor <BankovniPolozka> anyAggregation = null) { AggregationContainerDescriptor <BankovniPolozka> baseAggrDesc = null; baseAggrDesc = anyAggregation == null ? new AggregationContainerDescriptor <BankovniPolozka>().Sum("sumKc", m => m.Field(f => f.Castka)) : anyAggregation; Func <AggregationContainerDescriptor <BankovniPolozka>, AggregationContainerDescriptor <BankovniPolozka> > aggrFunc = (aggr) => { return(baseAggrDesc); }; Nest.ISearchResponse <BankovniPolozka> res = null; if (bu != null) { res = HlidacStatu.Lib.ES.Manager.GetESClient_Ucty() .Search <BankovniPolozka>(a => a .Size(500) .Aggregations(aggrFunc) .Query(qq => qq.Bool(b => b .Must( m => m.Term(t => t.Field(f => f.CisloUctu).Value(bu.Id)), m1 => m1.QueryString(qs => qs .Query(queryString) .DefaultOperator(Nest.Operator.And) )) ) ) ); } else { res = HlidacStatu.Lib.ES.Manager.GetESClient_Ucty() .Search <HlidacStatu.Lib.Data.TransparentniUcty.BankovniPolozka>(a => a .Size(500) .Aggregations(aggrFunc) .Query(qq => qq.QueryString(qs => qs .Query(queryString) .DefaultOperator(Nest.Operator.And) ) ) ); } return(res); }
public static bool DeleteUcet(BankovniUcet bu, string user) { if (bu == null) { return(false); } Func <int, int, Nest.ISearchResponse <HlidacStatu.Lib.Data.TransparentniUcty.BankovniPolozka> > searchFunc = (size, page) => { return(HlidacStatu.Lib.ES.Manager.GetESClient_Ucty() .Search <HlidacStatu.Lib.Data.TransparentniUcty.BankovniPolozka>(a => a .Size(size) .From(page * size) .Query(q => q.Term(t => t.Field(f => f.CisloUctu).Value(bu.Id))) .Scroll("2m") )); }; List <BankovniPolozka> transactionIds = new List <BankovniPolozka>(); HlidacStatu.Lib.ES.SearchTools.DoActionForQuery <HlidacStatu.Lib.Data.TransparentniUcty.BankovniPolozka>( HlidacStatu.Lib.ES.Manager.GetESClient_Ucty(), searchFunc, (p, o) => { transactionIds.Add(p.Source); return(new Devmasters.Core.Batch.ActionOutputData()); }, null, null, null, false, blockSize: 500 ); bool ok = true; foreach (var t in transactionIds) { ok = ok && t.Delete(user); } ok = ok && ES.Manager.GetESClient_Ucty().Delete <BankovniUcet>(bu.Id).IsValid; return(ok); }
public static bool DeleteUcet(BankovniUcet bu) { return(_client.DeleteData(bu.Id)); }
public static BankovniUcet Get(string cislo) { BankovniUcet bu = _client.GetData <BankovniUcet>(TextUtil.NormalizeToURL(cislo)); return(bu); }