예제 #1
0
 protected override AISTek.DataFlow.Shared.Classes.FileLink SaveFilePerform(AISTek.DataFlow.Shared.Classes.IRepository repository)
 {
     var buffer = Encoding.UTF8.GetBytes(Path);
     var id = repository.UploadNew(Name, new MemoryStream(buffer));
     var link = new FileLink { Id = id, Name = Name, Metadata = Metadata };
     return link;
 }
예제 #2
0
 public override FileLink SaveFile(IRepository repository)
 {
     var id = repository.CreateNew(Name);
     var link = new FileLink { Id = id };
     Link = link;
     return link;
 }
예제 #3
0
 protected override FileLink SaveFilePerform(IRepository repository)
 {
     using (var stream = new FileStream(Path, FileMode.Open))
     {
         var id = repository.UploadNew(Name, stream);
         var link = new FileLink { Id = id, Name = Name, Metadata = Metadata };
         return link;
     }
 }
예제 #4
0
 public override FileLink SaveFile(IRepository repository)
 {
     using (var stream = new FileStream(Path, FileMode.Open))
     {
         var id = repository.UploadNew(Name, stream);
         var link = new FileLink { Id = id, Name = Name };
         Link = link;
         return link;
     }
 }
예제 #5
0
파일: Map.cs 프로젝트: kapitanov/diploma
        private string ReadFile(FileLink l)
        {
            Func<FileLink, string> readPath = (link) =>
            {
                using (Perfomance.Trace(traceMessage + ": Read input file").BindToConsole())
                    using (var reader = new StreamReader(Repository.Download(link.Id), Encoding.UTF8, false, 4096))
                        return reader.ReadToEnd();
            };

            return System.IO.File.ReadAllText(readPath(l));
        }
예제 #6
0
 private string ReadFile(FileLink link)
 {
     using (Perfomance.Trace(traceMessage + ": Read input file").BindToConsole())
     {
         using (var reader = new StreamReader(Repository.Download(link.Id) ,Encoding.Default, false, 4096))
         {
             var text = reader.ReadToEnd();
             return text;
         }
     }
 }
예제 #7
0
        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");
                        }
                    }
                }
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
 protected override FileLink SaveFilePerform(IRepository repository)
 {
     var id = repository.CreateNew(Name);
     var link = new FileLink { Id = id, Metadata = Metadata };
     return link;
 }
예제 #10
0
 /// <summary>
 /// Converts object of data transfer class <see cref="FileLink"/> 
 /// into an instance of class <see cref="DataModel.FileLink"/>.
 /// </summary>
 /// <param name="link">
 /// An object to convert.
 /// </param>
 /// <returns>
 /// An instance of <see cref="DataModel.FileLink"/> that corresponds value of <paramref name="link"/>
 /// </returns>
 public DataModel.FileLink FromContract(FileLink link)
 {
     return new DataModel.FileLink(link.Id, link.Name, link.Metadata);
 }
예제 #11
0
파일: File.cs 프로젝트: kapitanov/diploma
 /// <summary>
 /// Initializes new instance of <see cref="File"/>.
 /// </summary>
 /// <param name="link">
 /// An instance of <see cref="FileLink"/> class that contains file's reference.
 /// </param>
 public File(FileLink link)
 {
     Id = link.Id;
     Name = link.Name;
 }