//получение класификатора по ид public async Task <JsonResult> GetStandardClassifier(int classifierId, bool del = false) { return(await Task.Run <JsonResult>(() => { JSEnvelope ret = new JSEnvelope(); try { var cls = CoreLogic.classifierManager.GetClassifierFromCache(classifierId, del); cls = new SortedClassifier(cls.ClassifierId, cls.Elements.Values.OrderBy(e => e.name).ToList <ClassifierItem>()); ret.ReturnObject = cls; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return Json(ret); })); }
//Изменение пользователя public JsonResult addRoletoUser([FromBody] object json) ///async Task { JSEnvelope ret = new JSEnvelope(); try { var us = JsonConvert.DeserializeObject <User>(json.ToString()); var id = CoreLogic.securityManager.AddRoleToUser(us, Uinf.CurUserId(Request)); ret.ReturnObject = id; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
/// <summary> /// получение списка ролей пользователей /// </summary> /// <param name="userId"> ид пользователя роли которого надо пометить голочкой, возвращается всегда полный список ролей</param> /// <param name=" "></param> /// <returns></returns> public JsonResult delUser(int userId) { JSEnvelope ret = new JSEnvelope(); try { var cls = CoreLogic.securityManager.DelUser(userId, Uinf.CurUserId(Request)); if (cls == -10) { ret.Message.IsError = true; ret.Message.MessageText = "Ошибкка удаления"; } else { ret.Message.IsError = false; ret.Message.MessageText = "Пользователь удален"; } ret.ReturnObject = cls; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
//получение списка класификаторов без данных public JsonResult GetClassifiers() { try { JSEnvelope ret = new JSEnvelope(); try { var clases = CoreLogic.classifierManager.GetClassifiersFromCache(Uinf.CurUserId(Request)); ret.ReturnObject = clases; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); } catch (Exception e) { throw e; } }
//Сохранение элемента класификатоора public JsonResult saveRole([FromBody] object json) { JSEnvelope ret = new JSEnvelope(); try { var cit = JsonConvert.DeserializeObject <Role>(json.ToString()); var id = CoreLogic.securityManager.SaveRole(cit, Uinf.CurUserId(Request)); ret.ReturnObject = id; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
/// <summary> /// смена пароля пользователя /// </summary> /// <param name=" "></param> /// <param name=" "></param> /// <returns></returns> public JsonResult changePass(int usid, string oldpass, string newpass) { JSEnvelope ret = new JSEnvelope(); try { if (usid == -1) { usid = Uinf.CurUserId(Request); } var cls = CoreLogic.securityManager.changePass(usid, oldpass, newpass); ret.ReturnObject = cls; ret.Message.MessageText = cls; ret.Message.IsError = false; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
/// <summary> /// получение макрорегиона по стране /// </summary> /// <param name="name">имя компании</param> /// <returns></returns> public JsonResult GetMakroRegvalByCounty(int countryId) { string retval = string.Empty; JSEnvelope ret = new JSEnvelope(); try { var clsit = CoreLogic.classifierManager.GetMakroRegvalByCounty(countryId); if (clsit != null) { retval = clsit.name; } ret.ReturnObject = retval; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
/// <summary> /// получение пользователя /// </summary> /// <param name=" "></param> /// <param name=" "></param> /// <returns></returns> public JsonResult getUsersInfo(int userId) { JSEnvelope ret = new JSEnvelope(); try { if (userId == -1) { ret.ReturnObject = new User(); } else { if (userId == 0) { userId = Uinf.CurUserId(Request); } var cls = CoreLogic.securityManager.GetUserInfo(userId); ret.ReturnObject = cls; } } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
public JsonResult LogOut() { HttpContext.Session.Clear(); ModelState.Clear(); var ret = new JSEnvelope { ReturnObject = true }; return(Json(ret)); }
//Удаление компании public JsonResult DelClassifierItem(int cid) ///async Task { // var res = CoreLogic.classifierManager.DelCompany(id, Uinf.CurUserId()); RepareClelement var res = CoreLogic.classifierManager.DelClelement(cid, Uinf.CurUserId(Request)); JSEnvelope ret = new JSEnvelope(); ret.Message.IsError = false; ret.Message.MessageText = res; return(Json(ret)); }
/// <summary> /// заявка на регистрацию нового пользователя /// </summary> /// <returns></returns> public JsonResult RegistryNewUser([FromBody] object json) { JSEnvelope ret = new JSEnvelope(); try { byte[] bb; string ds = ""; bool capres = false; var Us = JsonConvert.DeserializeObject <User>(json.ToString()); if (Request.HttpContext.Session.Keys.Contains("captcha")) { Request.HttpContext.Session.TryGetValue("captcha", out bb); ds = CoreLogic.GetString(bb); if (Us.captcha == ds) { capres = true; } } if (capres) { var res = CoreLogic.securityManager.RegisterNewUser(Us); ret.ReturnObject = res; ret.Message.MessageText = res; ret.Message.MessageCode = "-1"; } else { ret.Message.IsError = false; ret.Message.MessageText = "Неверно введены символы с картинки."; ret.Message.MessageCode = "-1"; } } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
/// <summary> /// получение класификатора в ввиде массива /// </summary> /// <param name="classifierId"></param> /// <returns></returns> public JsonResult GetStandardClassifierList(int classifierId) { var list = new List <IdName>(); JSEnvelope ret = new JSEnvelope(); try { var cls = CoreLogic.classifierManager.GetClassifierFromCache(classifierId); if (classifierId == 1) { var sortdemand = new SortedClassifier(1, cls.Elements.Values.OrderBy(e => e.SortOrder).ToList <ClassifierItem>()); foreach (ClassifierItem cc in sortdemand.Elements) { list.Add(new IdName() { id = cc.id, name = cc.name }); } } else { foreach (ClassifierItem cc in cls.Elements.Values) { list.Add(new IdName() { id = cc.id, name = cc.name }); } } ret.ReturnObject = list; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
public IActionResult ChangeFogPassword(string id, string pass, string cacpture) { JSEnvelope ret = new JSEnvelope(); var model = new Model.RememberPasswordModel() { UserId = id }; try { byte[] bb; string ds = ""; bool capres = false; if (Request.HttpContext.Session.Keys.Contains("captcha")) { Request.HttpContext.Session.TryGetValue("captcha", out bb); ds = CoreLogic.GetString(bb); if (cacpture == ds) { capres = true; } } if (capres) { var res = CoreLogic.securityManager.changePass(id, pass); return(View("../Home/Login")); } else { model.Message = "Ошибка! Неверно введены символы с картинки."; return(View("../Home/ChangePassReq", model)); } } catch (E24Exception e) { model.Message = "Ошибка! " + e.Message; return(View("../Home/ChangePassReq", model)); } catch (Exception e) { model.Message = "Ошибка! " + e.Message; return(View("../Home/ChangePassReq", model)); } }
public JsonResult SetReportParams(string dates, string datef, int classid, int valueid) { JSEnvelope ret = new JSEnvelope(); ret.ReturnObject = false; try { if (Request != null) { if (dates != null && datef != null) { var cid = CoreLogic.ConvertVal(classid); var vid = CoreLogic.ConvertVal(valueid); var ds = CoreLogic.GetBytes(dates); var df = CoreLogic.GetBytes(datef); Request.HttpContext.Session.Set("report_dates", ds); Request.HttpContext.Session.Set("report_datef", df); Request.HttpContext.Session.Set("report_classid", cid); Request.HttpContext.Session.Set("report_valueid", vid); ret.ReturnObject = true; } else { ret.ReturnObject = false; } } } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
/// <summary> /// заявка на регистрацию нового пользователя /// </summary> /// <returns></returns> public JsonResult requestForPass([FromBody] object json) { JSEnvelope ret = new JSEnvelope(); try { // var usemail= JsonConvert.DeserializeObject(json.ToString()); string usemail = ""; IDictionary <string, JToken> Jsondata = JObject.Parse(json.ToString()); foreach (KeyValuePair <string, JToken> element in Jsondata) { string innerKey = element.Key; if (innerKey == "usemail") { var ja = element.Value; usemail = ja.Root.Value <string>("usemail"); } } var res = CoreLogic.securityManager.requestForPass(usemail.ToString()); ret.Message.MessageText = res; ret.Message.MessageCode = "-1"; ret.ReturnObject = res; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
public JsonResult getEmptyRole() { JSEnvelope ret = new JSEnvelope(); try { ret.ReturnObject = new Role(); } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
/// <summary> /// получение пользователя /// </summary> /// <param name=" "></param> /// <param name=" "></param> /// <returns></returns> public JsonResult checkAvalibleTariff( ) { JSEnvelope ret = new JSEnvelope(); try { var userId = Uinf.CurUserId(Request); var cls = CoreLogic.securityManager.GetUserTasriff(userId); if (cls.active == true) { if (cls.id == 20) { ret.ReturnObject = 20; } else { ret.ReturnObject = 30; } } else { ret.ReturnObject = 20; } } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
//получение элемента классификатора по ид public JsonResult GetClassifierElement(int classifierId, int elementId) { JSEnvelope ret = new JSEnvelope(); try { var cls = CoreLogic.classifierManager.GetClassifierElement(classifierId, elementId); ret.ReturnObject = cls; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
//получение класификатора по ид GetClassifier_rel_childesMarked public JsonResult GetTreeClassifier(int parentid, int classifierId) { JSEnvelope ret = new JSEnvelope(); try { Classifier cls = CoreLogic.classifierManager.GetClassifierFromCache(classifierId); ret.ReturnObject = cls; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
/// <summary> /// получение списка тарифов /// </summary> /// <param name=" "></param> /// <param name=" "></param> /// <returns></returns> public JsonResult getTarifList() { JSEnvelope ret = new JSEnvelope(); try { var cls = CoreLogic.securityManager.GetTariffList(Uinf.CurUserId(Request)); ret.ReturnObject = cls; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
/// <summary> /// получение списка ролей пользователей /// </summary> /// <param name="userId"> ид пользователя роли которого надо пометить голочкой, возвращается всегда полный список ролей</param> /// <param name=" "></param> /// <returns></returns> public JsonResult getUsersRoles(int userId) { JSEnvelope ret = new JSEnvelope(); try { var cls = CoreLogic.securityManager.GetRoleList(userId); ret.ReturnObject = cls; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
/// <summary> /// получение класификатора по ид с помечеными элементами привязаными к другому классиф. /// </summary> /// <param name="parentId">ид элемента родительского классификатора</param> /// <param name="classifierId">ид классификатора</param> /// <returns></returns> public JsonResult GetStandardClassifierchildesMarked(int parentId, int classifierId) { JSEnvelope ret = new JSEnvelope(); try { Classifier cls = CoreLogic.classifierManager.GetClassifier_rel_childesMarked(parentId, classifierId); ret.ReturnObject = cls; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
public JsonResult GetClassifireItemEmptyObject(int classid) { JSEnvelope ret = new JSEnvelope(); try { var cmp = CoreLogic.classifierManager.GetEmptyClassifireItem(classid); ret.ReturnObject = cmp; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
public JsonResult GetAvailableOperations() { JSEnvelope ret = new JSEnvelope(); try { var res = CoreLogic.securityManager.GetAvailableOperations(Uinf.CurUserId(Request)); ret.ReturnObject = res; } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }
//Изменение пользователя public JsonResult saveUserData([FromBody] object json) ///async Task ,new JsonSerializerSettings(). { } { JSEnvelope ret = new JSEnvelope(); try { var us = JsonConvert.DeserializeObject <User>(json.ToString()); if (us.Id == -1) { us.Id = Uinf.CurUserId(Request); } var id = CoreLogic.securityManager.AddNewUser(us, Uinf.CurUserId(Request)); ret.ReturnObject = id; if (id == -10) { ret.Message.IsError = true; ret.Message.MessageText = "Такой логин существует в системе."; } } catch (E24Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; ret.Message.MessageCode = e.ExceptionCode.ToString(); } catch (Exception e) { ret.Message.IsError = true; ret.Message.MessageText = e.Message; } return(Json(ret)); }