Ejemplo n.º 1
0
        public async Task <ActionResult <ConnectionSet> > GetShares()
        {
            ConnectionSet connectionSet = new ConnectionSet();

            try
            {
                var profile    = _profileStorage.Current;
                var connection = _connectionFinder.GetPrimaryLITEConnection(profile);
                var dirs       = Directory.GetDirectories(connection.resourcePath + Path.DirectorySeparatorChar + connection.name);

                foreach (var dir in dirs)
                {
                    ShareDestinations dest = new ShareDestinations
                    {
                        boxUuid = dir.Replace(profile.tempPath + Path.DirectorySeparatorChar + connection.name + Path.DirectorySeparatorChar, "")
                    };
                    connectionSet.shareDestinations.Add(dest);
                    connectionSet.connectionName = connection.ServicePoint;
                }
            }
            catch (DirectoryNotFoundException)
            {
            }

            return(connectionSet);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Delete(string boxUuid, string fileID)
        {
            var profile    = _profileStorage.Current;
            var connection = _connectionFinder.GetPrimaryLITEConnection(profile);
            var path       = connection.resourcePath + Path.DirectorySeparatorChar + connection.name + Path.DirectorySeparatorChar + boxUuid + Path.DirectorySeparatorChar + fileID;

            System.IO.File.Delete(path);
            //using (new FileStream(path, FileMode.Truncate, FileAccess.ReadWrite, FileShare.Delete, 1, FileOptions.DeleteOnClose | FileOptions.Asynchronous)) {};
            return(NoContent());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create()
        {
            try
            {
                MemoryStream stream = new MemoryStream();
                await HttpContext.Request.Body.CopyToAsync(stream);

                stream.Position = 0;
                StreamReader reader      = new StreamReader(stream);
                string       profilejson = reader.ReadToEnd();
                Profile      profile     = _profileJsonHelper.DeserializeObject(profilejson);
                var          connection  = _connectionFinder.GetPrimaryLITEConnection(profile);
                var          manager     = _connectionManagerFactory.GetManager(connection) as ILiteConnectionManager;
                await manager.RegisterLITE(profile);

                return(CreatedAtRoute("GetLITE", new { username = _connectionFinder.GetPrimaryLifeImageConnection(profile).username }, profile));
                //return CreatedAtRoute("GetFile", new { boxUuid = paths[0], fileID = paths[0] }, paths);
            }
            catch (TaskCanceledException)
            {
                _logger.LogInformation($"Task was canceled.");
                return(StatusCode(503));
            }
            catch (Exception e)
            {
                _logger.LogCritical($"{e.Message} {e.StackTrace}");
                return(StatusCode(503));
            }
        }