示例#1
0
        public static async Task <Models.Dokumentum> LetoltesAsync(ossContext context, string sid, int dokumentumKod)
        {
            SessionBll.Check(context, sid);
            await CsoportDal.JogeAsync(context, JogKod.IRAT);

            return(await DokumentumDal.GetWithVolumeAsync(context, dokumentumKod));
        }
示例#2
0
        public static async Task <DokumentumDto> GetAsync(ossContext context, string sid, int dokumentumKod)
        {
            SessionBll.Check(context, sid);
            await CsoportDal.JogeAsync(context, JogKod.IRAT);

            var entity = await DokumentumDal.GetAsync(context, dokumentumKod);

            return(ObjectUtils.Convert <Models.Dokumentum, DokumentumDto>(entity));
        }
示例#3
0
        public static async Task DeleteAsync(ossContext context, string sid, DokumentumDto dto)
        {
            SessionBll.Check(context, sid);
            await CsoportDal.JogeAsync(context, JogKod.IRAT);

            await DokumentumDal.Lock(context, dto.Dokumentumkod, dto.Modositva);

            var entity = await DokumentumDal.GetAsync(context, dto.Dokumentumkod);

            await DokumentumDal.DeleteAsync(context, entity);
        }
示例#4
0
        public static async Task <List <DokumentumDto> > SelectAsync(ossContext context, string sid, int iratKod, bool imgprev, int imgwidth)
        {
            SessionBll.Check(context, sid);
            await CsoportDal.JogeAsync(context, JogKod.IRAT);

            var entities = await DokumentumDal.SelectAsync(context, iratKod);

            var entitiesDto = new List <DokumentumDto>();


            foreach (var ent in entities)
            {
                //újraolvasni a volume miatt
                var doc = await DokumentumDal.GetWithVolumeAsync(context, ent.Dokumentumkod);

                var entDto = ObjectUtils.Convert <Models.Dokumentum, DokumentumDto>(ent);

                if (imgprev)
                {
                    var ext = ent.Ext.ToLower();
                    if (ext == ".jpg" | ext == ".jpeg" | ext == ".png")
                    {
                        //kell a volume
                        var fb = LetoltesFajl(doc, 0, ent.Meret);

                        using (var image = new MagickImage(fb.b))
                        {
                            image.Resize(imgwidth, imgwidth);

                            entDto.Imgprev = image.ToBase64();
                        }
                    }
                }

                entitiesDto.Add(entDto);
            }

            return(entitiesDto);
        }
示例#5
0
        public static async Task <Models.Dokumentum> BejegyzesAsync(ossContext context, string sid, FajlBuf fajlBuf)
        {
            const int minSize = 100 * 1024 * 1024;

            SessionBll.Check(context, sid);
            await CsoportDal.JogeAsync(context, JogKod.IRAT);

            Models.Volume entityVolume;
            int           ujFajlMerete = fajlBuf.Meret;

            // lock-ban nem lehet async
            var entityParticio = await ParticioDal.GetAsync(context);

            var vc = JsonConvert.DeserializeObject <VolumeConf>(entityParticio.Volume);

            var Eleresiut = vc.UjvolumeEleresiut ?? throw new Exception(string.Format(Messages.ParticioHiba, "UjvolumeEleresiut"));

            if (!Directory.Exists(Eleresiut))
            {
                throw new Exception($"UjvolumeEleresiut: nem létező könyvtár: {Eleresiut}!");
            }

            var Maxmeret = vc.UjvolumeMaxmeret != null ? (int)vc.UjvolumeMaxmeret :
                           throw new Exception(string.Format(Messages.ParticioHiba, "UjvolumeMaxmeret"));

            if (Maxmeret < minSize)
            {
                throw new Exception($"UjvolumeMaxmeret: az érték legyen nagyobb, mint {minSize} - jelenleg {Maxmeret}!");
            }

            lock (LockMe)
            {
                var lstVolume = VolumeDal.ReadElegSzabadHely(context, ujFajlMerete);

                if (lstVolume.Count > 0)
                {
                    entityVolume = lstVolume[0];

                    if (++entityVolume.Fajlokszamautolsokonyvtarban > 100)
                    {
                        ++entityVolume.Utolsokonyvtar;
                        entityVolume.Fajlokszamautolsokonyvtarban = 1;
                    }
                    entityVolume.Jelenlegimeret += ujFajlMerete;
                    //ezt lehetne okosítani...
                    if ((entityVolume.Maxmeret - entityVolume.Jelenlegimeret) < (10 * 1024 * 1024))
                    {
                        entityVolume.Allapot = KotetAllapot.Closed.ToString();
                    }
                    entityVolume.Allapotkelte = DateTime.Now;

                    VolumeDal.Update(context, entityVolume);
                }
                else
                {
                    entityVolume = new Models.Volume
                    {
                        Particiokod    = (int)context.CurrentSession.Particiokod,
                        Volumeno       = context.KodGen(KodNev.Volume),
                        Eleresiut      = Eleresiut,
                        Maxmeret       = Maxmeret,
                        Jelenlegimeret = ujFajlMerete,
                        Utolsokonyvtar = 1,
                        Fajlokszamautolsokonyvtarban = 1,
                        Allapot      = KotetAllapot.Opened.ToString(),
                        Allapotkelte = DateTime.Now
                    };

                    VolumeDal.Add(context, entityVolume);
                }
            }

            var entityDokumentum = new Models.Dokumentum
            {
                Volumekod  = entityVolume.Volumekod,
                Konyvtar   = entityVolume.Utolsokonyvtar,
                Meret      = ujFajlMerete,
                Ext        = fajlBuf.Ext,
                Hash       = fajlBuf.Hash,
                Iratkod    = fajlBuf.IratKod,
                Megjegyzes = fajlBuf.Megjegyzes
            };

            var dokumentumKod = await DokumentumDal.AddAsync(context, entityDokumentum);

            return(await DokumentumDal.GetWithVolumeAsync(context, dokumentumKod));
        }