예제 #1
0
        private void showError(string message)
        {
            eJson json = new eJson();

            json.Add("errcode", "1");
            json.Add("message", message);
            Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            Response.Write(json.ToString());
            Response.End();
        }
예제 #2
0
        //this.Context.Request
        //[WebMethod(Description = "读取信息", EnableSession = true)]
        private eJson CheckUserInfo(string _json)
        {
            eJson js   = new eJson();
            eJson json = new eJson(_json);

            json.Convert = true;

            string UserName = json.GetValue("UserName");
            string PassWord = json.GetValue("PassWord");

            if (UserName.Length == 0 || PassWord.Length == 0)
            {
                js.Add("success", "0");
                js.Add("message", "用户验证信息不完整!");
                return(js);
            }

            string    sql = "Select top 1 UserID,YHM,MM From a_eke_sysUsers Where delTag=0 and Active=1 and YHM='" + UserName + "'";
            DataTable tb  = eOleDB.getDataTable(sql);

            if (tb.Rows.Count == 0)
            {
                js.Add("success", "0");
                js.Add("message", "用户验证信息不正确!");
                return(js);
            }
            if (eBase.GetMD5(PassWord, 16) == tb.Rows[0]["mm"].ToString() || PassWord == tb.Rows[0]["mm"].ToString())
            {
                js.Add("success", "1");
                js.Add("message", "验证3成功!");
                eUser user = new eUser("eWebService");
                user["id"]   = tb.Rows[0]["UserID"].ToString();
                user["name"] = tb.Rows[0]["YHM"].ToString();
                user.Save();
                return(js);
            }
            else
            {
                js.Add("success", "0");
                js.Add("message", "用户验证信息不正确!");
                return(js);
            }
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string accUrl = eConfig.getString("AccessorysURL");

            #region 安全性检查
            //1.WebAPI用户放行
            //2.同一来源放行
            //3.来源被授权时放行
            if (Request.Headers["auth"] != null) //WebAPI访问
            {
                string auth  = Request.Headers["auth"].ToString();
                eToken token = new eToken(auth);
                eUser  user  = new eUser(token);
            }
            else
            {
                if (Request.UrlReferrer == null) //无来源页面
                {
                    eJson ErrJson = new eJson();
                    ErrJson.Add("errcode", "1012");
                    ErrJson.Add("message", "访问未被许可!");
                    eBase.WriteJson(ErrJson);
                }
                else
                {
                    if (Request.Url.Host.ToLower() != Request.UrlReferrer.Host.ToLower() && accUrl.ToLower().IndexOf(Request.UrlReferrer.Host.ToLower()) == -1) //不是同一站点访问
                    {
                        DataRow[] rows = eBase.a_eke_sysAllowDomain.Select("Domain='" + Request.UrlReferrer.Host + "'");
                        if (rows.Length == 0)
                        {
                            eJson json = new eJson();
                            json.Add("domain", Request.UrlReferrer.Host);

                            eTable tb = new eTable("a_eke_sysErrors");
                            tb.Fields.Add("URL", Request.UrlReferrer.AbsoluteUri);
                            tb.Fields.Add("Message", "未授权访问!");
                            tb.Fields.Add("StackTrace", json.ToString());
                            tb.Add();

                            eJson ErrJson = new eJson();
                            ErrJson.Add("errcode", "1012");
                            ErrJson.Add("message", "访问未被许可!");
                            eBase.WriteJson(ErrJson);
                        }
                    }
                }
            }
            #endregion
            if (Request.UrlReferrer != null)
            {
                if (Request.UrlReferrer.Host.ToLower() != Request.Url.Host.ToLower())
                {
                    formhost = Request.UrlReferrer.Host.ToString();
                }
            }
            int PictureMaxWidth = 0;
            if (Request.QueryString["PictureMaxWidth"] != null)
            {
                PictureMaxWidth = Convert.ToInt32(Request.QueryString["PictureMaxWidth"]);
            }
            if (Request.QueryString["MaxWidth"] != null)
            {
                PictureMaxWidth = Convert.ToInt32(Request.QueryString["MaxWidth"]);
            }

            int ThumbWidth = 0;
            if (Request.QueryString["ThumbWidth"] != null)
            {
                ThumbWidth = Convert.ToInt32(Request.QueryString["ThumbWidth"]);
            }
            string dirpath = Server.MapPath("~/");
            #region 编辑器上传文件
            if (Request.QueryString["postdata"] != null)
            {
                string postdata = Request.QueryString["postdata"].ToString();
                postdata = HttpUtility.UrlDecode(postdata);
                postdata = postdata.Replace("0x2f", "/").Replace("0x2b", "+").Replace("0x20", " ");
                Response.Write(postdata);
                Response.End();
            }
            if (Request.QueryString["type"] != null)
            {
                #region 附件上传
                if (Request.QueryString["type"].ToLower() == "file")
                {
                    dirpath += "upload\\temp\\";
                    eJson json = new eJson();
                    json.Convert = true;
                    json.Add("errcode", "0");
                    json.Add("message", "请求成功!");


                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        HttpPostedFile f            = Request.Files[i];
                        int            pos          = f.FileName.LastIndexOf(".");
                        string         postFileName = f.FileName.Substring(pos, f.FileName.Length - pos).ToLower();

                        String fileExt  = Path.GetExtension(f.FileName).ToLower();
                        string filename = eBase.GetFileName() + postFileName;
                        string pathname = dirpath + filename;
                        while (File.Exists(pathname))
                        {
                            filename = eBase.GetFileName() + postFileName;
                            pathname = dirpath + filename;
                        }
                        if (!Directory.Exists(dirpath))
                        {
                            Directory.CreateDirectory(dirpath);
                        }
                        f.SaveAs(pathname);
                        eFileInfo finfo = new eFileInfo(filename);
                        filename = eBase.getBaseURL() + "upload/temp/" + filename;
                        eJson js = new eJson();
                        js.Add("name", f.FileName);
                        js.Add("url", filename);
                        json.Add("files", js);
                    }
                    // eBase.WriteJson(json);//IE解析有问题:文档的顶层无效
                    Response.Clear();
                    Response.Write(json.ToString());
                    Response.End();
                }
                #endregion
                #region 图片上传
                string allExt = ".gif.jpg.jpeg.bmp.png";
                if (Request.QueryString["type"].ToLower() == "image")
                {
                    if (Request.Files.Count == 0)
                    {
                        showError("请选择文件!");
                    }
                    dirpath += "upload\\temp\\";
                    #region bak

                    /*
                     * HttpPostedFile f = Request.Files["imgFile"];
                     * if (f == null) showError("请选择文件。");
                     * int pos = f.FileName.LastIndexOf(".");
                     * string postFileName = f.FileName.Substring(pos, f.FileName.Length - pos).ToLower();
                     *
                     * String fileExt = Path.GetExtension(f.FileName).ToLower();
                     * string filename = eBase.GetFileName() + postFileName;
                     * string pathname = dirpath + filename;
                     * while (File.Exists(pathname))
                     * {
                     *  filename = eBase.GetFileName() + postFileName;
                     *  pathname = dirpath + filename;
                     * }
                     * if (!Directory.Exists(dirpath)) Directory.CreateDirectory(dirpath);
                     * f.SaveAs(pathname);
                     *
                     * filename = ePicture.AutoHandle(pathname, PictureMaxWidth);
                     * //filename = "../upload/temp/" + filename;
                     * filename = eBase.getBaseURL() + "upload/temp/" + filename;
                     * //if (fileExt == ".bmp" || fileExt == ".tif" || fileExt == ".jpeg" || fileExt == ".png")
                     *
                     * eJson json = new eJson();
                     * json.Add("errcode", "0");
                     * json.Add("url", filename);
                     * eBase.WriteJson(json);
                     */
                    #endregion


                    eJson json = new eJson();
                    json.Convert = true;
                    json.Add("errcode", "0");
                    json.Add("message", "请求成功!");

                    //string filenames = "";
                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        HttpPostedFile f            = Request.Files[i];
                        int            pos          = f.FileName.LastIndexOf(".");
                        string         postFileName = f.FileName.Substring(pos, f.FileName.Length - pos).ToLower();

                        String fileExt  = Path.GetExtension(f.FileName).ToLower();
                        string filename = eBase.GetFileName() + postFileName;
                        string pathname = dirpath + filename;
                        while (File.Exists(pathname))
                        {
                            filename = eBase.GetFileName() + postFileName;
                            pathname = dirpath + filename;
                        }
                        if (!Directory.Exists(dirpath))
                        {
                            Directory.CreateDirectory(dirpath);
                        }
                        f.SaveAs(pathname);
                        filename = ePicture.AutoHandle(pathname, PictureMaxWidth);
                        eFileInfo finfo = new eFileInfo(filename);
                        #region 缩略图
                        if (ThumbWidth > 0 && allExt.IndexOf("." + finfo.Extension.ToLower()) > -1)
                        {
                            pathname = dirpath + filename;
                            eFileInfo fi            = new eFileInfo(dirpath + filename);
                            string    thumbpathname = dirpath + fi.Name + "_thumb." + fi.Extension;
                            System.IO.File.Copy(pathname, thumbpathname);
                            ePicture.ToWidth(thumbpathname, ThumbWidth);

                            filename = eBase.getBaseURL() + "upload/temp/" + fi.Name + "_thumb." + fi.Extension;
                        }
                        else
                        {
                            filename = eBase.getBaseURL() + "upload/temp/" + filename;
                        }
                        #endregion
                        #region 日志
                        if (writeLog)
                        {
                            eTable etb = new eTable("a_eke_sysErrors");
                            etb.Fields.Add("Message", "upload");
                            eJson _json = new eJson();
                            _json.Add("filename", f.FileName);
                            _json.Add("size", f.ContentLength.ToString());
                            _json.Add("path", "upload/" + string.Format("{0:yyyy/MM/dd}", DateTime.Now) + "/" + filename);
                            etb.Fields.Add("StackTrace", _json.ToString());
                            etb.Add();
                        }
                        #endregion

                        //if (filenames.Length > 0) filenames += ";";
                        //filenames += filename;
                        eJson js = new eJson();
                        js.Add("url", filename);
                        json.Add("files", js);
                    }

                    //json.Add("url", HttpUtility.UrlEncode(filenames));
                    if (Request.Url.Host.ToLower() != Request.UrlReferrer.Host.ToLower())
                    {
                        string postdata = json.ToString().Replace("/", "0x2f").Replace("+", "0x2b").Replace(" ", "0x20");
                        postdata = HttpUtility.UrlEncode(postdata);
                        Response.Redirect("http://" + Request.UrlReferrer.Host + "/Plugins/ProUpload.aspx?postdata=" + postdata, true);
                    }
                    else
                    {
                        //eBase.WriteJson(json); //IE解析有问题:文档的顶层无效
                        Response.Clear();
                        Response.Write(json.ToString());
                        Response.End();
                    }
                    Response.End();
                }
                #endregion
                #region Flash上传
                if (Request.QueryString["type"].ToLower() == "flash")
                {
                    HttpPostedFile f = Request.Files["flaFile"];
                    if (f == null)
                    {
                        showError("请选择文件。");
                    }
                    if (f.InputStream.Length == 0)
                    {
                        showError("请选择文件!");                          // showError(f.InputStream.Length.ToString());
                    }
                    dirpath += "upload\\temp\\";
                    int    pos          = f.FileName.LastIndexOf(".");
                    string postFileName = f.FileName.Substring(pos, f.FileName.Length - pos).ToLower();

                    String fileExt  = Path.GetExtension(f.FileName).ToLower();
                    string filename = eBase.GetFileName() + postFileName;
                    string pathname = dirpath + filename;
                    while (File.Exists(pathname))
                    {
                        filename = eBase.GetFileName() + postFileName;
                        pathname = dirpath + filename;
                    }
                    if (!Directory.Exists(dirpath))
                    {
                        Directory.CreateDirectory(dirpath);
                    }
                    f.SaveAs(pathname);

                    #region 日志
                    if (writeLog)
                    {
                        eTable etb = new eTable("a_eke_sysErrors");
                        etb.Fields.Add("Message", "upload");
                        eJson _json = new eJson();
                        _json.Add("filename", f.FileName);
                        _json.Add("size", f.ContentLength.ToString());
                        _json.Add("path", "upload/" + string.Format("{0:yyyy/MM/dd}", DateTime.Now) + "/" + filename);
                        etb.Fields.Add("StackTrace", _json.ToString());
                        etb.Add();
                    }
                    #endregion

                    //filename = ePicture.AutoHandle(pathname, PictureMaxWidth);
                    //filename = "../upload/temp/" + filename;
                    filename = eBase.getBaseURL() + "upload/temp/" + filename;
                    //if (fileExt == ".bmp" || fileExt == ".tif" || fileExt == ".jpeg" || fileExt == ".png")

                    string id = Request["id"].Trim();           //kindeditor控件的id
                    //string title = Path.GetFileName(fileName).Trim();   //文件名称(原名陈)
                    //string ext = fileExt.Substring(1).ToLower().Trim(); //文件后缀名

                    string w = Request["flaWidth"].Trim();
                    string h = Request["flaHeight"].Trim();
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    Response.Charset = "UTF-8";
                    sb.Append("<html>");
                    sb.Append("<head>");
                    sb.Append("<title>Insert Flash</title>");
                    sb.Append("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">");
                    sb.Append("</head>");
                    sb.Append("<body>");
                    sb.Append("<script type=\"text/javascript\">parent.KE.plugin[\"newflash\"].insert(\"" + id + "\", \"" + filename + "\",\"" + w + "\",\"" + h + "\");</script>");
                    sb.Append("</body>");
                    sb.Append("</html>");

                    if (Request.Url.Host.ToLower() != Request.UrlReferrer.Host.ToLower())
                    {
                        string postdata = "<script type=\"text/javascript\">parent.KE.plugin[\"newmedia\"].insert(\"" + id + "\", \"" + filename + "\",\"" + w + "\",\"" + h + "\");</script>";
                        postdata = postdata.Replace("/", "0x2f").Replace("+", "0x2b").Replace(" ", "0x20");
                        postdata = HttpUtility.UrlEncode(postdata);
                        Response.Redirect("http://" + Request.UrlReferrer.Host + "/Plugins/ProUpload.aspx?postdata=" + postdata, true);
                    }
                    else
                    {
                        Response.Write(sb.ToString());
                    }
                    Response.End();
                }
                #endregion
                #region 媒体上传
                if (Request.QueryString["type"].ToLower() == "media")
                {
                    HttpPostedFile f = Request.Files["flaFile"];
                    if (f == null)
                    {
                        showError("请选择文件。");
                    }
                    if (f.InputStream.Length == 0)
                    {
                        showError("请选择文件!");
                    }
                    dirpath += "upload\\temp\\";
                    int    pos          = f.FileName.LastIndexOf(".");
                    string postFileName = f.FileName.Substring(pos, f.FileName.Length - pos).ToLower();

                    String fileExt  = Path.GetExtension(f.FileName).ToLower();
                    string filename = eBase.GetFileName() + postFileName;
                    string pathname = dirpath + filename;
                    while (File.Exists(pathname))
                    {
                        filename = eBase.GetFileName() + postFileName;
                        pathname = dirpath + filename;
                    }
                    if (!Directory.Exists(dirpath))
                    {
                        Directory.CreateDirectory(dirpath);
                    }
                    f.SaveAs(pathname);

                    #region 日志
                    if (writeLog)
                    {
                        eTable etb = new eTable("a_eke_sysErrors");
                        etb.Fields.Add("Message", "upload");
                        eJson _json = new eJson();
                        _json.Add("filename", f.FileName);
                        _json.Add("size", f.ContentLength.ToString());
                        _json.Add("path", "upload/" + string.Format("{0:yyyy/MM/dd}", DateTime.Now) + "/" + filename);
                        etb.Fields.Add("StackTrace", _json.ToString());
                        etb.Add();
                    }
                    #endregion

                    //filename = ePicture.AutoHandle(pathname, PictureMaxWidth);
                    //filename = "../upload/temp/" + filename;
                    filename = eBase.getBaseURL() + "upload/temp/" + filename;
                    //if (fileExt == ".bmp" || fileExt == ".tif" || fileExt == ".jpeg" || fileExt == ".png")

                    string id = Request["id"].Trim();           //kindeditor控件的id
                    //string title = Path.GetFileName(fileName).Trim();   //文件名称(原名陈)
                    //string ext = fileExt.Substring(1).ToLower().Trim(); //文件后缀名

                    string w = Request["flaWidth"].Trim();
                    string h = Request["flaHeight"].Trim();
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    Response.Charset = "UTF-8";
                    sb.Append("<html>");
                    sb.Append("<head>");
                    sb.Append("<title>Insert Media</title>");
                    sb.Append("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">");
                    sb.Append("</head>");
                    sb.Append("<body>");
                    sb.Append("<script type=\"text/javascript\">parent.KE.plugin[\"newmedia\"].insert(\"" + id + "\", \"" + filename + "\",\"" + w + "\",\"" + h + "\");</script>");
                    sb.Append("</body>");
                    sb.Append("</html>");
                    Response.Write(sb.ToString());
                    Response.End();
                }
                #endregion
                #region 附件上传
                if (Request.QueryString["type"].ToLower() == "accessory")
                {
                    HttpPostedFile f = Request.Files["imgFile"];
                    if (f == null)
                    {
                        showError("请选择文件。");
                    }
                    if (f.InputStream.Length == 0)
                    {
                        showError("请选择文件!");
                    }
                    dirpath += "upload\\temp\\";
                    int    pos          = f.FileName.LastIndexOf(".");
                    string postFileName = f.FileName.Substring(pos, f.FileName.Length - pos).ToLower();

                    String fileExt  = Path.GetExtension(f.FileName).ToLower();
                    string filename = eBase.GetFileName() + postFileName;
                    string pathname = dirpath + filename;
                    while (File.Exists(pathname))
                    {
                        filename = eBase.GetFileName() + postFileName;
                        pathname = dirpath + filename;
                    }
                    if (!Directory.Exists(dirpath))
                    {
                        Directory.CreateDirectory(dirpath);
                    }
                    f.SaveAs(pathname);

                    #region 日志
                    if (writeLog)
                    {
                        eTable etb = new eTable("a_eke_sysErrors");
                        etb.Fields.Add("Message", "upload");
                        eJson _json = new eJson();
                        _json.Add("filename", f.FileName);
                        _json.Add("size", f.ContentLength.ToString());
                        _json.Add("path", "upload/" + string.Format("{0:yyyy/MM/dd}", DateTime.Now) + "/" + filename);
                        etb.Fields.Add("StackTrace", _json.ToString());
                        etb.Add();
                    }
                    #endregion


                    //filename = ePicture.AutoHandle(pathname, PictureMaxWidth);
                    //filename = "../upload/temp/" + filename;
                    filename = eBase.getBaseURL() + "upload/temp/" + filename;
                    //if (fileExt == ".bmp" || fileExt == ".tif" || fileExt == ".jpeg" || fileExt == ".png")

                    string id    = Request["id"].Trim();                  //kindeditor控件的id
                    string title = Path.GetFileName(filename).Trim();     //文件名称(原名陈)
                    string ext   = fileExt.Substring(1).ToLower().Trim(); //文件后缀名
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    Response.Charset = "UTF-8";
                    sb.Append("<html>");
                    sb.Append("<head>");
                    sb.Append("<title>Insert Accessory</title>");
                    sb.Append("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">");
                    sb.Append("</head>");
                    sb.Append("<body>");
                    sb.Append("<script type=\"text/javascript\">parent.KE.plugin[\"accessory\"].insert(\"" + id + "\", \"" + filename + "\",\"" + title + "\",\"" + ext + "\");</script>");
                    sb.Append("</body>");
                    sb.Append("</html>");

                    if (Request.Url.Host.ToLower() != Request.UrlReferrer.Host.ToLower())
                    {
                        string postdata = "<script type=\"text/javascript\">parent.KE.plugin[\"accessory\"].insert(\"" + id + "\", \"" + filename + "\",\"" + title + "\",\"" + ext + "\");</script>";
                        postdata = postdata.Replace("/", "0x2f").Replace("+", "0x2b").Replace(" ", "0x20");
                        postdata = HttpUtility.UrlEncode(postdata);
                        Response.Redirect("http://" + Request.UrlReferrer.Host + "/Plugins/ProUpload.aspx?postdata=" + postdata, true);
                    }
                    else
                    {
                        Response.Write(sb.ToString());
                    }
                    Response.End();
                }
                #endregion
            }
            #endregion
            if (Request.QueryString["act"] != null)
            {
                #region 获取大小
                if (Request.QueryString["act"].ToLower() == "getsize")
                {
                    string filename = Request.QueryString["file"].ToString();
                    int    ow       = 0;
                    int    oh       = 0;
                    if (filename.ToLower().IndexOf("http") > -1)
                    {
                        filename = filename.Replace(eBase.getBaseURL(), "");
                    }
                    string[] arr    = filename.Split(".".ToCharArray());
                    string   ext    = arr[arr.Length - 1].ToLower();
                    string   allExt = ".gif.jpg.jpeg.bmp.png";
                    if (allExt.IndexOf(ext) > -1)
                    {
                        filename = dirpath + filename.Replace("../", "").Replace("/", "\\");
                        if (System.IO.File.Exists(filename))
                        {
                            try
                            {
                                System.Drawing.Image img = System.Drawing.Image.FromFile(filename);
                                ow = img.Width;
                                oh = img.Height;
                                img.Dispose();
                            }
                            catch { }
                        }
                    }
                    eJson json = new eJson();
                    json.Add("width", ow.ToString());
                    json.Add("height", oh.ToString());
                    eBase.WriteJson(json);
                }
                #endregion
                #region  载网络文件
                if (Request.QueryString["act"].ToLower() == "down")
                {
                    string   file = Request.QueryString["file"].ToString();
                    string[] arr  = file.Split(".".ToCharArray());
                    string   ext  = "." + arr[arr.Length - 1];

                    string virtualDir = eConfig.UploadPath();
                    string basePath   = HttpContext.Current.Server.MapPath("~/");
                    basePath += virtualDir.Replace("/", "\\");
                    if (!Directory.Exists(basePath))
                    {
                        Directory.CreateDirectory(basePath);
                    }

                    string filename = eBase.GetFileName() + ext;
                    string savepath = basePath + filename;

                    eJson json = new eJson();
                    System.Net.WebClient wc = new System.Net.WebClient();
                    try
                    {
                        wc.DownloadFile(file, savepath);
                        wc.Dispose();
                        json.Add("url", eBase.getBaseURL() + virtualDir + filename);
                    }
                    catch
                    {
                        json.Add("url", file);
                    }

                    Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                    Response.Write(json.ToString());
                    Response.End();
                }
                #endregion
                #region  除正式文件
                if (Request.QueryString["act"].ToLower() == "deltrue")
                {
                    string filename = Request.QueryString["file"].ToString();
                    filename = Regex.Replace(filename, eBase.getBaseURL(), "", RegexOptions.IgnoreCase);
                    filename = dirpath + filename.Replace("../", "").Replace("/", "\\");
                    try
                    {
                        System.IO.File.Delete(filename);
                        System.IO.File.Delete(filename.Replace(".", "_sm."));
                    }
                    catch
                    {
                    }
                    Response.End();
                }
                #endregion
                #region 临时文件移动到正式文件夹下
                if (Request.QueryString["act"].ToLower() == "move")
                {
                    string file = Request.QueryString["file"].ToString();
                    file = Regex.Replace(file, eBase.getBaseURL(), "", RegexOptions.IgnoreCase);
                    string basePath = HttpContext.Current.Server.MapPath("~/");
                    string temppath = basePath + file.Replace("/", "\\");
                    eJson  json     = new eJson();
                    if (File.Exists(temppath) && file.ToLower().IndexOf("/temp/") > -1)
                    {
                        string[] arr        = temppath.Split("\\".ToCharArray());
                        string   filename   = arr[arr.Length - 1];
                        string   virtualDir = eConfig.UploadPath();
                        basePath += virtualDir.Replace("/", "\\");
                        if (!Directory.Exists(basePath))
                        {
                            Directory.CreateDirectory(basePath);
                        }
                        string newpath = basePath + filename;
                        File.Move(temppath, newpath);
                        //eBase.Writeln("newpath1:" + virtualDir + filename);
                        json.Add("url", eBase.getBaseURL() + virtualDir + filename);
                    }
                    else
                    {
                        json.Add("url", file);
                    }

                    Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                    Response.Write(json.ToString());
                    Response.End();
                }
                #endregion
                #region   完成
                if (Request.QueryString["act"].ToLower() == "finsh")
                {
                    if (Request.QueryString["sub"] != null)
                    {
                        Response.Write("<script>try{parent.document.getElementById('" + Request.QueryString["obj"].ToString() + "').value='" + Request.QueryString["file"].ToString() + "';}catch(e){}</script>");
                    }


                    Response.Write("<font color='#009900'>上传成功!</font><a style='line-height:22px;display:inline-block;margin-left:10px;margin-right:18px;text-decoration:none;' href='?act=del&obj=" + Request.QueryString["obj"].ToString() + "&PictureMaxWidth=" + PictureMaxWidth.ToString() + "&file=" + Request.QueryString["file"].ToString() + "' onclick='return del();'><font color='#FF0000'>删除重新上传?</font></a>");
                    string filename = Request.QueryString["file"].ToString();
                    if (filename.ToLower().IndexOf("http") > -1)
                    {
                        filename = filename.Replace(eBase.getBaseURL(), "");
                    }
                    string[] arr    = filename.Split(".".ToCharArray());
                    string   ext    = arr[arr.Length - 1].ToLower();
                    string   allExt = ".gif.jpg.jpeg.bmp.png";
                    //eBase.Write(allExt.IndexOf(ext).ToString());
                    if (allExt.IndexOf(ext) > -1)
                    {
                        int ow = 0;
                        int oh = 0;
                        if (Request.QueryString["ow"] != null)
                        {
                            ow = Convert.ToInt32(Request.QueryString["ow"].ToString());
                        }
                        if (Request.QueryString["oh"] != null)
                        {
                            oh = Convert.ToInt32(Request.QueryString["oh"].ToString());
                        }
                        filename = dirpath + filename.Replace("../", "").Replace("/", "\\");
                        if (System.IO.File.Exists(filename))
                        {
                            try
                            {
                                System.Drawing.Image img = System.Drawing.Image.FromFile(filename);
                                ow = img.Width;
                                oh = img.Height;
                                img.Dispose();
                            }
                            catch { }
                        }
                        else
                        {
                            if (accUrl.Length > 0)
                            {
                                string url    = accUrl + "Plugins/ProUpload.aspx?act=getsize&obj=" + Request.QueryString["obj"].ToString() + "&PictureMaxWidth=" + PictureMaxWidth.ToString() + "&file=" + Request.QueryString["file"].ToString();
                                string result = eBase.getRequest(url);
                                if (result.StartsWith("{"))
                                {
                                    eJson json = new eJson(result);
                                    ow = Convert.ToInt32(json.GetValue("width"));
                                    oh = Convert.ToInt32(json.GetValue("height"));
                                }
                            }
                        }
                        if (ow > 0)
                        {
                            Response.Write("<img src=\"" + eBase.getAbsolutePath() + "images/view.jpg\" width=\"12\" height=\"12\" style=\"cursor:pointer;\" alt=\"查看图片\" onclick=\"parent.viewImage('" + Request.QueryString["file"].ToString() + "'," + ow.ToString() + "," + oh.ToString() + ");\" align=\"absmiddle\" />");
                        }

                        /*
                         * else
                         * {
                         * ow = 400;
                         * oh = 300;
                         * Response.Write("<img src=\"" + eBase.getAbsolutePath() + "images/view.jpg\" width=\"12\" height=\"12\" style=\"cursor:pointer;\" alt=\"查看图片\" onclick=\"parent.viewImage('" + Request.QueryString["file"].ToString() + "'," + ow.ToString() + "," + oh.ToString() + ");\" align=\"absmiddle\" />");
                         * }
                         */
                    }
                }
                #endregion
                #region  除临时文件
                if (Request.QueryString["act"].ToLower() == "del")
                {
                    string filename = Request.QueryString["file"].ToString();
                    filename = Regex.Replace(filename, eBase.getBaseURL(), "", RegexOptions.IgnoreCase);
                    //filename = Server.MapPath(filename);
                    filename = dirpath + filename.Replace("../", "").Replace("/", "\\");


                    //只删除临时文件,防止删除正式文件且不保存。
                    if (filename.ToLower().IndexOf("\\temp\\") > -1 && filename.ToLower().IndexOf("http:") == -1)
                    {
                        //System.IO.File.Exists
                        try
                        {
                            System.IO.File.Delete(filename);
                            System.IO.File.Delete(filename.Replace(".", "_sm."));
                            System.IO.File.Delete(filename.Replace("_thumb", ""));
                        }
                        catch
                        {
                        }
                    }
                    if (filename.IndexOf("_thumb") > -1)
                    {
                        Response.End();
                    }
                    if (accUrl.Length > 0)
                    {
                        string url    = accUrl + "Plugins/ProUpload.aspx?act=del&obj=" + Request.QueryString["obj"].ToString() + "&PictureMaxWidth=" + PictureMaxWidth.ToString() + "&file=" + Request.QueryString["file"].ToString();
                        string result = eBase.getRequest(url);
                        Response.Write("<script>try{parent.document.getElementById('" + Request.QueryString["obj"].ToString() + "').value='';}catch(e){}\r\ndocument.location='" + accUrl + "Plugins/ProUpload.aspx?obj=" + Request.QueryString["obj"].ToString() + "&PictureMaxWidth=" + PictureMaxWidth.ToString() + "';</script>");
                    }
                    else
                    {
                        Response.Write("<script>try{parent.document.getElementById('" + Request.QueryString["obj"].ToString() + "').value='';}catch(e){}\r\ndocument.location='ProUpload.aspx?obj=" + Request.QueryString["obj"].ToString() + "&PictureMaxWidth=" + PictureMaxWidth.ToString() + "';</script>");
                    }
                    Response.End();
                }
                #endregion
            }
            if (Request.Form["act"] != null)
            {
                #region 保存文件
                HttpPostedFile f = imgFile.PostedFile;
                if (f.ContentLength > 0)
                {
                    dirpath += "upload\\temp\\";
                    int    pos          = f.FileName.LastIndexOf(".");
                    string postFileName = f.FileName.Substring(pos, f.FileName.Length - pos).ToLower();
                    //if (postFileName.IndexOf(".mp4") > -1) postFileName = ".webm";
                    if (1 == 1)//if (".gif.jpg.bmp.flv".IndexOf(postFileName) > -1)
                    {
                        string filename = eBase.GetFileName() + postFileName;
                        string pathname = dirpath + filename;
                        while (File.Exists(pathname))
                        {
                            filename = eBase.GetFileName() + postFileName;
                            pathname = dirpath + filename;
                        }
                        if (!Directory.Exists(dirpath))
                        {
                            Directory.CreateDirectory(dirpath);
                        }
                        f.SaveAs(pathname);

                        filename = ePicture.AutoHandle(pathname, PictureMaxWidth);
                        int    ow     = 0;
                        int    oh     = 0;
                        string allExt = ".gif.jpg.jpeg.bmp.png";
                        if (allExt.IndexOf(postFileName.ToLower()) > -1)
                        {
                            try
                            {
                                System.Drawing.Image img = System.Drawing.Image.FromFile(pathname);
                                ow = img.Width;
                                oh = img.Height;
                                img.Dispose();
                            }
                            catch { }
                        }
                        #region 日志
                        if (writeLog)
                        {
                            eTable etb = new eTable("a_eke_sysErrors");
                            etb.Fields.Add("Message", "upload");
                            eJson _json = new eJson();
                            _json.Add("filename", f.FileName);
                            _json.Add("size", f.ContentLength.ToString());
                            _json.Add("path", "upload/" + string.Format("{0:yyyy/MM/dd}", DateTime.Now) + "/" + filename);
                            etb.Fields.Add("StackTrace", _json.ToString());
                            etb.Add();
                        }
                        #endregion

                        //filename = "../upload/temp/" + filename;
                        filename = eBase.getBaseURL() + "upload/temp/" + filename;
                        // OleDB.Execute("insert into a_eke_sysTemp (uid,path) values ('" + SystemClass.getAdminID() + "','" + filename.Replace("../", "") + "')");

                        if (Request.Form["formhost"].ToString().Length > 0)
                        {
                            Response.Redirect("http://" + Request.Form["formhost"].ToString() + "/Plugins/ProUpload.aspx?act=finsh&sub=true&obj=" + Request.QueryString["obj"].ToString() + "&PictureMaxWidth=" + PictureMaxWidth.ToString() + "&file=" + filename + "&ow=" + ow.ToString() + "&oh=" + oh.ToString(), true);
                        }
                        else
                        {
                            Response.Write("<script>try{eval(\"parent.document.getElementById('" + Request.QueryString["obj"].ToString() + "').value='" + filename + "';\")}catch(e){}</script>");
                            Response.Write("<script>document.location='?act=finsh&obj=" + Request.QueryString["obj"].ToString() + "&PictureMaxWidth=" + PictureMaxWidth.ToString() + "&file=" + filename + "';</script>");
                        }
                        Response.End();
                    }

                    /*
                     * else
                     * {
                     * Response.Write("<script>alert('不支持的文件类型!');document.location='?obj=" + Request.QueryString["obj"].ToString() + "';</script>");
                     * Response.End();
                     * }
                     */
                }
                #endregion
            }
        }
예제 #5
0
        public void edt_onChange(object sender, eFormTableEventArgs e)
        {
            if (e.eventType == eFormTableEventType.Inserting)
            {
                if (user["ServiceID"].Length > 0)
                {
                    edt.Fields.Add("ServiceID", user["ServiceID"]);
                }
            }
            string parentID = e.ID;

            if (e.eventType == eFormTableEventType.Deleted)
            {
                sql = "update a_eke_sysPowers set delTag=1 where UserId='" + parentID + "' and ApplicationID is not null";
                eOleDB.Execute(sql);
            }
            if (e.eventType == eFormTableEventType.Updated || e.eventType == eFormTableEventType.Inserted)
            {
                string    Roles     = edt.Fields["RoleID"].ToString();
                DataTable rolePower = eBase.getUserPowerDefault(Roles, "", "");
                //eBase.Writeln("rolePower:角色的权限");
                //eBase.PrintDataTable(rolePower);

                string name  = "";
                string value = "";


                sql = "select ApplicationID,MC from a_eke_sysApplications where delTag=0 order by px,addTime";
                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);
                //eBase.Writeln("tb:应用下所有模块");
                //eBase.PrintDataTable(tb);

                //continue;
                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];
                    }

                    //eBase.Writeln("row");
                    //eBase.PrintDataRow(row);
                    DataTable PowerItems = new eJson(_dr["Power"].ToString()).toRows();
                    //eBase.Writeln("PowerItems");
                    //eBase.PrintDataTable(PowerItems);

                    #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 = eParameters.Form(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 = eParameters.Form(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 = eParameters.Form(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);
                    }



                    // eBase.Writeln(_dr["ModelID"].ToString() + "::" + value);

                    #endregion
                }
                eBase.clearDataCache("a_eke_sysPowers");
                //eBase.End();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            configName = eOleDB.getValue("select configName from ProductConfigs where ProductConfigID='" + PId + "'");
            string sql = "";

            if (act.Length == 0)
            {
                eList elist = new eList("a_eke_sysCheckUps");
                elist.Where.Add("ModelID='" + PId + "' ");
                elist.OrderBy.Add("px,addTime");
                elist.Bind(Rep);
            }
            else
            {
                #region 获取数据
                if (act == "getdata")
                {
                    Response.Clear();
                    List();
                    System.IO.StringWriter sw  = new System.IO.StringWriter();
                    HtmlTextWriter         htw = new HtmlTextWriter(sw);
                    Rep.RenderControl(htw);
                    Rep.Visible = false;
                    Response.Write(sw.ToString());
                    Response.End();
                }
                #endregion

                #region 流程
                #region 添加
                if (act == "addcheckup")
                {
                    eOleDB.Execute("insert into a_eke_sysCheckUps (ModelID) values ('" + PId + "')");
                    eJson json = new eJson();
                    json.Add("success", "1");
                    json.Add("message", "添加成功");
                    //Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                    Response.Write(json.ToString());
                    Response.End();
                }
                #endregion
                #region 修改动作
                if (act == "setcheckup")
                {
                    //拖动排序
                    if (item.ToLower() == "setorders")
                    {
                        string   ids = eParameters.Form("ids");
                        string[] arr = ids.Split(",".ToCharArray());
                        for (int i = 0; i < arr.Length; i++)
                        {
                            value = (i + 1).ToString();
                            eOleDB.Execute("update a_eke_sysCheckUps set px='" + value + "' where ModelID='" + PId + "' and CheckupID='" + arr[i] + "'");
                        }
                        Response.End();
                    }

                    if (item.ToLower() == "px" && (value.Length == 0 || value == "0"))
                    {
                        value = "999999";
                    }
                    if (item.ToLower() == "backprocess")
                    {
                        value = eBase.decode(value);
                    }
                    eOleDB.Execute("update a_eke_sysCheckUps set " + item + "='" + value + "' where ModelID='" + PId + "' and CheckupID='" + eParameters.QueryString("CheckupID") + "'");
                    Response.End();
                }
                #endregion
                #region   除
                if (act == "delcheckup")
                {
                    eOleDB.Execute("delete from a_eke_sysCheckUps where CheckupID='" + eParameters.QueryString("CheckupID") + "'");
                    Response.End();
                }
                #endregion
                #endregion
            }
        }
