/*
         * // GET: api/Mattermost
         * public IEnumerable<string> Get()
         * {
         *  return new string[] { "value1", "value2" };
         * }
         */

        /*
         * // GET: api/Mattermost/5
         * public string Get(int id)
         * {
         *  return "value";
         * }
         */

        // POST: api/Mattermost
        public MattermostReturnPayload PostData(System.Net.Http.Formatting.FormDataCollection formData)
        {
            string Command = "";

            if (formData != null)
            {
                Command = formData.Get("command");
            }

            MattermostReturnPayload response = new MattermostReturnPayload();

            if (!String.IsNullOrEmpty(Command) && Command.Contains("sample"))
            {
                response.text = "| Component  | Tests Run   | Tests Failed                                   |\n" +
                                "|:-----------|:------------|:-----------------------------------------------|\n" +
                                "| Server     | 948         | :white_check_mark: 0                           |\n" +
                                "| Web Client | 123         | :warning: [2(see details)]                     |\n" +
                                "| iOS Client | 78          | :warning: [3(see details)](http://linktologs)  |\n";
            }
            else if (!String.IsNullOrEmpty(Command) && Command.Contains("ean"))
            {
                string TargetEan = "";
                string UserName  = "";

                if (formData != null)
                {
                    TargetEan = formData.Get("text");
                    UserName  = formData.Get("user_name");
                }

                // Default Value
                response.text = "| Ean              | Price      | Title \n" +
                                "|:-----------------|:-----------|:----------------\n" +
                                "| N/A              | N/A        | No Ean provided \n";

                if (!String.IsNullOrEmpty(TargetEan))
                {
                    string Title = "";
                    string Price = "";

                    // Title = getTitle(TargetEan);
                    // Price = getPrice(TargetEan);

                    response.text = "| Ean              | Price      | Title \n" +
                                    "|:-----------------|:-----------|:-----------n" +
                                    "| " + TargetEan.PadLeft(13, '0') + "   | "
                                    + Price + "     | "
                                    + Title + "\n";

                    System.Console.WriteLine("DEBUG: User(" + UserName + ") requested to see the data for EAN(" + TargetEan + ").");
                }
            }

            // MORE SAMPLE CODE WILL BE WRITTEN HERE

            return(response);
        }
Esempio n. 2
0
        public HttpResponseMessage CreateMenu(System.Net.Http.Formatting.FormDataCollection form)
        {
            HttpResponseMessage msg = new HttpResponseMessage(HttpStatusCode.OK);

            try
            {
                string json   = form.Get("menu");
                string token  = GetAccessToken(sAppID);
                string apiUri = string.Format("https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}", token);

                HttpClient    client      = new HttpClient();
                string        requestJson = json;
                StringContent content     = new StringContent(requestJson, Encoding.UTF8);
                var           response    = client.PostAsync(apiUri, content);
                string        tickJson    = response.Result.Content.ReadAsStringAsync().Result;


                msg.Content = new StringContent(tickJson, System.Text.Encoding.UTF8, "text/html");
            }
            catch (Exception ex)
            {
                msg.Content = new StringContent(ex.Message, System.Text.Encoding.UTF8, "text/html");
            }
            return(msg);
        }
Esempio n. 3
0
        public IHttpActionResult   PostAllTareas(System.Net.Http.Formatting.FormDataCollection formulario)

        {
            //is this condition true ? yes : no



            //chequea el null y el vacio

            var valorgrupoPrograma = formulario.Get("grupoPrograma") ?? "0";
            //var GrupoPrograma = Int32.Parse(formulario.Get("grupoPrograma")=="" ? "0": formulario.Get("grupoPrograma"));
            var GrupoPrograma = Int32.Parse(valorgrupoPrograma == "" ? "0" : valorgrupoPrograma);

            var valorprograma = formulario.Get("programa") ?? "0";
            var Programa      = Int32.Parse(valorprograma == "" ? "0" : valorprograma);


            var valoractor = formulario.Get("actor") ?? "";
            var Actor      = valoractor == "" ? "" : valoractor;

            var valorusuarioID = formulario.Get("usuarioID") ?? "0";
            var UsuarioId      = Int32.Parse(valorusuarioID == "" ? "0" : valorusuarioID);

            // var UsuarioId = Int32.Parse(formulario.Get("usuarioID") == "" ? "0" : formulario.Get("usuarioID"));

            var valorusuario = formulario.Get("usuario") ?? "";
            var Usuario      = valorusuario == "" ? "" : valorusuario;


            //  var Formato = Int32.Parse(formulario.Get("formato") == "" ? "0" : formulario.Get("formato"));
            var valorformato = formulario.Get("formato") ?? "0";
            var Formato      = Int32.Parse(valorformato == "" ? "0" : valorformato);



            CircuitosService s = new CircuitosService();

            //List<Tarea> tareas = s.GetTareas(id);
            // string id = value.id;



            datos = s.GetCircuitosDatos(GrupoPrograma, Programa, Actor, UsuarioId, Usuario, Formato, datos);

            //datos = s.GetCircuitosDatos(0, 0, "", 0, "", 0, datos);

            try
            {
                return(Ok(datos));
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
                return(Ok(datos));
            }
        }