/// <summary> /// 域的身份认证 /// </summary> /// <param name="domainCode"></param> /// <param name="password"></param> /// <returns></returns> public static JsonModel<string> DomainIdentityAuth(string domainCode, string password) { JsonModel<string> jsonModel = new JsonModel<string>() { Success = false, ErrMsg = "域拥有者身份认证不通过", SuccessMsg = "域拥有者身份认证通过" }; IDomainDal domainDal = new DomainDal(); var domain = domainDal.GetEntity(new DomainSingleParam() { DomainCode = domainCode }); if (domainCode == null) { jsonModel.ErrMsg = "域不存在"; } if (string.IsNullOrEmpty(domainCode) || string.IsNullOrEmpty(password)) { jsonModel.ErrMsg = "域标识不正确或者域密码不正确"; return jsonModel; } string inputEncrypt = EncryptDomainPassword(password, domain.DomainCode, domain.DomainKey); if (!inputEncrypt.Trim().Equals(domain.DomainPassword.Trim())) { jsonModel.ErrMsg = "密码不正确"; } jsonModel.Success = true; return jsonModel; }
//// GET api/Order //public HttpResponseMessage Get() //{ // IEnumerable<OrderModel> orders = _orderService.Listing(); // return Request.CreateResponse(HttpStatusCode.OK, orders); //} //// GET api/Order/5 //public HttpResponseMessage Get(int id) //{ // OrderModel order = _orderService.Query(id); // return Request.CreateResponse(HttpStatusCode.OK, order); //} // POST api/Order public HttpResponseMessage Post(JsonModel model) { //string orderResonse = String.Empty; JsonModel responseModel = null; try { responseModel = _orderService.Insert(model); } catch (WebException wex) { if (wex.Response != null) { using (var errorResponse = (HttpWebResponse)wex.Response) { using (var reader = new StreamReader(errorResponse.GetResponseStream())) { string error = reader.ReadToEnd(); return Request.CreateResponse(errorResponse.StatusCode, error); } } } } catch (Exception e) { return Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message); } return Request.CreateResponse(HttpStatusCode.OK, responseModel); }
public JsonResult GetImageTypes() { List<JsonModel> result = new List<JsonModel>(); foreach (var type in BuiltIns.ImageTypes) { if (type.Id <= 16 && type.Id >= 12) { JsonModel jm = new JsonModel(); jm.Id = type.Id; jm.Name = type.Name; jm.Description = type.Description; result.Add(jm); } } return Json(new {Success = true, Rows = result.ToArray() }, JsonRequestBehavior.AllowGet); }
/// <summary> /// 添加一个单点登录池 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonModel<string> AddSSOPool(SSOPoolAddModel model) { JsonModel<string> jsonModel = new JsonModel<string>() { Success = false, SuccessMsg = "添加成功", ErrMsg = "添加失败" }; //对实体进行验证 var validate = DotNet.Utils.DataValidate.ValidateHelper<SSOPoolAddModel>.ValidateModel(model); if (!validate.Pass) { jsonModel.ErrMsg = validate.ResultList.FirstOrDefault().ErrorMessage; return jsonModel; } //字符过滤 model.ReMark = DotNet.Utils.Untility.StringHelper.FilterHtml(model.ReMark); //判断主域是否存在 IDomainDal domainDal = new DomainDal(); if (model.MainDomainId > 0) { var domain = domainDal.GetEntity(model.MainDomainId); if (domain == null) { jsonModel.ErrMsg = "主域不存在"; return jsonModel; } } //构建实体 SSOPool pool = new SSOPool() { PoolName = model.PoolName, IsEnabled = model.IsEnabled, MaxAmount = model.MaxAmount, MainDomainId = model.MainDomainId, DelFlag = (int)DelFlagEnum.Noraml, ReMark = model.ReMark }; ISSOPoolDal ssoPoolDal = new SSOPoolDal(); var r = ssoPoolDal.AddEntity(pool); if (r != null) { jsonModel.Success = true; } return jsonModel; }
/// <summary> /// Manager帐号登录 /// </summary> /// <param name="loginModel"></param> /// <returns></returns> public JsonModel<string> ManagerLogin(ManagerLoginModel loginModel) { JsonModel<string> jsonModel = new JsonModel<string>() { Success = false, ErrMsg = "登录失败", SuccessMsg = "登录成功" }; //实体验证 var validate = DotNet.Utils.DataValidate.ValidateHelper<ManagerLoginModel>.ValidateModel(loginModel); if (!validate.Pass) { jsonModel.ErrMsg = validate.ResultList.FirstOrDefault().ErrorMessage; return jsonModel; } IManagerDal managerDal = new ManagerDal(); //查询数据库中是否存在该实体 var manager = managerDal.GetEntity(new ManagerSingleParam() { LoginName = loginModel.LoginName }); if (manager == null) { jsonModel.ErrMsg = "帐号不存在"; return jsonModel; } //登录帐号加密后 string encryptPwd = DotNet.Utils.Encrypt.EncryptHelper.AESEncryString(loginModel.LoginPwd, manager.EncryptKey); if (!manager.LoginPwd.Trim().Equals(encryptPwd.Trim())) { jsonModel.ErrMsg = "密码不正确"; return jsonModel; } //验证 验证码 string imageCodeKey = BllUtility.ManagerHandler.GetImageCodeCookie(); if (!BllUtility.VerifyCodeHandler.VerifyCode(imageCodeKey, loginModel.ImageCode)) { jsonModel.ErrMsg = "验证码不正确"; return jsonModel; } //获取token,在获取的时候已经进行缓存 string token = BllUtility.ManagerHandler.AddLoginCache(manager); //写入到cookie中 BllUtility.ManagerHandler.WriteLoginCookie(token); jsonModel.Success = true; jsonModel.Data = token; return jsonModel; }
public static JsonModel<string> AccountVerifyOnly(AccountSingleParam parameter) { JsonModel<string> jsonModel = new JsonModel<string>() { Success = false, ErrMsg = "", SuccessMsg = "验证成功" }; //验证登录名 if (!BllUtility.AccountHandler.VerifyOnly(new AccountSingleParam() { LoginName = parameter.LoginName })) { jsonModel.ErrMsg = "用户名已经存在"; return jsonModel; }; if (!string.IsNullOrEmpty(parameter.Mobile)) { if (!DotNet.Utils.Untility.RegexValidate.IsMobileNumber(parameter.Mobile)) { jsonModel.ErrMsg = "手机号码格式不正确"; return jsonModel; } if (!BllUtility.AccountHandler.VerifyOnly(new AccountSingleParam() { Mobile = parameter.Mobile })) { jsonModel.ErrMsg = "手机号码已经存在"; return jsonModel; }; } if (!string.IsNullOrEmpty(parameter.Email)) { if (!DotNet.Utils.Untility.RegexValidate.IsEmailAddress(parameter.Email)) { jsonModel.ErrMsg = "Email格式不正确"; return jsonModel; } if (!BllUtility.AccountHandler.VerifyOnly(new AccountSingleParam() { Email = parameter.Email })) { jsonModel.ErrMsg = "邮箱已经存在"; return jsonModel; }; } jsonModel.Success = true; return jsonModel; }
public ActionResult InfinateScroll(string descricao, string ncm, int BlockNumber) { //////////////// THis line of code only for demo. Needs to be removed //// System.Threading.Thread.Sleep(3000); ////////////////////////////////////////////////////////////////////////// int BlockSize = 10; var listNcm = ElasticSearchDAO.ConsultaProdutosSensiveisElasticSearch(descricao, ncm, BlockNumber, BlockSize); JsonModel jsonModel = new JsonModel(); jsonModel.NoMoreData = listNcm.Count < BlockSize; jsonModel.HTMLString = RenderPartialViewToString("_NcmBlock", listNcm); return Json(jsonModel); }
public ActionResult SaveOdontogramaDetalle([FromBody] JsonModel jsonModel) { MicroDB.MicroDB db = new MicroDB.MicroDB(); int oids = (jsonModel != null)?int.Parse(jsonModel.oId.ToString()):0; List <Odontograma> odontograma = new List <Odontograma>(); var objects = JArray.Parse(jsonModel.detail); //Leer JSON que entra por POST foreach (JObject root in objects) //Recorrer JSON e insertarlos en el ArrayList { var oid = root.GetValue("nOdontogramaID"); var odi = root.GetValue("nOdontogramaDetalleID"); var d = root.GetValue("sDescripcion"); var nd = root.GetValue("sNombreDiente"); int odis = int.Parse(odi.ToString()); string ds = d.ToString(); string nds = nd.ToString(); Odontograma o = new Odontograma(oids, odis, ds, nds); odontograma.Add(o); } // ALGORITMO GENERAL //Los que vengan con nOdontogramaDetalleID: 0, insert //Los que vengan con nOdontogramaDetalleID: x, update //Los que no vengan, pero estén en la BD: logical delete // ALGORITMO EN C# : // 1- Recorrer lista de simbolos SQL de odontogramadetalle (active=1) // 2- Si el id existe en el array, actualizar el diente del arraylist hacia la BD // 3- Si el id solo existe en la BD, eliminar el registro logicamente (set active=0) // 4- Recorrer aparte los del arraylist e insertarlos si no existen en la BD // 5- No puede pasar que un registro oid!=0 este en el arraylist y no en la BD, // porque para existir en el arraylist con un id, tuvo que extraerse de la BD con anterioridad. // Sin embargo, para evitar cualquier inconsistencia, se creará un nuevo id para este. var consulta = db.ExecuteReaderList("select * from vwOdontogramaDetalle where nOdontogramaID=" + oids); foreach (var i in consulta) { Odontograma item = odontograma.Where(c => c.d.Equals(i["sDescripcion"]) && c.nd.Equals(i["sNombreDiente"]) && c.odi == int.Parse(i["nOdontogramaDetalleID"].ToString())).FirstOrDefault(); //Si existe en el array... if (item != null) { //Actualizar sNombreDiente en la BD con el odi especifico string strSQL = string.Format("Exec spGrabarOdontogramaDetalle {0}, {1}, '{2}', '{3}', 0; ", item.oid, item.odi, item.nd, item.d); db.ExecuteSqlCommand(strSQL); } else { //Desactivar el simbolo con el odi especifico string strSQL = string.Format("Exec spGrabarOdontogramaDetalle {0}, {1}, '{2}', '{3}', 1; ", i["nOdontogramaID"], i["nOdontogramaDetalleID"], i["sNombreDiente"], i["sDescripcion"]); db.ExecuteSqlCommand(strSQL); } } //Recorrer arraylist foreach (var i in odontograma) { //Si no existe en la BD... if (consulta.Where(c => int.Parse(c["nOdontogramaDetalleID"].ToString()) == i.odi && c["sDescripcion"].Equals(i.d) && c["sNombreDiente"].Equals(i.nd)).ToList().Count == 0) { //Insertar registro nuevo string strSQL = string.Format("Exec spGrabarOdontogramaDetalle {0}, {1}, '{2}', '{3}', 0; ", i.oid, i.odi, i.nd, i.d); db.ExecuteSqlCommand(strSQL); } } return(Json(1)); }
public ActionResult UploadPropPic(string data, int userId) { JsonModel jm = new JsonModel(); UserSessionModel sessionModel = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO]; string directory = Server.MapPath(ConstantParam.PROPERTY_USER_HEAD_DIR); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } var fileName = DateTime.Now.ToFileTime().ToString() + ".jpg"; var path = Path.Combine(directory, fileName); using (FileStream fs = new FileStream(path, FileMode.Create)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] datas = Convert.FromBase64String(data); bw.Write(datas); bw.Close(); } } ////生成缩略图 //string thumpFile = DateTime.Now.Millisecond + PSPlatformUtils.CreateValidateCode(4) + ".jpg"; //var thumpPath = Path.Combine(Server.MapPath("~/Upload/User"), thumpFile); //PSPlatformUtils.getThumImage(path, 18, 3, thumpPath); // 若当前登录用户为物业用户 IPropertyUserBLL UserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); var user = UserBll.GetEntity(m => m.DelFlag == 0 && m.Id == userId); //用户存在 if (user != null) { string oldFile = user.HeadPath; user.HeadPath = ConstantParam.PROPERTY_USER_HEAD_DIR + fileName; UserBll.Update(user); //更新SessionModel中的最新个人信息 sessionModel.HeadPath = ConstantParam.PROPERTY_USER_HEAD_DIR + fileName; //删除旧头像 if (!string.IsNullOrEmpty(oldFile)) { oldFile = Server.MapPath(oldFile); FileInfo f = new FileInfo(oldFile); if (f.Exists) { f.Delete(); } } } //用户不存在 else { jm.Msg = "用户不存在"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 开启或者关闭域 /// </summary> /// <param name="domainId"></param> /// <param name="isEnabled"></param> /// <returns></returns> public JsonModel<string> ChangeDomainEnabled(int domainId, int isEnabled) { JsonModel<string> jsonModel = new JsonModel<string>() { Success = false, ErrMsg = "操作失败", SuccessMsg = "操作成功" }; IDomainDal domainDal = new DomainDal(); var domain = domainDal.GetEntity(domainId); if (domain == null || domain.DomainId == 0) { jsonModel.ErrMsg = "当前域不存在"; return jsonModel; } if (!Enum.IsDefined(typeof(IsEnabledEnum), isEnabled)) { jsonModel.ErrMsg = "域的状态不正确"; return jsonModel; } domain.IsEnabled = isEnabled; var r = domainDal.UpdateEntity(domain); if (r != null && r.DomainId > 0) { jsonModel.Success = true; } return jsonModel; }
/// <summary> /// 修改域 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonModel<Domain> EditDomain(DomainEditModel model) { JsonModel<Domain> jsonModel = new JsonModel<Domain>() { Success = false, ErrMsg = "修改失败", SuccessMsg = "修改成功" }; //对实体进行验证 var validate = DotNet.Utils.DataValidate.ValidateHelper<DomainEditModel>.ValidateModel(model); if (!validate.Pass) { jsonModel.ErrMsg = validate.ResultList.FirstOrDefault().ErrorMessage; return jsonModel; } //字符过滤 model.ReMark = DotNet.Utils.Untility.StringHelper.FilterHtml(model.ReMark); IDomainDal domainDal = new DomainDal(); var dbDomain = domainDal.GetEntity(model.DomainId); if (dbDomain == null) { jsonModel.ErrMsg = "当前域不存在"; return jsonModel; } //先判断当前域的级别,如果为1级,则没有上一级,否则,就检测上一级是否存在 if (model.DomainLevel > 1) { var parentDomain = domainDal.GetEntity(model.ParentDomainId); if (parentDomain == null) { jsonModel.ErrMsg = "父域不存在"; return jsonModel; } } else { model.DomainLevel = 1; model.ParentDomainId = 0; } int oldPoolId = dbDomain.SSOPoolPoolId; //检测单点登录池是否存在 ISSOPoolDal ssoPoolDal = new SSOPoolDal(); var pool = ssoPoolDal.GetEntity(model.SSOPoolPoolId); if (pool == null) { jsonModel.ErrMsg = "你选择的单点登录池不存在"; return jsonModel; } #region 生成修改的属性 //域密码 //string encryptPassword = BllUtility.DomainHandler.EncryptDomainPassword(model.DomainPassword,dbDomain.DomainCode,dbDomain.DomainKey); dbDomain.DomainName = model.DomainName; dbDomain.DomainUrl = model.DomainUrl; dbDomain.DomainLevel = model.DomainLevel; dbDomain.ParentDomainId = model.ParentDomainId; dbDomain.CookieDomain = model.CookieDomain; dbDomain.IsEnabled = model.IsEnabled; dbDomain.IsSSO = model.IsSSO; dbDomain.SSOUrl = model.SSOUrl; dbDomain.ReMark = model.ReMark; dbDomain.SSOPoolPoolId = model.SSOPoolPoolId; // dbDomain.DomainPassword = encryptPassword; #endregion var r = domainDal.UpdateEntity(dbDomain); if (r != null && r.DomainId > 0) { jsonModel.Success = true; jsonModel.Data = r; } //最后,判断是否修改了池子 if (oldPoolId != dbDomain.SSOPoolPoolId) { //判断池子的主域是否是这个 if (pool.MainDomainId == oldPoolId) { pool.MainDomainId = 0; ssoPoolDal.UpdateEntity(pool); } } return jsonModel; }
/// <summary> /// 修改单点登录池 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonModel<string> EditSSOPool(SSOPoolEditModel model) { JsonModel<string> jsonModel = new JsonModel<string>() { Success = false, SuccessMsg = "修改成功", ErrMsg = "修改失败" }; //对实体进行验证 var validate = DotNet.Utils.DataValidate.ValidateHelper<SSOPoolEditModel>.ValidateModel(model); if (!validate.Pass) { jsonModel.ErrMsg = validate.ResultList.FirstOrDefault().ErrorMessage; return jsonModel; } //字符过滤 model.ReMark = DotNet.Utils.Untility.StringHelper.FilterHtml(model.ReMark); IDomainDal domainDal = new DomainDal(); //检测选择的主要验证域是否正确 if (model.MainDomainId > 0) { var domain = domainDal.GetEntity(model.MainDomainId); if (domain == null || domain.SSOPoolPoolId != model.PoolId) { jsonModel.ErrMsg = "您选择的主要验证域不正确"; return jsonModel; } } //查看最大的域数量是否超出限制 var poolDomainCount = domainDal.GetPoolDomain(model.PoolId).Count; if (poolDomainCount > model.MaxAmount) { jsonModel.ErrMsg = string.Format("您输入的最大域数量不正确,应大于{0}", poolDomainCount); return jsonModel; } ISSOPoolDal ssoPoolDal = new SSOPoolDal(); var dbPool = ssoPoolDal.GetEntity(model.PoolId); if (dbPool != null) { dbPool.PoolName = model.PoolName; dbPool.MainDomainId = model.MainDomainId; dbPool.IsEnabled = model.IsEnabled; dbPool.MaxAmount = model.MaxAmount; dbPool.ReMark = model.ReMark; } var r = ssoPoolDal.UpdateEntity(dbPool); if (r != null && r.PoolId > 0) { jsonModel.Success = true; } return jsonModel; }
/// <summary> /// 改变池子的启用或者禁用的状态 /// </summary> /// <param name="poolId"></param> /// <param name="isEnabled"></param> /// <returns></returns> public JsonModel<string> ChangeSSOPoolEnabled(int poolId, int isEnabled) { JsonModel<string> jsonModel = new JsonModel<string>() { Success = false, ErrMsg = "操作失败", SuccessMsg = "操作成功" }; ISSOPoolDal ssoPoolDal = new SSOPoolDal(); var ssoPool = ssoPoolDal.GetEntity(poolId); if (ssoPool == null || ssoPool.PoolId == 0) { jsonModel.ErrMsg = "当前池子不存在"; return jsonModel; } if (!Enum.IsDefined(typeof(IsEnabledEnum), isEnabled)) { jsonModel.ErrMsg = "池子状态不正确"; return jsonModel; } ssoPool.IsEnabled = isEnabled; var r = ssoPoolDal.UpdateEntity(ssoPool); if (r != null && r.PoolId > 0) { jsonModel.Success = true; } return jsonModel; }
/// <summary> /// 为返回的数据添加用户姓名列 /// </summary> /// <param name="jsonModel">数据</param> /// <param name="type">type 0获取所有学生(默认);1获取所有教师;2 根据UniqueNo获取用户;3 根据UniqueNo获取学生;4 获取所有用户信息</param> /// <param name="ispage">数据是否是分页的</param> /// <param name="oneUserField">第一个需要返回用户姓名的列</param> /// <param name="uniqueNos">uniqueNos字符串,以逗号分隔,默认为空</param> /// <param name="twoUserField">第二个需要返回用户姓名的列</param> /// <param name="name">根据名称搜索</param> /// <param name="AcademicId">默认0 当前学期; 历史学期 传学期id</param> /// <returns></returns> public JsonModel AddCreateNameForData(JsonModel jsonModel, int type = 0, bool ispage = false, string oneUserField = "CreateUID", string uniqueNos = "", string twoUserField = "", string name = "", string AcademicId = "0") { if (jsonModel.errNum == 0) { List <Dictionary <string, object> > list = new List <Dictionary <string, object> >(); List <Dictionary <string, object> > classList = new List <Dictionary <string, object> >(); PagedDataModel <Dictionary <string, object> > pageModel = null; if (ispage) { pageModel = jsonModel.retData as PagedDataModel <Dictionary <string, object> >; list = pageModel.PagedData as List <Dictionary <string, object> >; } else { list = jsonModel.retData as List <Dictionary <string, object> >; } List <Dictionary <string, object> > allList = new List <Dictionary <string, object> >(); allList = GetUnifiedUserData(type, uniqueNos, name, AcademicId); if (!string.IsNullOrEmpty(name)) { List <string> stuUniqueNo = (from dic in allList select dic["UniqueNo"].ToString()).ToList(); list = (from dic in list where stuUniqueNo.Contains(dic[oneUserField].ToString()) select dic).ToList(); } foreach (Dictionary <string, object> item in list) { try { Dictionary <string, object> dicItem = (from dic in allList where dic["UniqueNo"].ToString() == item[oneUserField].ToString() select dic).FirstOrDefault(); item.Add("CreateName", dicItem == null?"":dicItem["Name"].ToString()); item.Add("AbsHeadPic", dicItem == null ? "" : dicItem["AbsHeadPic"].ToString()); item.Add("Sex", dicItem == null ? "" : dicItem["Sex"].ToString()); if (dicItem != null && dicItem.ContainsKey("OrgName")) { item.Add("OrgName", dicItem["OrgName"].ToString()); } if (dicItem != null && dicItem.ContainsKey("GradeName")) { item.Add("GradeName", dicItem["GradeName"].ToString()); } if (!string.IsNullOrEmpty(twoUserField)) { Dictionary <string, object> dicItem_two = (from dic in allList where dic["UniqueNo"].ToString() == item[twoUserField].ToString() select dic).FirstOrDefault(); item.Add("TwoUserName", dicItem_two == null?"": dicItem_two["Name"].ToString()); item.Add("TwoAbsHeadPic", dicItem_two == null ? "" : dicItem_two["AbsHeadPic"].ToString()); } } catch (Exception ex) { LogService.WriteErrorLog(ex.Message); } } if (ispage) { pageModel.PagedData = list; jsonModel.retData = pageModel; } else { jsonModel.retData = list; } } return(jsonModel); }
public void TableGetTest() { // Arrange // Set language to swedish since reference data is on that language SetSwedishLanguage(); ResultController resultController = new ResultController(); var taxaIds = new ObservableCollection <int> { 100573, Convert.ToInt32(TaxonId.Butterflies) }; SessionHandler.MySettings = new MySettings(); SessionHandler.MySettings.Filter.Taxa.TaxonIds = taxaIds; SessionHandler.MySettings.Filter.Taxa.IsActive = true; SessionHandler.MySettings.Presentation.Table.IsActive = true; // Act var viewResult = resultController.Tables(); Assert.IsNotNull(viewResult); var result = resultController.SpeciesObservationTable(); Assert.IsNotNull(result); var obsResult = resultController.GetPagedObservationListAsJSON(1, 0, 25); Assert.IsNotNull(obsResult); JsonModel jsonResult = (JsonModel)obsResult.Data; List <Dictionary <string, string> > observationListResult = (List <Dictionary <string, string> >)jsonResult.Data; // Assert Assert.IsNotNull(jsonResult, "jsonResult is null"); Assert.IsTrue(jsonResult.Success, "jsonResult.Success is not true"); var data = jsonResult.Data as IList; Assert.IsNotNull(data, "jsonResult.Data is null"); Assert.IsTrue(data.Count >= 0, "jsonResult.Data.Count is not gerater than 0"); Assert.IsTrue(observationListResult.Count >= 0, "List<Dictionary<string, string>> observationListResult.Count is not greater than 0"); bool testPerformed = false; foreach (Dictionary <string, string> item in observationListResult) { if (item.ContainsKey("VernacularName")) { if (item.Any(keyValuePair => keyValuePair.Key.Equals("VernacularName") && keyValuePair.Value.Equals("griffelblomfluga"))) { BaseDataTest.VerifyObservationDataForGriffelblomfluga1000573(observationListResult); testPerformed = true; } } if (testPerformed) { break; } } // Reset to english language SetEnglishLanguage(); }
public JsonResult UpdateSystemConfig(SystemInformationDto[] systemInformations) { var result = SystemInformationService.UpdateSystemConfig(systemInformations); return(Json(JsonModel.Create(result))); }
protected override string ResponseScript(HttpContext context) { var request = context.Request; var converter = new ClientMetaFactory(); var op = converter.Option; op.ignoreCommands = request.GetQueryStringOrDefault("ignoreCommands", 0) == 1; op.isDetail = request.GetQueryStringOrDefault("isDetail", 0) == 1; op.isLookup = request.GetQueryStringOrDefault("isLookup", 0) == 1; op.isReadonly = request.GetQueryStringOrDefault("isReadonly", 0) == 1; op.viewName = request.GetQueryStringOrDefault("viewName", string.Empty); var moduleName = request.GetQueryStringOrDefault("module", string.Empty); var typeName = request.GetQueryStringOrDefault("type", string.Empty); var templateType = request.GetQueryStringOrDefault("templateType", string.Empty); var isAggt = request.GetQueryStringOrDefault("isAggt", 0) == 1; JsonModel jsonResult = null; //如果指定了 module,则直接返回模块的格式。 if (!string.IsNullOrEmpty(moduleName)) { var module = CommonModel.Modules[moduleName]; var aggt = UIModel.AggtBlocks.GetModuleBlocks(module); jsonResult = converter.ConvertToAggtMeta(aggt); } else { var type = ClientEntities.Find(typeName); //需要聚合块 if (isAggt) { AggtBlocks aggt = null; //通过定义的模板类来返回模块格式 if (!string.IsNullOrEmpty(templateType)) { var uiTemplateType = Type.GetType(templateType); var template = Activator.CreateInstance(uiTemplateType) as BlocksTemplate; template.EntityType = type.EntityType; aggt = template.GetBlocks(); } else { //通过定义的聚合块名称来获取聚合块 if (!string.IsNullOrEmpty(op.viewName)) { aggt = UIModel.AggtBlocks.GetDefinedBlocks(op.viewName); } else { //通过默认的聚合块名称来获取聚合块 aggt = UIModel.AggtBlocks.GetDefaultBlocks(type.EntityType); } } jsonResult = converter.ConvertToAggtMeta(aggt); } else { //获取单块 UI 的元数据 var evm = UIModel.Views.Create(type.EntityType, op.viewName) as WebEntityViewMeta; jsonResult = converter.ConvertToClientMeta(evm); } } var json = jsonResult.ToJsonString(); return(json); }
public void SetUserToRole(HttpContext context) { int intSuccess = (int)errNum.Success; try { HttpRequest Request = context.Request; string UniqueNos = RequestHelper.string_transfer(Request, "UniqueNo"); int Roleid = RequestHelper.int_transfer(Request, "Roleid"); string[] us = Split_Hepler.str_to_stringss(UniqueNos); //----------------------------------------------------------------------- //先把选中的 角色进行判断性的变更【若不为改类型则设置为该类型】 foreach (var unique in us) { Sys_RoleOfUser roleofuser = Constant.Sys_RoleOfUser_List.FirstOrDefault(r => r.UniqueNo == unique); if (roleofuser != null && roleofuser.Role_Id != Roleid) { Sys_RoleOfUser RoleOfUser_Clone = Constant.Clone <Sys_RoleOfUser>(roleofuser); RoleOfUser_Clone.Role_Id = Roleid; //改数据库 JsonModel m1 = Constant.Sys_RoleOfUserService.Update(RoleOfUser_Clone); if (m1.errNum == 0) { //改缓存 roleofuser.Role_Id = Roleid; } } } //----------------------------------------------------------------------- //若不为改类型则进行剔除(获取已存在的该类型角色 查看这次是否剔除) var roles = (from r in Constant.Sys_RoleOfUser_List where r.Role_Id == Roleid select r).ToList(); foreach (Sys_RoleOfUser role in roles) { //Sys_RoleOfUser Sys_RoleOfUser_=new Sys_RoleOfUser(); //Sys_RoleOfUser_.UniqueNo= if (!us.Contains(role.UniqueNo)) { Teacher teacher = Constant.Teacher_List.FirstOrDefault(t => t.UniqueNo == role.UniqueNo); Student student = Constant.Student_List.FirstOrDefault(s => s.UniqueNo == role.UniqueNo); int roleID = 2; if (teacher != null) { roleID = 3; } else if (student != null) { roleID = 2; } Sys_RoleOfUser edit_RoleOfUser = Constant.Sys_RoleOfUser_List.FirstOrDefault(u => u.UniqueNo == role.UniqueNo); if (edit_RoleOfUser != null) { Sys_RoleOfUser role_u_clone = Constant.Clone <Sys_RoleOfUser>(edit_RoleOfUser); role_u_clone.Role_Id = roleID; //改数据库 JsonModel m2 = Constant.Sys_RoleOfUserService.Update(role_u_clone); if (m2.errNum == 0) { //改缓存 edit_RoleOfUser.Role_Id = roleID; } } } } jsonModel = JsonModel.get_jsonmodel(intSuccess, "success", "0"); } catch (Exception ex) { LogHelper.Error(ex); } finally { //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】 context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}"); } }
public void GetTeachers(HttpContext context) { int intSuccess = (int)errNum.Success; try { HttpRequest Request = context.Request; string Major_ID = RequestHelper.string_transfer(context.Request, "Major_ID"); //返回所有用户信息 List <UserInfo> UserInfo_List_ = Constant.UserInfo_List; if (!string.IsNullOrEmpty(Major_ID)) { UserInfo_List_ = UserInfo_List_.Where(t => t.Major_ID == Major_ID).ToList(); } List <Major> Major_List = Constant.Major_List; //LogHelper.Info("Get_UserInfo_List:开始"); var query = from ul in UserInfo_List_ join s in Constant.Teacher_List on ul.UniqueNo equals s.UniqueNo select new { id = ul.Id, Name = (ul.Name == null) ? string.Empty : ul.Name, Sex = GetSex(Convert.ToString(ul.Sex)), //Department_Name = (ul.Department_Name == null) ? string.Empty : ul.Department_Name, //Major_Name = (ul.Major_Name == null) ? string.Empty : ul.Major_Name, //College_Name = (ul.College_Name == null) ? string.Empty : ul.College_Name, LoginName = (ul.LoginName == null) ? string.Empty : ul.LoginName, Phone = (ul.Phone == null) ? string.Empty : ul.Phone, Email = (ul.Email == null) ? string.Empty : ul.Email, UserType = ul.UserType, Roleid = 3, RoleName = "教师", UniqueNo = ul.UniqueNo, Pwd = ul.ClearPassword, //MajorName=SysMajor.Major_Name MajorName = "", Major_ID = ul.Major_ID }; var query1 = from q in query join SysMajor in Major_List on q.Major_ID equals SysMajor.Id into gj from lf in gj.DefaultIfEmpty() select new { id = q.id, Name = (q.Name == null) ? string.Empty : q.Name, Sex = q.Sex, //Department_Name = (ul.Department_Name == null) ? string.Empty : ul.Department_Name, //Major_Name = (ul.Major_Name == null) ? string.Empty : ul.Major_Name, //College_Name = (ul.College_Name == null) ? string.Empty : ul.College_Name, LoginName = (q.LoginName == null) ? string.Empty : q.LoginName, Phone = (q.Phone == null) ? string.Empty : q.Phone, Email = (q.Email == null) ? string.Empty : q.Email, UserType = q.UserType, Roleid = q.Roleid, RoleName = q.RoleName, UniqueNo = q.UniqueNo, Pwd = q.Pwd, //MajorName=SysMajor.Major_Name MajorName = (lf == null ? "" : lf.Major_Name), Major_ID = q.Major_ID }; int count = query1.Count(); jsonModel = JsonModel.get_jsonmodel(intSuccess, "success", query1); } catch (Exception ex) { LogHelper.Error(ex); } finally { //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】 context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}"); } }
public void GetUserByType_Course(HttpContext context) { int intSuccess = (int)errNum.Success; try { HttpRequest Request = context.Request; var college_TeacherUID = RequestHelper.string_transfer(Request, "college_TeacherUID"); object query = new object(); //if (string.IsNullOrEmpty(college_TeacherUID)) //{ // var major_id = (from t in Constant.Teacher_List where t.UniqueNo == college_TeacherUID select t.Major_ID).First(); // int type = RequestHelper.int_transfer(Request, "type"); // List<UserInfo> UserInfo_List_ = Constant.UserInfo_List; // List<Sys_Role> Sys_Role_List = Constant.Sys_Role_List; // List<Sys_RoleOfUser> Sys_RoleOfUser_List = Constant.Sys_RoleOfUser_List; // query = (from ul in UserInfo_List_ // where ul.Major_ID== major_id // join SysRoleOfUser in Sys_RoleOfUser_List on ul.UniqueNo equals SysRoleOfUser.UniqueNo // where SysRoleOfUser.Role_Id == type // join SysRole in Sys_Role_List on SysRoleOfUser.Role_Id equals SysRole.Id // join t in Constant.Teacher_List on ul.UniqueNo equals t.UniqueNo // join major in Constant.Major_List on t.Major_ID equals major.Id // orderby SysRole.Sort // select new // { // a_Id = ul.Id, // a_Name = (ul.Name == null) ? string.Empty : ul.Name, // a_Sex = GetSex(Convert.ToString(ul.Sex)), // a_LoginName = (ul.LoginName == null) ? string.Empty : ul.LoginName, // a_Phone = (ul.Phone == null) ? string.Empty : ul.Phone, // a_Email = (ul.Email == null) ? string.Empty : ul.Email, // a_UserType = ul.UserType, // a_Roleid = SysRole.Id, // a_Pwd = ul.ClearPassword, // a_UniqueNo = ul.UniqueNo, // list = (from c1 in Constant.CourseRoom_List.Distinct() // where c1.TeacherUID == ul.UniqueNo // join c2 in Constant.Course_List on c1.Coures_Id equals c2.UniqueNo // select c2).Distinct().ToList() // }).ToList(); //} //else //{ int type = RequestHelper.int_transfer(Request, "type"); List <UserInfo> UserInfo_List_ = Constant.UserInfo_List; List <Sys_Role> Sys_Role_List = Constant.Sys_Role_List; List <Sys_RoleOfUser> Sys_RoleOfUser_List = Constant.Sys_RoleOfUser_List; query = (from ul in UserInfo_List_ join SysRoleOfUser in Sys_RoleOfUser_List on ul.UniqueNo equals SysRoleOfUser.UniqueNo where SysRoleOfUser.Role_Id == type join SysRole in Sys_Role_List on SysRoleOfUser.Role_Id equals SysRole.Id join t in Constant.Teacher_List on ul.UniqueNo equals t.UniqueNo join major in Constant.Major_List on t.Major_ID equals major.Id orderby SysRole.Sort select new { a_Id = ul.Id, a_Name = (ul.Name == null) ? string.Empty : ul.Name, a_Sex = GetSex(Convert.ToString(ul.Sex)), a_LoginName = (ul.LoginName == null) ? string.Empty : ul.LoginName, a_Phone = (ul.Phone == null) ? string.Empty : ul.Phone, a_Email = (ul.Email == null) ? string.Empty : ul.Email, a_UserType = ul.UserType, a_Roleid = SysRole.Id, a_Pwd = ul.ClearPassword, a_UniqueNo = ul.UniqueNo, list = (from c1 in Constant.CourseRoom_List.Distinct() where c1.TeacherUID == ul.UniqueNo join c2 in Constant.Course_List on c1.Coures_Id equals c2.UniqueNo select c2).Distinct().ToList() }).ToList(); //} jsonModel = JsonModel.get_jsonmodel(intSuccess, "success", query); } catch (Exception ex) { LogHelper.Error(ex); } finally { //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】 context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}"); } }
/// <summary> /// 单点登录 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonModel<string> Login(SSOLoginModel model) { JsonModel<string> jsonModel = new JsonModel<string>() { Success = false }; try { //实体中的验证 var validate = DotNet.Utils.DataValidate.ValidateHelper<SSOLoginModel>.ValidateModel(model); if (!validate.Pass) { jsonModel.ErrMsg = validate.ResultList.FirstOrDefault().ErrorMessage; return jsonModel; } //过滤 model.LoginStr = DotNet.Utils.Untility.StringHelper.FilterHtml(model.LoginStr); model.LoginPassword = DotNet.Utils.Untility.StringHelper.FilterHtml(model.LoginPassword); //判断帐号的类型 int loginType = BllUtility.SSOLoginHandler.GetLoginType(model.LoginStr); if (!Enum.IsDefined(typeof(LoginTypeEnum), loginType)) { jsonModel.ErrMsg = "您输入的帐号格式不正确"; return jsonModel; } //查询帐号 var param = BllUtility.SSOLoginHandler.GetLoginTypeParam(loginType, model.LoginStr); IAccountDal accountDal = new AccountDal(); var account = accountDal.GetEntity(param); if (account == null) { jsonModel.ErrMsg = "帐号不存在"; return jsonModel; } //密码校验 string enLoginPassword = BllUtility.AccountHandler.EncryptPassword(account.OpenId, model.LoginPassword, account.EncryptKey); if (!enLoginPassword.Trim().Equals(account.Password.Trim())) { //添加监控 DotNet.Utils.Monitor.MonitorHelper.AddMonitor(account.OpenId, 5, 300, 60); jsonModel.ErrMsg = "密码不正确"; return jsonModel; } //判断监控是否密码输入错误次数达到了5次,进行验证码认证 if (DotNet.Utils.Monitor.MonitorHelper.IsMonitorMax(account.OpenId)) { if (string.IsNullOrEmpty(model.VerifyKey) || string.IsNullOrEmpty(model.Code)) { jsonModel.ErrMsg = "请输入验证码"; return jsonModel; } if (!BllUtility.VerifyCodeHandler.VerifyCode(model.VerifyKey, model.Code)) { jsonModel.ErrMsg = "验证码不正确"; return jsonModel; } } jsonModel.Success = true; //登录成功,移除监控 DotNet.Utils.Monitor.MonitorHelper.RemoveMonitor(account.OpenId); } catch { jsonModel.ErrMsg = "登录失败"; } return jsonModel; }
/// <summary> ///获取课程类型 /// </summary> public void GetCourse_Type(HttpContext context) { int intSuccess = (int)errNum.Success; HttpRequest Request = context.Request; //课程类型 DictionType_Enum dictiontype = DictionType_Enum.Course_Type; int SectionId = RequestHelper.int_transfer(Request, "SectionId"); try { bool HasSection = RequestHelper.bool_transfer(Request, "HasSection"); var list = (from dic in Constant.Sys_Dictionary_List join section in Constant.StudySection_List on dic.SectionId equals section.Id where dic.Type == Convert.ToString((int)dictiontype) && dic.SectionId == section.Id orderby section.EndTime descending select new CourseSection() { SectionId = dic.SectionId, Sort = dic.Sort, Type = dic.Type, Value = dic.Value, DisPlayName = section.DisPlayName, CreateTime = section.CreateTime, StartTime = section.StartTime, EndTime = section.EndTime, Id = dic.Id, Key = dic.Key, Pid = dic.Pid, Study_IsEnable = section.IsEnable, IsEnable = dic.IsEnable, State = "", ReguState = 0, }).ToList(); //带学年学期的课程 if (HasSection) { if (SectionId > 0) { list = (from li in list where li.SectionId == SectionId select li).ToList(); } } else { StudySection section = Constant.StudySection_List.FirstOrDefault(item => item.IsEnable == 0); if (section != null) { list = (from li in list where section.Id == li.SectionId select li).ToList(); } } ReguState regustate = ReguState.进行中; foreach (var li in list) { if (li.StartTime < DateTime.Now && li.EndTime >= DateTime.Now) { regustate = ReguState.进行中; } else if (li.StartTime > DateTime.Now) { regustate = ReguState.未开始; } else { regustate = ReguState.已结束; } li.State = Convert.ToString(regustate); li.ReguState = (int)regustate; } //返回所有表格数据 jsonModel = JsonModel.get_jsonmodel(intSuccess, "success", list); } catch (Exception ex) { LogHelper.Error(ex); } finally { //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】 context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}"); } }
/// <summary> /// 删除单点登录池 /// </summary> /// <param name="poolId"></param> /// <returns></returns> public JsonModel<string> DeleteSSOPool(int poolId) { JsonModel<string> jsonModel = new JsonModel<string>() { Success = false, ErrMsg = "删除失败", SuccessMsg = "删除成功" }; ISSOPoolDal ssoPoolDal = new SSOPoolDal(); var dbPool = ssoPoolDal.GetEntity(poolId); if (dbPool == null) { jsonModel.ErrMsg = "该单点池不存在"; return jsonModel; } dbPool.DelFlag = (int)DelFlagEnum.LogicalDelete; var r = ssoPoolDal.UpdateEntity(dbPool); if (r != null && r.PoolId > 0) { jsonModel.Success = true; } return jsonModel; }
/// <summary> /// 删除单点登录帐号 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonModel<string> DeleteAccount(AccountDeleteModel model) { JsonModel<string> jsonModel = new JsonModel<string>() { Success = false, SuccessMsg = "删除成功", ErrMsg = "删除失败" }; //身份认证 //var auth = BllUtility.DomainHandler.DomainIdentityAuth(model.DomainCode,model.DomainPassword); //if (!auth.Success) //{ // jsonModel.ErrMsg = auth.ErrMsg; // return jsonModel; //} //过滤 if (!string.IsNullOrEmpty(model.OpenId)) { model.OpenId = DotNet.Utils.Untility.StringHelper.FilterHtml(model.OpenId); } IAccountDal accountDal = new AccountDal(); var account = accountDal.GetEntity(new AccountSingleParam() { AccountId = model.AccountId, OpenId = model.OpenId }); if (account == null) { jsonModel.ErrMsg = "帐号不存在"; return jsonModel; } account.DelFlag = (int)DelFlagEnum.LogicalDelete; var r = accountDal.UpdateEntity(account); if (r != null) { jsonModel.Success = true; } return jsonModel; }
//获取用户信息 public void Get_UserInfo_List(HttpContext context) { int intSuccess = (int)errNum.Success; try { HttpRequest Request = context.Request; //返回所有用户信息 List <UserInfo> UserInfo_List_ = Constant.UserInfo_List; List <Sys_Role> Sys_Role_List = Constant.Sys_Role_List; List <Sys_RoleOfUser> Sys_RoleOfUser_List = Constant.Sys_RoleOfUser_List; List <Major> Major_List = Constant.Major_List; var query = from ul in UserInfo_List_ join SysRoleOfUser in Sys_RoleOfUser_List on ul.UniqueNo equals SysRoleOfUser.UniqueNo join SysRole in Sys_Role_List on SysRoleOfUser.Role_Id equals SysRole.Id join stu in Constant.Student_List on ul.UniqueNo equals stu.UniqueNo into clasStus from stu_ in clasStus.DefaultIfEmpty() where SysRole.Name != "超级管理员" orderby SysRole.Sort select new { id = ul.Id, Name = (ul.Name == null) ? string.Empty : ul.Name, Sex = GetSex(Convert.ToString(ul.Sex)), LoginName = (ul.LoginName == null) ? string.Empty : ul.LoginName, Phone = (ul.Phone == null) ? string.Empty : ul.Phone, Email = (ul.Email == null) ? string.Empty : ul.Email, UserType = ul.UserType, Roleid = SysRole.Id, RoleName = SysRole.Name, UniqueNo = ul.UniqueNo, Pwd = ul.ClearPassword, Major_ID = ul.Major_ID, DepartmentName = ul.DepartmentName, SubDepartmentID = ul.SubDepartmentID, SubDepartmentName = ul.SubDepartmentName, ClassID = stu_ != null ? stu_.ClassNo : "", ClassName = stu_ != null ? stu_.ClassName : "", }; var data = new { MainData = query, DPList = (from q in query where q.DepartmentName != "" select new DPModel() { Major_ID = q.Major_ID, DepartmentName = q.DepartmentName, }).Distinct(new DPModelComparer()), ClsList = (from q in query where q.ClassID != "" select new ClsModel() { ClassID = q.ClassID, ClassName = q.ClassName, Major_ID = q.Major_ID }).Distinct(new ClsModelComparer()), }; jsonModel = JsonModel.get_jsonmodel(intSuccess, "success", data); } catch (Exception ex) { LogHelper.Error(ex); } finally { //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】 context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}"); } }
public ActionResult GetCommentsInJSON(int BlockNumber, int BlockSize, int KhachSan) { var _dsBinhLuan = GetBinhluans(BlockNumber, BlockSize, KhachSan); JsonModel jsonModel = new JsonModel(); jsonModel.NoMoreData = _dsBinhLuan.Count < BlockSize; jsonModel.HtmlString = RenderViewToHtmlString("_CommentList", _dsBinhLuan); return Json(jsonModel); }
public virtual JsonModel GetPage(Hashtable ht, bool IsPage = true, string where = "") { int RowCount = 0; BLLCommon common = new BLLCommon(); try { int PageIndex = 0; int PageSize = 0; if (IsPage) { //增加起始条数、结束条数 ht = common.AddStartEndIndex(ht); PageIndex = Convert.ToInt32(ht["PageIndex"]); PageSize = Convert.ToInt32(ht["PageSize"]); } DataTable modList = CurrentDal.GetListByPage(ht, out RowCount, IsPage, where); //定义分页数据实体 PagedDataModel <Dictionary <string, object> > pagedDataModel = null; //定义JSON标准格式实体中 JsonModel jsonModel = null; if (modList == null || modList.Rows.Count <= 0) { jsonModel = new JsonModel() { errNum = 999, errMsg = "无数据", retData = "" }; return(jsonModel); } List <Dictionary <string, object> > list = new List <Dictionary <string, object> >(); list = common.DataTableToList(modList); if (IsPage) { //list.Add(common.DataTableToJson(modList)); //总条数 //int RowCount = modList.Rows.Count;// CurrentDal.GetRecordCount(ht, null); //总页数 int PageCount = (int)Math.Ceiling(RowCount * 1.0 / PageSize); //将数据封装到PagedDataModel分页数据实体中 pagedDataModel = new PagedDataModel <Dictionary <string, object> >() { PageCount = PageCount, PagedData = list, PageIndex = PageIndex, PageSize = PageSize, RowCount = RowCount }; //将分页数据实体封装到JSON标准实体中 jsonModel = new JsonModel() { errNum = 0, errMsg = "success", retData = pagedDataModel }; } else { jsonModel = new JsonModel() { errNum = 0, errMsg = "success", retData = list }; } return(jsonModel); } catch (Exception ex) { JsonModel jsonModel = new JsonModel() { errNum = 400, errMsg = ex.Message, retData = "" }; return(jsonModel); } }
private void AddRewardEditionData(HttpContext context) { try { int Id = RequestHelper.int_transfer(context.Request, "Id"); int lid = RequestHelper.int_transfer(context.Request, "LID"); DateTime beginTime = RequestHelper.DateTime_transfer(context.Request, "BeginTime"); DateTime endTime = RequestHelper.DateTime_transfer(context.Request, "EndTime"); //" BeginTime>" +endTime + " or EndTime<"+beginTime 时间不重叠(not取非,获取不重叠) string id_str = Id == 0 ? "" : " and Id!=" + Id; Hashtable ht = new Hashtable(); ht.Add("TableName", "TPM_RewardEdition"); JsonModel edition_result = RewardEdition_bll.GetPage(ht, false, id_str + " and IsDelete=0 and lid=" + lid + " and not( convert(varchar(10),BeginTime,21)>'" + context.Request["endTime"] + "' or convert(varchar(10),EndTime,21)<'" + context.Request["beginTime"] + "')"); if (edition_result.errNum == 0) { jsonModel = JsonModel.get_jsonmodel(-1, "与其他版本时间交叉!", edition_result.retData); return; } if (Id == 0) { TPM_RewardEdition model = new TPM_RewardEdition(); model.Name = context.Request["Name"]; model.LID = lid; model.BeginTime = beginTime; model.EndTime = endTime; jsonModel = RewardEdition_bll.Add(model); Id = Convert.ToInt32(jsonModel.retData); } else { //版本编辑时判断时间(时间、时间已在业绩中使用) string definddates = SQLHelp.ExecuteScalar(@"select STUFF((select '、' + CAST(CONVERT(varchar(10),a.DefindDate,21) AS NVARCHAR(MAX)) from TPM_AcheiveRewardInfo a left join TPM_RewardLevel lev on lev.Id = a.Lid where a.IsDelete = 0 and lev.EID =" + lid + " and(a.DefindDate < '" + context.Request["beginTime"] + "' or a.DefindDate > '" + context.Request["endTime"] + "') FOR xml path('')), 1, 1, '')", CommandType.Text, null).ToString(); if (!string.IsNullOrEmpty(definddates)) { jsonModel = JsonModel.get_jsonmodel(-2, "日期" + definddates + "已在业绩中使用!", ""); return; } TPM_RewardEdition model = RewardEdition_bll.GetEntityById(Id).retData as TPM_RewardEdition; model.Name = context.Request["Name"]; model.BeginTime = beginTime; model.EndTime = endTime; jsonModel = RewardEdition_bll.Update(model); } if (jsonModel.errNum == 0) { string add_Path = RequestHelper.string_transfer(context.Request, "Add_Path"); string edit_PathId = RequestHelper.string_transfer(context.Request, "Edit_PathId"); if (!string.IsNullOrEmpty(add_Path) || !string.IsNullOrEmpty(edit_PathId)) { List <Sys_Document> pathlist = new List <Sys_Document>(); if (!string.IsNullOrEmpty(add_Path)) { pathlist = JsonConvert.DeserializeObject <List <Sys_Document> >(add_Path); } new Sys_DocumentService().OperDocument(pathlist, edit_PathId, Id); } } } catch (Exception ex) { jsonModel = new JsonModel() { errNum = 400, errMsg = ex.Message, retData = "" }; LogService.WriteErrorLog(ex.Message); } }
/// <summary> /// 删除域 /// </summary> /// <param name="domainId"></param> /// <returns></returns> public JsonModel<string> DeleteDomain(int domainId) { JsonModel<string> jsonModel = new JsonModel<string>() { Success = false, ErrMsg = "删除失败", SuccessMsg = "删除成功" }; IDomainDal domainDal = new DomainDal(); var domain = domainDal.GetEntity(domainId); if (domain == null) { jsonModel.ErrMsg = "该域不存在"; return jsonModel; } domain.DelFlag = (int)DelFlagEnum.LogicalDelete; var r = domainDal.UpdateEntity(domain); if (r != null && r.DomainId > 0) { jsonModel.Success = true; } return jsonModel; }
public void GetStudents(HttpContext context) { int intSuccess = (int)errNum.Success; try { HttpRequest Request = context.Request; //返回所有用户信息 List <UserInfo> UserInfo_List_ = Constant.UserInfo_List; List <Major> Major_List = Constant.Major_List; var query = from ul in UserInfo_List_ join s in Constant.Student_List on ul.UniqueNo equals s.UniqueNo select new { id = ul.Id, Name = (ul.Name == null) ? string.Empty : ul.Name, Sex = GetSex(Convert.ToString(ul.Sex)), LoginName = (ul.LoginName == null) ? string.Empty : ul.LoginName, Phone = (ul.Phone == null) ? string.Empty : ul.Phone, Email = (ul.Email == null) ? string.Empty : ul.Email, UserType = ul.UserType, Roleid = 2, RoleName = "学生", UniqueNo = ul.UniqueNo, Pwd = ul.ClearPassword, MajorName = "", Major_ID = ul.Major_ID, s.SubDepartmentID, s.SubDepartmentName, }; var query1 = from q in query join SysMajor in Major_List on q.Major_ID equals SysMajor.Id into gj from lf in gj.DefaultIfEmpty() select new { id = q.id, Name = (q.Name == null) ? string.Empty : q.Name, Sex = q.Sex, LoginName = (q.LoginName == null) ? string.Empty : q.LoginName, Phone = (q.Phone == null) ? string.Empty : q.Phone, Email = (q.Email == null) ? string.Empty : q.Email, UserType = q.UserType, Roleid = q.Roleid, RoleName = q.RoleName, UniqueNo = q.UniqueNo, Pwd = q.Pwd, MajorName = (lf == null ? "" : lf.Major_Name), Major_ID = q.Major_ID, q.SubDepartmentID, q.SubDepartmentName, }; int count = query1.Count(); jsonModel = JsonModel.get_jsonmodel(intSuccess, "success", query1); } catch (Exception ex) { LogHelper.Error(ex); } finally { //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】 context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}"); } }
/// <summary> /// 添加域的实体 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonModel<Domain> AddDomain(DomainAddModel model) { JsonModel<Domain> jsonModel = new JsonModel<Domain>() { Success = false, ErrMsg = "添加失败", SuccessMsg = "添加成功" }; try { //对实体进行验证 var validate = DotNet.Utils.DataValidate.ValidateHelper<DomainAddModel>.ValidateModel(model); if (!validate.Pass) { jsonModel.ErrMsg = validate.ResultList.FirstOrDefault().ErrorMessage; return jsonModel; } //过滤 model.DomainName = DotNet.Utils.Untility.StringHelper.FilterHtml(model.DomainName); model.ReMark = DotNet.Utils.Untility.StringHelper.FilterHtml(model.ReMark); //生成当前域的级别 int domainLevel = model.DomainLevel; int parentDomainId = model.ParentDomainId; BllUtility.DomainHandler.GetDomainLevel(ref domainLevel, ref parentDomainId); string domainKey = BllUtility.DomainHandler.GetDomainKey(); string domainCode = BllUtility.DomainHandler.GetDomainCode(); string domainPassword = BllUtility.DomainHandler.EncryptDomainPassword(model.DomainPassword, domainCode, domainKey); //构造实体 Domain domain = new Domain() { DomainName = model.DomainName, DomainCode = domainCode, DomainUrl = model.DomainUrl, DomainLevel = domainLevel, ParentDomainId = parentDomainId, IsEnabled = model.IsEnabled, IsSSO = model.IsSSO, SSOUrl = model.SSOUrl, DomainKey = domainKey, DomainPassword = domainPassword, CookieDomain = model.CookieDomain, DelFlag = (int)DelFlagEnum.Noraml, ReMark = model.ReMark, SSOPoolPoolId = model.SSOPoolPoolId }; IDomainDal domainDal = new DomainDal(); var r = domainDal.AddEntity(domain); if (r != null) { jsonModel.Success = true; jsonModel.Data = r; } else { jsonModel.ErrMsg = "数据插入失败"; } } catch (Exception ex) { jsonModel.ErrMsg = ex.Message; } return jsonModel; }
public ActionResult ResumoConsultaDetalhada(string descricao, string ncm) { var listNcm = ElasticSearchDAO.ConsultaResumoConsulta(descricao, ncm); JsonModel jsonModel = new JsonModel(); jsonModel.NoMoreData = false; jsonModel.HTMLString = RenderPartialViewToString("_ResumoConsulta", listNcm); return Json(jsonModel); }
/// <summary> /// 添加单点登录的帐号 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonModel<Account> AddAccount(AccountAddModel model) { JsonModel<Account> jsonModel = new JsonModel<Account>() { Success = false, ErrMsg = "添加失败", SuccessMsg = "添加成功" }; try { //对实体进行验证 var validate = DotNet.Utils.DataValidate.ValidateHelper<AccountAddModel>.ValidateModel(model); if (!validate.Pass) { jsonModel.ErrMsg = validate.ResultList.FirstOrDefault().ErrorMessage; return jsonModel; } //过滤 model.LoginName = DotNet.Utils.Untility.StringHelper.FilterHtml(model.LoginName); model.Mobile = DotNet.Utils.Untility.StringHelper.FilterHtml(model.Mobile); model.LoginName = DotNet.Utils.Untility.StringHelper.FilterHtml(model.LoginName); #region 验证 if (!BllUtility.AccountHandler.VerifyOnly(new AccountSingleParam() { LoginName = model.LoginName })) { jsonModel.ErrMsg = "用户名已经存在"; return jsonModel; }; //验证Mobile int mobileBinding = (int)BindingEnum.NotBinded; if (!string.IsNullOrEmpty(model.Mobile)) { if (!DotNet.Utils.Untility.RegexValidate.IsMobileNumber(model.Mobile)) { jsonModel.ErrMsg = "手机号码格式不正确"; return jsonModel; } mobileBinding=(int)BindingEnum.Binded; if (!BllUtility.AccountHandler.VerifyOnly(new AccountSingleParam() { Mobile = model.Mobile })) { jsonModel.ErrMsg = "手机号码已经存在"; return jsonModel; }; } //验证Email int emailBinding = (int)BindingEnum.NotBinded; if (!string.IsNullOrEmpty(model.Email)) { if (!DotNet.Utils.Untility.RegexValidate.IsEmailAddress(model.Email)) { jsonModel.ErrMsg = "Email格式不正确"; return jsonModel; } emailBinding=(int)BindingEnum.Binded; if (!BllUtility.AccountHandler.VerifyOnly(new AccountSingleParam() { Email = model.Email })) { jsonModel.ErrMsg = "邮箱已经存在"; return jsonModel; }; } //验证安全密码 int safeBinding = (int)BindingEnum.NotBinded; if (!string.IsNullOrEmpty(model.SafePassword)) { if (!DotNet.Utils.Untility.RegexValidate.IsPasswordOne(model.SafePassword, 6, 25)) { jsonModel.ErrMsg = "安全密码格式不正确"; return jsonModel; } model.SafePassword = BllUtility.AccountHandler.EncryptSafePassword(model.SafePassword); safeBinding = (int)BindingEnum.Binded; } //验证提交的域是否存在 IDomainDal domainDal = new DomainDal(); var domain = domainDal.GetEntity(new DomainSingleParam() { DomainCode=model.SubmitDomainCode }); if (domain == null || domain.DomainId <= 0) { jsonModel.ErrMsg = "域不存在"; return jsonModel; } #endregion string openId = BllUtility.AccountHandler.CreateOpenId(); string encryptKey = BllUtility.AccountHandler.CreateEncryptKey(); string encryptPassword = BllUtility.AccountHandler.EncryptPassword(openId, model.Password, encryptKey); string mobile = string.IsNullOrEmpty(model.Mobile) ? "" : model.Mobile; string email = string.IsNullOrEmpty(model.Email) ? "" : model.Email; string safePassword = string.IsNullOrEmpty(model.SafePassword) ? "" : model.SafePassword; Account account = new Account() { OpenId = openId, LoginName = model.LoginName, EncryptKey = encryptKey, Password = encryptPassword, Mobile = mobile, MobileBinding = mobileBinding, Email = email, EmailBinding = emailBinding, SafePassword = safePassword, SafeBinding = safeBinding, CreateDate = DateTime.Now, DelFlag = (int)DelFlagEnum.Noraml, ReMark = model.ReMark, SubmitDomainId = domain.DomainId }; IAccountDal accountDal = new AccountDal(); var r = accountDal.AddEntity(account); if (r != null && r.AccountId > 0) { jsonModel.Success = true; jsonModel.Data = r; } else { jsonModel.ErrMsg = "数据插入失败"; } } catch { jsonModel.ErrMsg = "系统内部错误"; } return jsonModel; }
public void SetUserToRole(HttpContext context) { int intSuccess = (int)errNum.Success; try { HttpRequest Request = context.Request; string UniqueNos = RequestHelper.string_transfer(Request, "UniqueNo"); int Roleid = RequestHelper.int_transfer(Request, "Roleid"); string[] us = Split_Hepler.str_to_stringss(UniqueNos); bool IsMutexCombine = RequestHelper.bool_transfer(Request, "IsMutexCombine"); //互斥 if (IsMutexCombine) { //----------------------------------------------------------------------- //先把选中的 角色进行判断性的变更【若不为改类型则设置为该类型】 foreach (var unique in us) { Sys_RoleOfUser Sys_RoleOfUser = Constant.Sys_RoleOfUser_List.FirstOrDefault(r => r.UniqueNo == unique); if (Sys_RoleOfUser != null) { RoleUserUpdate(Roleid, Sys_RoleOfUser); } else { RoleUserAdd(Roleid, unique); } } } else { //----------------------------------------------------------------------- //先把选中的 角色进行判断性的变更【若不为改类型则设置为该类型】 foreach (var unique in us) { int count = Constant.Sys_RoleOfUser_List.Count(r => r.UniqueNo == unique && r.Role_Id == Roleid); if (count == 0) { RoleUserAdd(Roleid, unique); } } } string[] deleteDatas = (from r in Constant.Sys_RoleOfUser_List where !us.Contains(r.UniqueNo) && r.Role_Id == Roleid select Convert.ToString(r.Id)).ToArray(); if (deleteDatas.Count() > 0) { var jsm = Constant.Sys_RoleOfUserService.DeleteBatch(deleteDatas); if (jsm.errNum == 0) { Constant.Sys_RoleOfUser_List.RemoveAll(r => deleteDatas.Contains(Convert.ToString(r.Id))); } } jsonModel = JsonModel.get_jsonmodel(intSuccess, "success", "0"); } catch (Exception ex) { LogHelper.Error(ex); } finally { //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】 context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}"); } }
public ActionResult GetHotelsInJSON(int BlockNumber, int BlockSize, string ThanhPho, string SapXep) { var _dsKhachSan = GetHotels(BlockNumber,BlockSize,ThanhPho,SapXep); JsonModel jsonModel = new JsonModel(); jsonModel.NoMoreData = _dsKhachSan.Count < BlockSize; jsonModel.HtmlString = RenderViewToHtmlString("_HotelList", _dsKhachSan); return Json(jsonModel); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string func = context.Request["Func"]; string result = string.Empty; try { switch (func) { /*业绩等级*/ case "GetAcheiveLevelData": GetAcheiveLevelData(context); break; case "AddAcheiveLevelData": AddAcheiveLevelData(context); break; case "DelAcheiveLevelData": DelAcheiveLevelData(context); break; case "TPM_AcheiveLevelSort": TPM_AcheiveLevelSort(context); break; case "ChangeAwardSwichStatus": ChangeAwardSwichStatus(context); break; /*奖励项目版本*/ case "GetRewardEditionData": GetRewardEditionData(context); break; case "AddRewardEditionData": AddRewardEditionData(context); break; case "ChangeRewardEditionAllot": ChangeRewardEditionAllot(context); break; case "Del_RewardEdition": Del_RewardEdition(context); break; /*奖励项目等级*/ case "GetRewardLevelData": GetRewardLevelData(context); break; case "AddRewardLevelData": AddRewardLevelData(context); break; case "SortRewardLevelData": SortRewardLevelData(context); break; /*奖项管理*/ case "GetRewardInfoData": GetRewardInfoData(context); break; case "AddRewardInfoData": AddRewardInfoData(context); break; case "SortRewardInfoData": SortRewardInfoData(context); break; case "AddRewardDash": AddRewardDash(context); break; /*奖金批次*/ case "Get_RewardBatchData": Get_RewardBatchData(context); break; case "Add_RewardBatch": Add_RewardBatch(context); break; case "Del_RewardBatch": Del_RewardBatch(context); break; case "ChangeIsMoneyAllot": ChangeIsMoneyAllot(context); break; case "Add_RewardBatchDetail": Add_RewardBatchDetail(context); break; case "Del_RewardBatchDetail": Del_RewardBatchDetail(context); break; case "BatchAllot_RewardBatchDetail": BatchAllot_RewardBatchDetail(context); break; default: jsonModel = JsonModel.get_jsonmodel(5, "没有此方法", ""); break; } LogService.WriteLog(func); } catch (Exception ex) { LogHelper.Error(ex); jsonModel = JsonModel.get_jsonmodel(7, "出现异常,请通知管理员", ""); } finally { result = "{\"result\":" + Constant.jss.Serialize(jsonModel) + "}"; context.Response.Write(result); context.Response.End(); } }