예제 #7
0
        protected void Action_Actioning(string Actioning)
        {
            eform         = new eForm("Demo_Persons", user);
            eform.ModelID = ModelID.Replace("-", "_");
            eJson js;

            switch (Actioning)
            {
            case "":
                List();
                break;

            case "show":    //是否显示
                if (!Convert.ToBoolean(model.Power["show"]))
                {
                    eBase.Write("<script>alert('没有权限!');history.back();</script>");
                    eBase.End();
                }
                string sql = eParameters.Replace("update Demo_Persons set show='{querystring:value}' where ID='{querystring:id}'", null, null);
                eOleDB.Execute(sql);
                Response.Redirect(Request.ServerVariables["HTTP_REFERER"] == null ? "Default.aspx" : Request.ServerVariables["HTTP_REFERER"].ToString(), true);
                eBase.End();
                break;

            case "removesearch":
                #region  除搜索条件
                sql = "delete from a_eke_sysUserCustoms where UserCustomID='" + eParameters.QueryString("removeid") + "'";
                eOleDB.Execute(sql);
                eBase.clearDataCache("a_eke_sysUserCustoms");
                js = new eJson();
                js.Add("success", "1");
                js.Add("message", "删除成功!");
                js.Add("html", eBase.encode(model.getSearchFilter()));
                HttpContext.Current.Response.Clear();
                eBase.Write(js.ToString());
                eBase.End();
                #endregion
                break;

            case "setsearch":
                #region 保存搜索条件
                string ApplicationID = eParameters.QueryString("appid");
                sql  = "if exists (select * from a_eke_sysUserCustoms Where " + (ApplicationID.Length == 0 ? "ApplicationID is null" : "ApplicationID='" + ApplicationID + "'") + " and ModelID='" + ModelID + "' and  UserID='" + user.ID + "' and MC='" + eParameters.QueryString("mc") + "' and parName='search')";
                sql += "update a_eke_sysUserCustoms set parValue='" + eParameters.QueryString("value") + "' where " + (ApplicationID.Length == 0 ? "ApplicationID is null" : "ApplicationID='" + ApplicationID + "'") + " and ModelID='" + ModelID + "' and UserID='" + user.ID + "' and MC='" + eParameters.QueryString("mc") + "'";
                sql += " else ";
                sql += "insert into a_eke_sysUserCustoms (ApplicationID,ModelID,UserID,parName,MC,parValue) ";
                sql += " values (" + (ApplicationID.Length == 0 ? "NULL" : "'" + ApplicationID + "'") + ",'" + ModelID + "','" + user.ID + "','search','" + eParameters.QueryString("mc") + "','" + eParameters.QueryString("value") + "')";
                eOleDB.Execute(sql);
                eBase.clearDataCache("a_eke_sysUserCustoms");
                js = new eJson();
                js.Add("success", "1");
                js.Add("message", "保存成功!");
                js.Add("html", eBase.encode(model.getSearchFilter()));
                HttpContext.Current.Response.Clear();
                eBase.Write(js.ToString());
                eBase.End();
                #endregion
                break;

            default:
                eform.AddControl(eFormControlGroup);
                eform.Handle();
                break;
            }
        }
