示例#1
0
    public void ExtractValues(System.Collections.Specialized.IOrderedDictionary dictionary)
    {
        var conditionsJsonStr = conditions.Value;
        var expressionJsonStr = expression.Value;

        dictionary[ConditionsFieldName] = conditionsJsonStr;
        dictionary[ExpressionFieldName] = expressionJsonStr;

        if (RelexFieldName != null && !String.IsNullOrEmpty(conditionsJsonStr) && !String.IsNullOrEmpty(expressionJsonStr))
        {
            var expressionData = JsHelper.FromJsonString <IDictionary <string, object> >(expressionJsonStr);
            var exprStr        = Convert.ToString(expressionData["expression"]);

            if (String.IsNullOrEmpty(exprStr.Trim()))
            {
                dictionary[RelexFieldName] = "1=1";
            }
            else
            {
                var fieldData = JsHelper.FromJsonString <IList <Dictionary <string, object> > >(fieldDescriptors.Value);

                var fieldTypeMapping      = new Dictionary <string, string>();
                var relexConditionMapping = new Dictionary <string, string>();
                foreach (var fldData in fieldData)
                {
                    fieldTypeMapping[Convert.ToString(fldData["name"])] = Convert.ToString(fldData["dataType"]);
                    if (fldData.ContainsKey("relexcondition"))
                    {
                        relexConditionMapping[Convert.ToString(fldData["name"])] = Convert.ToString(fldData["relexcondition"]);
                    }
                }
                dictionary[RelexFieldName] = QueryBuilderHelper.GenerateRelexFromQueryBuilder(JsHelper.FromJsonString <IList <IDictionary <string, object> > >(conditionsJsonStr), exprStr, fieldTypeMapping, relexConditionMapping);
            }
        }
    }
示例#2
0
    protected override IEnumerable GetControlSelectedIds()
    {
        var json         = new JavaScriptSerializer();
        var selectedList = JsHelper.FromJsonString <IList <IDictionary> >(selectedValues.Value);

        return(selectedList.Select(v => v["Key"]).ToArray());
    }
示例#3
0
 protected override void OnLoad(EventArgs e)
 {
     if (RegisterJs)
     {
         JsHelper.RegisterJsFile(Page, JsScriptName);
     }
 }
示例#4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string action = Request["action"];
         if (action == "edit")
         {
             string id = Request["id"];
             //如果id为null或者空字符串就返回
             if (string.IsNullOrEmpty(id))
             {
                 return;
             }
             DataTable dt = news.FindNewById(id);
             if (dt.Rows.Count == 0)
             {
                 JsHelper.Alert("该新闻不存在!");
                 return;
             }
             tipe.Value    = dt.Rows[0]["tipe"].ToString();
             title.Value   = dt.Rows[0]["title"].ToString();
             content.Value = dt.Rows[0]["contents"].ToString();
         }
     }
 }
示例#5
0
        /// <summary>
        /// 判断是否存在 [带参数] 返回bool
        /// </summary>
        /// <param name="SQLString">SQL</param>
        /// <param name="param">参数集合</param>
        /// <returns></returns>
        public static Boolean SqlCheckIsExists(string SQLString, SqlParameter[] param)
        {
            bool returnbool = false;

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(SQLString, conn))
                {
                    try
                    {
                        cmd.CommandTimeout = 10;
                        conn.Open();
                        cmd.Parameters.AddRange(param); //添加参数集
                        SqlDataReader sqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                        if (sqlDataReader.Read())
                        {
                            returnbool = true;
                        }
                        else
                        {
                            returnbool = false;
                        }
                        return(returnbool);
                    }
                    catch (Exception ex)
                    {
                        conn.Close();
                        JsHelper.MsgBox_GoHistory(ex.Message, -1);
                        return(returnbool);
                    }
                }
            }
        }
