Example #1
0
 private void UpdateMetadata(PostedDataDto postedData, Action <MetadataContext> updateMethod)
 {
     using (var inputStream = fileService.GetFileStream(postedData.guid, false))
         using (MetadataContext context = new MetadataContext(inputStream, postedData.password))
         {
             updateMethod(context);
             context.Save();
         }
 }
Example #2
0
        public void CleanMetadata(PostedDataDto postedData)
        {
            string filePath     = metadataConfiguration.GetAbsolutePath(postedData.guid);
            var    tempFilePath = GetTempPath(filePath);

            using (MetadataContext context = new MetadataContext(filePath, postedData.password))
            {
                context.Sanitize();
                context.Save(tempFilePath);
            }
            DirectoryUtils.MoveFile(tempFilePath, filePath);
        }
Example #3
0
        public void RemoveProperties(PostedDataDto postedData)
        {
            string filePath     = metadataConfiguration.GetAbsolutePath(postedData.guid);
            var    tempFilePath = GetTempPath(filePath);

            using (MetadataContext context = new MetadataContext(filePath, postedData.password))
            {
                foreach (var packageInfo in postedData.packages)
                {
                    context.RemoveProperties(packageInfo.id, packageInfo.properties.Select(p => p.name));
                }
                context.Save(tempFilePath);
            }
            DirectoryUtils.MoveFile(tempFilePath, filePath);
        }