예제 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string auth = "";

            if (1 == 1)
            {
                if (Request.Headers["auth"] == null)
                {
                    eJson ErrJson = new eJson();
                    ErrJson.Add("errcode", "1");
                    ErrJson.Add("message", "未携带eToKen");
                    eBase.WriteJson(ErrJson);
                }
                auth = Request.Headers["auth"].ToString();

                #region 日志
                if (1 == 1)
                {
                    eTable etb = new eTable("a_eke_sysErrors");
                    etb.Fields.Add("Message", "auth");
                    etb.Fields.Add("StackTrace", auth);
                    etb.Add();
                }
                #endregion
            }
            else
            {
                auth = "06841095ADDB705B76053D24C19BF707ED46C19D50CD552953B29A5B52A40AAD35CD1D9B25C640205D2767CA2C4A97F0A2B98CC48242454E00040655734261D6BFBE7CED29CA8AF766721AEA61ED411113CA840E5959FBCC0002BAB64731467E8705BAB1267CE992C2785DAE905F84C8B54C352C3D87C5D20D2C09DE7DC3F542E2AC6A66D8D1021E4E58051851C86871";
            }



            eToken token = new eToken(auth);
            eUser  user  = new eUser(token);

            eModel model = new eModel(ModelID, user);

            model.Ajax = true;
            model.Mode = "WebAPI";
            switch (model.Action.Value)
            {
            case "":
                model.WebAPIList();
                break;

            case "edit":
                model.WebAPIEdit();
                break;

            case "view":
                model.WebAPIView();
                break;

            case "save":
                model.WebAPISave();
                break;

            case "del":
                model.WebAPIDelete();
                break;
            }
            eBase.End();
        }
