internal static PushStats GetPushStats() { int statusOk=0; int statusFail=0; var messages = repo.Select<Message>(); //var messageCount = messages.Count(); int devicesCount = 0; int devicesRegistered = repo2.Select<Device>().Count(); List<PhoneNumber> nList = new List<PhoneNumber>(); foreach (var message in messages) { if (message.StatusCode.ToString() == "200") statusOk += 1; else statusFail += 1; var numbers = JsonConvert.DeserializeObject<List<string>>(message.PhoneNumber); foreach (var number in numbers) { PhoneNumber n = new PhoneNumber {Number = number}; nList.Add(n); } } devicesCount = nList.Count(); PushStats pn = new PushStats { PushesSent = statusOk+statusFail, TotalFail = statusFail, TotalOk = statusOk, RegisteredDevices=devicesRegistered }; return pn; }
internal static List<PhoneNumber> GetNumbers(long id) { List<PhoneNumber> nList = new List<PhoneNumber>(); var retList = new List<string>(); var firstOrDefault = repo.Select<Message>().FirstOrDefault(k => k.Id == id); if (firstOrDefault != null) { var numbs = firstOrDefault.PhoneNumber; var numbers= JsonConvert.DeserializeObject<List<string>>(numbs); foreach (var number in numbers) { PhoneNumber n = new PhoneNumber {Number = number}; nList.Add(n); } } return nList; }
public ActionResult Lock(PhoneNumber phone) { var ret = string.Empty; if (ModelState.IsValid) { var resp = DeviceLogic.SendLock(phone); switch (resp) { case "1": Success(@"Phone number locked Successfully"); break; case "0": Error(@"Phone number not found"); break; } // return RedirectToAction("Index"); } else Error("An error occured."); return View("Index",new PhoneNumber()); }
internal static string SendLock(PhoneNumber phone) { var number = ReturnHash(phone.Number); string sURL; var serviceId = ConfigurationManager.AppSettings["AppServiceId"]; sURL = "https://bankingsvc.vanso.com/unregister_user?app_id="+serviceId+"&user_array="+number; WebRequest wrGETURL; wrGETURL = WebRequest.Create(sURL); Stream objStream; objStream = wrGETURL.GetResponse().GetResponseStream(); StreamReader objReader = new StreamReader(objStream); string sLine = ""; int i = 0; sLine = objReader.ReadLine(); return sLine; }