示例#6
0
        //方法2
        /// <summary>
        /// 图片保存到数据库
        /// </summary>
        /// <param name="UP_FILE1"></param>
        public void SavePicToDB(System.Web.UI.WebControls.FileUpload UP_FILE1)
        {
            HttpPostedFile UpFile     = UP_FILE1.PostedFile;       //HttpPostedFile对象,用于读取图象 文件属性
            Int64          FileLength = UpFile.InputStream.Length; //记录文件长度变量

            try
            {
                if (FileLength == 0)
                {   //文件长度为零时
                    JsHelper.MsgBox("请选择图片");
                }
                else
                {
                    Byte[] FileByteArray = new Byte[FileLength];               //图象文件临时储存Byte数组
                    Stream StreamObject  = UpFile.InputStream;                 //建立数据流对像
                    //读取图象文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度
                    StreamObject.Read(FileByteArray, 0, UpFile.ContentLength); //建立SQL Server链接

                    SqlHelper.SqlCheckIsExists("SQL语句");
                    JsHelper.MsgBox("你已经成功上传你的图片");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#7
0
        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            UserBLL      User      = new UserBLL();
            AdminUserBLL adminUser = new AdminUserBLL();

            string    userName = user.Value;
            string    password = pwd.Value;
            DataTable dt       = User.selectid(userName, password);

            if (userName == "" && password == "")
            {
                JsHelper.Alert("账号或密码不能为空!");
                return;
            }
            Session["ID"] = dt.Rows[0]["id"];
            if (adminUser.UserLoginCheck(userName, password))
            {
                Session["UserName"] = userName;
                Response.Redirect("indexs.aspx");
            }
            else
            {
                JsHelper.Alert("账号或密码不正确!");
            }
        }
示例#8
0
        //添加班级处理
        public void AddGra(FormCollection col)
        {
            ViewBag.AId = Session["AId"];
            string  ACName = col["ACName"];
            ACademy ac     = entity.ACademys.Where(p => p.ACName == ACName).FirstOrDefault();

            if (ac != null)
            {
                string ACId = ac.ACId;
                Grade  gra  = new Grade();
                gra.GId   = col["GId"];
                gra.GName = col["GName"];
                gra.GNum  = Convert.ToInt16(col["GNum"]);
                gra.ACId  = ACId;

                entity.Grades.Add(gra);
                int i = entity.SaveChanges();
                if (i != 0)
                {
                    Response.Write(JsHelper.Messagebox("添加成功!", "Admin", "AdminList"));
                }
                else
                {
                    Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddGrade"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddGrade"));
            }
        }
示例#9
0
 public BaseMatSlider()
 {
     jsHelper = new JsHelper(this);
     ClassMapper
     .Add("mdc-slider")
     .If("mdc-slider--discrete", () => Discrete)
     ;
 }
示例#10
0
        //显示验证码
        public ActionResult SecurityCode()
        {
            string oldcode = TempData["SecurityCode"] as string;
            string code    = JsHelper.CreateRandomCode(4); //验证码的字符为4个

            TempData["SecurityCode"] = code;               //验证码存放在TempData中
            return(File(JsHelper.CreateValidateGraphic(code), "image/Jpeg"));
        }
示例#11
0
 public void Login(string userType, string userName, string Pwd, string yzm)
 {
     if (!yzm.Equals(TempData["SecurityCode"]))
     {
         Response.Write(JsHelper.Messagebox("验证码不正确,登录不成功!", "Login", "Index"));
     }
     else
     {
         if (userType == "管理员")
         {
             Admin admin = entity.Admins.Where(p => p.AName == userName && p.APassword == Pwd).FirstOrDefault();
             if (admin == null)
             {
                 Response.Write(JsHelper.Messagebox("登录不成功!", "Login", "Index"));
             }
             else
             {
                 Session["AId"]       = admin.AId;
                 Session["userName"]  = userName;
                 Session["userType"]  = userType;
                 Session["userPower"] = admin.APower;
                 Response.Write(JsHelper.Messagebox("登录成功!", "Admin", "AdminList"));
             }
         }
         else if (userType == "教师")
         {
             Teacher teacher = entity.Teachers.Where(p => p.TName == userName && p.TPassword == Pwd).FirstOrDefault();
             if (teacher == null)
             {
                 Response.Write(JsHelper.Messagebox("登录不成功!", "Login", "Index"));
             }
             else
             {
                 Session["TId"] = teacher.TId;
                 Response.Write(JsHelper.Messagebox("登录成功!", "Teacher", "Index"));
             }
         }
         else if (userType == "学生")
         {
             Student student = entity.Students.Where(p => p.SName == userName && p.SPassword == Pwd).FirstOrDefault();
             if (student == null)
             {
                 Response.Write(JsHelper.Messagebox("登录不成功!", "Login", "Index"));
             }
             else
             {
                 Session["SId"] = student.SId;
                 Response.Write(JsHelper.Messagebox("登录成功!", "Student", "Index"));
             }
         }
         else
         {
             Response.Write(JsHelper.Messagebox("登录不成功!", "Login", "Index"));
         }
     }
 }
示例#12
0
 protected override void OnLoad(EventArgs e)
 {
     if (RegisterJs)
     {
         foreach (var jsName in JsScriptNames)
         {
             JsHelper.RegisterJsFile(Page, jsName);
         }
     }
 }
示例#13
0
        private async Task OnDeleteNoteModalDeleteClickedAsync(NoteModel note)
        {
            await NoteService.DeleteAsync(note.Id);

            await JsHelper.CloseModal(DeleteNoteModal.Id);

            AppState.SetCurrentNote(null);

            AppState.LastActivity = DateTime.UtcNow;
        }
示例#14
0
        // 设置编辑器值
        protected void btnSet_Click(object sender, EventArgs e)
        {
            // 直接操作 textarea 失败
            //edtArea.InnerText = "## This is title";

            // 注册脚本到客户端成功
            string content = "## This is title";

            PageContext.RegisterStartupScript(String.Format("updateEditor({0});", JsHelper.Enquote(content)));
        }
示例#15
0
        //使用邮件修改密码功能
        public void forgetemail()
        {
            string s    = Session["email"].ToString();
            User   user = entity.User.Where(p => p.QQ == s).FirstOrDefault();

            user.Password = "******";
            entity.Entry <User>(user).State = System.Data.EntityState.Modified;
            entity.SaveChanges();
            Response.Write(JsHelper.Messagebox("密码修改成功!", "Home", "Index"));
        }
示例#16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var tokenID = TokenHelper.TokenGet();

            if (Request["IsLoginOut"] != null)
            {
                Response.Clear();
                Response.Write(JsHelper.Serialize(new { Data = Request["IsLoginOut"] }));
                Response.End();
            }

            if (Request["Tip"] != null)
            {
                if (Request["Tip"] == "false")
                {
                    Response.Clear();
                    Response.Write(JsHelper.Serialize(new { Data = Request["Tip"] }));
                    Response.End();
                }
            }


            //没有tokenID则条用接口进行获取
            if (!string.IsNullOrEmpty(tokenID))
            {
                //获取token
                var token = Constant.client.ValidateToken(tokenID);
                if (token != null)
                {
                    LoginID = token.LoginID;

                    ////登录成功标识(加载注销页面)
                    //string LoginMessage = "登录成功,登录用户:"
                    //          + token.User.UserName;

                    //bool result = Constant.client.LoginOut(LoginID);

                    //Response.Clear();
                    //Response.Write(JsHelper.Serialize(new { Data = LoginMessage }));
                    //Response.End();
                }
                else
                {
                    //到sso去返回tokenID  进入到server ---Login【有可能是过期的tokenID,需要重新登录】
                    Response.Redirect("http://192.168.1.69:3001/SSO_Server/Handles/SSO_ServerCenter.ashx?returnUrl=" +
                                      Server.UrlEncode("http://192.168.1.69:3001/SSO_Test/Login2.aspx"));
                }
            }
            else
            {
                //到sso去返回tokenID 进入到server ---Login
                Response.Redirect("http://192.168.1.69:3001/SSO_Server/Handles/SSO_ServerCenter.ashx?returnUrl=" +
                                  Server.UrlEncode("http://192.168.1.69:3001/SSO_Test/Login2.aspx"));
            }
        }