예제 #9
0
        private void eform_onChange(object sender, eFormTableEventArgs e)
        {
            DataRow dr;
            string  pid      = "";
            string  oldpid   = "";
            int     oldindex = 0;
            string  maxpx    = "";

            switch (e.eventType)
            {
            case eFormTableEventType.Inserting:
                #region 添加
                string px = eform.Fields["px"].ToString();
                pid   = eform.Fields["ParentID"].ToString();
                maxpx = eOleDB.getValue("select isnull(max(px),0) + 1 from Organizationals where delTag=0 " + (pid.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + pid + "'"));
                if (px == "" || px == "0" || px == "999999" || Convert.ToInt32(px) > Convert.ToInt32(maxpx))
                {
                    eform.Fields["px"] = maxpx;
                }
                else
                {
                    sql = "update Organizationals set PX=PX+1 where delTag=0 " + (pid.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + pid + "'") + " and PX>=" + px;
                    eOleDB.Execute(sql);
                }
                #endregion
                break;

            case eFormTableEventType.Updating:
                #region 修改
                dr       = eOleDB.getDataTable("SELECT * FROM Organizationals where OrganizationalID='" + e.ID + "'").Select()[0];
                pid      = eform.Fields["ParentID"].ToString();
                oldpid   = dr["ParentID"].ToString();
                oldindex = Convert.ToInt32(dr["px"]);
                int index = Convert.ToInt32(eform.Fields["px"]);
                if (pid == oldpid)        //父级不变
                {
                    if (oldindex < index) //小变大
                    {
                        sql = "update Organizationals set PX=PX-1 where delTag=0 " + (pid.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + pid + "'") + " and PX>" + oldindex.ToString() + " and PX<=" + index.ToString();
                        eOleDB.Execute(sql);
                    }
                    else     //大变小
                    {
                        sql = "update Organizationals set PX=PX+1 where delTag=0 " + (pid.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + pid + "'") + " and PX>=" + index.ToString() + " and PX<" + oldindex.ToString();
                        eOleDB.Execute(sql);
                    }
                    maxpx = eOleDB.getValue("select isnull(max(px),0) + 1 from Organizationals where delTag=0 " + (pid.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + pid + "'"));
                    if (index > Convert.ToInt32(maxpx))
                    {
                        eform.Fields["px"] = maxpx;
                    }
                }
                else
                {
                    sql = "update Organizationals set PX=PX-1 where delTag=0 " + (oldpid.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + oldpid + "'") + " and PX>" + oldindex.ToString();
                    eOleDB.Execute(sql);

                    sql = "update Organizationals set PX=PX+1 where delTag=0 " + (pid.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + pid + "'") + " and PX>=" + index.ToString();
                    eOleDB.Execute(sql);

                    maxpx = eOleDB.getValue("select isnull(max(px),0) + 1 from Organizationals where delTag=0 " + (pid.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + pid + "'"));
                    if (index > Convert.ToInt32(maxpx))
                    {
                        eform.Fields["px"] = maxpx;
                    }
                }
                #endregion
                break;

            case eFormTableEventType.Deleting:
                #region  除
                dr       = eOleDB.getDataTable("SELECT * FROM Organizationals where OrganizationalID='" + e.ID + "'").Select()[0];
                oldpid   = dr["ParentID"].ToString();
                oldindex = Convert.ToInt32(dr["px"]);

                sql = "update Organizationals set PX=PX-1 where delTag=0 " + (oldpid.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + oldpid + "'") + " and PX>" + oldindex.ToString();
                eOleDB.Execute(sql);

                sql = "update Organizationals set PX='0' where OrganizationalID='" + e.ID + "'";
                eOleDB.Execute(sql);


                #endregion
                break;

            case eFormTableEventType.Deleted:
                oldpid = eOleDB.getValue("SELECT ParentID FROM Organizationals where OrganizationalID='" + e.ID + "'");

                if (Request.QueryString["ajaxget"] != null)
                {
                    eJson json = new eJson();
                    json.Add("success", "1");
                    json.Add("message", "删除成功!");
                    Response.Clear();
                    Response.Write(json.ToString());
                    Response.End();
                }
                else
                {
                    string url = "Organizationals.aspx?modelid=" + ModelID;
                    if (oldpid.Length > 0)
                    {
                        url += "&act=view&id=" + oldpid;
                    }
                    Response.Redirect(url, true);
                }



                break;
            }
        }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable tb;
            eJson     ErrJson;
            string    sql = "";

            #region 帐号密码登录
            if (Request.Form["username"] != null)
            {
                ErrJson = new eJson();
                sql     = "Select top 1 * From a_eke_sysUsers Where delTag=0 and YHM='" + Request.Form["username"].ToString() + "'"; // and Active=1
                tb      = eOleDB.getDataTable(sql);

                if (tb.Rows.Count == 0)
                {
                    ErrJson.Add("errcode", "1005");
                    ErrJson.Add("message", "登录信息有误!");
                    eBase.WriteJson(ErrJson);
                }
                else
                {
                    #region 禁用处理
                    if (tb.Rows[0]["Active"].ToString().ToLower() == "false")
                    {
                        ErrJson.Add("errcode", "1014");
                        ErrJson.Add("message", "该用户已被禁用!");
                        eBase.WriteJson(ErrJson);
                    }
                    #endregion
                    if (eBase.GetMD5(Request.Form["password"].ToString(), 16) == tb.Rows[0]["mm"].ToString())
                    {
                        eToken token = new eToken();
                        token.Exp = 7 * 24 * 60 * 60; //默认为30分钟,根据实际需要修改。单位:秒。 当前为1天,60分钟*60秒 为一小时
                        token.Add("id", tb.Rows[0]["UserID"].ToString());
                        //token.Add("nickname", tb.Rows[0]["nickname"].ToString());

                        string tokenString = token.Create();
                        eJson  json        = new eJson();
                        json.Add("errcode", "0");
                        json.Add("message", "请求成功!");
                        json.Add("token", tokenString);


                        #region 日志
                        if (1 == 1)
                        {
                            eTable etb = new eTable("a_eke_sysErrors");
                            etb.Fields.Add("Message", "getToken");
                            etb.Fields.Add("StackTrace", tokenString);
                            etb.Add();
                        }
                        #endregion

                        sql  = "if exists (select * from a_eke_sysToKens Where UserID='" + tb.Rows[0]["UserID"].ToString() + "')";
                        sql += "update a_eke_sysToKens set ExpireDate='" + token.ExpireDate.ToString() + "' where  UserID='" + tb.Rows[0]["UserID"].ToString() + "'";
                        sql += " else ";
                        sql += "insert into a_eke_sysToKens (UserID,ExpireDate) ";
                        sql += " values ('" + tb.Rows[0]["UserID"].ToString() + "','" + token.ExpireDate.ToString() + "')";
                        eOleDB.Execute(sql);
                        eBase.WriteJson(json);
                    }
                    else
                    {
                        ErrJson.Add("errcode", "1005");
                        ErrJson.Add("message", "登录信息有误!");
                        eBase.WriteJson(ErrJson);
                    }
                }
            }
            #endregion
            #region 微信小程序登录
            if (Request.Form["code"] != null)
            {
                ErrJson = new eJson();

                string code   = Request["code"].ToString();
                string url    = string.Format("https://api.weixin.qq.com/sns/jscode2session?appid={0}&secret={1}&js_code={2}&grant_type=authorization_code", "dmConfig.GetAppID()", "dmConfig.GetAppSecret()", code);
                string result = eBase.getRequest(url);
                eJson  _json  = new eJson(result);
                string openid = _json.GetValue("openid");

                sql = "Select top 1 * From a_eke_sysUsers Where delTag=0 and openid='" + openid + "'";
                tb  = eOleDB.getDataTable(sql);
                eToken token = new eToken();
                if (tb.Rows.Count == 0)
                {
                    eTable etb = new eTable("a_eke_sysUsers");
                    etb.Fields.Add("openid", openid);
                    etb.Fields.Add("nickname", Request.Form["nickname"].ToString());
                    etb.Fields.Add("sex", Request.Form["gender"].ToString());
                    etb.Fields.Add("headimgurl", Request.Form["avatarUrl"].ToString());
                    etb.Fields.Add("country", Request.Form["country"].ToString());
                    etb.Fields.Add("province", Request.Form["province"].ToString());
                    etb.Fields.Add("city", Request.Form["city"].ToString());
                    etb.Add();

                    token.Add("id", etb.ID.ToLower());
                    token.Add("nickname", Request.Form["nickname"].ToString());
                }
                else
                {
                    token.Add("id", tb.Rows[0]["UserID"].ToString());
                    token.Add("nickname", tb.Rows[0]["nickname"].ToString());
                }



                ErrJson.Add("errcode", "0");
                ErrJson.Add("message", "登录成功!");
                ErrJson.Add("token", token.Create());
                eBase.WriteJson(ErrJson);
            }
            #endregion
            Response.End();
        }
