public void GetAvaliableCompanyJson(string query, string appkey) { if (appkey != Globals.Settings.AppServiceSecureKey) { return; } var js = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }; var allCOmpanyNamesList = new List <AllCompanyForAutocompliteResult>(); var allCompanyNames = new UsersProfiles(); var allCOmpanyNamesDs = allCompanyNames.GetAllItems(); foreach ( DataRow row in allCOmpanyNamesDs.Tables[0].AsEnumerable() .Where(c => c.Field <string>("CompanyName") != null && c.Field <string>("CompanyName").ToLower().Trim().Contains(query.ToLower().Trim())).OrderBy(c => c.Field <string>("CompanyName")) ) { allCOmpanyNamesList.Add(new AllCompanyForAutocompliteResult() { value = string.Format("{0} (UID: {1})", row["CompanyName"], row["UserID"]), }); } Context.Response.ContentType = "application/json; charset=UTF-8"; Context.Response.Write("{\"query\": \"Unit\",\"suggestions\": " + js.Serialize(allCOmpanyNamesList) + "}"); }
public List <AllProfileResult> GetProfilesXML(string email, string password) { if (ApiMethods.IsApiAuthRequest()) { var js = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }; var allCityList = new List <AllProfileResult>(); var user = new Users { Email = email }; user.GetByEmail(); if (user.Password != OtherMethods.HashPassword(password)) { allCityList.Add(new AllProfileResult { Name = "Ошибка", ID = "Такой комбинации логина и пароля не найдено!" }); } else { var profiles = new UsersProfiles { UserID = user.ID }; var allProfilesDS = profiles.GetAllItems(); foreach (DataRow row in allProfilesDS.Tables[0].Rows) { string fioOrCompanyName; if (String.IsNullOrEmpty(row["CompanyName"].ToString())) { fioOrCompanyName = row["FirstName"] + " " + row["LastName"]; } else { fioOrCompanyName = row["CompanyName"].ToString(); } var iDPlusType = row["TypeID"].ToString() + row["ID"]; allCityList.Add(new AllProfileResult { Name = fioOrCompanyName, ID = iDPlusType }); } } var responceBody = js.Serialize(allCityList); ApiMethods.LoggingRequest("GetProfilesXML", "UserProileAPI", "UserAPI", null, responceBody.Length, Convert.ToInt32(HttpContext.Current.Request.Params["userid"]), HttpContext.Current.Request.Params["apikey"]); return(allCityList); } return(null); }
public void GetProfilesJSON() { if (ApiMethods.IsApiAuthRequest()) { var js = new JavaScriptSerializer(); var userIdString = HttpContext.Current.Request.Params["userid"]; var profiles = new UsersProfiles { UserID = Convert.ToInt32(userIdString) }; var allProfilesDS = profiles.GetAllItems(); var allCityList = new List <AllProfileResult>(); foreach (DataRow row in allProfilesDS.Tables[0].Rows) { string fioOrCompanyName; if (String.IsNullOrEmpty(row["CompanyName"].ToString())) { fioOrCompanyName = row["FirstName"] + " " + row["LastName"]; } else { fioOrCompanyName = row["CompanyName"].ToString(); } var iDPlusType = row["TypeID"].ToString() + row["ID"]; allCityList.Add(new AllProfileResult { Name = fioOrCompanyName, ID = iDPlusType }); } Context.Response.ContentType = "application/json; charset=UTF-8"; var responceBody = js.Serialize(allCityList); Context.Response.Write(responceBody); ApiMethods.LoggingRequest("GetProfilesJSON", "UserProileAPI", "UserAPI", null, responceBody.Length, Convert.ToInt32(HttpContext.Current.Request.Params["userid"]), HttpContext.Current.Request.Params["apikey"]); } else { ApiMethods.ReturnNotAuth(); } }