private void SendFileList(TCPProtocol protocol, ListFilesRequest request)
        {
            var response = new ListFilesResponse();

            try
            {
                response.Cmd    = CommandEnum.ListFiles;
                response.Result = TransferResponseEnum.OK;

                StringBuilder sb = new StringBuilder();

                foreach (var file in ServerData.Instance.FileList)
                {
                    sb.Append(file);
                    sb.Append(",");
                }

                response.Data       = sb.ToString();
                response.FileLength = sb.Length;

                //Envio respuesta
                protocol.SendMessage(response);
            }
            catch (Exception ex)
            {
                response.Result = TransferResponseEnum.ConnectionError;

                protocol.SendMessage(response);
            }
        }
示例#2
0
        public void SyncServers()
        {
            var protocol = new TCPProtocol();

            try
            {
                var request = new ListFilesRequest();

                //Me conecto al servidor de archivos
                protocol.ConnectClient(ClientData.Instance.ServerIP, ClientData.Instance.ServerPort);

                SendRemotingConnectionRequest();

                //Reutilizo este mensaje, cambiandole el CMD
                request.Cmd = CommandEnum.Backup;
                //Envio pedido
                var response = request.ListFiles(protocol);
            }
            catch
            {
                CurrentStatus = "Ocurrio un error.";
            }
            finally
            {
                protocol.Disconnect();
                SendRemotingDisconnectionRequest();
            }
        }
示例#3
0
        public List <string> ListFiles()
        {
            var protocol = new TCPProtocol();

            try
            {
                var request = new ListFilesRequest();

                //Me conecto al servidor de archivos
                protocol.ConnectClient(ClientData.Instance.ServerIP, ClientData.Instance.ServerPort);

                SendRemotingConnectionRequest();

                //Envio pedido y obtengo respuesta
                var response = request.ListFiles(protocol);


                List <string> fileList = response.Data.Split(',').ToList();
                fileList.Remove(fileList.Last());
                CurrentStatus = "Listado recibido con exito.";
                return(fileList);
            }
            catch (Exception e)
            {
                CurrentStatus = "Ocurrio un error desconocido.";
                return(new List <string>());
            }
            finally
            {
                protocol.Disconnect();
                SendRemotingDisconnectionRequest();
            }
        }
示例#4
0
        public async Task <ActionResult <IEnumerable <File> > > ListFiles()
        {
            var assetClient = _mindSphereSdkService.GetAssetManagementClient();
            var request     = new ListFilesRequest()
            {
                Size = 100
            };
            var files = (await assetClient.ListFilesAsync(request)).ToList();

            return(StatusCode(200, files));
        }
        private void SyncFiles(TCPProtocol protocol, ListFilesRequest request)
        {
            int pos = 0;

            foreach (var serverIP in ServerData.Instance.ServersIPs)
            {
                //Envio pedido y obtengo respuesta
                var port = ServerData.Instance.ServersPorts[pos];

                //Me conecto al servidor "serverIP"
                protocol.ConnectClient(serverIP, port);
                var response = request.ListFiles(protocol);


                List <string> fileList = response.Data.Split(',').ToList();
                fileList.Remove(fileList.Last());


                foreach (var file in fileList)
                {
                    if (!ServerData.Instance.FileList.Contains(file))
                    {
                        //El archivo no existe, pido para descargarlo
                        var downloadRequest = new DownloadRequest();
                        downloadRequest.FileName = file;
                        downloadRequest.Rest     = 0;

                        var downloadResponse = downloadRequest.DownloadFile(protocol, ServerData.Instance.FileRepository);

                        if (downloadResponse.Result == TransferResponseEnum.OK)
                        {
                            Console.WriteLine("Archivo descargado con exito");
                            ServerData.Instance.FileList.Add(file);
                        }
                    }
                }
                pos++;
            }
        }
示例#6
0
 /// <summary>
 /// List files and their properties
 /// </summary>
 public async Task <ListFilesResponse> ListFiles(ListFilesRequest request)
 {
     return(await _apiClient.ExecuteGetWithResponseAsync <ListFilesResponse>($"files/list", request));
 }