コード例 #1
0
        /// <summary>
        /// Validates and saves a largeObject
        /// </summary>
        /// <param name="largeObjectModel"></param>
        public void Save(Model.LargeObject.LargeObjectModel largeObjectModel)
        {
            Common.Validation.ValidationService validationService = new Common.Validation.ValidationService();
            validationService.ValidateObject(largeObjectModel);

            largeObjectRepository.InsertOrReplace(largeObjectModel);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: rollemira/Architecture-Azure
        public Form1()
        {
            InitializeComponent();
            // Configure the system based upon where it is running
            // This will set all configuration values and register all types for dependency injection
            Sample.Azure.Config.Configuration.Configure();

            largeObjectModel = CreateLargeObjectModel();
        }
コード例 #3
0
        public void LargeObjectRedisCache()
        {
            Model.LargeObject.LargeObjectModel largeObjectModel = this.CreateLargeObjectModel();
            largeObjectModel.LargeObjectId = 1;

            Interface.Repository.ICacheRepository cacheManager = DI.Container.Resolve <Interface.Repository.ICacheRepository>();
            string cacheKey = Guid.NewGuid().ToString();

            cacheManager.Set(cacheKey, largeObjectModel, TimeSpan.FromMinutes(1));

            Model.LargeObject.LargeObjectModel loadedModel = cacheManager.Get <Model.LargeObject.LargeObjectModel>(cacheKey);
            Assert.AreEqual(loadedModel.Payload, largeObjectModel.Payload);
        } // LargeObjectRedisCache
コード例 #4
0
        public void LargeObjectAzureBlob()
        {
            // Register Repository (Override existing regristation)
            Sample.Azure.DI.Container.RegisterType <Sample.Azure.Interface.Repository.ILargeObjectRepository,
                                                    Sample.Azure.Repository.File.LargeObject.LargeObjectRepository>();

            Model.LargeObject.LargeObjectModel largeObjectModel = this.CreateLargeObjectModel();
            largeObjectModel.LargeObjectId = 1;

            Interface.Service.ILargeObjectService largeObjectService = DI.Container.Resolve <Interface.Service.ILargeObjectService>();
            largeObjectService.Save(largeObjectModel);

            Model.LargeObject.LargeObjectModel loadedModel = largeObjectService.Get(largeObjectModel.LargeObjectId);
            Assert.AreEqual(loadedModel.Payload, largeObjectModel.Payload);
        } // LargeObjectAzureBlob
コード例 #5
0
ファイル: Form1.cs プロジェクト: rollemira/Architecture-Azure
        private Model.LargeObject.LargeObjectModel CreateLargeObjectModel()
        {
            Model.LargeObject.LargeObjectModel largeObjectModel = new Model.LargeObject.LargeObjectModel();

            largeObjectModel.LargeObjectId = 0;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            // 8 MB
            for (int i = 1; i <= 8000000; i++)
            {
                sb.Append("A");
            }
            largeObjectModel.Payload = sb.ToString();

            return(largeObjectModel);
        }
コード例 #6
0
        public Sample.Azure.Model.LargeObject.LargeObjectModel Select(int largeObjectId)
        {
            string fileName  = largeObjectId.ToString().ToLower() + ".json";
            string container = "largeobject";

            Common.JSON.JSONService jsonService     = new Common.JSON.JSONService();
            Model.File.FileModel    loadedFileModel = fileRepository.GetFileAsText(container, fileName);

            if (loadedFileModel == null)
            {
                return(null);
            }
            else
            {
                string loadedJson = loadedFileModel.Text;
                Model.LargeObject.LargeObjectModel loadedModel = jsonService.Deserialize <Model.LargeObject.LargeObjectModel>(loadedJson);
                return(loadedModel);
            }
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: rollemira/Architecture-Azure
        private void blobRead_Click(object sender, EventArgs e)
        {
            int loop = Int32.Parse(txtLoop.Text);

            // Register Repository (Override existing regristation)
            Sample.Azure.DI.Container.RegisterType <Sample.Azure.Interface.Repository.ILargeObjectRepository,
                                                    Sample.Azure.Repository.File.LargeObject.LargeObjectRepository>();

            Interface.Service.ILargeObjectService largeObjectService = DI.Container.Resolve <Interface.Service.ILargeObjectService>();

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
            for (int i = 1; i <= loop; i++)
            {
                Model.LargeObject.LargeObjectModel loadedModel = largeObjectService.Get(i);
            }
            stopwatch.Stop();

            txtResult.Text  = string.Empty;
            txtResult.Text += "Blob Read (" + loop.ToString() + ") took: " + stopwatch.ElapsedMilliseconds.ToString() + " milliseconds." + Environment.NewLine;
            txtResult.Text += "Blob Read (" + loop.ToString() + ") took: " + (stopwatch.ElapsedMilliseconds / 1000).ToString() + " seconds." + Environment.NewLine;
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: rollemira/Architecture-Azure
        private void cacheRead_Click(object sender, EventArgs e)
        {
            int loop = Int32.Parse(txtLoop.Text);

            Interface.Repository.ICacheRepository cacheManager = DI.Container.Resolve <Interface.Repository.ICacheRepository>();
            string cacheKey = largeObjectModel.LargeObjectId.ToString();

            Model.LargeObject.LargeObjectModel loadedModel = null;

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
            for (int i = 1; i <= loop; i++)
            {
                cacheKey    = i.ToString();
                loadedModel = cacheManager.Get <Model.LargeObject.LargeObjectModel>(cacheKey);
            }
            stopwatch.Stop();

            txtResult.Text  = string.Empty;
            txtResult.Text += "Cache Read (" + loop.ToString() + ") took: " + stopwatch.ElapsedMilliseconds.ToString() + " milliseconds." + Environment.NewLine;
            txtResult.Text += "Cache Read (" + loop.ToString() + ") took: " + (stopwatch.ElapsedMilliseconds / 1000).ToString() + " seconds." + Environment.NewLine;
        }
コード例 #9
0
        public void LargeObjectAzureSearch()
        {
            Model.LargeObject.LargeObjectModel largeObjectModel = this.CreateLargeObjectModel();
            largeObjectModel.LargeObjectId = 1;

            // This would save to blob or somewhere
            //Interface.Service.ILargeObjectService largeObjectService = DI.Container.Resolve<Interface.Service.ILargeObjectService>();
            //largeObjectService.Save(largeObjectModel);

            Model.Search.SearchLargeObjectModel searchLargeObjectModel = new Model.Search.SearchLargeObjectModel();
            searchLargeObjectModel.LargeObjectId = largeObjectModel.LargeObjectId.ToString();
            searchLargeObjectModel.Payload       = largeObjectModel.Payload;

            Interface.Repository.IIndexerRepository azureSearch = DI.Container.Resolve <Interface.Repository.IIndexerRepository>();

            azureSearch.UpsertLargeObject(Interface.GlobalEnum.IndexerIndexName.LargeObject, searchLargeObjectModel);

            List <Model.Search.SearchLargeObjectModel> list = azureSearch.LargeObjectSearch(
                Interface.GlobalEnum.IndexerIndexName.LargeObject, largeObjectModel.LargeObjectId.ToString());

            Assert.AreEqual(list[0].LargeObjectId, largeObjectModel.LargeObjectId.ToString());
        } // LargeObjectAzureSearch