Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        public string addinfo(string _json)
        {
            eUser user = new eUser("eWebService");

            #region 验证
            if (!user.Logined)
            {
                eJson bjs = CheckUserInfo(_json);
                if (bjs.GetValue("success") != "1")
                {
                    return(bjs.ToString());
                }
                user = new eUser("eWebService");
            }
            #endregion
            eJson json = new eJson(_json);
            json.Convert = true;
            string        ModelID = json.GetValue("ModelID");
            eModelService model   = new eModelService(ModelID, user);
            return(model.adddata(json));
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 安全性检查
            if (Request.UrlReferrer == null)
            {
                Response.End();
            }
            if (Request.Url.Host.ToLower() != Request.UrlReferrer.Host.ToLower() || Request.Url.Port != Request.UrlReferrer.Port)
            {
                Response.End();
            }
            #endregion
            #region 保存文件
            if (Request.Form["act"] != null)
            {
                HttpPostedFile f = imgFile.PostedFile;
                if (f.ContentLength > 0)
                {
                    string dirpath = Server.MapPath("~/") + "upload\\temp\\";

                    int    pos = f.FileName.LastIndexOf(".");
                    string Ext = f.FileName.Substring(pos, f.FileName.Length - pos).ToLower();
                    if (Ext.ToLower().IndexOf("efw") == -1)
                    {
                        Response.Write("<script>alert('文件格式不正确!');document.location='Models.aspx';</script>");
                        Response.End();
                    }

                    string filename = eBase.GetFileName() + Ext;
                    string pathname = dirpath + filename;
                    if (!Directory.Exists(dirpath))
                    {
                        Directory.CreateDirectory(dirpath);
                    }
                    f.SaveAs(pathname);

                    string _json = eBase.ReadFile(pathname);

                    try
                    {
                        System.IO.File.Delete(pathname);
                    }
                    catch
                    {
                    }

                    eJson  json     = new eJson(_json);
                    eJson  model    = json.GetCollection("a_eke_sysModels").Collection[0];
                    string file     = model.GetValue("AspxFile");
                    string aspxFile = Server.MapPath("~/System/") + file + ".log";
                    if (json.IsValue("aspxFile"))
                    {
                        string text = json.GetValue("aspxFile");
                        eBase.WriteFile(aspxFile, text);
                    }
                    string csFile = Server.MapPath("~/System/") + file + ".cs.log";
                    if (json.IsValue("csFile"))
                    {
                        string text = json.GetValue("csFile");
                        eBase.WriteFile(csFile, text);
                    }
                    string desFile = Server.MapPath("~/System/") + file + ".designer.cs.log";
                    if (json.IsValue("desFile"))
                    {
                        string text = json.GetValue("desFile");
                        eBase.WriteFile(desFile, text);
                    }
                    eOleDB.ImportJson(_json, false);


                    Response.Write("<script>alert('导入成功!');document.location='Models.aspx';</script>");
                    Response.End();
                }
            }
            #endregion
        }
Ejemplo n.º 4
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();
            }
            if (act.Length == 0)
            {
                return;
            }
            parentID = eParameters.QueryString("id");

            eUser user = new eUser(UserArea);

            switch (act)
            {
            case "save":
                #region 保存
                eTable tb     = new eTable("Demo_Customs_PartOne", user);
                string json   = eParameters.Form("eformdata_" + parentModelID);
                eJson  jmodel = new eJson(json);
                jmodel.Convert = true;
                jmodel         = jmodel.GetCollection("eformdata_" + parentModelID);
                eJson jrow = jmodel.Collection[0];
                tb.Fields.Add("DZ", jrow.GetValue("ma_f1"));
                tb.Fields.Add("gddh", jrow.GetValue("ma_f2"));
                string tmp = jrow.GetValue("id");

                if (tmp.Length > 0)
                {
                    parentID = tmp;
                }


                string id = eOleDB.getValue("select PartOneID from Demo_Customs_PartOne where CustomID='" + parentID + "'");
                if (id.Length == 0)
                {
                    tb.Fields.Add("CustomID", parentID);
                    tb.Add();
                }
                else
                {
                    tb.Where.Add("CustomID='" + parentID + "'");
                    tb.Update();
                }
                #endregion
                break;

            case "del":
                eTable etb = new eTable("Demo_Customs_PartOne", user);
                etb.Where.Add("CustomID='" + parentID + "'");
                etb.Delete();
                break;

            default:
                #region 读取
                DataTable dt = eOleDB.getDataTable("select dz,gddh from Demo_Customs_PartOne where CustomID='" + parentID + "' and delTag=0");
                if (dt.Rows.Count > 0)
                {
                    dz   = dt.Rows[0]["DZ"].ToString();
                    gddh = dt.Rows[0]["GDDH"].ToString();
                }
                #endregion
                break;
            }
        }
