Exemplo n.º 1
0
        private static void TestManyTenants(string folderName)
        {
            var tenantList = new string[] {
                "Tenant 1",
                "Tenant 2",
                "Tenant 3",
            };

            //Create the manager object
            using (var service = new SystemConnection())
            {
                foreach (var tenantName in tenantList)
                {
                    //Get/create tenant
                    var tenantId = service.GetOrAddTenant(tenantName);

                    //Encrypt all files in Notepad++ folder
                    var allFiles = Directory.GetFiles(folderName, "*.*", SearchOption.AllDirectories);
                    var timer    = Stopwatch.StartNew();
                    var index    = 0;
                    foreach (var file in allFiles)
                    {
                        service.SaveFile(tenantId, Container, file);
                        index++;
                        Console.WriteLine(string.Format("Tenant: " + tenantName + ", Saved file {0} / {1}", index, allFiles.Length));
                    }
                    timer.Stop();
                    Console.WriteLine(string.Format("Tenant: " + tenantName + ", Load {0} files in {1} ms", allFiles.Length, timer.ElapsedMilliseconds));

                    //Compare total count of disk vs storage
                    var arr = service.GetFileList(tenantId, folderName);
                    Debug.Assert(allFiles.Length == arr.Count);
                }
            }
        }
Exemplo n.º 2
0
        private static void TestMultipleTenants()
        {
            //This is the plain text file to test
            var plainFile = @"c:\temp\test.txt";

            //Create multiple tenants
            using (var service = new SystemConnection())
            {
                for (var ii = 1; ii <= 10; ii++)
                {
                    var tid = service.GetOrAddTenant("Tenant " + ii);
                    //Save the same file to different tenants and look in the storage folder
                    //Each file is unqiue as each file uses a unqiue data key
                    //Each data key is encrypted with the the tenant key
                    //Each tenant key is encrypted with the master key
                    //NOTE: Do not loose the master key!!
                    service.SaveFile(tid, "Default", plainFile);
                }

                //Look and find all files for each tenant and remove each
                //Note:the container is a grouping. It abstracts a virtual file system
                for (var ii = 1; ii <= 10; ii++)
                {
                    var tid = service.GetOrAddTenant("Tenant " + ii);
                    var arr = service.GetFileList(tid);
                    foreach (var item in arr)
                    {
                        service.RemoveFile(tid, "Default", item);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static void Test3(string folderName)
        {
            //Create the manager object
            using (var service = new SystemConnection())
            {
                //Get/create tenant
                const string TenantName = "Test1";
                var          tenantId   = service.GetOrAddTenant(TenantName);

                //Encrypt all files in Notepad++ folder
                var allFiles = Directory.GetFiles(folderName, "*.*", SearchOption.AllDirectories);
                var timer    = Stopwatch.StartNew();
                var index    = 0;
                foreach (var file in allFiles)
                {
                    service.SaveFile(tenantId, Container, file);
                    index++;
                    Console.WriteLine(string.Format("Saved file {0} / {1}", index, allFiles.Length));
                }
                timer.Stop();
                Console.WriteLine(string.Format("Load {0} files in {1} ms", allFiles.Length, timer.ElapsedMilliseconds));

                //Wait for files to post process on server
                System.Threading.Thread.Sleep(2000);

                //Compare total count of disk vs storage
                var arr = service.GetFileList(tenantId, folderName);
                Debug.Assert(allFiles.Length == arr.Count);
            }
        }