Ejemplo n.º 1
0
        private static async void ExecuteAction(string act, string t, uint comp)
        {
            switch (act)
            {
            case Action.Create:
                for (var i = 1; i <= comp; ++i)
                {
                    Console.WriteLine("Executing action \"{0}\" of type \"{1}\", {2}", act,
                                      Path.GetFileName(t).Split('.')[0], i);
                    var wo = WorkOrder.FromJson(File.ReadAllText(t));
                    wo.idWorkOrder  = Guid.NewGuid().ToString();
                    wo.timeLaunched = DateTime.Now;

                    OpenedWorkOrders[wo.idWorkOrder] = wo;


                    var strwo = WorkOrder.ToJson(wo);

                    var m = new Message
                    {
                        action      = Message.NetworkAction.Forward,
                        source      = Message.ApprovedEndpoint.WorkOrderManager,
                        destination = Message.ApprovedEndpoint.BOMOrderManager,
                        content     = strwo
                    };
                    try
                    {
                        var response = await HttpClientLayer.getInstance().Post("http://127.0.0.1:8081/", m);

                        Console.WriteLine("Received response: {0}", response.content);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }

                break;

            case Action.Help:
                Console.WriteLine(help);
                break;

            default:
                Console.WriteLine(help);
                break;
            }
        }
 public static HttpClientLayer getInstance()
 {
     return(INSTANCE ?? (INSTANCE = new HttpClientLayer()));
 }