示例#1
0
        public static async Task <IActionResult> feedback([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log)
        {
            string ClientIP = req.HttpContext.Connection.RemoteIpAddress.ToString();

            string customerid = req.Query["customerid"];

            customerid = customerid ?? "";

            string name = req.Query["name"];

            name = name ?? "";
            string ver = req.Query["ver"];

            ver = ver ?? "";
            string man = req.Query["man"];

            man = man ?? "";

            string ok = req.Query["ok"];

            ok = ok ?? "";
            string user = req.Query["user"];

            user = user ?? "";
            string text = req.Query["text"];

            text = text ?? "";

            if (!Base.ValidateIP(ClientIP))
            {
                if (Environment.GetEnvironmentVariable("EnforceGetURL") == "true")
                {
                    return(null);
                }
            }

            string Shortname = Base.GetShortname(name, ver, man, customerid);

            if (!string.IsNullOrEmpty(Shortname))
            {
                try
                {
                    bool bWorking = false;
                    try
                    {
                        if (string.IsNullOrEmpty(ok))
                        {
                            ok = "false";
                        }

                        bool.TryParse(ok, out bWorking);

                        if (text.ToLower().Trim() != "test")
                        {
                            if (bWorking)
                            {
                                Base.WriteLog($"{Shortname} : {text}", ClientIP, 2000, customerid);
                            }
                            else
                            {
                                Base.WriteLog($"{Shortname} : {text}", ClientIP, 2001, customerid);
                            }
                        }

                        Base.StoreFeedback(name, ver, man, Shortname, text, user, !bWorking, ClientIP, customerid);
                    }
                    catch { }


                    if (bWorking)
                    {
                        Base.IncCounter(Shortname, "SUCCESS", customerid);
                    }
                    else
                    {
                        Base.IncCounter(Shortname, "FAILURE", customerid);
                    }
                }
                catch { }
            }
            else
            {
                Base.WriteLog($"{man} {name} {ver} : {text}", ClientIP, 2001, customerid);
            }

            return(new OkResult());
        }