public string getJsonText(string jsonstr, string name) { StringBuilder sb = new StringBuilder(); if (jsonstr.Length > 0) { eJson json = new eJson(jsonstr); foreach (eJson m in json.GetCollection()) { sb.Append("<span style=\"display:inline-block;margin-right:6px;border:1px solid #ccc;padding:3px 12px 3px 12px;\">" + HttpUtility.HtmlDecode(m.GetValue(name)) + "</span>"); } } return(sb.ToString()); }
protected void Page_Load(object sender, EventArgs e) { Type type = HttpContext.Current.Handler.GetType();//CurrentHandler System.Reflection.FieldInfo fi = type.GetField("UserArea"); if (fi != null) { UserArea = fi.GetValue(Activator.CreateInstance(type)).ToString(); } act = eParameters.QueryString("act"); if (act.Length == 0) { act = eParameters.Request("act").ToLower(); } if (act.Length == 0) { return; } parentID = eParameters.QueryString("id"); eUser user = new eUser(UserArea); switch (act) { case "save": #region 保存 eTable tb = new eTable("Demo_Customs_PartOne", user); string json = eParameters.Form("eformdata_" + parentModelID); eJson jmodel = new eJson(json); jmodel.Convert = true; jmodel = jmodel.GetCollection("eformdata_" + parentModelID); eJson jrow = jmodel.Collection[0]; tb.Fields.Add("DZ", jrow.GetValue("ma_f1")); tb.Fields.Add("gddh", jrow.GetValue("ma_f2")); string tmp = jrow.GetValue("id"); if (tmp.Length > 0) { parentID = tmp; } string id = eOleDB.getValue("select PartOneID from Demo_Customs_PartOne where CustomID='" + parentID + "'"); if (id.Length == 0) { tb.Fields.Add("CustomID", parentID); tb.Add(); } else { tb.Where.Add("CustomID='" + parentID + "'"); tb.Update(); } #endregion break; case "del": eTable etb = new eTable("Demo_Customs_PartOne", user); etb.Where.Add("CustomID='" + parentID + "'"); etb.Delete(); break; default: #region 读取 DataTable dt = eOleDB.getDataTable("select dz,gddh from Demo_Customs_PartOne where CustomID='" + parentID + "' and delTag=0"); if (dt.Rows.Count > 0) { dz = dt.Rows[0]["DZ"].ToString(); gddh = dt.Rows[0]["GDDH"].ToString(); } #endregion break; } }
protected void Page_Load(object sender, EventArgs e) { #region 安全性检查 if (Request.UrlReferrer == null) { Response.End(); } if (Request.Url.Host.ToLower() != Request.UrlReferrer.Host.ToLower() || Request.Url.Port != Request.UrlReferrer.Port) { Response.End(); } #endregion #region 保存文件 if (Request.Form["act"] != null) { HttpPostedFile f = imgFile.PostedFile; if (f.ContentLength > 0) { string dirpath = Server.MapPath("~/") + "upload\\temp\\"; int pos = f.FileName.LastIndexOf("."); string Ext = f.FileName.Substring(pos, f.FileName.Length - pos).ToLower(); if (Ext.ToLower().IndexOf("efw") == -1) { Response.Write("<script>alert('文件格式不正确!');document.location='Models.aspx';</script>"); Response.End(); } string filename = eBase.GetFileName() + Ext; string pathname = dirpath + filename; if (!Directory.Exists(dirpath)) { Directory.CreateDirectory(dirpath); } f.SaveAs(pathname); string _json = eBase.ReadFile(pathname); try { System.IO.File.Delete(pathname); } catch { } eJson json = new eJson(_json); eJson model = json.GetCollection("a_eke_sysModels").Collection[0]; string file = model.GetValue("AspxFile"); string aspxFile = Server.MapPath("~/System/") + file + ".log"; if (json.IsValue("aspxFile")) { string text = json.GetValue("aspxFile"); eBase.WriteFile(aspxFile, text); } string csFile = Server.MapPath("~/System/") + file + ".cs.log"; if (json.IsValue("csFile")) { string text = json.GetValue("csFile"); eBase.WriteFile(csFile, text); } string desFile = Server.MapPath("~/System/") + file + ".designer.cs.log"; if (json.IsValue("desFile")) { string text = json.GetValue("desFile"); eBase.WriteFile(desFile, text); } eOleDB.ImportJson(_json, false); Response.Write("<script>alert('导入成功!');document.location='Models.aspx';</script>"); Response.End(); } } #endregion }
protected void Page_Load(object sender, EventArgs e) { Type type = HttpContext.Current.Handler.GetType();//CurrentHandler System.Reflection.FieldInfo fi = type.GetField("UserArea"); if (fi != null) { UserArea = fi.GetValue(Activator.CreateInstance(type)).ToString(); } act = eParameters.QueryString("act"); if (act.Length == 0) { act = eParameters.Request("act").ToLower(); } parentModelID = eParameters.QueryString("modelid"); parentID = eParameters.QueryString("id"); eUser user = new eUser(UserArea); switch (act) { case "save": #region 保存 string jsonstr = eParameters.Form("eformdata_" + parentModelID); eJson json = new eJson(jsonstr); json.Convert = true; json = json.GetCollection("eformdata_" + parentModelID).GetCollection()[0]; string Roles = json.GetValue("Roles"); eOleDB.Execute("update a_eke_sysUsers set RoleID='" + Roles + "' where UserID='" + parentID + "'"); DataTable rolePower = eBase.getUserPowerDefault(Roles, "", ""); string name = ""; string value = ""; //eBase.Writeln(Roles); //eBase.PrintDataTable(rolePower); //eBase.Writeln(json.ToString()); sql = "select ModelID,MC,Power from a_eke_sysModels where subModel=0 and delTag=0 and Type=1 order by px,addTime"; DataTable tb = eOleDB.getDataTable(sql); foreach (DataRow _dr in tb.Rows) //应用下所有模块 { #region 模块 DataRow row = rolePower.NewRow(); //row["ApplicationID"] = _dr["ApplicationID"].ToString(); row["ModelID"] = _dr["ModelID"].ToString(); for (int i = 0; i < row.Table.Columns.Count; i++) { if (row.Table.Columns[i].ColumnName.ToLower() != "modelid") { row[row.Table.Columns[i].ColumnName] = "false"; } } DataRow[] rows = rolePower.Select("ModelID='" + _dr["ModelID"].ToString() + "'"); if (rows.Length > 0) { row = rows[0]; } DataTable PowerItems = new eJson(_dr["Power"].ToString()).toRows(); #region 角色的权限 eJson rolePowerJson = new eJson(); rolePowerJson.Convert = true; #region 基本权限 foreach (DataRow dr1 in PowerItems.Rows) { if (row.Table.Columns.Contains(dr1["value"].ToString())) { value = row[dr1["value"].ToString()].ToString(); eJson _power = new eJson(); _power.Add(dr1["value"].ToString(), value); rolePowerJson.Add(_power); } } #endregion #region 审批权限 DataTable PowerCheckUpItems = eOleDB.getDataTable("SELECT CheckMC as text,LOWER(CheckCode) as value FROM a_eke_sysCheckUps where ModelID='" + _dr["ModelID"].ToString() + "' and delTag=0 and LEN(CheckMC)>0 and LEN(CheckCode)>0 order by px,addTime"); foreach (DataRow dr1 in PowerCheckUpItems.Rows) { value = row[dr1["value"].ToString()].ToString(); eJson _power = new eJson(); _power.Add(dr1["value"].ToString(), value); rolePowerJson.Add(_power); } #endregion //eBase.Writeln(rolePowerJson.ToString()); #endregion string canList = "0"; string cond = ""; #region 用户自定义权限 eJson selPower = new eJson(); selPower.Convert = true; #region 基本权限 foreach (DataRow dr1 in PowerItems.Rows) { name = "model_" + dr1["value"].ToString() + "_" + _dr["ModelID"].ToString().Replace("-", ""); value = json.GetValue(name); if (value.Length == 0) { value = "false"; } eJson _power = new eJson(); _power.Add(dr1["value"].ToString(), value); selPower.Add(_power); if (dr1["value"].ToString().ToLower() == "list") { canList = value; } // eBase.Writeln(dr1["value"].ToString() + "::" + value); } #endregion #region 审批权限 foreach (DataRow dr1 in PowerCheckUpItems.Rows) { name = "model_" + dr1["value"].ToString() + "_" + _dr["ModelID"].ToString().Replace("-", ""); value = json.GetValue(name); if (value.Length == 0) { value = "false"; } eJson _power = new eJson(); _power.Add(dr1["value"].ToString(), value); selPower.Add(_power); } #endregion //eBase.Writeln(selPower.ToString()); #endregion name = "model_cond_" + _dr["ModelID"].ToString().Replace("-", ""); cond = json.GetValue(name); if (selPower.ToString() == rolePowerJson.ToString() && cond.Length == 0) //与角色的相同 { sql = " delete from a_eke_sysPowers where RoleID is Null and ApplicationID is Null and ModelID='" + _dr["ModelID"].ToString() + "' and UserID='" + parentID + "'"; eOleDB.Execute(sql); //eBase.Writeln( _dr["ModelID"].ToString() + "::" + ":::" + cond.Length.ToString()); } else { sql = "if exists (select * from a_eke_sysPowers Where RoleID is Null and ApplicationID is Null and ModelID='" + _dr["ModelID"].ToString() + "' and UserID='" + parentID + "')"; sql += " update a_eke_sysPowers set delTag=0,canList='" + canList + "',Condition='" + cond + "',power='" + selPower.ToString() + "' where RoleID is Null and ApplicationID is Null and ModelID='" + _dr["ModelID"].ToString() + "' and UserID='" + parentID + "'"; sql += " else "; sql += "insert into a_eke_sysPowers (ApplicationID,ModelID,UserID,canList,Condition,Power) "; sql += " values (NULL,'" + _dr["ModelID"].ToString() + "','" + parentID + "','" + canList + "','" + cond + "','" + selPower.ToString() + "')"; eOleDB.Execute(sql); } #endregion } //eBase.End(); #endregion eBase.clearDataCache("a_eke_sysPowers"); break; case "del": eOleDB.Execute("Update a_eke_sysPowers set delTag=1 where UserId='" + parentID + "' and ApplicationID is null"); eBase.clearDataCache("a_eke_sysPowers"); break; default: string selRoles = eOleDB.getValue("Select RoleID from a_eke_sysUsers Where UserId='" + parentID + "'"); //eBase.Writeln(selRoles); //if (selRoles.Length == 0) selRoles = "";//默认角色 LitRoles.Text = getRoles(selRoles); break; } }
protected void Page_Load(object sender, EventArgs e) { Type type = HttpContext.Current.Handler.GetType();//CurrentHandler System.Reflection.FieldInfo fi = type.GetField("UserArea"); if (fi != null) { UserArea = fi.GetValue(Activator.CreateInstance(type)).ToString(); } act = eParameters.QueryString("act"); if (act.Length == 0) { act = eParameters.Request("act").ToLower(); } if (act.Length == 0) { return; } parentID = eParameters.QueryString("id"); eUser user = new eUser(UserArea); eTable etb; switch (act) { case "save": #region 保存 string jsonstr = eParameters.Form("eformdata_" + parentModelID); eJson json = new eJson(jsonstr); json.Convert = true; json = json.GetCollection("eformdata_" + parentModelID).GetCollection()[0]; json = json.GetCollection("eformdata_" + modelid); foreach (eJson jrow in json.GetCollection()) { string _ID = jrow.GetValue("ID"); string _Delete = jrow.GetValue("Delete"); string _xm = jrow.GetValue("m2_f1"); string _xb = jrow.GetValue("m2_f2"); string _dh = jrow.GetValue("m2_f3"); etb = new eTable("Demo_Customs_PartMore", user); if (_Delete.ToLower() == "true") { etb.Where.Add("PartMoreID='" + _ID + "'"); etb.Delete(); } else { etb.Fields.Add("XM", _xm); etb.Fields.Add("XB", _xb); etb.Fields.Add("DH", _dh); if (_ID.Length == 0) //添加 { etb.Fields.Add("CustomID", parentID); etb.Add(); } else //修改 { etb.Where.Add("PartMoreID='" + _ID + "'"); etb.Update(); } } } #endregion break; case "del": etb = new eTable("Demo_Customs_PartMore", user); etb.Where.Add("CustomID='" + parentID + "'"); etb.Delete(); break; } }
protected void Page_Load(object sender, EventArgs e) { Type type = HttpContext.Current.Handler.GetType();//CurrentHandler System.Reflection.FieldInfo fi = type.GetField("UserArea"); if (fi != null) { UserArea = fi.GetValue(Activator.CreateInstance(type)).ToString(); } act = eParameters.QueryString("act"); if (act.Length == 0) { act = eParameters.Request("act").ToLower(); } if (act.Length == 0) { return; } parentID = eParameters.QueryString("id"); eUser user = new eUser(UserArea); eform = new eForm("Demo_Accessorys", user); eform.AutoRedirect = false; //子模块,记得要关闭自动跳转 eform.AddControl(eFormControlGroup); switch (act) { case "save": #region 保存 string json = eParameters.Form("eformdata_" + parentModelID); eJson jmodel = new eJson(json); jmodel.Convert = true; jmodel = jmodel.GetCollection("eformdata_" + parentModelID); eJson jrow = jmodel.Collection[0]; string tmp = jrow.GetValue("id"); if (tmp.Length > 0) { parentID = tmp; } string id = eOleDB.getValue("select AccessoryID from Demo_Accessorys where DemoID='" + parentID + "' and delTag=0"); if (id.Length > 0) { eform.ID = id; } ma_f1.Value = jrow.GetValue("ma_f1"); ma_f2.Value = jrow.GetValue("ma_f2"); ma_f3.Value = jrow.GetValue("ma_f3"); if (id.Length == 0) { eform.Fields.Add("DemoID", parentID); eform.Add(); } else { eform.Update(); } #endregion break; case "del": eTable etb = new eTable("Demo_Accessorys", user); etb.Where.Add("DemoID='" + parentID + "'"); etb.Delete(); break; default: #region 读取Json string accUrl = eConfig.getString("AccessorysURL"); string virtualPath = eBase.getVirtualPath(); DataTable dt = eOleDB.getDataTable("select sfz,fkb,byz from Demo_Accessorys where DemoID='" + parentID + "' and delTag=0"); if (dt.Rows.Count > 0) { string basepath = accUrl.Length > 0 ? accUrl : virtualPath; if (act == "view" && dt.Rows[0]["sfz"].ToString().Length > 0) { dt.Rows[0]["sfz"] = basepath + dt.Rows[0]["sfz"].ToString(); } if (act == "view" && dt.Rows[0]["fkb"].ToString().Length > 0) { dt.Rows[0]["fkb"] = basepath + dt.Rows[0]["fkb"].ToString(); } if (act == "view" && dt.Rows[0]["byz"].ToString().Length > 0) { dt.Rows[0]["byz"] = basepath + dt.Rows[0]["byz"].ToString(); } eform.Data = dt.Rows[0]; ma_f1.Value = dt.Rows[0]["sfz"].ToString(); ma_f2.Value = dt.Rows[0]["fkb"].ToString(); ma_f3.Value = dt.Rows[0]["byz"].ToString(); sfz = basepath + dt.Rows[0]["sfz"].ToString(); fkb = basepath + dt.Rows[0]["fkb"].ToString(); byz = basepath + dt.Rows[0]["byz"].ToString(); } #endregion break; } }
private void Example1() { StringBuilder sb = new StringBuilder(); #region 例1 sb.Append("<font color=\"#ff0000\"><b>例1:</b></font><br />\r\n"); eJson item = new eJson(); item.Add("Name", "eFrameWork"); item.Add("Version", "V1.0"); sb.Append("生成:" + item.ToString() + "<br />\r\n"); sb.Append("解析:<br />\r\n"); eJson model1 = new eJson(item.ToString()); foreach (string key in model1.GetKeys()) { sb.Append(key + " = " + model1.GetValue(key) + "<br />\r\n"); } #endregion #region 例2 sb.Append("<font color=\"#ff0000\"><b>例2:</b></font><br />\r\n"); eJson json = new eJson(); eJson item1 = new eJson(); item1.Add("Name", "李先生"); item1.Add("Sex", "男"); json.Add(item1); eJson item2 = new eJson(); item2.Add("Name", "韩小姐"); item2.Add("Sex", "女"); json.Add(item2); sb.Append("生成:" + json.ToString() + "<br />\r\n"); sb.Append("解析:<br />\r\n"); eJson model2 = new eJson(json.ToString()); foreach (eJson m in model2.GetCollection()) { foreach (string key in m.GetKeys()) { sb.Append(key + " = " + m.GetValue(key) + "<br>\r\n"); } } #endregion #region 例3 sb.Append("<font color=\"#ff0000\"><b>例3:</b></font><br />\r\n"); eJson itemAll = new eJson(); itemAll.Add("Name", "所有"); itemAll.Add("Items", json); sb.Append("生成:" + itemAll.ToString() + "<br />\r\n"); sb.Append("解析:<br />\r\n"); eJson model3 = new eJson(itemAll.ToString()); foreach (string key in model3.GetKeys()) { if (model3.IsValue(key)) { sb.Append(key + " = " + model3.GetValue(key) + "<br />\r\n"); } if (model3.IsCollection(key)) { sb.Append(key + ":<br>"); foreach (eJson m in model3.GetCollection(key).GetCollection()) { foreach (string key1 in m.GetKeys()) { sb.Append(key1 + " = " + m.GetValue(key1) + "<br>\r\n"); } } } } #endregion #region 例4 #endregion litSingle1.Text = sb.ToString(); }