Ejemplo n.º 5
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
            }
        }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 7
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();
            }
            if (act.Length == 0)
            {
                return;
            }
            parentID = eParameters.QueryString("id");

            eUser user = new eUser(UserArea);

            eform = new eForm("Demo_Accessorys", user);
            eform.AutoRedirect = false; //子模块,记得要关闭自动跳转
            eform.AddControl(eFormControlGroup);
            switch (act)
            {
            case "save":
                #region 保存
                string json   = eParameters.Form("eformdata_" + parentModelID);
                eJson  jmodel = new eJson(json);
                jmodel.Convert = true;
                jmodel         = jmodel.GetCollection("eformdata_" + parentModelID);
                eJson jrow = jmodel.Collection[0];

                string tmp = jrow.GetValue("id");
                if (tmp.Length > 0)
                {
                    parentID = tmp;
                }
                string id = eOleDB.getValue("select AccessoryID from Demo_Accessorys where DemoID='" + parentID + "' and delTag=0");
                if (id.Length > 0)
                {
                    eform.ID = id;
                }

                ma_f1.Value = jrow.GetValue("ma_f1");
                ma_f2.Value = jrow.GetValue("ma_f2");
                ma_f3.Value = jrow.GetValue("ma_f3");

                if (id.Length == 0)
                {
                    eform.Fields.Add("DemoID", parentID);
                    eform.Add();
                }
                else
                {
                    eform.Update();
                }
                #endregion
                break;

            case "del":
                eTable etb = new eTable("Demo_Accessorys", user);
                etb.Where.Add("DemoID='" + parentID + "'");
                etb.Delete();
                break;

            default:
                #region 读取Json
                string    accUrl      = eConfig.getString("AccessorysURL");
                string    virtualPath = eBase.getVirtualPath();
                DataTable dt          = eOleDB.getDataTable("select sfz,fkb,byz from Demo_Accessorys where DemoID='" + parentID + "' and delTag=0");
                if (dt.Rows.Count > 0)
                {
                    string basepath = accUrl.Length > 0 ? accUrl : virtualPath;

                    if (act == "view" && dt.Rows[0]["sfz"].ToString().Length > 0)
                    {
                        dt.Rows[0]["sfz"] = basepath + dt.Rows[0]["sfz"].ToString();
                    }
                    if (act == "view" && dt.Rows[0]["fkb"].ToString().Length > 0)
                    {
                        dt.Rows[0]["fkb"] = basepath + dt.Rows[0]["fkb"].ToString();
                    }
                    if (act == "view" && dt.Rows[0]["byz"].ToString().Length > 0)
                    {
                        dt.Rows[0]["byz"] = basepath + dt.Rows[0]["byz"].ToString();
                    }

                    eform.Data = dt.Rows[0];


                    ma_f1.Value = dt.Rows[0]["sfz"].ToString();
                    ma_f2.Value = dt.Rows[0]["fkb"].ToString();
                    ma_f3.Value = dt.Rows[0]["byz"].ToString();

                    sfz = basepath + dt.Rows[0]["sfz"].ToString();
                    fkb = basepath + dt.Rows[0]["fkb"].ToString();
                    byz = basepath + dt.Rows[0]["byz"].ToString();
                }
                #endregion
                break;
            }
        }
Ejemplo n.º 8
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();
        }
Ejemplo n.º 9
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();
        }