Esempio n. 1
0
 public GuidMessage InitInversion(FileUploadMessage request)
 {
     var ownerId = Guid.NewGuid();
     var inversion = InversionFactory.CreateInversion(ownerId, request);
     // Add into user-inversion Dictionary
     UserInversionLookup.Add(ownerId, inversion);
     // Add into inversion list
     Inversions.Add(inversion);
     // save the files into input folder
     inversion.Init();
     GuidMessage guidMessage = new GuidMessage();
     guidMessage.InversionId = inversion.InversionId;
     return guidMessage;
 }
Esempio n. 2
0
        public Inversion(Guid ownerId, FileUploadMessage request)
        {
            _inversionId = Guid.NewGuid();

            // TODO how to define the name ???
            _name = InversionId.ToString();
            _ownerId = ownerId;
            _request = request;

            // TODO how to generate the accessCode
            _accessCode = Guid.NewGuid().ToString();

            // TODO
            _wellId = GetWellId(request);
        }
 public static Inversion CreateInversion(Guid ownerId, FileUploadMessage request)
 {
     Inversion inversion = new Inversion(ownerId, request);
     return inversion;
 }
Esempio n. 4
0
 private void init(FileUploadMessage request)
 {
     string fileName = request.FileName;
     Stream sourceStream = request.FileData;
     // TODO How to get well Id ?????????????
     _wellId = GetWellId(request);
     SaveStreamToFile(fileName, sourceStream);
 }
Esempio n. 5
0
 private Guid GetWellId(FileUploadMessage request)
 {
     return _wellId;
 }
 public GuidMessage InitInversion(FileUploadMessage request)
 {
     return _robot.InitInversion(request);
 }
Esempio n. 7
0
        static void Main(string[] args)
        {
            RobotServiceClient client = new RobotServiceClient();

            // Use the 'client' variable to call operations on the service.

            FileUploadMessage request = new FileUploadMessage();
            request.FileName = "InversionSettings.zip";
            request.FileData = new FileStream(@"C:\InversionSettings.zip", FileMode.Open);

            Guid ownerId = Guid.NewGuid();
            Console.WriteLine("The ownerId is" + ownerId.ToString());

            // return inversionId
            Guid inversionId = client.InitInversion(request.FileName, request.FileData);

            Console.WriteLine("The inversionId is " + inversionId);
            Console.WriteLine("StartInversion = " + client.StartInversion(ownerId, inversionId));
            Console.WriteLine("StopInversion = " + client.StopInversion(ownerId, inversionId));
            Console.WriteLine("The inversionId is " + inversionId);

            // the returned Filedata from FileDownloadMessage
            string filePath = Path.Combine(@"C:\", "InversionResult.zip");
            Stream myStream;
            Stream outstream;
            Stream memoryStream = new MemoryStream();
            Console.WriteLine(client.RetrieveInversion("accessCode", inversionId, ownerId, out outstream));

            outstream.CopyTo(memoryStream);

            //using (myStream = new FileStream(filePath, FileMode.Create))
            //{
            //    ////read from the input stream in 4K chunks
                ////and save to output stream
                //const int bufferLen = 4096;
                //byte[] buffer = new byte[bufferLen];
                //int count = 0;
                //while ((count = outstream.Read(buffer, 0, bufferLen)) > 0)
                //{
                //    myStream.Write(buffer, 0, count);
                //}

               // memoryStream.CopyTo(myStream);

                //using (ZipFile zip = ZipFile.Read(myStream))
                //{
                //    foreach (ZipEntry entry in zip)
                //    {
                //        entry.Extract();
                //    }
                //    //ZipEntry entry = zip["NameOfEntryInArchive.doc"];
                //    //entry.Extract();  // create filesystem file here.
                //}

                Console.WriteLine("Returned outstream: {0}", outstream.GetType());
                //Console.WriteLine("Returned myStream: {0}", myStream.GetType());
                Console.WriteLine("Returned memoryStream: {0}", memoryStream.Length);

            Stream fileStream = new FileStream(filePath, FileMode.Create);
            memoryStream.CopyTo(fileStream);

                outstream.Close();

               // myStream.Close();
                memoryStream.Close();

            if( outstream == memoryStream)
            {
                Console.WriteLine("11111111111111");
            }
            //}

            //Always close the client.
            client.Close();

            Console.ReadLine();
        }