SHARE
TWEET

Untitled

a guest Dec 16th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections.Generic;
  2. using System.Text;
  3.  
  4. namespace bm2_get
  5. {
  6.     class Program
  7.     {
  8.         static bm2_get.gsiwebservices.BlobManII bm2;
  9.  
  10.         static void GetBlob(string guid, string destination)
  11.         {
  12.             Guid g = new Guid(guid);
  13.             byte[] b = bm2.RetrieveBlobbyID(g, 0);
  14.  
  15.             string s = bm2.GetBlobInfo(g);
  16.             System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
  17.  
  18.             doc.LoadXml(s);
  19.  
  20.             string filename = doc.SelectSingleNode("//@strFileName").Value + "." + doc.SelectSingleNode("//@strFileExtension").Value;
  21.             string filepath = string.Format("{0}\\{1}", destination, filename.ToUpper());
  22.  
  23.             using (System.IO.BinaryWriter bw = new System.IO.BinaryWriter(System.IO.File.Open(filepath, System.IO.FileMode.Create)))
  24.             {
  25.                 bw.Write(b);
  26.             }
  27.  
  28.             System.Console.WriteLine(string.Format("Saving {0}", filepath));
  29.         }
  30.  
  31.         static void Main(string[] args)
  32.         {
  33.             if (args.Length != 2)
  34.             {
  35.                 System.Console.WriteLine("bm2_get <path to file list of BM2 idBlobs> <destination folder>");
  36.                 return;
  37.             }
  38.  
  39.             if (!System.IO.Directory.Exists(args[1]))
  40.             {
  41.                 System.Console.WriteLine(args[1] + " is not a folder");
  42.                 return;
  43.             }
  44.  
  45.             System.IO.TextReader tr = new System.IO.StreamReader(args[0]);
  46.             bm2 = new bm2_get.gsiwebservices.BlobManII();
  47.             string s;
  48.  
  49.             while ((s = tr.ReadLine()) != null)
  50.             {
  51.                 Guid g = new Guid(s);
  52.                 try
  53.                 {
  54.                     GetBlob(s, args[1]);
  55.                 }
  56.                 catch (Exception e)
  57.                 {
  58.                     System.Console.WriteLine(e.Message);
  59.                 }
  60.             }
  61.         }
  62.     }
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top