예제 #11
0
        protected void Action_Actioning(string Actioning)
        {
            eform         = new eForm("Organizationals", user);
            eform.ModelID = "1";
            if (Actioning.ToLower() == "gethtml")
            {
                //Response.AddHeader("Content-Type", "application/json; charset=UTF-8");
                Response.Write(getTree(eParameters.QueryString("pid")));
                Response.End();
                return;
            }
            if (Actioning.ToLower() == "setsort")
            {
                #region 位置
                string  ParentID = eParameters.QueryString("pid").Replace("NULL", "");
                int     index    = Convert.ToInt32(eParameters.QueryString("index"));
                DataRow dr       = eOleDB.getDataTable("SELECT * FROM Organizationals where OrganizationalID='" + id + "'").Select()[0];
                string  oldpid   = dr["ParentID"].ToString();
                int     oldindex = Convert.ToInt32(dr["px"]);


                if (ParentID == oldpid)   //父级不变
                {
                    if (oldindex < index) //小变大
                    {
                        sql = "update Organizationals set PX=PX-1 where delTag=0 " + (ParentID.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + ParentID + "'") + " and PX>" + oldindex.ToString() + " and PX<=" + index.ToString();
                        eOleDB.Execute(sql);
                    }
                    else //大变小
                    {
                        sql = "update Organizationals set PX=PX+1 where delTag=0 " + (ParentID.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + ParentID + "'") + " and PX>=" + index.ToString() + " and PX<" + oldindex.ToString();
                        eOleDB.Execute(sql);
                    }
                    sql = "update Organizationals set PX='" + index.ToString() + "' where OrganizationalID='" + id + "'";
                    eOleDB.Execute(sql);
                }
                else
                {
                    sql = "update Organizationals set PX=PX-1 where delTag=0 " + (oldpid.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + oldpid + "'") + " and PX>" + oldindex.ToString();
                    eOleDB.Execute(sql);

                    sql = "update Organizationals set PX=PX+1 where delTag=0 " + (ParentID.Length == 0 ? " and ParentID IS NULL" : " and ParentID='" + ParentID + "'") + " and PX>=" + index.ToString();
                    eOleDB.Execute(sql);

                    sql = "update Organizationals set PX='" + index.ToString() + "',ParentID=" + (ParentID.Length == 0 ? "NULL" : "'" + ParentID + "'") + " where OrganizationalID='" + id + "'";
                    eOleDB.Execute(sql);
                }
                eBase.End();
                #endregion
            }

            if (Actioning.Length > 0)
            {
                eform.onChange += new eFormTableEventHandler(eform_onChange);
                eform.AddControl(eFormControlGroup);
                if (Actioning == "add" && pid.Length > 0)
                {
                    M1_F2.Value = pid;
                }
                eform.Handle();
            }
            else
            {
                eTree = getTree("");
                if (Request.QueryString["ajax"] != null)
                {
                    Response.Clear();
                    eJson json = new eJson();
                    json.Add("body", eBase.encode(eTree));
                    HttpContext.Current.Response.Write(json.ToString());
                    HttpContext.Current.Response.End();
                }
            }
        }
