// GET: User public ActionResult Index() { var claims = User.Identity as ClaimsIdentity; var sessionKey = claims.FindFirst(ClaimTypes.Hash).Value; var values = new Dictionary <string, string> { { "iam", User.Identity.Name }, { "sessionKey", sessionKey } }; ApiConnect api = new ApiConnect(); JToken jObjet = api.PostApi(values, "users", "users_get_my_details"); User account = new User(); try { account = jObjet.ToObject <User>(); account.lastAccess = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Convert.ToDouble(account.lastAccess)).ToString(); account.timestamp = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Convert.ToDouble(account.timestamp)).ToString(); } catch (Exception e) { throw; } return(View(account)); }
static async Task Main(string[] args) { GetFixtures getFixtures = new GetFixtures(); Console.WriteLine("Getting fixtures"); await getFixtures.AllFixtures(); Console.WriteLine("Picking team"); ApiConnect apiConnect = new ApiConnect(); MyTeam myTeam = await apiConnect.Connect(getFixtures.fixtures); Console.WriteLine("Value: " + myTeam.value + ",000"); Console.WriteLine("Players: " + myTeam.players.Count); if (myTeam.players.Count < 15) { throw new SystemException("Not enough players selected"); } Console.WriteLine("\r\nFull Team"); foreach (var player in myTeam.players) { Console.WriteLine(player.web_name + " - " + player.teamName + " - " + player.position + " - " + player.potential); } Console.WriteLine("\r\nStarters"); foreach (var player in myTeam.starters) { Console.WriteLine(player.web_name + " - " + player.teamName + " - " + player.position); } Console.WriteLine("\r\nCaptain: " + myTeam.captain); Console.WriteLine("Vice Captain: " + myTeam.viceCaptain); // Console.WriteLine(JsonConvert.SerializeObject(myTeam)); }
public IHttpActionResult GetToken(Token token) { if (!ModelState.IsValid) { // check the request. return(Json(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState).RequestMessage)); } var values = new Dictionary <string, string> { { "grant_type", token.grant_type }, { "client_id", token.client_id }, { "username", token.username }, { "password", token.password }, { "client_secret", token.client_secret }, { "scope", token.scope } }; try { var strUrl = ConfigurationManager.AppSettings["auth"].ToString(); //request token url. Uri url = new Uri(strUrl); ApiConnect api = new ApiConnect(); var res = api.PostApi(values, url); //requst the post method return(Json(res)); } catch (Exception e) { return(Json(e.Message)); } }
public ActionResult Recipes(FormCollection form) { string recipeID = form["recipeID"].ToString(); var result = ApiConnect.Post("/recipeDeliver", new Dictionary <string, string> { { "RecipeID", recipeID } }); if (result.Result.ToString() == "1") { ToastrService.AddToUserQueue(new Toastr("Başarılı Bir Şekilde Gerçekleşti", "Teslim Bildirildi", ToastrType.Info)); return(RedirectToAction("Recipes", "Patient")); } return(RedirectToAction("Recipes", "Patient")); }
public ActionResult WriteRecipe(FormCollection form) { ApiOperation reOP = ApiOperation.GetInstance(); string doctorId = GetDoctorID().ToString(); var result = ApiConnect.Post("/createrecipefordoctor", new Dictionary <string, string> { { "doctorId", doctorId.ToString() }, { "tcNo", form["txtTcNo"] } }); if (Convert.ToInt16(result.Result) == -1) { ToastrService.AddToUserQueue(new Toastr("Hasta Bulunamadı", "Reçete Yazılamadı.", ToastrType.Error)); return(RedirectToAction("Recipes", "Doctor")); } int i = Convert.ToInt32(form["counter"]); for (int j = 1; j <= i; j++) { string medName, medType, medUsage; medName = form["txtMedName" + j]; medType = form["txtMedType" + j]; medUsage = form["txtMedUsage" + j]; var result2 = ApiConnect.Post("/addmedicinetorecipefordoctor", new Dictionary <string, string> { { "medName", medName }, { "medType", medType }, { "medUsage", medUsage } }); } if (Convert.ToInt32(result.Result) == 0) { ToastrService.AddToUserQueue(new Toastr("Reçete Başarılı Bir Şekilde Eklendi", "Reçete Yazıldı.", ToastrType.Success)); return(RedirectToAction("Recipes", "Doctor", new { @id = doctorId })); } else { ToastrService.AddToUserQueue(new Toastr("Reçete Eklenemedi", "Reçete Yazılamadı.", ToastrType.Error)); } return(null); }
public IHttpActionResult postInvoice(Transfer transfer) { if (!ModelState.IsValid) { return(Json(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState).RequestMessage)); } JObject jsonObject = new JObject { ["clave"] = transfer.clave, ["fecha"] = transfer.fecha, ["emisor"] = new JObject { ["tipoIdentification"] = transfer.tipoIdentification, ["numeroIdentificacion"] = transfer.numeroIdentificacion, } ["receptor"] = new JObject { ["tipoIdentification"] = transfer.tipoIdentification, ["numeroIdentificacion"] = transfer.numeroIdentificacion, } ["comprobanteXml"] = transfer.comprobanteXml }; var values = JsonExtension.ToDictionary(jsonObject); Dictionary <string, string> value = values.ToDictionary(k => k.Key, k => k.Value == null ? "" : k.Value.ToString()); var strUrl = ConfigurationManager.AppSettings["reception"].ToString(); //reception url try { Uri url = new Uri(strUrl); ApiConnect api = new ApiConnect(); var res = api.PostApi(value, url); return(Json(res)); } catch (Exception e) { return(Json(e.Message)); } }
public ActionResult Settings(FormCollection form) { string pharmacyId = form["PharmacyList"].ToString(); string patientId = GetPatientId().ToString(); var result = ApiConnect.Post("/changePharmacy", new Dictionary <string, string> { { "PatientID", patientId }, { "PharmacyID", pharmacyId } }); if (result.Result.ToString() == "1") { ToastrService.AddToUserQueue(new Toastr("Başarılı Bir Şekilde Gerçekleşti", "Eczane Değiştirildi", ToastrType.Info)); return(RedirectToAction("Recipes", "Patient")); } return(RedirectToAction("Recipes", "Patient")); }
public ActionResult Logoff() { try { var claims = User.Identity as ClaimsIdentity; var sessionKey = claims.FindFirst(ClaimTypes.Sid).Value; var values = new Dictionary <string, string> { { "iam", User.Identity.Name }, { "sessionKey", sessionKey } }; ApiConnect api = new ApiConnect(); JToken jObjet = api.PostApi(values, "users", "users_log_me_out"); } catch (Exception e) { } IAuthenticationManager authenticationManager = HttpContext.GetOwinContext().Authentication; authenticationManager.SignOut(MyAuthentication.ApplicationCookie); return(RedirectToAction("Index")); }
// GET: User public ActionResult Index() { var claims = User.Identity as ClaimsIdentity; var sessionKey = claims.FindFirst(ClaimTypes.Sid).Value; var values = new Dictionary <string, string> { { "iam", User.Identity.Name }, { "sessionKey", sessionKey } }; ApiConnect api = new ApiConnect(); JToken jObjet = api.PostApi(values, "users", "users_get_my_details"); User account = new User(); try { account = jObjet.ToObject <User>(); account.lastAccess = new DateTime(int.Parse(account.lastAccess) * 10000).ToString(); } catch (Exception e) { } return(View(account)); }
public IHttpActionResult getStatus(string clave) { if (clave == null) // check the empty value. { return(Json(clave)); } var strUrl = ConfigurationManager.AppSettings["reception"].ToString() + "?clave=" + clave; //reception url try { Uri url = new Uri(strUrl); ApiConnect api = new ApiConnect(); var res = api.GetApi(url); //Requst the get method return(Json(res)); // if status is 200, output json } catch (Exception e) { return(Json(e.Message)); } }
public ActionResult Settings() { string patientID = GetPatientId().ToString(); var result = ApiConnect.Post("/getPatientInformation", new Dictionary <string, string> { { "PatientID", patientID } }); List <Patient> patients = JsonConvert.DeserializeObject <List <Patient> >(result.Result.ToString()); var getPharmacies = ApiConnect.Get("/getPharmacies"); List <Pharmacy> pharmacies = JsonConvert.DeserializeObject <List <Pharmacy> >(getPharmacies.Result.ToString()); List <SelectListItem> pharmaciesSelectList = new List <SelectListItem>(); foreach (var item in pharmacies) { if (patients[0].PharmacyName != item.PharmacyName) { pharmaciesSelectList.Add(new SelectListItem { Text = item.PharmacyName, Value = item.PharmacyID.ToString() }); } else { pharmaciesSelectList.Add(new SelectListItem { Text = item.PharmacyName, Value = item.PharmacyID.ToString(), Selected = true }); } } ViewData["PharmacyList"] = pharmaciesSelectList; return(View(patients[0])); }
public async Task <IActionResult> Index() { #region Nginx string url = "http://localhost:8088/api/student"; #endregion #region Consul //Consul能提供的就只有服务的Ip:Port--DNS //url = "http://NGITHubWebapi/api/student"; //ConsulClient client = new ConsulClient(c => //{ // c.Address = new Uri("http://localhost:8500/"); // c.Datacenter = "dc1"; //}); //var response = client.Agent.Services().Result.Response; ////foreach (var item in response) ////{ //// Console.WriteLine("***************************************"); //// Console.WriteLine(item.Key); //// var service = item.Value; //// Console.WriteLine($"{service.Address}--{service.Port}--{service.Service}"); //// Console.WriteLine("***************************************"); ////} //Uri uri = new Uri(url); //string groupName = uri.Host; //AgentService agentService = null; //var serviceDictionary = response.Where(s => s.Value.Service.Equals(groupName, StringComparison.OrdinalIgnoreCase)).ToArray();//得到3个实例 5726 5727 5728 ////{ //// agentService = serviceDictionary[0].Value;//写死访问第1个 ////} ////{ // if (iIndex > 100000) iIndex = 0; //// agentService = serviceDictionary[iIndex++ % serviceDictionary.Length].Value;//轮询 ////} //{ // int index = new Random(iIndex++).Next(0, serviceDictionary.Length); // agentService = serviceDictionary[index].Value;//随机--平均 //} //{ // //权重策略--能给不同的实例分配不同的压力---注册时提供权重 // List<KeyValuePair<string, AgentService>> pairsList = new List<KeyValuePair<string, AgentService>>(); // foreach (var pair in serviceDictionary) // { // int count = int.Parse(pair.Value.Tags?[0]);//1 5 10 // for (int i = 0; i < count; i++) // { // pairsList.Add(pair); // } // } // //16个 // // agentService = pairsList.ToArray()[new Random(iIndex++).Next(0, pairsList.Count())].Value; //} //url = $"{uri.Scheme}://{agentService.Address}:{agentService.Port}{uri.PathAndQuery}"; #endregion #region Gateway url = "http://localhost:5100/api/studentservice/student/all"; #endregion HomeViewModel home = new HomeViewModel(); string cacheKey = "HomeCacheKey"; try { var context = new ServiceResultOfT <IEnumerable <StudentModel> >(); var result = _cache.GetStringAsync(cacheKey).Result; if (result == null) { context = ApiConnect.InvokeApi <ServiceResultOfT <IEnumerable <StudentModel> > >(url, ApiConnect.RequestFunction.Get); home.Students = context.Entities; await _cache.SetStringAsync(cacheKey, JsonConvert.SerializeObject(context), new DistributedCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(30))); } else { context = JsonConvert.DeserializeObject <ServiceResultOfT <IEnumerable <StudentModel> > >(_cache.GetStringAsync(cacheKey).Result); home.Students = context.Entities; } } catch (Exception) { home.Students = null; } return(View(home)); }
public bool Login(string loginNo, string Password, string Role) { if (Role == "patient") { var result = ApiConnect.Post("/login", new Dictionary <string, string> { { "TCNo", loginNo }, { "Password", Password }, { "Role", Role } }); List <Patient> patients = JsonConvert.DeserializeObject <List <Patient> >(result.Result.ToString()); if (patients.Count > 0) { patient = patients[0]; FormsAuthentication.SetAuthCookie(Role.ToString(), false); Session["PatientID"] = patient.PatientID; return(true); } return(false); } else if (Role == "doctor") { var result = ApiConnect.Post("/login", new Dictionary <string, string> { { "TCNo", loginNo }, { "Password", Password }, { "Role", Role } }); List <Doctor> doctors = JsonConvert.DeserializeObject <List <Doctor> >(result.Result.ToString()); if (doctors.Count > 0) { doctor = doctors[0]; FormsAuthentication.SetAuthCookie(Role.ToString(), false); Session["DoctorID"] = doctor.DoctorID; return(true); } return(false); } else if (Role == "pharmacy") { var result = ApiConnect.Post("/login", new Dictionary <string, string> { { "RecordNo", loginNo }, { "Password", Password }, { "Role", Role } }); List <Pharmacy> pharmacies = JsonConvert.DeserializeObject <List <Pharmacy> >(result.Result.ToString()); if (pharmacies.Count > 0) { pharmacy = pharmacies[0]; FormsAuthentication.SetAuthCookie(Role.ToString(), false); Session["PharmacyId"] = pharmacy.PharmacyID; return(true); } return(false); } else { return(false); } }
public RepositoryLogin() { this.connet = new ApiConnect(); this.session = new StorageSession(); }
public RepositoryProductList() { this.connect = new ApiConnect(); }