private void button1_Click(object sender, EventArgs e) { SharePointFtpService.SharePointFtpServiceClient client = new SharePointFtpService.SharePointFtpServiceClient(); try { OpenRequest request = new OpenRequest() { Url = textUrl.Text, Username = textUser.Text, Password = textPassword.Text }; OpenResponse result = client.Open(request); textOutput.Text += string.Format("SUCCESS. Web URL: {0}, Folder URL: {1}\n\r", result.WebUrl, result.FolderUrl); } catch (FaultException <InvalidUrlFault> fault) { textOutput.Text += string.Format("FAILURE. The URL {0} is not valid.", fault.Detail.Url); } catch (FaultException <Exception> fault) { textOutput.Text += string.Format("Unexpected Error: {0}.", fault.Detail.Message); } finally { if (client.State == System.ServiceModel.CommunicationState.Opened) { client.Close(); } } }
internal void Open(OpenResponse openResponse) { Id = openResponse.Sid; if (_pingToken == null) { _pingToken = new CancellationTokenSource(); } else { _pingToken.Cancel(); } Task.Factory.StartNew(async() => { await SendNamespaceAsync(); while (!_pingToken.IsCancellationRequested) { await Task.Delay(openResponse.PingInterval); try { PingTime = DateTime.Now; await Socket.SendMessageAsync("2"); OnPing?.Invoke(this, new EventArgs()); } catch { } } }, _pingToken.Token); }
/// <summary> </summary> JsonResult IDriver.Open(string target, bool tree, Hashtable posting_json_obj) { FullPath fullPath = ParsePath(target); OpenResponse answer = new OpenResponse(DTOBase.Create(fullPath.Directory, fullPath.Root), fullPath); foreach (var item in fullPath.Directory.GetFiles()) { if (HttpContext.Current.Request.Params.AllKeys.Contains("mimes[]")) { if (file_mime.mime_type(item.Extension.Trim('.')).IndexOf(HttpContext.Current.Request.Params["mimes[]"]) > -1) { answer.AddResponse(DTOBase.Create(item, fullPath.Root, posting_json_obj)); } } else { answer.AddResponse(DTOBase.Create(item, fullPath.Root, posting_json_obj)); } } foreach (var item in fullPath.Directory.GetDirectories()) { answer.AddResponse(DTOBase.Create(item, fullPath.Root)); } return(Json(answer)); }
public JsonResult Open(string target, bool tree) { if (string.IsNullOrEmpty(target)) { return(Init(target)); } var path = Helper.DecodePath(target).Trim(Path.DirectorySeparatorChar); if (string.IsNullOrEmpty(path)) { return(Init(target)); } var folder = mediaService.GetMediaFolder(path); var folders = mediaService.GetMediaFolders(path); var files = mediaService.GetMediaFiles(path); var response = new OpenResponse(CreateDto(folder, Path.GetDirectoryName(path))); foreach (var file in files) { response.AddResponse(CreateDto(file)); } foreach (var child in folders) { response.AddResponse(CreateDto(child, path)); } return(Json(response)); }
/// <summary> </summary> JsonResult IDriver.retrive_object(string target) { FullPath fullPath = ParsePath(target); OpenResponse answer = new OpenResponse(DTOBase.Create(fullPath.File.Directory, fullPath.Root), fullPath); answer.AddResponse(DTOBase.Create(fullPath.File, fullPath.Root)); return(Json(answer)); }
public void TestOpenResponse() { var openResponse = new OpenResponse(); var command = openResponse.ToString(); var expected = "OPN000"; Assert.AreEqual(expected, command); }
public async Task <JsonResult> OpenAsync(FullPath path, bool tree, IEnumerable <string> mimeTypes) { var response = new OpenResponse(await BaseModel.CreateAsync(path.Directory, path.RootVolume), path); // Get all files and directories var items = await AzureStorageAPI.ListFilesAndDirectoriesAsync(path.Directory.FullName); // Add visible files foreach (var file in items.Where(i => i is CloudFile)) { var f = new AzureStorageFile(file as CloudFile); if (!f.Attributes.HasFlag(FileAttributes.Hidden)) { if (mimeTypes != null && mimeTypes.Count() > 0 && !mimeTypes.Contains(f.MimeType) && !mimeTypes.Contains(f.MimeType.Type)) { continue; } response.Files.Add(await BaseModel.CreateAsync(f, path.RootVolume)); } } // Add visible directories foreach (var dir in items.Where(i => i is CloudFileDirectory)) { var d = new AzureStorageDirectory(dir as CloudFileDirectory); if (!d.Attributes.HasFlag(FileAttributes.Hidden)) { response.Files.Add(await BaseModel.CreateAsync(d, path.RootVolume)); } } // Add parents if (tree) { var parent = path.Directory; while (parent != null && parent.FullName != path.RootVolume.RootDirectory) { // Update parent parent = parent.Parent; // Ensure it's a child of the root if (parent != null && path.RootVolume.RootDirectory.Contains(parent.FullName)) { response.Files.Insert(0, await BaseModel.CreateAsync(parent, path.RootVolume)); } } } return(await Json(response)); }
public void Unpack(SocketIO client, string text) { if (text.StartsWith("{\"sid\":\"")) { var openResponse = new OpenResponse(); var doc = JsonDocument.Parse(text); var root = doc.RootElement; openResponse.Sid = root.GetProperty("sid").GetString(); openResponse.PingInterval = root.GetProperty("pingInterval").GetInt32(); openResponse.PingTimeout = root.GetProperty("pingTimeout").GetInt32(); client.Open(openResponse); } }
public void TestMpackOpenResponseWriteRead() { // Arrange var response = Message.Create(null, null, null, OpenResponse.Create()); var stream = new MemoryStream(); // Act response.Encode(stream, CodecId.Mpack); byte[] buf = Interop.MessageDecodeEncode(CodecId.Mpack, 1, stream.GetBuffer(), stream.Length, buffer, buffer.Length); var returned = Serializable.Decode <Message>(new MemoryStream(buf), CodecId.Mpack); // Assert Assert.IsTrue(response.Equals(returned)); }
JsonResult IDriver.Open(string target, bool tree) { FullPath fullPath = ParsePath(target); OpenResponse answer = new OpenResponse(DTOBase.Create(fullPath.Directory, fullPath.Root), fullPath); foreach (var item in fullPath.Directory.GetFiles()) { answer.AddResponse(DTOBase.Create(item, fullPath.Root)); } foreach (var item in fullPath.Directory.GetDirectories()) { answer.AddResponse(DTOBase.Create(item, fullPath.Root)); } return(Json(answer)); }
JsonResult IDriver.Open(string target, bool tree) { var fullPath = ParsePath(target); var answer = new OpenResponse(DTOBase.Create(fullPath.Directory, fullPath.Root), fullPath); if (fullPath.Directory.Parent == null) { // volume var volume = ResourceManager.Instance.GetOrAddVolumeFolder(_project, fullPath.Directory.TypesOfResource); if (volume != null) { var folders = ResourceManager.Instance.GetFolders(fullPath.Directory); foreach (var item in folders.Where(item => item.CanRead())) { answer.Files.Add(DTOBase.Create(item, fullPath.Root)); } // if volume does not exists we treat it as empty var files = ResourceManager.Instance.GetFiles(fullPath.Directory); foreach (var item in files.Where(item => item.CanRead())) { answer.Files.Add(DTOBase.Create(item, fullPath.Root)); } } } else { var folders = ResourceManager.Instance.GetFolders(fullPath.Directory); foreach (var item in folders.Where(item => item.CanRead())) { answer.Files.Add(DTOBase.Create(item, fullPath.Root)); } var files = ResourceManager.Instance.GetFiles(fullPath.Directory); foreach (var item in files) { //sfullPath.Root.Directory = fullPath.Directory; if (item.CanRead()) { answer.Files.Add(DTOBase.Create(item, fullPath.Root)); } } } return(Json(answer)); }
JsonResult IDriver.Open(string target, bool tree) { FullPath fullPath = ParsePath(target); OpenResponse answer = new OpenResponse(DTOBase.Create(fullPath.Directory, fullPath.Root), fullPath); foreach (FileInfo item in fullPath.Directory.GetFiles()) { if ((item.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) { answer.Files.Add(DTOBase.Create(item, fullPath.Root)); } } foreach (DirectoryInfo item in fullPath.Directory.GetDirectories()) { if ((item.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) { answer.Files.Add(DTOBase.Create(item, fullPath.Root)); } } return(Json(answer)); }
public async Task <JsonResult> OpenAsync(FullPath path, bool tree, IEnumerable <string> mimeTypes) { var response = new OpenResponse(await BaseModel.CreateAsync(path.Directory, path.RootVolume), path); foreach (var item in await path.Directory.GetFilesAsync(mimeTypes)) { if (!item.Attributes.HasFlag(FileAttributes.Hidden)) { response.Files.Add(await BaseModel.CreateAsync(item, path.RootVolume)); } } foreach (var item in await path.Directory.GetDirectoriesAsync()) { if (!item.Attributes.HasFlag(FileAttributes.Hidden)) { response.Files.Add(await BaseModel.CreateAsync(item, path.RootVolume)); } } // Add parents if (tree) { var parent = path.Directory; var rootDirectory = new DirectoryInfo(path.RootVolume.RootDirectory); while (parent != null && parent.Name != rootDirectory.Name) { // Update parent parent = parent.Parent; // Ensure it's a child of the root if (parent != null && path.RootVolume.RootDirectory.Contains(parent.Name)) { response.Files.Insert(0, await BaseModel.CreateAsync(parent, path.RootVolume)); } } } return(await Json(response)); }
public override async Task <Message> ReadAsync(Reader reader, SerializerContext context, CancellationToken ct) { var message = Message.Get(); var members = await reader.ReadObjectHeaderAsync(ct).ConfigureAwait(false); if (members != 9) { throw new FormatException($"Unexpected number of properties {members}"); } message.Version = await reader.ReadUInt32Async(ct).ConfigureAwait(false); if ((message.Version >> 16) != (VersionEx.Assembly.ToUInt() >> 16)) { throw new FormatException($"Bad message version {message.Version}"); } message.Source = await context.Get <Reference>().ReadAsync( reader, context, ct).ConfigureAwait(false); message.Proxy = await context.Get <Reference>().ReadAsync( reader, context, ct).ConfigureAwait(false); message.Target = await context.Get <Reference>().ReadAsync( reader, context, ct).ConfigureAwait(false); message.SequenceId = await reader.ReadUInt32Async(ct).ConfigureAwait(false); message.Error = await reader.ReadInt32Async(ct).ConfigureAwait(false); message.IsResponse = await reader.ReadBoolAsync(ct).ConfigureAwait(false); message.TypeId = await reader.ReadUInt32Async(ct).ConfigureAwait(false); if (message.IsResponse) { /**/ if (message.TypeId == MessageContent.Data) { message.Content = await context.Get <DataMessage>().ReadAsync( reader, context, ct).ConfigureAwait(false); } else if (message.TypeId == MessageContent.Ping) { message.Content = await context.Get <PingResponse>().ReadAsync( reader, context, ct).ConfigureAwait(false); } else if (message.TypeId == MessageContent.Link) { message.Content = await context.Get <LinkResponse>().ReadAsync( reader, context, ct).ConfigureAwait(false); } else if (message.TypeId == MessageContent.GetOpt) { message.Content = await context.Get <GetOptResponse>().ReadAsync( reader, context, ct).ConfigureAwait(false); } else if (message.TypeId == MessageContent.Close) { message.Content = await context.Get <CloseResponse>().ReadAsync( reader, context, ct).ConfigureAwait(false); } else { await reader.ReadAsync(ct).ConfigureAwait(false); /**/ if (message.TypeId == MessageContent.Open) { message.Content = OpenResponse.Create(); } else if (message.TypeId == MessageContent.SetOpt) { message.Content = SetOptResponse.Create(); } else if (message.TypeId == MessageContent.Poll) { message.Content = PollResponse.Create(); } else { message.Content = null; } } }
public async Task <JsonResult> OpenAsync(FullPath path, bool tree, IEnumerable <string> mimeTypes) { // todo: BaseModel.CreateAsync internally calls GetDirectoriesAsync() which calls AzureBlobStorageApi.ListFilesAndDirectoriesAsync // todo: AzureBlobStorageApi.ListFilesAndDirectoriesAsync is then called again here few lines below; // todo: we should be able to reduce it to one single call var response = new OpenResponse(await BaseModel.CreateAsync(path.Directory, path.RootVolume), path); // Get all files and directories var items = AzureBlobStorageApi.ListFilesAndDirectoriesAsync(path.Directory.FullName); var itemList = items.ToList(); var mimeTypesList = mimeTypes.ToList(); // Add visible files foreach (var file in itemList.Where(i => !i.Name.EndsWith("/"))) { var f = new AzureBlobFile(file); if (f.Attributes.HasFlag(FileAttributes.Hidden)) { continue; } if (mimeTypesList.Any() && !mimeTypesList.Contains(f.MimeType) && !mimeTypesList.Contains(f.MimeType.Type)) { continue; } response.Files.Add(await CustomBaseModel.CustomCreateAsync(f, path.RootVolume)); } // Add visible directories foreach (var dir in itemList.Where(i => i.Name.EndsWith("/"))) { var d = new AzureBlobDirectory(dir); if (!d.Attributes.HasFlag(FileAttributes.Hidden)) { response.Files.Add(await BaseModel.CreateAsync(d, path.RootVolume)); } } // Add parents if (!tree) { return(await Json(response)); } var parent = path.Directory; while (parent != null && parent.FullName != path.RootVolume.RootDirectory) { // Update parent parent = parent.Parent; // Ensure it's a child of the root if (parent != null && path.RootVolume.RootDirectory.Contains(parent.FullName)) { response.Files.Insert(0, await BaseModel.CreateAsync(parent, path.RootVolume)); } } return(await Json(response)); }