예제 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Charset         = "UTF-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            string    ModelID = eParameters.QueryString("ModelID");
            DataTable dt      = eOleDB.getDataTable("select ModelID,MC,Code,Auto,AspxFile from a_eke_sysModels where ModelID='" + ModelID + "'");

            if (dt.Rows.Count == 0)
            {
                Response.End();
            }



            string json = "";

            if (dt.Rows[0]["Auto"].ToString() == "True") //自动模块
            {
                json = getModelJson(ModelID);
            }
            else //自定义模块
            {
                #region 自定义模块
                eMTable models = new eMTable("a_eke_sysModels");
                models.Where.Add("ModelID='" + ModelID + "'");

                json = models.ExportJson();
                eJson _json = new eJson(json);
                _json.Convert = true;
                string text     = "";
                string file     = dt.Rows[0]["AspxFile"].ToString();
                string aspxFile = Server.MapPath("~/System/") + file;
                if (System.IO.File.Exists(aspxFile))
                {
                    text = eBase.ReadFile(aspxFile);
                    text = eBase.encode(text);
                    _json.Add("aspxFile", text);
                }
                string csFile = Server.MapPath("~/System/") + file + ".cs";
                if (System.IO.File.Exists(csFile))
                {
                    text = eBase.ReadFile(csFile);
                    text = eBase.encode(text);
                    _json.Add("csFile", text);
                }
                string desFile = Server.MapPath("~/System/") + file + ".designer.cs";
                if (System.IO.File.Exists(desFile))
                {
                    text = eBase.ReadFile(desFile);
                    text = eBase.encode(text);
                    _json.Add("desFile", text);
                }
                json = _json.ToString();
                #endregion
            }
            byte[] buffer    = Encoding.UTF8.GetBytes(json);
            byte[] outBuffer = new byte[buffer.Length + 3];
            outBuffer[0] = (byte)0xEF;
            outBuffer[1] = (byte)0xBB;
            outBuffer[2] = (byte)0xBF;
            Array.Copy(buffer, 0, outBuffer, 3, buffer.Length);
            if (outFile)
            {
                string fileName = dt.Rows[0]["mc"].ToString() + ".efw";
                if (Request.ServerVariables["HTTP_USER_AGENT"].ToString().ToLower().IndexOf("msie") > -1)
                {
                    fileName = HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8);                                                                                        //IE需要编码
                }
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Accept-Ranges", "bytes");
                Response.AddHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
                Response.Write(Encoding.UTF8.GetString(outBuffer));
            }
            else
            {
                Response.Write(json);
            }
            Response.End();
        }