示例#17
0
        //添加学生处理
        public void AddStu(FormCollection col)
        {
            ViewBag.AId = Session["AId"];
            string ACName = col["ACName"];
            string GName  = col["GName"];

            ACademy ac = entity.ACademys.Where(p => p.ACName == ACName).FirstOrDefault();

            if (ac != null)
            {
                Grade grade = ac.Grades.Where(p => p.GName == GName).FirstOrDefault();
                if (grade != null)
                {
                    string  ACId = ac.ACId;
                    string  GId  = grade.GId;
                    Student stu  = new Student();
                    stu.SId         = col["SId"];
                    stu.SName       = col["SName"];
                    stu.SSex        = col["SSex"];
                    stu.SAge        = Convert.ToInt16(col["SAge"]);
                    stu.SDepartment = col["SDepartment"];
                    stu.SClass      = GId;
                    stu.ACId        = ACId;
                    stu.SPassword   = col["SPassword"];

                    entity.Students.Add(stu);
                    int i = entity.SaveChanges();

                    ac.ACStudentNum++;
                    entity.Entry <ACademy>(ac).State = System.Data.EntityState.Modified;
                    int j = entity.SaveChanges();

                    grade.GNum++;
                    entity.Entry <Grade>(grade).State = System.Data.EntityState.Modified;
                    int k = entity.SaveChanges();
                    if (i != 0 && j != 0 && k != 0)
                    {
                        Response.Write(JsHelper.Messagebox("添加成功!", "Admin", "CheckStudent"));
                    }
                    else
                    {
                        Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddStudent"));
                    }
                }
                else
                {
                    Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddStudent"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddStudent"));
            }
        }
