public static IDataFlowConnection CreateDefaultConnection() { var repositoryClientFactory = new RepositoryClientFactory(); var jobManagerClientFactory = new JobManagerClientFactory(); return new DataFlowConnection( jobManagerClientFactory.CreateClient(JobManagerCallback), repositoryClientFactory.CreateClient()); }
public static IDataFlowConnection CreateConnection(string jobManagerConfigurationName, string repositoryConfigurationName) { var repositoryClientFactory = new RepositoryClientFactory(); var jobManagerClientFactory = new JobManagerClientFactory(); return new DataFlowConnection( jobManagerClientFactory.CreateClient(JobManagerCallback, jobManagerConfigurationName), repositoryClientFactory.CreateClient(repositoryConfigurationName)); }
static void Main() { while (true) { Console.Write("Enter file's size (MB): "); int size; if (!int.TryParse(Console.ReadLine(), out size)) return; using (var client = new RepositoryClientFactory().CreateClient()) { Console.WriteLine("Connecting..."); client.Open(); for (var i = 0; i < 1; i++) { Stream stream = null; using (stream) { string data; using (Perfomance.Trace("Generating data stream...").BindToConsole()) { data = GenerateRandomString(size * 1024 * 1024); stream = WriteString(data); } // Write Guid id; using (Perfomance.Trace("client.Upload").BindToConsole()) { id = client.UploadNew("test", stream); } // Read all var link = new FileLink { Id = id }; Stream download; using (Perfomance.Trace("client.Download").BindToConsole()) { download = client.Download(link.Id); } var readString = ReadString(download); Console.WriteLine(readString == data ? "Pass" : "Fail"); } } } } }
private void CreateButton_Click(object sender, RoutedEventArgs _) { try { using (var client = new RepositoryClientFactory().CreateClient()) { client.Open(); for (var i = 0; i < 5; i++) { var data = GenerateRandomString(16 * 1024 * 1024); // Create var id = client.CreateNew("testFile"); var link = new FileLink { Id = id }; // Write using (var stream = WriteString(data)) { Action<string, long> onCompleted = (msg, ms) => MessageBox.Show(string.Format("{0} in {1} ms", msg, ms)); using (Perfomance.Trace("client.Upload").BindToCallback(onCompleted)) { client.Upload(link.Id, stream); } // Read all Stream download; using (Perfomance.Trace("client.Download").BindToCallback(onCompleted)) { download = client.Download(link.Id); } MessageBox.Show(ReadString(download) == data ? "Pass" : "Fail", "All file"); } } } } catch (WebException e) { var data = e.Response.GetResponseStream().ReadToBuffer(); var str = Encoding.Default.GetString(data); MessageBox.Show(str); ErrorView.Show(e); } }
private void LoadPage(int page, int pageNumber) { IEnumerable<FileInfo> files = null; this.Asynch(() => { using (var client = new RepositoryClientFactory().CreateClient()) { client.Open(); files = client.Browse(page * pageNumber, page).Select(x => new FileInfo { Id = x.Id, Name = x.Name }); client.Close(); } }, ShowWait, HideWait, () => { filesListView.ItemsSource = files; }); }
private static void ExecuteJob(Japi.Job job) { var stagesProvider = new StagesProvider(); var repositoryClientFactory = new RepositoryClientFactory(); var jobManagerClientFactory = new JobManagerClientFactory(); using(var repository = repositoryClientFactory.CreateClient()) { using(var jobManager = jobManagerClientFactory.CreateClient(new JobManagerCallback())) { foreach(var stage in stagesProvider.Stages) { Console.WriteLine(stage.Name + "..."); stage.Execute(job, Console.WriteLine, repository, jobManager); } } } }
private void DeleteFile_Executed(object sender, ExecutedRoutedEventArgs e) { var fileInfo = e.Parameter as FileInfo; if (MessageBox.Show( string.Format("Delete file {0} ({1})?", fileInfo.Name, fileInfo.Id), "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { this.Asynch(() => { var id = fileInfo.Id; using (var client = new RepositoryClientFactory().CreateClient()) { client.Open(); client.Delete(id); client.Close(); } }, ShowWait, HideWait); } }
public static void Main(string[] args) { var bufferSizes = Enumerable.Range(0, 16).Select(n => (int)Math.Pow(2, n + 10)); Console.WriteLine("Enter path to text file:"); var path = Console.ReadLine(); string text; using (var reader = File.OpenText(path)) { text = reader.ReadToEnd(); } using (var client = new RepositoryClientFactory().CreateClient()) { var stream = new MemoryStream(Encoding.Default.GetBytes(text)); var id = client.UploadNew("text_upload_test", stream); foreach (var bufferSize in bufferSizes) { var readenText = ReadFile(client, id, bufferSize); if(!text.Equals(readenText)) Console.WriteLine("Failed."); } } }