예제 #13
0
        private string getModelJson(string ModelID)
        {
            eMTable models = new eMTable("a_eke_sysModels");

            models.Where.Add("ModelID='" + ModelID + "'");

            eMTable Items = new eMTable("a_eke_sysModelItems");

            models.AddChild(Items);

            eMTable Conds     = new eMTable("a_eke_sysModelConditions");
            eMTable CondItems = new eMTable("a_eke_sysModelConditionItems");

            Conds.AddChild(CondItems);
            models.AddChild(Conds);

            eMTable action = new eMTable("a_eke_sysActions");

            models.AddChild(action);

            eMTable modelcond = new eMTable("a_eke_sysConditions");

            models.AddChild(modelcond);

            eMTable tabs = new eMTable("a_eke_sysModelTabs");

            models.AddChild(tabs);

            eMTable groups = new eMTable("a_eke_sysModelPanels");

            models.AddChild(groups);

            string ct = eOleDB.getValue("select count(*) from a_eke_sysCheckUps where ModelID='" + ModelID + "'");

            if (ct.Length > 0 && ct != "0")
            {
                eMTable checkups = new eMTable("a_eke_sysCheckUps");
                models.AddChild(checkups);
            }


            string json = models.ExportJson();

            eJson _json = new eJson(json);

            _json.Convert = true;
            string code     = eOleDB.getValue("select Code from a_eke_sysModels where ModelID='" + ModelID + "'");
            string modelSQL = eOleDB.getTableSql(code);

            _json.Add("modelSQL", HttpUtility.UrlEncode(modelSQL));

            DataTable dt = eOleDB.getDataTable("select ModelID,MC,Code,Auto,AspxFile from a_eke_sysModels where ParentID='" + ModelID + "' and delTag=0");

            foreach (DataRow dr in dt.Rows)
            {
                string js  = getModelJson(dr["ModelID"].ToString());
                eJson  _js = new eJson(js);
                _js.Convert = true;
                _json.Add("subModels", _js);
            }
            return(_json.ToString());
        }