示例#18
0
 //退出功能
 public void goback()
 {
     if (Convert.ToInt16(Session["coockie"]) != 0)
     {
         HttpCookie hc = Request.Cookies["AUFElogin"];
         hc.Expires = DateTime.Now.AddDays(-1);
         Response.Cookies.Add(hc);
     }
     Session.Abandon();
     Response.Write(JsHelper.Messagebox("退出成功!", "Home", "Index"));
 }
示例#19
0
 //竞赛登录模块
 public void OCLogin(int page, int OCid)
 {
     if (Convert.ToInt32(Session["Login"]) == 1)
     {
         Response.Write(JsHelper.Jump("Home", "OnlineCP?id=" + OCid));
     }
     else
     {
         Response.Write(JsHelper.Messagebox("请先登录!", "OnlineCon?page=" + page));
     }
 }
示例#20
0
        public void GetUserInfoByToken(HttpContext context)
        {
            //响应者
            HttpResponse Response = context.Response;
            //请求者
            HttpRequest Request = context.Request;
            //往返路径
            string returnUrl = Request["returnUrl"];

            JsonModel jsonModel = new JsonModel();

            if (Request["tokenID"] != string.Empty)
            {
                string tokenID = Request["tokenID"];
                if (KeepToken(tokenID))
                {
                    SSOToken token = KeepToken_Valied(tokenID);
                    if (token != null)
                    {
                        Sys_UserInfo userInfo = UserManage.GetUserInfo(token.User.UserName, token.User.PassWord);
                        if (userInfo != null)
                        {
                            jsonModel.retData = userInfo;
                            jsonModel.errNum  = 0;
                        }
                        else
                        {
                            jsonModel.errMsg = "用户名密码错误";
                            jsonModel.errNum = 999;
                        }
                    }
                    else
                    {
                        jsonModel.errMsg = "获取用户信息失败";
                        jsonModel.errNum = 222;
                    }
                }
                else
                {
                    jsonModel.errMsg = "无效令牌";
                    jsonModel.errNum = 333;
                }
            }
            else
            {
                jsonModel.errMsg = "未获取到令牌";
                jsonModel.errNum = 666;
            }
            //Response.Write(JsHelper.Serialize(new { Data = returnData }));

            string callback = context.Request["jsoncallback"];

            Response.Write(callback + "({\"result\":" + JsHelper.Serialize(jsonModel) + "})");
        }
