static void Main(string[] args) { HttpChannel channel = new HttpChannel(); ChannelServices.RegisterChannel(channel, false); GeneralRemoteClass remote = (GeneralRemoteClass)Activator.GetObject( typeof(GeneralRemoteClass), "http://localhost:32121/OurFirstSoapProject.soap"); remote.SendToSraver("Привет"); Console.WriteLine(remote.ReplyFromSraver()); Console.ReadLine(); }
static void Main(string[] args) { var ps = System.Diagnostics.Process.GetProcesses(); System.Diagnostics.Process proc = null; var q = from p in ps where p.ProcessName.ToLower() == CLIENT_APP_NAME select p; if (q != null) { proc = q.First(); } proc.EnableRaisingEvents = true; proc.Exited += Proc_Exited; var param = args[0].Split(new string[] { "\\//" }, StringSplitOptions.RemoveEmptyEntries); //Console.Write("Connecting to server... "); TcpChannel tcpChannel = new TcpChannel(); ChannelServices.RegisterChannel(tcpChannel, false); try { remote = (GeneralRemoteClass)Activator.GetObject( typeof(GeneralRemoteClass), String.Format("tcp://{0}:{1}/{2}", param[0], param[1], param[2])); host = System.Net.Dns.GetHostName(); } catch (Exception e) { Console.WriteLine(e.Message); Application.Exit(); return; } Application.Run(); }
static GeneralRemote.Task task, model = null; // Написал с именем пространства имён, т. к. неоднозначная ссылка (конфликт с Threading, плохо!) public static void Main(string[] args) { Console.Write("Чтение параметров... "); Init(); Console.WriteLine("Готово"); try { Process p = Process.Start("ClientMonitor.exe", String.Join("\\//", ClientSettings.Address, ClientSettings.Port.ToString(), ClientSettings.RemName)); } catch { Console.WriteLine("Не удалось запустить монитор процесса. Выполнение будет продолжено..."); } // Подключение к серверу с спользованием GeneralRemote Console.Write("Подключение к серверу... "); TcpChannel tcpChannel = new TcpChannel(); ChannelServices.RegisterChannel(tcpChannel, false); try { remote = (GeneralRemoteClass)Activator.GetObject( typeof(GeneralRemoteClass), String.Format("tcp://{0}:{1}/{2}", ClientSettings.Address, ClientSettings.Port, ClientSettings.RemName)); host = System.Net.Dns.GetHostName(); remote.SendToServer(host + " подключён"); Console.WriteLine("Готово"); } catch { Console.WriteLine("Не удалось подключиться к серверу"); return; } // Задаём погрешности if (!remote.IsEpsilonsSet) { Coord.Epsilon = remote.GetCoordEpsilon(); Delta.Epsilon = remote.GetDeltaEpsilon(); } // Получение задания с сервера Console.Write("Получение задания... "); try { task = remote.GetTaskFromServer(out ClientSettings.PUNumber); // "Побочный эффект" - возврат номера ПЕ model = remote.GetModelFromServer(); } catch { Console.WriteLine("Не удалось получить задание: очередь заданий пуста"); return; } GetTaskFile(task.GetTask().Item1, ClientSettings.InputFile1); GetTaskFile(task.GetTask().Item2, ClientSettings.InputFile2); GetTaskFile(model.GetTask().Item1, ClientSettings.GeneralInputFile1); GetTaskFile(model.GetTask().Item2, ClientSettings.GeneralInputFile2); Console.WriteLine("Готово"); Parallel.Invoke( () => { CoordsPU = Parser.ParseCoords(ClientSettings.InputFile1); remote.AddNodesForReport(CoordsPU.Count); // Кол-во узлов для отчёта Console.WriteLine("Координаты узлов ПЕ считаны"); }, () => { DeltasPU = Parser.ParseDeltas(ClientSettings.InputFile2); Console.WriteLine("Перемещения в узлах ПЕ считаны"); }, () => { CoordsMain = Parser.ParseCoords(ClientSettings.GeneralInputFile1); Console.WriteLine("Координаты узлов модели считаны"); }, () => { DeltasMain = Parser.ParseDeltas(ClientSettings.GeneralInputFile2); Console.WriteLine("Перемещения в узлах модели считаны"); }); Console.WriteLine("Готово"); Console.Write("Проверка... "); Check(); Console.WriteLine("Готово"); try { remote.SendToServer($"{host} закончил"); remote.Send(WrongNodes); } catch { Console.WriteLine("Сервер оборвал связь с клиентскими приложениями, выполнение задачи завершено"); return; } Console.Read(); }