static void Main(string[] args) { Console.Write("\n CoreConsoleClient"); Console.Write("\n ===================\n"); if (!parseCommandLine(args)) { return; } Console.Write("Press key to start: "); Console.ReadKey(); //string url = "https://localhost:44342/api/Files"; string url = args[0]; CoreConsoleClient client = new CoreConsoleClient(url); //Dispatcher disp = createDispatcher(client); showCommandLine(args); Console.Write("\n sending request to {0}\n", url); switch (args[1]) { case "/fl": Task <IEnumerable <string> > tfl = client.GetFileList(); //Task<HttpResponseMessage> t = disp[args[1]](param1, param2); var resultfl = tfl.Result; foreach (var item in resultfl) { Console.Write("\n {0}", item); } break; case "/up": Task <HttpResponseMessage> tup = client.SendFile(args[2]); Console.Write(tup.Result); break; case "/dn": int id = Int32.Parse(args[2]); Task <HttpResponseMessage> tdn = client.GetFile(id); Console.Write(tdn.Result); break; case "/dl": break; } Console.WriteLine("\n Press Key to exit: "); Console.ReadKey(); }
static void Main(string[] args) { Console.Write("\n CoreConsoleClient"); Console.Write("\n ===================\n"); if (!parseCommandLine(args)) { return; } Console.Write("Press key to start: "); Console.ReadKey(); string url = args[0]; CoreConsoleClient client = new CoreConsoleClient(url); showCommandLine(args); Console.Write("\n sending request to {0}\n", url); switch (args[1]) { case "/fl": Task <IEnumerable <Book> > tfl = client.GetBookList(); var resultfl = tfl.Result; foreach (var item in resultfl) { Console.Write("\n {0}", item); } break; case "/up": Task <HttpResponseMessage> tup = client.CreateBook(args[2]); Console.Write(tup.Result); break; case "/dn": int id = Int32.Parse(args[2]); Task <HttpResponseMessage> tdn = client.GetFile(id); Console.Write(tdn.Result); break; case "/dl": // ToDo break; } Console.WriteLine("\n Press Key to exit: "); Console.ReadKey(); }
static void Main(string[] args) { Console.Write("\n CoreConsoleClient"); Console.Write("\n ===================\n"); if (!parseCommandLine(args)) { return; } Console.Write("Press key to start: "); Console.ReadKey(); string url = args[0]; CoreConsoleClient client = new CoreConsoleClient(url); showCommandLine(args); Console.Write("\n sending request to {0}\n", url); switch (args[1]) { case "/fl": Task <IEnumerable <string> > tfl = client.GetFileList(); var resultfl = tfl.Result; foreach (var item in resultfl) { Console.Write("\n {0}", item); } break; case "/up": try { Task <HttpResponseMessage> tup = client.SendFile(args[2]); Console.Write(tup.Result); } catch (AggregateException ex) { Console.Write(ex + "No such file exists"); } break; case "/dn": try { int id = Int32.Parse(args[2]); Task <HttpResponseMessage> tdn = client.GetFile(id); var content = tdn.Result.Content; string x = tdn.Result.Content.Headers.ContentDisposition.FileNameStar; ToLocalSystem(content, x); Console.Write(tdn); } catch (Exception ex) { Console.WriteLine(ex + "An error occurred while downloading"); } break; } Console.WriteLine("\n Press Key to exit: "); Console.ReadKey(); }
static void Main(string[] args) { Console.Write("\n CoreConsoleClient"); Console.Write("\n ===================\n"); if (!parseCommandLine(args)) { return; } Console.Write("Press key to start: "); Console.ReadKey(); string url = args[0]; CoreConsoleClient client = new CoreConsoleClient(url); showCommandLine(args); Console.Write("\n sending request to {0}\n", url); switch (args[1]) { case "/fl": Task <IEnumerable <string> > tfl = client.GetFileList(); var resultfl = tfl.Result; foreach (var item in resultfl) { Console.Write("\n {0}", item); } break; case "/up": Task <HttpResponseMessage> tup = client.SendFile(args[2]); Console.Write(tup.Result); break; case "/dn": int id = Int32.Parse(args[2]); Task <HttpResponseMessage> tdn = client.GetFile(id); Console.Write(tdn.Result); break; case "/dl": int id0 = Int32.Parse(args[2]); Task <HttpResponseMessage> tdl = client.DeleteFile(id0); Console.Write(tdl.Result); break; case "/getStory": Task <IEnumerable <string> > stl = client.GetStory(); var resulstl = stl.Result; foreach (var item in resulstl) { Console.Write("\n {0}", item); } break; case "/getDetails": Task <IEnumerable <string> > sdt = client.GetStoryDetails(Int32.Parse(args[2])); var resulsdt = sdt.Result; foreach (var item in resulsdt) { Console.Write("\n {0}", item); } break; } Console.WriteLine("\n Press Key to exit: "); Console.ReadKey(); }
static void Main(string[] args) { Console.Write("\n CoreConsoleClient"); Console.Write("\n ===================\n"); if (!parseCommandLine(args)) { return; } Console.Write("Press key to start: "); Console.ReadKey(); string url = args[0]; CoreConsoleClient client = new CoreConsoleClient(url); showCommandLine(args); Console.Write("\n sending request to {0}\n", url); switch (args[1]) { case "/fl": Task <IEnumerable <string> > tfl = client.GetFileList(); var resultfl = tfl.Result; foreach (var item in resultfl) { Console.Write("\n {0}", item); } break; case "/up": Task <HttpResponseMessage> tup = client.SendFile(args[2]); Console.Write(tup.Result); break; case "/dn": string fileName = args[2]; List <string> fileListdl = new List <string>(); Task <IEnumerable <string> > tfldn = client.GetFileList(); var resultfldn = tfldn.Result; foreach (var item in resultfldn) { fileListdl.Add(item); } if (fileListdl.Contains(fileName)) { Task <HttpResponseMessage> tdn = client.GetFile(fileName); } else { Console.Write("File not found"); } break; case "/dl": string file = args[2]; List <string> fileList = new List <string>(); Task <IEnumerable <string> > tfldl = client.GetFileList(); var resultfldl = tfldl.Result; foreach (var item in resultfldl) { fileList.Add(item); } if (fileList.Contains(file)) { Task <HttpResponseMessage> tdl = client.DeleteFile(file); Console.Write(tdl.Result); if (tdl.Result.IsSuccessStatusCode) { Console.Write("File Deleted Successfully"); } } else { Console.Write("File not found"); } break; } Console.WriteLine("\n Press Key to exit: "); Console.ReadKey(); }