示例#21
0
    protected string GenerateFieldDescriptorsJsonString()
    {
        if (ComposeFieldsData == null)
        {
            throw new Exception("ComposeFieldsData is not defined");
        }

        var fieldsData = ComposeFieldsData(DataContext);

        return(JsHelper.ToJsonString(fieldsData));
    }
示例#22
0
        protected async Task DownloadExcel()
        {
            ShowTitleContextMenu = false;
            byte[] bytes = await GridConfig.DownloadExcel(await GridConfig.GetListAsync(GridSearch));

            string fileName = string.IsNullOrWhiteSpace(GridConfig.ExcelFileName)
                ? $"{GridConfig.GridTitle}{DateTime.Now.Date.ToShortDateString().Replace("/", "-")}.xlsx"
                : GridConfig.ExcelFileName;
            JsHelper jsHelper = new JsHelper();

            ErrorMessage = await jsHelper.DownloadExcelAsync(jSRuntime, bytes, fileName);
        }
示例#23
0
        //登录功能
        public void Login(FormCollection col)
        {
            string UserName = col["UserName"];
            string Password = col["Password"];
            string Checkbox = col["checkbox"];
            string yzm      = col["yzm"];
            string Href     = col["Href"];

            if (!yzm.Equals(TempData["SecurityCode"]))
            {
                Response.Write(JsHelper.Messagebox("验证码不正确,登录不成功!", Href));
            }
            else
            {
                User user = entity.User.Where(p => p.Name == UserName && p.Password == Password).FirstOrDefault();
                //判断用户是否存在
                if (user == null)
                {
                    Session["UId"] = null;
                    Response.Write(JsHelper.Messagebox("登录不成功,请检查用户名或密码是否正确!", Href));
                }
                else
                {
                    Session["Login"]     = 1;
                    Session["UId"]       = user.ID;
                    Session["UserName"]  = UserName;
                    Session["Password"]  = Password;
                    Session["QQ"]        = user.QQ;
                    Session["Tel"]       = user.Tel;
                    Session["Introduce"] = user.Introduce;
                    Session["coockie"]   = 0;

                    //是否记住
                    if (Checkbox != null)
                    {
                        if (Checkbox.Equals("on"))
                        {
                            //保存cookie
                            Session["coockie"] = 1;
                            cookie["UId"]      = user.ID.ToString();
                            cookie["Password"] = Password;
                            cookie["UserName"] = HttpUtility.UrlEncode(UserName);
                            cookie.Expires     = System.DateTime.Now.AddDays(7.0);
                            Response.Cookies.Add(cookie);
                        }
                    }


                    //记录表和用户记录表添加记录
                    AddRecord(user, Href, Href, 1, 1);
                }
            }
        }
示例#24
0
        protected void lvNewList_ItemDeleting(object sender, ListViewDeleteEventArgs e)
        {
            NewBLL newsBll = new NewBLL();

            if (newsBll.RemoveNew(e.Keys["id"].ToString()) == 1)
            {
                lvNewList.EditIndex = -1;
                BindNewList();
                return;
            }
            JsHelper.Alert("删除失败");
        }
