protected void ddl_TableName_SelectedIndexChanged(object sender, EventArgs e) { ddl_Field.DataSource = UD_ModelFieldsBLL.GetModelList("TableID='" + ddl_TableName.SelectedValue + "'"); ddl_Field.DataBind(); ddl_Field.Items.Insert(0, new ListItem("请选择...", "0")); if (_ontableselectedindexchanged != null) { _ontableselectedindexchanged.Invoke(sender, e); } }
protected void ddl_RelationTableName_SelectedIndexChanged(object sender, EventArgs e) { if (ddl_RelationTableName.Visible && rbl_RelationType.SelectedValue == "2") { ddl_RelationTextField.DataSource = UD_ModelFieldsBLL.GetModelList("TableID='" + new UD_TableListBLL(ddl_RelationTableName.SelectedValue).Model.ID.ToString() + "'"); ddl_RelationTextField.DataBind(); ddl_RelationValueField.DataSource = ddl_RelationTextField.DataSource; ddl_RelationValueField.DataBind(); } }
private void BindDropDown() { if (ViewState["TableName"] != null) { IList <UD_TableList> tablelist = UD_TableListBLL.GetModelList("Name='" + ViewState["TableName"].ToString() + "'"); if (tablelist.Count > 0) { ViewState["TableID"] = tablelist[0].ID; IList <UD_ModelFields> fieldlist = UD_ModelFieldsBLL.GetModelList("Tableid='" + tablelist[0].ID + "'"); ddl_FieldName.DataSource = fieldlist; ddl_FieldName.DataTextField = "DisplayName"; ddl_FieldName.DataValueField = "ID"; ddl_FieldName.DataBind(); ddl_FieldName.Items.Insert(0, new ListItem("所有", "0")); } } }
protected void ddl_TableName_SelectedIndexChanged(object sender, EventArgs e) { IList <UD_ModelFields> fields = UD_ModelFieldsBLL.GetModelList("TableID='" + ddl_TableName.SelectedValue + "'"); foreach (Rpt_DataSetFields f in new Rpt_DataSetBLL((Guid)ViewState["ID"]).GetFields()) { UD_ModelFields field = fields.FirstOrDefault(p => p.ID == f.FieldID); if (field != null) { UD_TableList table = new UD_TableListBLL(field.RelationTableName).Model; if (field.RelationType == 2 && table != null && table.TreeFlag == "Y") { continue; } fields.Remove(field); } } cbxl_Fields.DataSource = fields; cbxl_Fields.DataBind(); }
/// <summary> /// 用IList(IModel)数据源来绑定GridView /// </summary> /// <param name="m"></param> public void BindGrid <T>(IList <T> source) { this.DataSource = source; this.DataBind(); if (source.Count == 0) { return; } IList <UD_TableList> _tables = new UD_TableListBLL()._GetModelList("ModelName='" + ((IModel)source[0]).ModelName + "'"); if (_tables.Count == 0) { return; } UD_TableList table = _tables[0]; IList <UD_ModelFields> fields = new UD_TableListBLL(table.ID).GetModelFields(); for (int i = 0; i < Columns.Count; i++) { DataControlField column = Columns[i]; if (column.GetType().Name == "BoundField") { BoundField field = (BoundField)column; if (!column.Visible) { continue; } IList <UD_ModelFields> _models = UD_ModelFieldsBLL.GetModelList("TableID='" + table.ID.ToString() + "' AND FieldName='" + field.DataField + "'"); if (_models.Count == 0) { continue; } UD_ModelFields model = _models[0]; switch (model.RelationType) { case 1: //关联字典表 foreach (GridViewRow row in Rows) { Dictionary <string, Dictionary_Data> dic = DictionaryBLL.GetDicCollections(model.RelationTableName, false); row.Cells[i].Text = dic.ContainsKey(row.Cells[i].Text) ? dic[row.Cells[i].Text].Name : ""; } break; case 2: //关联实体表 foreach (GridViewRow row in Rows) { row.Cells[i].Text = TreeTableBLL.GetRelationTableDataValue(model.RelationTableName, model.RelationValueField, model.RelationTextField, row.Cells[i].Text); } break; } if (model.DataType == 4) //日期型 { foreach (GridViewRow row in Rows) { if (row.Cells[i].Text.StartsWith("1900-01-01")) { row.Cells[i].Text = ""; } } } } } }
/// <summary> /// 用户登录 /// </summary> /// <param name="UserName">用户名</param> /// <param name="EncryptPassword">加密后的登录密码</param> /// <param name="DeviceCode">设备识别号</param> /// <param name="AuthKey">输出:授权码</param> /// <param name="ExtParams">扩展登录参数Json格式,包括AppCode、AppVersion、DeviceModel、DeviceOS、OSVersion、NetworkType /// 如:{"AppCode":"YSLRMAPP","AppVersion":43,"DeviceModel":"SM-G7108V","DeviceOS":"Android","OSVersion":"4.3","NetworkType":"ChinaMobile TD-SCDMA"} /// </param> /// <returns>0:登录成功 /// -1001:用户名或密码错误,登录失败 /// -1002:未能获取到对称加密密钥 /// -1003:设备号未在可登录的列表中登记 /// -1004:当前用户不允许从该设备号登录 /// -1005:登录失败 /// -1009:APP版本过低必须更新 /// </returns> public static int Login(string UserName, string EncryptPassword, string DeviceCode, string ExtParams, out string AuthKey) { LogWriter.WriteLog("UserLogin.LoginEx2:UserName="******",EncryptPassword="******",DeviceCode=" + DeviceCode + ",ExtParams=" + ExtParams); AuthKey = ""; Hashtable hs = string.IsNullOrEmpty(ExtParams) ? new Hashtable() : JsonConvert.DeserializeObject <Hashtable>(ExtParams); #region 判断是否符合最新版本要求 if (hs["AppCode"] != null) { int MinAppVersion = 0; if (hs["AppCode"].ToString() == "PBMSAPP") { MinAppVersion = ConfigHelper.GetConfigInt("MinAppVersion"); } else if (hs["AppCode"].ToString() == "PBMSAPP-iOS") { MinAppVersion = ConfigHelper.GetConfigInt("MinAppVersion-iOS"); } if (MinAppVersion > 0 && hs["AppVersion"] != null) { int AppVersion = 0; if (int.TryParse(hs["AppVersion"].ToString(), out AppVersion) && AppVersion < MinAppVersion) { LogWriter.WriteLog("UserLogin.LoginEx2: AppVersion too lower! UserName="******",DeviceCode=" + DeviceCode + ",AppVersion=" + AppVersion.ToString()); return(-1009); //APP版本过低必须更新 } } } #endregion #region 组织登录扩展属性 string ExtPropertys = ""; try { IList <UD_TableList> tables = UD_TableListBLL.GetModelList("Name='MCS_SYS.dbo.User_Online'"); if (tables.Count > 0) { IList <UD_ModelFields> models = UD_ModelFieldsBLL.GetModelList("Tableid='" + tables[0].ID.ToString() + "' AND Flag='N'"); foreach (UD_ModelFields item in models.OrderBy(p => p.Position)) { if (hs.ContainsKey(item.FieldName)) { ExtPropertys += hs[item.FieldName].ToString(); } ExtPropertys += "|"; } } } catch { } #endregion string cachekey = "EBMIF_DeviceCryptKey-" + DeviceCode; DeviceCryptKey key = null; #region 从数据库中加载保存的密钥 if (key == null) { string _keystr = ""; if (UserBLL.AppCryptKey_LoadKey(DeviceCode, out _keystr) == 0 && !string.IsNullOrEmpty(_keystr)) { try { key = JsonConvert.DeserializeObject <DeviceCryptKey>(_keystr); if (key != null) { DataCache.SetCache(cachekey, key, DateTime.Now.AddMinutes(5), System.Web.Caching.Cache.NoSlidingExpiration); } } catch { } } } #endregion int ret = 0; string Password = EncryptPassword; if (key == null) { LogWriter.WriteLog("UserLogin.LoginEx: Get DeviceCrytKey Null! UserName="******",DeviceCode=" + DeviceCode); return(-1002); //未能获取到对称加密密钥 } else { ret = AESProvider.DecryptText(EncryptPassword, key.AESKey, key.AESIV, out Password); if (ret < 0) { LogWriter.WriteLog("UserLogin.LoginEx! AESProvider.DecryptText Ret=" + ret.ToString() + ",DeviceCode=" + DeviceCode + ",EncryptPassword="******",AESKey=" + key.AESKey + ",AESIV=" + key.AESIV); return(-1002); } } ret = userlogin(UserName, Password, DeviceCode, ExtPropertys, out AuthKey); if (ConfigHelper.GetConfigBool("DebugMode") && key != null) { LogWriter.WriteLog("UserLogin.LoginEx:Login Return ret=" + ret.ToString() + ",DeviceCode=" + DeviceCode + ",AESKey=" + key.AESKey + ",AESIV=" + key.AESIV + ",AuthKey=" + AuthKey); } switch (ret) { case -1003: //设备号未在可登录的列表中登记 return(-1003); case -3: case -5: case -10: //当前用户不允许从该设备号登录 return(-1004); case -2: case -11: case -12: case -13: //用户名或密码错误,登录失败 return(-1001); case 1: //登录成功 return(0); default: //登录失败 return(-1005); } }