Exemplo n.º 1
0
        public override void Call()
        {
            Progress.Caption = "Actualizando metadatos";
            Progress.Total   = 1;
            if (current == null)
            {
                return;
            }
            PublicId.SetLowestFreeId(current.Contact);
            PublicId.SetLowestFreeId(current.Institution);
            PublicId.SetLowestFreeId(current);

            context.Data.Session.SaveOrUpdate(current.Contact);
            context.Data.Session.SaveOrUpdate(current.Institution);


            if (current.MetadataSources != null)
            {
                foreach (var src in current.MetadataSources)
                {
                    PublicId.SetLowestFreeId(src.Source.Contact);
                    PublicId.SetLowestFreeId(src);
                    PublicId.SetLowestFreeId(src.Source.Institution);
                    PublicId.SetLowestFreeId(src.Source);

                    context.Data.Session.SaveOrUpdate(src.Source.Contact);

                    context.Data.Session.SaveOrUpdate(src.Source.Institution);

                    context.Data.Session.SaveOrUpdate(src.Source);

                    context.Data.Session.SaveOrUpdate(src);
                }
            }
            context.Data.Session.SaveOrUpdate(current);

            foreach (var file in current.Files)
            {
                if (file.FileAdded && file.File != null)
                {
                    PublicId.SetLowestFreeId(file);
                    FileSave fs = new FileSave(this, file.File);
                    fs.Call();
                }
            }
        }
Exemplo n.º 2
0
        public override void Call()
        {
            Progress.Caption = "Actualizando copia de archivo";
            Progress.Total   = 2;
            Progress.Increment();
            List <FileChunk> keepItems = new List <FileChunk>();

            if (current.FileChunks.Count > 0 &&
                current.FileChunks[0].Id.HasValue == false)
            {
                // has nuevos
                keepItems.AddRange(current.FileChunks);
                int totalSize = 0;
                foreach (var v in current.FileChunks)
                {
                    totalSize += v.Content.Length;
                }
                current.Size = totalSize;
                current.FileChunks.Clear();
            }
            else
            {
                PublicId.SetId(current);
                context.Data.Session.SaveOrUpdate(current);
                return;
            }
            Progress.Total = keepItems.Count + 1;
            PublicId.SetId(current);

            context.Data.Session.SaveOrUpdate(current);

            foreach (var chunk in keepItems)
            {
                current.FileChunks.Add(chunk);

                PublicId.SetId(chunk);

                context.Data.Session.SaveOrUpdate(chunk);
                Progress.Increment();
            }
        }