예제 #14
0
        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();
        }
예제 #15
0
        public void edt_onChange(object sender, eFormTableEventArgs e)
        {
            string sql = "";

            if (e.eventType == eFormTableEventType.Inserting || e.eventType == eFormTableEventType.Updating || e.eventType == eFormTableEventType.Deleting)
            {
            }
            if (e.eventType == eFormTableEventType.Inserting)
            {
                if (user["ServiceID"].Length > 0)
                {
                    edt.Fields.Add("ServiceID", user["ServiceID"]);
                }
            }
            if (e.eventType == eFormTableEventType.Deleted)
            {
                sql = "update a_eke_sysPowers set delTag=1 where RoleID='" + e.ID + "' and UserId is null and ApplicationID is not null";
                eOleDB.Execute(sql);
            }
            if (e.eventType == eFormTableEventType.Updated || e.eventType == eFormTableEventType.Inserted)
            {
                sql  = "select a.ModelID,a.MC,a.Power,b.Power as userPower,b.canList,b.Condition from a_eke_sysModels a ";
                sql += " left join a_eke_sysPowers b on a.ModelID=b.ModelID and b.delTag=0 and b.UserID is null and b.ApplicationID is null and b.RoleID='" + e.ID + "'";
                sql += " where a.subModel=0 and a.delTag=0 and a.Type=1 order by a.px,a.addTime";


                DataTable tb = eOleDB.getDataTable(sql);
                foreach (DataRow _dr in tb.Rows)
                {
                    string name = "model_list_" + _dr["ModelID"].ToString().Replace("-", "");
                    string temp = eParameters.Form(name);

                    if (temp.Length > 0) //有权限
                    {
                        string canList = "0";
                        string cond    = "";
                        string power   = "";
                        eJson  uPower  = new eJson();
                        uPower.Convert = true;
                        #region 基本权限
                        DataTable Power = new eJson(_dr["Power"].ToString()).toRows();
                        foreach (DataRow dr1 in Power.Rows)
                        {
                            temp = eParameters.Form("model_" + dr1["value"].ToString() + "_" + _dr["ModelID"].ToString().Replace("-", ""));
                            eJson _power = new eJson();
                            if (temp.Length == 0)
                            {
                                _power.Add(dr1["value"].ToString(), "false");
                                if (dr1["value"].ToString().ToLower() == "list")
                                {
                                    canList = "0";
                                }
                            }
                            else
                            {
                                _power.Add(dr1["value"].ToString(), "true");
                                if (dr1["value"].ToString().ToLower() == "list")
                                {
                                    canList = "1";
                                }
                            }
                            uPower.Add(_power);
                        }
                        #endregion
                        #region 审批权限
                        sql   = "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";
                        Power = eOleDB.getDataTable(sql);
                        foreach (DataRow dr1 in Power.Rows)
                        {
                            temp = eParameters.Form("model_" + dr1["value"].ToString() + "_" + _dr["ModelID"].ToString().Replace("-", ""));
                            eJson _power = new eJson();
                            if (temp.Length == 0)
                            {
                                _power.Add(dr1["value"].ToString(), "false");
                                if (dr1["value"].ToString().ToLower() == "list")
                                {
                                    canList = "0";
                                }
                            }
                            else
                            {
                                _power.Add(dr1["value"].ToString(), "true");
                                if (dr1["value"].ToString().ToLower() == "list")
                                {
                                    canList = "1";
                                }
                            }
                            uPower.Add(_power);
                        }
                        power = uPower.ToString();


                        #endregion
                        name = "model_cond_" + _dr["ModelID"].ToString().Replace("-", "");
                        cond = eParameters.Form(name);


                        sql  = "if exists (select * from a_eke_sysPowers where UserID is Null and ApplicationID is null and ModelID='" + _dr["ModelID"].ToString() + "'  and RoleID='" + e.ID + "')";
                        sql += " update a_eke_sysPowers set delTag=0,canList='" + canList + "',Condition='" + cond + "',power='" + power + "' where UserID is Null and ApplicationID is Null and ModelID='" + _dr["ModelID"].ToString() + "'  and RoleID='" + e.ID + "'";
                        sql += " else ";
                        sql += "insert into a_eke_sysPowers (ApplicationID,ModelID,UserID,RoleID,canList,Condition,Power) ";
                        sql += " values (NULL,'" + _dr["ModelID"].ToString() + "',NULL,'" + e.ID + "','" + canList + "','" + cond + "','" + power + "')";

                        eOleDB.Execute(sql);
                    }
                    else //无权限
                    {
                        sql = "update a_eke_sysPowers set canList=0,Power='',Condition='',delTag=1 where userID is Null and ApplicationID is null and ModelID='" + _dr["ModelID"].ToString() + "' and RoleID='" + e.ID + "'";
                        sql = "delete from a_eke_sysPowers where userID is Null and ApplicationID is null and ModelID='" + _dr["ModelID"].ToString() + "' and RoleID='" + e.ID + "'";
                        eOleDB.Execute(sql);
                    }
                }
                eBase.clearDataCache("a_eke_sysPowers");
            }
        }