public void Run()
        {
            // base storage folder
            string folder = CommonSettings.StorageDataFolder;
            // setup source folder path to copy
            string srcFolder = "Folder1";
            // setup source storage name; null if default storage
            string srcStorage = null;
            // setup target folder path
            string destFolder = "CopyFolder1";
            // setup target storage name; null if default storage
            string destStorage = null;

            var srcPath  = Path.Combine(folder, srcFolder).Replace('\\', '/');
            var destPath = Path.Combine(folder, destFolder).Replace('\\', '/');

            IStorageFolderApi fApi = new StorageApi(CommonSettings.ClientId, CommonSettings.ClientSecret, CommonSettings.BasePath);
            var response           = fApi.CopyFolder(srcPath, destPath, srcStorage, destStorage);

            if (response.Code == 200)
            {
                Console.Out.WriteLine($"Folder {srcPath} copied to {destPath}");
                IStorageApi stApi  = (IStorageApi)fApi;
                bool        exists = stApi.FileOrFolderExists(destPath);
                Console.Out.WriteLine($"New folder {destPath} exists: {exists}");
            }
        }
Exemplo n.º 2
0
        public void Run()
        {
            // setup the file name to copy
            string name = "testpage1.html";
            // setup the folder where is the file to copy
            string srcFolder = "/Html/TestData";
            // setup the folder where the file will be copied to
            string destFolder = "/Html/Testout";
            // setup the file name the source file will be copied to
            string newName = "testpage1_copy.html";
            // setup storage name (default storage if null, source and target storages may be different)
            string storage = null;
            // setup file version to copy (the latest version if null)
            string versionId = null;

            var srcPath  = Path.Combine(srcFolder, name).Replace('\\', '/');
            var destPath = Path.Combine(destFolder, newName ?? name).Replace('\\', '/');

            IStorageFileApi fileApi  = new StorageApi(CommonSettings.ClientId, CommonSettings.ClientSecret, CommonSettings.BasePath);
            var             response = fileApi.MoveFile(srcPath, destPath, storage, storage, versionId);

            if (response.Code == 200)
            {
                Console.Out.WriteLine($"File {srcPath} copied to {destPath}");
                IStorageApi stApi  = (IStorageApi)fileApi;
                bool        exists = stApi.FileOrFolderExists(destPath);
                Console.Out.WriteLine($"New file {destPath} exists: {exists}");
            }
        }
Exemplo n.º 3
0
        public StorageService(StorageType storageType)
        {
            switch (storageType)
            {
            case StorageType.PlayerPrefs:
                StorageInstance = PlayerPrefsStorage.GetInstance();
                Api             = new PlayerPrefsApi();
                break;

            case StorageType.FileStorage:
                StorageInstance = FileStorageStorage.GetInstance();
                Api             = new FileStorageApi();
                break;

            case StorageType.InMemory:
                StorageInstance = InMemoryStorage.GetInstance();
                Api             = new InMemoryStorageApi();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(storageType), storageType, null);
            }

            OnChangeValue += StorageInstance.OnKeyValueUpdated;
        }
 private void CheckIfFolderExistsAndCreate(IStorageApi api, string folderPath, string storage)
 {
     if (!api.FileOrFolderExists(folderPath, storage))
     {
         IStorageFolderApi fApi = (IStorageFolderApi)api;
         fApi.CreateFolder(folderPath, storage);
     }
 }
Exemplo n.º 5
0
 protected DialogItem(IStorageApi storageApi,ILogger logger,UserMeta user)
 {
     _storageApi = storageApi;
     isProcessed = false;
     _logger = logger;
     itemId=Guid.NewGuid();
     lastImpactTime=DateTime.Now;
     storageUserId = user.StorageUserId;
 }
        public void Run()
        {
            string folder = CommonSettings.StorageDataFolder;
            // setup folder path to create
            string newFolder = Path.Combine(folder, "NewFolder").Replace('\\', '/');;
            // setup storage name (your default storage if null)
            string storage = null;

            IStorageFolderApi api = new StorageApi(CommonSettings.ClientId, CommonSettings.ClientSecret, CommonSettings.BasePath);
            var response          = api.CreateFolder(newFolder, storage);

            if (response.Code == 200)
            {
                IStorageApi stApi = (IStorageApi)api;
                stApi.FileOrFolderExists(newFolder, storage);
                Console.Write($"Folder {newFolder} successfully created");
            }
        }
Exemplo n.º 7
0
        public void Run()
        {
            // setup a file to upload
            string name = "testpage3_embcss.html";
            // setup a local file system directory where is the source file
            string srcLocalDir = CommonSettings.LocalDataFolder;
            // setup a folder path where the file will be uploaded
            string folder = CommonSettings.StorageDataFolder;
            // setup storage name (your default storage if null)
            string storage = null;

            string suffix  = "new";
            var    newName = $"{Path.GetFileNameWithoutExtension(name)}_{suffix}{Path.GetExtension(name)}";
            var    srcPath = Path.Combine(srcLocalDir, name);
            var    dstPath = Path.Combine(folder, newName).Replace('\\', '/');

            IStorageFileApi fApi  = new StorageApi(CommonSettings.ClientId, CommonSettings.ClientSecret, CommonSettings.BasePath);
            IStorageApi     stApi = (IStorageApi)fApi;

            CheckIfFolderExistsAndCreate(stApi, folder, storage);

            using (Stream fstr = File.Open(srcPath, FileMode.Open, FileAccess.Read))
            {
                var response = fApi.UploadFile(fstr, dstPath, storage);
                if (response.Code == 200)
                {
                    bool exists = stApi.FileOrFolderExists(dstPath);
                    if (exists)
                    {
                        Console.WriteLine($"File uploaded by path: {dstPath}");
                    }
                    else
                    {
                        Console.WriteLine($"Something went wrong: file not found by path {dstPath}");
                    }
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>C-tor</summary>
 public EmailJobClient(IRestClientFactory restClientFactory)
 {
     EmailsApi  = restClientFactory.Generate <IEmailsApi>();
     StorageApi = restClientFactory.Generate <IStorageApi>();
 }
Exemplo n.º 9
0
 public WhatIsDialogItem(IStorageApi storageApi, ILogger logger, UserMeta user) : base(storageApi, logger, user)
 {
     itemType = DialogItemType.CommandExecution;
 }
Exemplo n.º 10
0
 public CaloricManagmentItem(IStorageApi storageApi, ILogger logger, UserMeta user) : base(storageApi, logger, user)
 {
     itemType = DialogItemType.CaloricManagement;
     _possibleProducts = new Dictionary<Guid, ProductInfo>();
     _productWeight = 0;
 }
Exemplo n.º 11
0
 public EmojiMatchFunctionAnalyseFace(IFaceApi faceApi, IStorageApi storageApi)
 {
     _faceApi    = faceApi;
     _storageApi = storageApi;
 }
Exemplo n.º 12
0
 public DialogItemFactory(IStorageApi storageApi, ILogger logger, UserMeta user)
 {
     _storageApi = storageApi;
     _logger = logger;
     _user = user;
 }
Exemplo n.º 13
0
 private ChatOperator()
 {
     OperatorID = Guid.NewGuid();
     _chatHistory = new List<IDialogItem>();
     _storageApi = new StorageApi();
 }
Exemplo n.º 14
0
 public StorageApiWrapper(
     IStorageApi storageApi)
 {
     _storageApi = storageApi;
 }