示例#25
0
    /// <summary>
    /// 上传图片(传递控件)
    /// </summary>
    /// <param name="myFile">控件名称</param>
    /// <param name="myFileName">文件名称</param>
    /// <param name="myFileSize">文件大小(M)</param>
    /// <param name="myFileType">允许上传的文件类别</param>
    /// <param name="mySaveDirectory">文件保存路径</param>
    /// <param name="file_fg">如果文件存在是否覆盖,TRUE覆盖,FALSE不覆盖</param>
    public static bool myUpFile(System.Web.UI.WebControls.FileUpload myFile, string myFileName, int myFileSize, string myFileType, string mySaveDirectory, string file_fg)
    {
        try
        {
            //判断文件是否存在或有数据
            if (myFile.PostedFile.ContentLength <= 0)
            {
                JsHelper.MsgBox("请选择您要上传的图片!");
                return(false);
            }

            //判断文件是否超过限制
            if (myFile.PostedFile.ContentLength / 1048576d > myFileSize)
            {
                JsHelper.MsgBox("上传的文件不能超过 " + myFileSize.ToString() + "M!");
                return(false);
            }

            //判断文件类别是否允许上传
            string myType = System.IO.Path.GetExtension(myFile.PostedFile.FileName).Substring(1).ToLower();
            if (myFileType.IndexOf(myType) < 0)
            {
                JsHelper.MsgBox("对不起,只允许 " + myFileType + " 类别的文件上传!");
                return(false);
            }

            //判断文件夹是否存在
            if (!Directory.Exists(mySaveDirectory))
            {
                Directory.CreateDirectory(mySaveDirectory);
            }

            //获取文件物理路径
            string mySaveFile = mySaveDirectory + myFileName;
            //判断文件是否存在
            if (System.IO.File.Exists(mySaveFile))
            {
                if (file_fg == "FALSE")
                {
                    JsHelper.MsgBox("文件已经存在,请选择其它要上传的文件!");
                    return(false);
                }
            }
            myFile.PostedFile.SaveAs(mySaveFile);
            return(true);
        }
        catch (Exception ex)
        {
            JsHelper.MsgBox(ex.Message);
            return(false);
        }
    }
示例#26
0
    protected override void OnLoad(EventArgs e)
    {
        if (RegisterJs)
        {
            JsHelper.RegisterJsFile(Page, JsScriptName);
        }

        // change behaviour for filter container
        if (FindFilter() != null)
        {
            AutoPostBack = true;
        }
    }
示例#27
0
        public BaseMatSlider()
        {
            jsHelper = new JsHelper(this);

            ClassMapper
            .Add("mdc-slider")
            .If("mdc-slider--discrete", () => Discrete);
            CallAfterRender(async() =>
            {
                dotNetObjectRef = dotNetObjectRef ?? CreateDotNetObjectRef(jsHelper);
                await Js.InvokeAsync <object>("matBlazor.matSlider.init", Ref, dotNetObjectRef);
            });
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            string content = Request.Form["UEditor1"].ToString();
            Regex  regex   = new Regex(@"<[^>]+>|</[^>]+>");

            content = regex.Replace(content, "");
            if (content.Length > 100)
            {
                content = content.Substring(0, 97) + "...";
            }

            PageContext.RegisterStartupScript(String.Format("updateUEditor2({0});", JsHelper.Enquote(content)));
        }
示例#29
0
        protected async Task DownloadSample()
        {
            ShowTitleContextMenu = false;
            ShowUploadSubMenu    = false;
            byte[] bytes = await GridConfig.DownloadExcel(new List <object>());

            string fileName = "Sample_" + (string.IsNullOrWhiteSpace(GridConfig.ExcelFileName)
                ? $"{GridConfig.GridTitle}{DateTime.Now.Date.ToShortDateString().Replace("/", "-")}.xlsx"
                : GridConfig.ExcelFileName);

            JsHelper jsHelper = new JsHelper();

            ErrorMessage = await jsHelper.DownloadExcelAsync(jSRuntime, bytes, fileName);
        }
示例#30
0
        protected async Task FilesReadyForContent(IMatFileUploadEntry[] files)
        {
            ErrorMessage = await GridConfig.FilesReadyForContent(files);

            ShowTitleContextMenu = false;
            ShowUploadSubMenu    = false;
            if (!string.IsNullOrEmpty(ErrorMessage))
            {
                JsHelper jsHelper = new JsHelper();
                await jsHelper.ShowErrorAsync(jSRuntime, ErrorMessage);

                ErrorMessage = "";
            }
        }