Beispiel #1
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                _3DRAPI_Imp api = new _3DRAPI_Imp(true);

                Metadata md = new Metadata
                {
                    Title       = metadataDetails.Metadata.Title,
                    Description = metadataDetails.Metadata.Description,
                    License     = metadataDetails.LicenseUrl,
                    AssetType   = "Model"
                };
                var pid = api.InsertMetadata(md);
                using (FileStream modelStream = new FileStream(metadataDetails.Metadata.ModelLocation, FileMode.Open))
                {
                    byte[] data = new byte[modelStream.Length];
                    modelStream.Read(data, 0, data.Length);
                    api.UploadFile(data, pid);
                }
                using (FileStream modelStream = new FileStream(metadataDetails.Metadata.ScreenshotLocation, FileMode.Open))
                {
                    byte[] data = new byte[modelStream.Length];
                    modelStream.Read(data, 0, data.Length);
                    api.UploadScreenShot(data, pid, Path.GetFileName(metadataDetails.Metadata.ScreenshotLocation));
                }
                if (Complete != null)
                {
                    Complete(this, new EventArgs());
                }
            }
        }
Beispiel #2
0
 private void btnUpload_Click(object sender, EventArgs e)
 {
     foreach (TempMetadata tmp in lstFiles.CheckedItems)
     {
         if (tmp != null && File.Exists(tmp.ModelLocation))
         {
             _3DRAPI_Imp api = new _3DRAPI_Imp(true);
             Metadata    md  = new Metadata
             {
                 License     = tmp.License,
                 Title       = tmp.Title,
                 Description = tmp.Description,
                 AssetType   = "Model"
             };
             var pid = api.InsertMetadata(md);
             using (FileStream modelStream = new FileStream(tmp.ModelLocation, FileMode.Open))
             {
                 byte[] data = new byte[modelStream.Length];
                 modelStream.Read(data, 0, data.Length);
                 api.UploadFile(data, pid);
             }
             if (File.Exists(tmp.ScreenshotLocation))
             {
                 using (FileStream modelStream = new FileStream(tmp.ScreenshotLocation, FileMode.Open))
                 {
                     byte[] data = new byte[modelStream.Length];
                     modelStream.Read(data, 0, data.Length);
                     api.UploadScreenShot(data, pid, Path.GetFileName(tmp.ScreenshotLocation));
                 }
             }
         }
     }
     if (Complete != null)
     {
         Complete(this, new EventArgs());
     }
 }