public static async Task <IActionResult> IncCounter([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 shortname = req.Query["shortname"]; shortname = shortname ?? ""; string counter = req.Query["counter"]; counter = counter ?? "DL"; if (!Base.ValidateIP(ClientIP)) { if (Environment.GetEnvironmentVariable("EnforceGetURL") == "true") { return(new OkObjectResult(false)); } } else { } if (string.IsNullOrEmpty(customerid)) { //if (ClientIP.StartsWith("152.195.1")) // return false; //if (ClientIP.StartsWith("152.199.1")) // return false; } if (string.IsNullOrEmpty(shortname)) { return(new OkObjectResult(false)); } else { try { Message bMSG; bMSG = new Message() { Label = "RuckZuck/WCF/downloaded/" + shortname, TimeToLive = new TimeSpan(24, 0, 0) }; bMSG.UserProperties.Add("ShortName", shortname); bMSG.UserProperties.Add("ClientIP", ClientIP); bMSG.UserProperties.Add("CustomerID", customerid); if (!string.IsNullOrEmpty(sbconnection)) { if (tcRuckZuck == null) { Console.WriteLine("SBConnection:" + sbconnection); tcRuckZuck = new TopicClient(sbconnection, "RuckZuck", RetryPolicy.Default); } } else { tcRuckZuck = null; } if (tcRuckZuck != null) { await tcRuckZuck.SendAsync(bMSG); } Base.WriteLog($"Content donwloaded: {shortname}", ClientIP, 1300, customerid); } catch { } return(new OkObjectResult(Base.IncCounter(shortname, counter, customerid))); } }
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()); }