Exemplo n.º 1
0
 void Start()
 {
     client      = StorageServiceClient.Create(storageAccount, accessKey);
     blobService = client.GetBlobService();
     GetBlobList();
     currentFile = "";
 }
Exemplo n.º 2
0
		public Guid StoreDocument(DocumentInfo documentInfo, byte[] document)
		{
			using (StorageServiceClient client = new StorageServiceClient())
			{
				return client.StoreDocument(documentInfo, document);
			}
		}
Exemplo n.º 3
0
		public void DocumentStorageTest_Load()
		{
			using (var client = new StorageServiceClient())
			{
				Stopwatch sw = new Stopwatch();
				sw.Start();

				//int testContentLength = 1024 * 1024 * 100;// 100 Mb 
				int testContentLength = 1024 * 1024;// 1 Mb 

				MemoryStream memoryStream = new MemoryStream();
				Random r = new Random();
				for (int i = 0; i < testContentLength; i++)
				{
					memoryStream.WriteByte((byte)r.Next(0, 255));
				}
				memoryStream.Position = 0;

				Trace.WriteLine(String.Format("Fill array at [{0}] ms", sw.ElapsedMilliseconds));
				sw.Restart();

				Guid documentId = Guid.NewGuid();
				client.StoreDocumentStream(documentId, memoryStream);

				Trace.WriteLine(String.Format("Storedocument at [{0}] ms", sw.ElapsedMilliseconds));
				//Assert.IsTrue(5000 >= sw.ElapsedMilliseconds); //5 s max

				DocumentInfo documentInfo = client.GetDocumentInfo(documentId);
				Assert.IsNull(documentInfo);
				Assert.IsTrue(client.IsDocumentExist(documentId));

				client.Delete(documentId);
				Assert.IsFalse(client.IsDocumentExist(documentId));
			}
		}
Exemplo n.º 4
0
		public byte[] GetStaticContent(string fileName)
		{
			using (var client = new StorageServiceClient())
			{
				return client.GetStaticContent(fileName);
			}
		}
Exemplo n.º 5
0
		public void DocumentStorageTest_Base()
		{
			using (var client = new StorageServiceClient())
			{
				byte[] testFileContent = ASCIIEncoding.Default.GetBytes("Test file content");
				Stream s = new MemoryStream(testFileContent);

				Guid documentId = client.BeginStoreDocument(new DocumentInfo { Name = "DocName", Size = testFileContent.Length, IsEncrypted = false });
				client.StoreDocumentStream(documentId, s);


				using (Stream documentStream = client.GetDocumentStream(documentId))
				{
					using (MemoryStream ms = new MemoryStream())
					{
						documentStream.CopyTo(ms);
						byte[] outFileContent = ms.ToArray();
						CollectionAssert.AreEqual(testFileContent, outFileContent);
					}
				}

				DocumentInfo documentInfo = client.GetDocumentInfo(documentId);
				Assert.AreEqual("DocName", documentInfo.Name);
				Assert.AreEqual(testFileContent.Length, documentInfo.Size);
				Assert.IsTrue(client.IsDocumentExist(documentId));

				client.Delete(documentId);
				documentInfo = client.GetDocumentInfo(documentId);
				Assert.IsNull(documentInfo);
				Assert.IsFalse(client.IsDocumentExist(documentId));
			}
		}
Exemplo n.º 6
0
		public byte[] GetDocument(Guid documentStorageId)
		{
			using (StorageServiceClient client = new StorageServiceClient())
			{
				return client.GetDocument(documentStorageId);
			}
		}
Exemplo n.º 7
0
		public void DeleteDocument(Guid documentId)
		{
			using (var client = new StorageServiceClient())
			{
				client.Delete(documentId);
			}
		}
Exemplo n.º 8
0
		public DocumentInfo GetDocumentInfo(Guid documentStorageId)
		{
			using (StorageServiceClient client = new StorageServiceClient())
			{
				return client.GetDocumentInfo(documentStorageId);
			}
		}
Exemplo n.º 9
0
		public bool IsDocumentExist(Guid documentStorageId)
		{
			using (StorageServiceClient client = new StorageServiceClient())
			{
				return client.IsDocumentExist(documentStorageId);
			}
		}
Exemplo n.º 10
0
		public void AvmServiceTest_StoreInDb_StoreInStorage()
		{
			//arrange
			var orderId = 1;
			var currentUserId = 1;
			_orderManager.GetOrderById(1).Returns(new Order
				{
					Id = orderId,
					GeneralInfo = new OrderGeneralInfo
						{
							PropertyAddress = new Address(),
						},
				});

			//act
			var address = new AddressViewModel
			{
				ZIP = "92037",
				Street = "5961 LA JOLLA MESA DR"
			};
			_avmRequestsService.SendRequest(orderId, currentUserId);

			//assert
			var a = _avmRequestsRepository.Get(q => q.RequestUserId == currentUserId && q.OrderId == orderId);
			a.Should().HaveCount(1);
			a.Should().NotBeNull();
			foreach (var item in a)
			{
				using (var client = new StorageServiceClient())
				{
					var fileExist = client.IsDocumentExist(item.ResponseDocumentId.Value);
					fileExist.Should().BeTrue();
				}
			}
		}
Exemplo n.º 11
0
        public AzureStorage()
        {
            //String storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=oom;AccountKey=sIRqaNUlztHLFaaE/BKasMU/zg4M3V4+a8pfKI/oiUcGtv51VDoMWqt3E1UK+6Ion5jmohFM3+uTl7pMcrdQjw==";
            StorageServiceClient cl = new StorageServiceClient("oom", "sIRqaNUlztHLFaaE/BKasMU/zg4M3V4+a8pfKI/oiUcGtv51VDoMWqt3E1UK+6Ion5jmohFM3+uTl7pMcrdQjw==");

            bs = new BlobService(cl);
        }
Exemplo n.º 12
0
 public void AddMethodTest()
 {
     using (var service = new StorageServiceClient(new BasicHttpBinding(), new EndpointAddress(@"http://localhost:801/StorageService/")))
     {
         service.Open();
         service.AddRecord(1, "lalala");
     }
 }
Exemplo n.º 13
0
 private static void ServiceCall(string id)
 {
     using (var client = new StorageServiceClient())
     {
         client.Store(id);
         client.Close();
     }
 }
Exemplo n.º 14
0
 private static void ServiceCall(string id)
 {
     using (var client = new StorageServiceClient())
     {
         client.Store(id);
         client.Close();
     }
 }
Exemplo n.º 15
0
 private void Start()
 {
     if (string.IsNullOrEmpty(storageAccount) || string.IsNullOrEmpty(accessKey))
     {
         return;
     }
     client      = StorageServiceClient.Create(storageAccount, accessKey);
     blobService = client.GetBlobService();
 }
Exemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        if (string.IsNullOrEmpty(storageAccount) || string.IsNullOrEmpty(accessKey))
        {
            Log.Text(label, "Storage account and access key are required", "Enter storage account and access key in Unity Editor", Log.Level.Error);
        }

        client      = StorageServiceClient.Create(storageAccount, accessKey);
        blobService = client.GetBlobService();
    }
Exemplo n.º 17
0
        // button click event for uploading file to server
        protected void btnFileUpload_Click(object sender, EventArgs e)
        {
            StorageServiceClient storageClient = new StorageServiceClient();

            Console.WriteLine("filename: {0}", FileUpload1.FileName);
            string filePath = storageClient.storeFile(FileUpload1.FileName);

            FileUpload1.SaveAs(filePath);
            lblFilePath.Text = filePath.Trim();
        }
Exemplo n.º 18
0
 public static void CreateGame(string host, Action<Game> success, Action failure)
 {
     var sc = new StorageServiceClient();
     sc.CreateGameCompleted += (o, a) =>
     {
         if (a.Error == null)
             success(a.Result);
         else
             failure();
     };
     sc.CreateGameAsync(host);
 }
Exemplo n.º 19
0
 public static void JoinGame(string username, Action<Game> success, Action failure, string gameId = null)
 {
     var sc = new StorageServiceClient();
     sc.JoinGameCompleted += (o, a) =>
     {
         if (a.Error == null)
             success(a.Result);
         else
             failure();
     };
     sc.JoinGameAsync(username, gameId);
 }
Exemplo n.º 20
0
 public static void GetPlayerByName(string username, Action<Player> success, Action failure)
 {
     var sc = new StorageServiceClient();
     sc.GetPlayerByNameCompleted += (o, a) =>
     {
         if (a.Error == null)
             success(a.Result);
         else
             failure();
     };
     sc.GetPlayerByNameAsync(username);
 }
Exemplo n.º 21
0
 public static void GetPlayerByIdentifier(string identifier, Action<Player> success, Action failure)
 {
     var sc = new StorageServiceClient();
     sc.GetPlayerByIdentifierCompleted += (o, a) =>
     {
         if (a.Error == null)
             success(a.Result);
         else
             failure();
     };
     sc.GetPlayerByIdentifierAsync(identifier);
 }
Exemplo n.º 22
0
        public static bool CallStorageService(string path, byte[] fileData, string fileName)
        {
            var fileEntity = new fileEntity
            {
                path     = path.Replace("/", "|").Replace(@"\", "|"),
                fileData = fileData,
                fileName = fileName
            };
            var storage = new StorageServiceClient("StorageServiceImplPort");

            return(storage.AddFileObj(fileEntity));
        }
    // Use this for initialization
    void Start()
    {
        if (string.IsNullOrEmpty(storageAccount) || string.IsNullOrEmpty(accessKey))
        {
            Log.Text(label, "Storage account and access key are required", "Enter storage account and access key in Unity Editor", Log.Level.Error);
        }

        client      = StorageServiceClient.Create(storageAccount, accessKey);
        blobService = client.GetBlobService();

        items = new List <Blob>();
        // set TSTableView delegate
        tableView.dataSource = this;

        ListBlobs();
    }
Exemplo n.º 24
0
    // Use this for initialization
    void Start()
    {
        if (string.IsNullOrEmpty(azureAccount) ||
            string.IsNullOrEmpty(azureAppKey) ||
            string.IsNullOrEmpty(container))
        {
            Debug.LogError("Azure account, key and container resource required");
        }
        // setup blob service
        client = new StorageServiceClient(azureAccount, azureAppKey);
        azure  = new BlobService(client);

        // populate menus
        ReplaceDropdownOptions(modelsMenu, models);
        ListBlobs();
    }
Exemplo n.º 25
0
        public static void GetPlayerByName(string username, Action <Player> success, Action failure)
        {
            var sc = new StorageServiceClient();

            sc.GetPlayerByNameCompleted += (o, a) =>
            {
                if (a.Error == null)
                {
                    success(a.Result);
                }
                else
                {
                    failure();
                }
            };
            sc.GetPlayerByNameAsync(username);
        }
Exemplo n.º 26
0
        public static void GetPlayerByIdentifier(string identifier, Action <Player> success, Action failure)
        {
            var sc = new StorageServiceClient();

            sc.GetPlayerByIdentifierCompleted += (o, a) =>
            {
                if (a.Error == null)
                {
                    success(a.Result);
                }
                else
                {
                    failure();
                }
            };
            sc.GetPlayerByIdentifierAsync(identifier);
        }
Exemplo n.º 27
0
        public static void ScorePlayer(string playerId, int addedScore, Action <Player> success, Action failure)
        {
            var sc = new StorageServiceClient();

            sc.ScorePlayerCompleted += (o, a) =>
            {
                if (a.Error == null)
                {
                    success(a.Result);
                }
                else
                {
                    failure();
                }
            };
            sc.ScorePlayerAsync(playerId, addedScore);
        }
Exemplo n.º 28
0
        public static void PlayerGames(string username, Action <IEnumerable <Game> > success, Action failure)
        {
            var sc = new StorageServiceClient();

            sc.PlayerGamesCompleted += (o, a) =>
            {
                if (a.Error == null)
                {
                    success(a.Result);
                }
                else
                {
                    failure();
                }
            };
            sc.PlayerGamesAsync(username);
        }
Exemplo n.º 29
0
        public static void CreateGame(string host, Action <Game> success, Action failure)
        {
            var sc = new StorageServiceClient();

            sc.CreateGameCompleted += (o, a) =>
            {
                if (a.Error == null)
                {
                    success(a.Result);
                }
                else
                {
                    failure();
                }
            };
            sc.CreateGameAsync(host);
        }
Exemplo n.º 30
0
        public static void UpdateGame(string playerId, Game game, Action <Game> success, Action failure)
        {
            var sc = new StorageServiceClient();

            sc.UpdateGameCompleted += (o, a) =>
            {
                if (a.Error == null)
                {
                    success(a.Result);
                }
                else
                {
                    failure();
                }
            };
            sc.UpdateGameAsync(playerId, game);
        }
Exemplo n.º 31
0
        public static void JoinGame(string username, Action <Game> success, Action failure, string gameId = null)
        {
            var sc = new StorageServiceClient();

            sc.JoinGameCompleted += (o, a) =>
            {
                if (a.Error == null)
                {
                    success(a.Result);
                }
                else
                {
                    failure();
                }
            };
            sc.JoinGameAsync(username, gameId);
        }
Exemplo n.º 32
0
    /// <summary>
    /// Handler to get selected row item
    /// </summary>
    public void OnSelectedRow(Button button)
    {
        dynamicLoad.blobName = button.name;
        Debug.Log("Load blob: " + dynamicLoad.blobName);


        Debug.Log("This blob is: " + dynamicLoad.blobName);

        if (string.IsNullOrEmpty(storageAccount) || string.IsNullOrEmpty(accessKey))
        {
            Debug.Log("Storage account and access key are required - Enter storage account and access key in Unity Editor");
        }

        client      = StorageServiceClient.Create(storageAccount, accessKey);
        blobService = client.GetBlobService();

        string resourcePath = container + "/" + dynamicLoad.blobName;

        StartCoroutine(blobService.GetTextBlob(GetTextBlob, resourcePath));
    }
Exemplo n.º 33
0
    void Start()
    {
        // Create Storage Service client with name and access key
        _client = new StorageServiceClient(ACC_NAME, KEY);

        // Create Service from client
        _service = _client.GetBlobService();

        // Create Audio Sources
        voiceInputAudio        = gameObject.GetComponent <AudioSource>();
        startAudio             = gameObject.AddComponent <AudioSource>();
        stopAudio              = gameObject.AddComponent <AudioSource>();
        startAudio.playOnAwake = false;
        startAudio.clip        = StartListeningSound;
        stopAudio.playOnAwake  = false;
        stopAudio.clip         = StopListeningSound;

        // Get Microphone manager
        microphoneManager = GetComponent <MicrophoneManager>();
    }
    private void UploadAssetBundleFile(string path)
    {
        if (!File.Exists(path))
        {
            Debug.LogError("No asset bundle file found:" + path);
            return;
        }
        string filename = Path.GetFileName(path);

        byte[] bytes = File.ReadAllBytes(path);

        if (client == null)
        {
            client  = new StorageServiceClient(storageAccount, accessKey);
            service = client.GetBlobService();
            Debug.Log("Created Storage Service");
        }

        Debug.Log("Reading file bytes: " + path + "\nUpload asset bundle file: " + filename + " size:" + bytes.Length);
        StartCoroutine(service.PutAssetBundle(CompletedUploadingAssetBundle, bytes, container, filename));
    }
Exemplo n.º 35
0
        public void UploadFile(string path, string name, byte[] data)
        {
            if (data == null)
            {
                return;
            }
            var storage = new StorageServiceClient();

            var f = new fileEntity
            {
                path     = path,
                fileData = data,
                fileName = name
            };

            try
            {
                storage.AddFileObj(f);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 36
0
 public static void ScorePlayer(string playerId, int addedScore, Action<Player> success, Action failure)
 {
     var sc = new StorageServiceClient();
     sc.ScorePlayerCompleted += (o, a) =>
     {
         if (a.Error == null)
             success(a.Result);
         else
             failure();
     };
     sc.ScorePlayerAsync(playerId, addedScore);
 }
Exemplo n.º 37
0
        public static void Reset()
        {
            var sc = new StorageServiceClient();

            sc.ResetAsync();
        }
Exemplo n.º 38
0
 void Start()
 {
     client      = new StorageServiceClient(storageAccount, accessKey);
     blobService = client.GetBlobService();
 }
Exemplo n.º 39
0
		public void DocumentChunkedStorageTest_Load()
		{
			using (var client = new StorageServiceClient())
			{
				int testContentLength = 1024 * 1024;// 1 Mb 

				MemoryStream memoryStream = new MemoryStream();
				Random r = new Random();
				for (int i = 0; i < testContentLength; i++)
				{
					memoryStream.WriteByte((byte)r.Next(0, 255));
				}
				memoryStream.Position = 0;

				int chunkedSize = 16 * 1024;
				byte[] buffer = new byte[chunkedSize];

				int count = 0;
				Guid documentId = client.BeginStoreDocument(new DocumentInfo { Name = "DocName", IsEncrypted = false });
				client.BeginStoreChunkedDocument(documentId);
				while ((count = memoryStream.Read(buffer, 0, chunkedSize)) > 0)
				{
					client.StoreChunkedDocument(buffer, documentId);
				}
				client.EndStoreChunkedDocument(documentId);
				using (Stream documentStream = client.GetDocumentStream(documentId))
				{
					using (MemoryStream ms = new MemoryStream())
					{
						documentStream.CopyTo(ms);
						byte[] inFileContent = memoryStream.ToArray();
						byte[] outFileContent = ms.ToArray();
						CollectionAssert.AreEqual(inFileContent, outFileContent);
					}
				}
				Assert.IsTrue(client.IsDocumentExist(documentId));
				client.Delete(documentId);
				Assert.IsFalse(client.IsDocumentExist(documentId));
			}
		}
Exemplo n.º 40
0
        public CmaFile GetFileById(long id, string para)
        {
            string path     = "";
            string fileName = "";
            string fileType = "";

            if (para == "VAV") //for home page download
            {
                path = "|VAV|Home";
                using (var db = new CMAEntities())
                {
                    fileType = db.HOMEFILEs.Where(f => f.ID == id).Select(f => f.FILETYPE).ToList().FirstOrDefault();
                    fileName = id + "." + fileType;
                }
            }
            else if (para == "IPP") //for macro-ecnomic 100 charts and user uploaded file
            {
                using (var db = new IPPEntities())
                {
                    var subPath = (from f in db.FILEINFOs
                                   join t in db.TOPICs on f.TOPICID equals t.ID
                                   join m in db.MODULEINFOs on t.MODULEID equals m.ID
                                   where f.ID == id
                                   select new { m.NAMEEN, t.ID, f.FILETYPE }).ToList().FirstOrDefault();
                    path     = "|IPP|" + subPath.NAMEEN + "|" + subPath.ID;
                    fileName = id + "." + subPath.FILETYPE;
                    fileType = subPath.FILETYPE;
                }
            }
            else if (para.Contains("WMP"))//cmafiledb
            {
                using (var db = new Genius_HistEntities())
                {
                    if (para == "WMP_PROSP")
                    {
                        var accRoute = db.BANK_FIN_PRD_PROSP.Where(f => f.INNER_CODE == id).ToList().Select(f => f.ACCE_ROUTE).FirstOrDefault().Replace("\\", "|");
                        path     = "|WMP|RROSP|" + accRoute.Substring(0, accRoute.LastIndexOf("|"));
                        fileName = id.ToString() + accRoute.Substring(accRoute.LastIndexOf("."));
                        fileType = accRoute.Substring(accRoute.LastIndexOf(".") + 1);
                    }
                    else if (para == "WMP_REP")
                    {
                        var accRoute = db.FIN_PRD_RPT.Where(f => f.RPT_ID == id).ToList().Select(f => f.ACCE_ROUTE).FirstOrDefault().Replace("\\", "|");
                        path     = "|WMP|PRD_RPT|" + accRoute.Substring(0, accRoute.LastIndexOf("|"));
                        fileName = id.ToString() + accRoute.Substring(accRoute.LastIndexOf("."));
                        fileType = accRoute.Substring(accRoute.LastIndexOf(".") + 1);
                    }
                    else if (para == "WMP_DISC")
                    {
                        var accRoute = db.DISC_ACCE_CFP.Where(f => f.SEQ == id).ToList().Select(f => f.ACCE_ROUTE).FirstOrDefault().Replace("\\", "|");
                        var accOrder = db.DISC_ACCE_CFP.Where(f => f.SEQ == id).ToList().Select(f => f.ACCE_ORDER).FirstOrDefault().ToString();
                        var disc_id  = db.DISC_ACCE_CFP.Where(f => f.SEQ == id).ToList().Select(f => f.DISC_ID).FirstOrDefault().ToString();
                        path     = "|WMP|DISC_CFP|" + accRoute.Substring(0, accRoute.LastIndexOf("|"));
                        fileName = disc_id + "_" + accOrder + accRoute.Substring(accRoute.LastIndexOf("."));
                        fileType = accRoute.Substring(accRoute.LastIndexOf(".") + 1);
                    }
                }
            }
            else if (para == "ZCX")
            {
                using (var db = new ZCXEntities())
                {
                    var accRoute = db.RATE_REP.Where(f => f.RATE_ID == id).ToList().Select(f => f.RATE_FILE_PATH).FirstOrDefault().Replace("/", "|");
                    path     = "|ZCX|RATE" + accRoute.Substring(0, accRoute.LastIndexOf("|"));
                    fileName = accRoute.Substring(accRoute.LastIndexOf("|") + 1);
                    fileType = accRoute.Substring(accRoute.LastIndexOf(".") + 1);
                }
            }
            else if (para == "RR")
            {
                using (var db = new ResearchReportEntities())
                {
                    path     = "|RR|" + db.ALLFILESINFOes.Where(f => f.FILEID == id).ToList().Select(f => f.BIZCODE + "|" + f.INSTITUTIONINFOCODE + "|" + f.FILETYPECODE).FirstOrDefault();
                    fileName = db.ALLFILESINFOes.Where(f => f.FILEID == id).ToList().Select(f => f.FILEID.ToString() + "." + f.EXTENSION).FirstOrDefault();
                }
            }
            else if (para.ToUpper() == "LOGO")
            {
                using (var db = new ResearchReportEntities())
                {
                    var institution = db.INSTITUTIONINFOes.FirstOrDefault(i => i.ID_C == (decimal)id);
                    if (institution != null)
                    {
                        path     = "|RR|Logo";
                        fileName = string.Format("{0}.{1}", institution.CODE, institution.EXTENSION);
                    }
                }
            }

            var storage = new StorageServiceClient();
            var obj     = new fileEntity();

            try
            {
                obj = storage.RetriveFileObj(path, fileName);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            if (obj.fileData == null || obj.fileData.Length == 0)
            {
                return(null);
            }

            return(new CmaFile {
                Id = id, Content = obj.fileData, FileType = fileType
            });
        }
Exemplo n.º 41
0
 public static void Reset()
 {
     var sc = new StorageServiceClient();
     sc.ResetAsync();
 }
Exemplo n.º 42
0
 public static void UpdateGame(string playerId, Game game, Action<Game> success, Action failure)
 {
     var sc = new StorageServiceClient();
     sc.UpdateGameCompleted += (o, a) =>
     {
         if (a.Error == null)
             success(a.Result);
         else
             failure();
     };
     sc.UpdateGameAsync(playerId, game);
 }
Exemplo n.º 43
0
 public static void PlayerGames(string username, Action<IEnumerable<Game>> success, Action failure)
 {
     var sc = new StorageServiceClient();
     sc.PlayerGamesCompleted += (o, a) =>
     {
         if (a.Error == null)
             success(a.Result);
         else
             failure();
     };
     sc.PlayerGamesAsync(username);
 }