Exemplo n.º 1
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_common_resource", EnumCollection.ActionEnum.Modify.ToString()); //检查权限
            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = bll.GetModel(this.id);

            model.from_id     = Convert.ToInt32(txtfrom_id.Text);
            model.group_id    = Convert.ToInt32(txtgroup_id.Text);
            model.type        = Convert.ToInt32(txttype.Text);
            model.school_id   = Convert.ToInt32(txtschool_id.Text);
            model.school_name = Convert.ToString(txtschool_name.Text);
            model.data_id     = Convert.ToInt32(txtdata_id.Text);
            model.user_id     = Convert.ToInt32(txtuser_id.Text);
            model.title       = Convert.ToString(txttitle.Text);
            model.cover       = Convert.ToString(txtcover.Text);
            model.path        = Convert.ToString(txtpath.Text);
            model.qrcode      = Convert.ToString(txtqrcode.Text);
            model.file_name   = Convert.ToString(txtfile_name.Text);
            model.extend      = Convert.ToString(txtextend.Text);
            model.likn_url    = Convert.ToString(txtlikn_url.Text);
            model.share_user  = Convert.ToString(txtshare_user.Text);
            model.sort        = Convert.ToInt32(txtsort.Text);
            model.add_time    = Convert.ToDateTime(txtadd_time.Text);
            model.is_del      = Convert.ToInt32(txtis_del.Text);

            if (bll.Update(model))
            {
                AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改资源信息信息,主键:" + id); //记录日志
                JscriptMsg("修改资源信息信息成功!", "Manage.aspx");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }
Exemplo n.º 2
0
        private void SetCaseIsShow()
        {
            int id = RequestHelper.GetFormInt("id");

            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = bll.GetModel(id);
            if (model != null)
            {
                if (model.is_del == (int)EnumCollection.YesOrNot.是)
                {
                    model.is_del = (int)EnumCollection.YesOrNot.否;
                }
                else
                {
                    model.is_del = (int)EnumCollection.YesOrNot.是;
                }

                bll.Update(model);

                HttpContext.Current.Response.Write("1");
                HttpContext.Current.Response.End();
            }
            else
            {
                HttpContext.Current.Response.Write("0");
                HttpContext.Current.Response.End();
            }
        }
Exemplo n.º 3
0
        private bool DoEdit(int id)
        {
            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = bll.GetModel(id);

            model.from_id     = (int)EnumCollection.resource_from.课堂;
            model.group_id    = (int)EnumCollection.resource_group.公共资源;
            model.type        = (int)EnumCollection.resource_type.图文资源;
            model.school_id   = 0;
            model.school_name = "";
            model.data_id     = class_id;
            model.user_id     = user_id;
            model.title       = Convert.ToString(txttitle.Text.Trim());
            model.cover       = "";
            model.path        = Convert.ToString(txtcontents.Text.Trim());
            model.qrcode      = "/QrCode.aspx?type=re&id=" + id;
            model.file_name   = "";
            model.extend      = "";
            model.likn_url    = "";
            model.share_user  = "";

            if (bll.Update(model))
            {
                AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改课堂知识点信息,主键:" + id); //记录日志
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        private void BindData()
        {
            #region 组装查询条件
            string whereStr  = " from_id = " + (int)EnumCollection.resource_from.精品微课 + " and is_del = 1 ";
            string _keywords = keywords.Replace("'", "");

            if (!string.IsNullOrEmpty(_keywords))
            {
                if (Utils.IsSafeSqlString(_keywords))
                {
                    whereStr += " and (Title like  '%" + _keywords + "%')";
                }
                else
                {
                    JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("resource_back.aspx", "keywords={0}", ""));
                    return;
                }
            }

            #endregion

            this.page        = RequestHelper.GetQueryInt("page", 1);
            txtKeywords.Text = this.keywords;
            BLL.common_resource bll = new BLL.common_resource();
            this.rptList.DataSource = bll.GetListByPage("*", "View_ChapterResource", whereStr, " sort asc ", this.page, this.pageSize);
            this.rptList.DataBind();

            this.totalCount = bll.GetRecordCount(whereStr);
            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("resource_back.aspx", "keywords={0}&page={1}", this.keywords, "__id__");
            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_classroom_article_materials", EnumCollection.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.common_resource bll = new BLL.common_resource();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.UpdateField(id, "is_del = 1"))
                    {
                        sucCount += 1;
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除资源信息" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("article_list.aspx", "keywords={0}&class_id={1}", this.keywords, this.class_id + ""));
        }
Exemplo n.º 6
0
 private void BindInfo()
 {
     BLL.common_resource   bll   = new BLL.common_resource();
     Model.common_resource model = bll.GetModel(this.id);
     if (model == null)
     {
         JscriptMsg("信息不存在或已被删除!", "back");
         return;
     }
     txtfrom_id.Text     = model.from_id + "";
     txtgroup_id.Text    = model.group_id + "";
     txttype.Text        = model.type + "";
     txtschool_id.Text   = model.school_id + "";
     txtschool_name.Text = model.school_name + "";
     txtdata_id.Text     = model.data_id + "";
     txtuser_id.Text     = model.user_id + "";
     txttitle.Text       = model.title + "";
     txtcover.Text       = model.cover + "";
     txtpath.Text        = model.path + "";
     txtqrcode.Text      = model.qrcode + "";
     txtfile_name.Text   = model.file_name + "";
     txtextend.Text      = model.extend + "";
     txtlikn_url.Text    = model.likn_url + "";
     txtshare_user.Text  = model.share_user + "";
     txtsort.Text        = model.sort + "";
     txtadd_time.Text    = model.add_time + "";
     txtis_del.Text      = model.is_del + "";
 }
Exemplo n.º 7
0
        private bool DoEdit(int id)
        {
            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = bll.GetModel(id);

            model.from_id     = (int)EnumCollection.resource_from.课堂;
            model.group_id    = (int)EnumCollection.resource_group.公共资源;
            model.type        = (int)EnumCollection.resource_type.视频资源;
            model.school_id   = 0;
            model.school_name = "";
            model.data_id     = class_id;
            model.user_id     = admin_info.id;
            model.title       = getStr(this.hdfVal.Value, 1);
            model.cover       = this.txtcover.Text.Trim();
            model.path        = this.txtpath.Text.Trim();
            model.file_name   = this.hdfVal.Value;
            model.extend      = getStr(this.hdfVal.Value, 2);
            model.likn_url    = "";
            model.qrcode      = "/QrCode.aspx?type=re&id=" + id;
            model.share_user  = "";

            if (bll.Update(model))
            {
                AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改课堂视频资源信息,主键:" + id); //记录日志
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 8
0
        private void SaveClassroomResource()
        {
            int    class_id = RequestHelper.GetFormInt("class_id");
            string ids      = RequestHelper.GetFormString("ids");

            string[]              idArr    = ids.Split(',');
            BLL.common_resource   bll      = new BLL.common_resource();
            Model.common_resource model    = null;
            Model.common_resource newModel = null;
            for (int i = 0; i < idArr.Length; i++)
            {
                int id = Convert.ToInt32(idArr[i]);

                model = bll.GetModel(id);
                if (model != null)
                {
                    newModel         = model;
                    newModel.id      = 0;
                    newModel.from_id = (int)EnumCollection.resource_from.课堂;
                    newModel.data_id = class_id;

                    bll.Add(newModel);
                }
            }

            writeMsgSuccess("成功");
        }
Exemplo n.º 9
0
        private void getWordVoice()
        {
            int id = RequestHelper.GetFormInt("id");

            Model.common_resource model = new BLL.common_resource().GetModel(id);

            writeMsgSuccess("", model);
        }
Exemplo n.º 10
0
        private void GetCourseResource()
        {
            int    type     = RequestHelper.GetFormInt("type");
            string keywords = RequestHelper.GetFormString("keywords");
            int    page     = RequestHelper.GetFormInt("pageIndex", 1);
            int    pageSize = RequestHelper.GetFormInt("pageSize", 10);

            Utils.WriteCookie("manager_page_size", "AppoaPage", pageSize.ToString(), 14400);

            #region 组装查询条件
            string whereStr  = " from_id = " + (int)EnumCollection.resource_from.精品微课 + " and is_del = 0 and type = " + type;
            string _keywords = keywords.Replace("'", "");

            if (!string.IsNullOrEmpty(_keywords))
            {
                if (Utils.IsSafeSqlString(_keywords))
                {
                    whereStr += " and (Title like  '%" + _keywords + "%')";
                }
                else
                {
                    writeMsgError("搜索关键词中包含危险字符,检索终止!");
                    return;
                }
            }

            #endregion

            BLL.common_resource bll = new BLL.common_resource();
            DataTable           dt  = bll.GetListByPage("*", "View_ChapterResource", whereStr, " sort asc ", page, pageSize);

            int totalCount = bll.GetRecordCount("View_ChapterResource", whereStr);

            int pageCount = 0;
            if (totalCount % pageSize == 0)
            {
                pageCount = (int)(totalCount / pageSize);
            }
            else
            {
                pageCount = ((int)(totalCount / pageSize)) + 1;
            }

            var obj = new
            {
                DataList   = dt,
                TotalCount = totalCount,
                PageCount  = pageCount
            };

            writeMsgSuccess("", new List <object>()
            {
                obj
            });
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int id = RequestHelper.GetQueryInt("id");

                Model.common_resource model = new BLL.common_resource().GetModel(id);
                if (model != null)
                {
                    src = model.path;
                }
            }
        }
Exemplo n.º 12
0
        private void ShowInfo(int _id)
        {
            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = bll.GetModel(this.id);

            if (model == null)
            {
                JscriptMsg("信息不存在或已被删除!", "back");
                return;
            }

            this.txttitle.Text    = model.title + "";
            this.txtcontents.Text = model.path + "";
        }
        private void ShowInfo(int _id)
        {
            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = bll.GetModel(this.id);

            if (model == null)
            {
                JscriptMsg("信息不存在或已被删除!", "back");
                return;
            }

            this.txtpath.Text = model.path + "";
            this.hdfVal.Value = model.title + "." + model.extend;
        }
Exemplo n.º 14
0
        private bool DoAdd()
        {
            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = new Model.common_resource();

            model.from_id     = (int)EnumCollection.resource_from.课堂;
            model.group_id    = (int)EnumCollection.resource_group.公共资源;
            model.type        = (int)EnumCollection.resource_type.图文资源;
            model.school_id   = 0;
            model.school_name = "";
            model.data_id     = class_id;
            model.user_id     = user_id;
            model.title       = Convert.ToString(txttitle.Text.Trim());
            model.cover       = "";
            model.path        = Convert.ToString(txtcontents.Text.Trim());
            model.qrcode      = "";
            model.file_name   = "";
            model.extend      = "";
            model.likn_url    = "";
            model.share_user  = "";
            model.add_time    = System.DateTime.Now;

            Model.common_resource maxModel = bll.GetModel(" from_id = " + model.from_id + " and group_id = " + model.group_id + " and type = " + model.type + " and data_id = " + class_id + " order by sort desc ");
            if (maxModel != null)
            {
                model.sort = maxModel.sort + 1;
            }
            else
            {
                model.sort = 1;
            }

            int id = bll.Add(model);

            if (id > 0)
            {
                model.id     = id;
                model.qrcode = "/QrCode.aspx?type=re&id=" + id;
                bll.Update(model);

                AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加课堂知识点信息,主键:" + id); //记录日志
                return(true);
            }
            else
            {
                return(false);
            }
        }
 //保存排序
 protected void btnSave_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("_classroom_article_materials", EnumCollection.ActionEnum.Modify.ToString()); //检查权限
     BLL.common_resource bll = new BLL.common_resource();
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
         int sortId;
         if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtsort")).Text.Trim(), out sortId))
         {
             sortId = 1;
         }
         bll.UpdateField(id, "sort=" + sortId.ToString());
     }
     AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "保存课堂图文排序"); //记录日志
     JscriptMsg("保存排序成功!", Utils.CombUrlTxt("article_list.aspx", "keywords={0}&class_id={1}&page={2}", this.keywords, this.class_id + "", this.page + ""));
 }
        private void BindData()
        {
            #region 组装查询条件

            if (this.class_id > 0)
            {
                this.ddlClass.SelectedValue = this.class_id + "";
            }
            else
            {
                this.class_id = Convert.ToInt32(this.ddlClass.SelectedValue);
            }

            string whereStr  = " from_id = " + (int)EnumCollection.resource_from.课堂 + " and is_del = 0 and type = " + (int)EnumCollection.resource_type.图文资源 + " and data_id = " + this.class_id;
            string _keywords = keywords.Replace("'", "");

            if (!string.IsNullOrEmpty(_keywords))
            {
                if (Utils.IsSafeSqlString(_keywords))
                {
                    whereStr += " and (Title like  '%" + _keywords + "%')";
                }
                else
                {
                    JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("article_list.aspx", "keywords={0}&class_id={1}", "", this.class_id + ""));
                    return;
                }
            }

            #endregion

            this.page        = RequestHelper.GetQueryInt("page", 1);
            txtKeywords.Text = this.keywords;
            BLL.common_resource bll = new BLL.common_resource();
            this.rptList.DataSource = bll.GetListByPage(whereStr, " sort asc ", this.page, this.pageSize);
            this.rptList.DataBind();

            this.totalCount = bll.GetRecordCount(whereStr);
            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("article_list.aspx", "keywords={0}&class_id={1}&page={2}", this.keywords, this.class_id + "", "__id__");
            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
Exemplo n.º 17
0
        private void ShowInfo(int _id)
        {
            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = bll.GetModel(this.id);

            if (model == null)
            {
                JscriptMsg("信息不存在或已被删除!", "back");
                return;
            }

            this.rbtnGroup.SelectedValue = model.group_id + "";
            this.rbtnType.SelectedValue  = model.type + "";
            if (model.type == (int)EnumCollection.resource_type.图文资源)
            {
                this.txttitle.Text    = model.title + "";
                this.txtcontents.Text = model.path + "";
            }
            else
            {
                this.txtpath.Text = model.path + "";
                this.hdfVal.Value = model.title + "." + model.extend;
            }

            if (model.group_id == (int)EnumCollection.resource_group.共享资源)
            {
                string[] uidArr = model.share_user.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < this.ckbUser.Items.Count; i++)
                {
                    for (int n = 0; n < uidArr.Length; n++)
                    {
                        if (uidArr[n] == this.ckbUser.Items[i].Value)
                        {
                            this.ckbUser.Items[i].Selected = true;
                        }
                    }
                }
            }
        }
        private bool DoEdit(int id)
        {
            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = bll.GetModel(id);

            model.from_id     = (int)EnumCollection.resource_from.课堂;
            model.group_id    = (int)EnumCollection.resource_group.公共资源;
            model.type        = (int)EnumCollection.resource_type.文档资源;
            model.school_id   = 0;
            model.school_name = "";
            model.data_id     = class_id;
            model.user_id     = user_id;

            string fileNames = Utils.DelLastChar(this.hdfVal.Value, "|");
            string path      = Utils.DelLastChar(this.txtpath.Text, "|");

            string[] files = fileNames.Split('|');
            string[] paths = path.Split('|');

            model.title      = getStr(files[0], 1);
            model.cover      = "";
            model.path       = paths[0];
            model.file_name  = files[0];
            model.extend     = getStr(files[0], 2);
            model.likn_url   = "";
            model.qrcode     = "/QrCode.aspx?type=re&id=" + id;
            model.share_user = "";

            if (bll.Update(model))
            {
                AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改资源信息,主键:" + id); //记录日志
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int    id = RequestHelper.GetQueryInt("id");
                string f  = RequestHelper.GetQueryString("f");
                switch (f)
                {
                case "cp":
                    Model.company_info cp = new BLL.company_info().GetModel(id);
                    if (cp != null)
                    {
                        src   = cp.video_url;
                        thumb = cp.video_thumb_img;
                    }
                    break;

                case "case":
                    Model.common_resource re = new BLL.common_resource().GetModel(id);
                    if (re != null)
                    {
                        src   = re.path;
                        thumb = re.cover;
                    }
                    break;

                case "partner":
                    Model.company_partner partner = new BLL.company_partner().GetModel(id);
                    if (partner != null)
                    {
                        src   = partner.video_url;
                        thumb = partner.video_thumb_img;
                    }
                    break;
                }
            }
        }
Exemplo n.º 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string source_url = Request.QueryString["source_url"];
            string code       = Request.QueryString["code"];
            string state      = Request.QueryString["state"];

            if (!string.IsNullOrEmpty(source_url))
            {
                string location = Request.RawUrl;
                int    index    = location.IndexOf('=');
                source_url = location.Substring(index + 1, location.Length - index - 1);
                source_url = source_url.Replace('&', '*');


                Utils.StringToTxt("wxOAuth_WeChat_GetCode————source_url==" + source_url);
                Utils.WriteCookie("wxOAuth_WeChatGrant", "True");
                string url = WeChatContext.GetRedirectCode("/html/wxOAuth.aspx", source_url, true);

                Response.Redirect(url);
            }
            else if (!string.IsNullOrEmpty(code))
            {
                string temp      = Utils.UrlDecode(state);
                string decodeurl = temp.Replace('*', '&');

                Utils.StringToTxt("wxOAuth_wxLogin————code==" + code + ";wxOAuth_state==" + decodeurl);

                WeiXin_Access_token access_token = WeChatContext.GetAccessModel(code);

                if (access_token != null)
                {
                    SnsapiUserInfo userInfo = WeChatContext.GetSnsapiUserInfo(access_token.Access_token, access_token.Openid);//获取用户信息
                    if (userInfo != null)
                    {
                        user_info_entity entity = new user_info_entity();

                        //公众号openid存在
                        Model.user_oauths oaModel = new BLL.user_oauths().GetModel(" appid = '" + access_token.Openid + "'");
                        if (oaModel != null)
                        {
                            try
                            {
                                Utils.StringToTxt("wxOAuth_wxLogin————公众号openid存在,则更新openID=" + access_token.Openid + "和unionID=" + userInfo.unionid);
                                Model.user_info model = new BLL.user_info().GetModel(oaModel.user_id);

                                Utils.StringToTxt("wxOAuth_wxLogin————用户信息:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
                                Utils.StringToTxt("wxOAuth_wxLogin————认证信息:" + Newtonsoft.Json.JsonConvert.SerializeObject(oaModel));

                                //更新unionid(多应用唯一识别码)
                                oaModel.appid   = userInfo.openid;
                                oaModel.unionid = userInfo.unionid;
                                new BLL.user_oauths().Update(oaModel);

                                if (model.school_id == 0)//没有学校,公共资源
                                {
                                    decodeurl += "&method=scan";
                                    Response.Redirect(decodeurl);
                                }
                                else//有学校,学校资源
                                {
                                    int    idindex = decodeurl.IndexOf('=');
                                    string id      = decodeurl.Substring(idindex + 1, decodeurl.Length - idindex - 1);

                                    BLL.common_resource   resBll = new BLL.common_resource();
                                    Model.common_resource res    = resBll.GetModel(Convert.ToInt32(id));
                                    if (res != null)
                                    {
                                        if (res.from_id == (int)EnumCollection.resource_from.精品微课)       //如果是精品微课的资源
                                        {
                                            if (res.group_id == (int)EnumCollection.resource_group.公共资源) //若此资源是公共资源,查询此章节下的学校资源
                                            {
                                                Model.common_resource newRes = resBll.GetModel(string.Format(" from_id = {0} and group_id = {1} and type = {2} and data_id = {3}",
                                                                                                             res.from_id, (int)EnumCollection.resource_group.学校资源, res.type, res.data_id));
                                                if (newRes != null)
                                                {
                                                    decodeurl = decodeurl.Replace("id=" + id, "id=" + newRes.id);
                                                    Utils.StringToTxt("wxOAuth_wxLogin————学校资源=" + decodeurl);
                                                }

                                                decodeurl += "&method=scan";
                                                Response.Redirect(decodeurl);
                                            }
                                            else if (res.group_id == (int)EnumCollection.resource_group.学校资源)//若此资源是学校资源,判断是否是本学校的
                                            {
                                                if (model.school_id != res.school_id)
                                                {
                                                    Response.Write("您没有权限查看此资源");
                                                }
                                                else
                                                {
                                                    decodeurl += "&method=scan";
                                                    Response.Redirect(decodeurl);
                                                }
                                            }
                                        }
                                        else if (res.from_id == (int)EnumCollection.resource_from.课堂)//如果是课堂的资源
                                        {
                                            decodeurl += "&method=scan";
                                            Response.Redirect(decodeurl);
                                        }
                                    }
                                    else
                                    {
                                        decodeurl += "&method=scan";
                                        Response.Redirect(decodeurl);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Utils.StringToTxt("wxOAuth_wxLogin————获取数据库用户信息出现异常:" + ex.Message);
                                Response.Write("获取数据库用户信息出现异常:" + ex.Message);
                                return;
                            }
                        }
                        else//不存在
                        {
                            if (Utils.GetCookie("wxOAuth_WeChatGrant") == "True")
                            {
                                Utils.WriteCookie("wxOAuth_WeChatGrant", "False");

                                Utils.StringToTxt("wxOAuth_wxLogin————公众号openid不存在,是全新用户");

                                #region 创建用户
                                Model.user_info model = new Model.user_info();
                                model.group_id    = (int)EnumCollection.user_group.普通用户;
                                model.user_name   = "";
                                model.phone       = "";
                                model.salt        = Utils.GetCheckCode(6);
                                model.user_pwd    = "";
                                model.nick_name   = userInfo.nickname;
                                model.avatar      = userInfo.headimgurl;
                                model.integral    = 0;
                                model.school_id   = 0;
                                model.school_name = "";
                                model.college     = "";
                                model.job         = "";
                                model.course      = "";
                                model.line_way    = "";
                                model.area        = userInfo.country + userInfo.province + userInfo.city;
                                model.address     = "";
                                model.reg_ip      = RequestHelper.GetIP();
                                model.add_time    = System.DateTime.Now;

                                BLL.user_info bll = new BLL.user_info();
                                int           row = bll.Add(model);
                                if (row > 0)
                                {
                                    model.id                 = row;
                                    entity.UserInfo          = model;
                                    entity.UserInfo.user_pwd = "";
                                    entity.UserInfo.salt     = "";
                                    entity.UserInfo.reg_ip   = "";

                                    BLL.user_tree tBll = new BLL.user_tree();
                                    //1 创建code
                                    string tree_code = string.Empty;
                                    do
                                    {
                                        tree_code = Utils.Number(6);
                                    } while (tBll.GetModel(" code = '" + tree_code + "'") != null);

                                    //添加关系
                                    #region 添加关系
                                    Model.user_tree tree = new Model.user_tree();
                                    tree.user_id     = row;
                                    tree.code        = tree_code;
                                    tree.parent_code = "0";
                                    tree.grand_code  = "0";

                                    int treeid = tBll.Add(tree);
                                    if (treeid > 0)
                                    {
                                        tree.id         = treeid;
                                        entity.UserTree = tree;
                                    }
                                    #endregion

                                    #region 添加认证信息
                                    Utils.StringToTxt("wxOAuth_wxLogin————用户信息:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));

                                    Model.user_oauths model1 = new Model.user_oauths();
                                    model1.user_id = row;
                                    model1.type    = (int)EnumCollection.user_oauths.公众号微信登录;
                                    model1.name    = EnumCollection.user_oauths.公众号微信登录.ToString();
                                    model1.appid   = userInfo.openid;
                                    model1.unionid = userInfo.unionid;

                                    int oaid = new BLL.user_oauths().Add(model1);
                                    if (row > 0)
                                    {
                                        model1.id         = row;
                                        entity.UserOAuths = model1;

                                        Utils.StringToTxt("wxOAuth_wxLogin————新增的认证信息:" + Newtonsoft.Json.JsonConvert.SerializeObject(model1));
                                    }
                                    #endregion

                                    Response.Redirect(decodeurl);
                                    return;
                                }
                                else
                                {
                                    Utils.WriteCookie("wxOAuth_WeChatGrant", "True");
                                    string url = WeChatContext.GetRedirectCode("/html/wxOAuth.aspx", state, true);
                                    Response.Redirect(url);
                                    return;
                                }
                                #endregion
                            }
                            else
                            {
                                Utils.WriteCookie("wxOAuth_WeChatGrant", "True");
                                string url = WeChatContext.GetRedirectCode("/html/wxOAuth.aspx", state, true);
                                Response.Redirect(url);
                                return;
                            }
                        }
                    }
                    else
                    {
                        Response.Write("微信认证失败,请重试");
                        return;
                    }
                }
                else
                {
                    Response.Write("token获取失败");
                    return;
                }
            }
        }
Exemplo n.º 21
0
        private void DownCourseQrCode()
        {
            var Server = HttpContext.Current.Server;

            int    course_id      = RequestHelper.GetFormInt("course_id");
            string WebPath        = System.Configuration.ConfigurationManager.AppSettings["WebPath"];
            string webApi_address = WebPath + "/QrCode.aspx";

            BLL.course_info   bll    = new BLL.course_info();
            Model.course_info course = bll.GetModel(course_id);
            if (course != null)
            {
                string course_name = course.name.Trim();
                //1、生成书籍的二维码文件夹
                string virualRootPath = string.Format("/tempDown/{0}", course.name.Trim());
                string tempRootPath   = Server.MapPath(string.Format("/tempDown/{0}", course_name)).Trim();

                if (Directory.Exists(tempRootPath))
                {
                    Directory.Delete(tempRootPath, true);
                }
                if (!Directory.Exists(tempRootPath))
                {
                    Directory.CreateDirectory(tempRootPath);
                }

                if (string.IsNullOrWhiteSpace(webApi_address))
                {
                    writeMsgError(-1, "没有配置WebPath地址!");
                    return;
                }

                string bookQrCodePath = System.IO.Path.Combine(tempRootPath, string.Format("{0}_书籍资源.png", course_name)).Trim();

                string course_qrcode = string.Format("{0}/html/course_details.html?id={1}", WebPath, course.id); //要根据各个的生成规则生成二维码

                string logoPath = course.qrcode_logo;                                                            //二维码logo
                if (string.IsNullOrEmpty(logoPath))
                {
                    Model.common_albums defaultlogo = new BLL.common_albums().GetModel(" group_id = " + (int)Appoa.Common.EnumCollection.img_group.系统默认二维码logo);
                    if (defaultlogo != null)
                    {
                        logoPath = defaultlogo.original_path;
                    }
                    else
                    {
                        logoPath = "/html/images/Logo.png";
                    }
                }
                using (var ms = new MemoryStream())
                {
                    QrCodeHelper.GetRQCodeCombin(course_qrcode, ms, bookQrCodePath, Server.MapPath(logoPath));
                }
                //2、生成章的文件夹
                BLL.course_chapter          ccBll            = new BLL.course_chapter();
                BLL.common_resource         crBll            = new BLL.common_resource();
                List <Model.course_chapter> firstChapterList = ccBll.GetModelList(" group_id = 1 and chapter_level = 1 and course_id = " + course.id);
                foreach (Model.course_chapter chapter in firstChapterList)
                {
                    string chapterPath = System.IO.Path.Combine(tempRootPath, string.Format("章_{0}", chapter.name)).Trim();
                    if (Directory.Exists(chapterPath))
                    {
                        Directory.Delete(chapterPath, true);
                    }
                    if (!Directory.Exists(chapterPath))
                    {
                        Directory.CreateDirectory(chapterPath);
                    }

                    //3、生成节的文件夹
                    //List<Model.course_chapter> secondChapterList = ccBll.GetModelList(" group_id = 1 and chapter_level = 2 and course_id = " + course.id + " and parent_id = " + chapter.id);
                    //foreach (Model.course_chapter part in secondChapterList)
                    //{
                    //    string partPath = System.IO.Path.Combine(chapterPath, string.Format("节_{0}", part.name)).Trim();
                    //    if (Directory.Exists(partPath))
                    //    {
                    //        Directory.Delete(partPath, true);
                    //    }
                    //    if (!Directory.Exists(partPath))
                    //    {
                    //        Directory.CreateDirectory(partPath);
                    //    }

                    //4、生成章下所有资源二维码图片
                    List <Model.common_resource> resourceList = crBll.GetModelList(" is_del = 0 and from_id = " + (int)EnumCollection.resource_from.精品微课 + " and data_id = " + chapter.id);
                    foreach (Model.common_resource item in resourceList)
                    {
                        string resCode = string.Empty;
                        switch (item.type)
                        {
                        case (int)EnumCollection.resource_type.图文资源:
                            if (item.from_id == (int)EnumCollection.resource_from.精品微课)
                            {
                                resCode = WebPath + "/html/article_details.html?id=" + item.id;
                            }
                            else
                            {
                                resCode = WebPath + "/html/knowledge_details.html?id=" + item.id;
                            }
                            break;

                        case (int)EnumCollection.resource_type.文档资源:
                            item.path = item.path.Substring(0, item.path.LastIndexOf('.'));
                            //resCode = WebPath + item.path + ".html";
                            resCode = "/html/doc_detail.html?id=" + item.id;
                            break;

                        case (int)EnumCollection.resource_type.音频资源:
                            resCode = WebPath + "/html/video_details.html?id=" + item.id;
                            break;

                        case (int)EnumCollection.resource_type.视频资源:
                            resCode = WebPath + "/html/video_details.html?id=" + item.id;
                            break;

                        case (int)EnumCollection.resource_type.英文发音:
                            resCode = WebPath + "/html/voice_detail.html?id=" + item.id;
                            break;

                        case (int)EnumCollection.resource_type.维模型:
                            resCode = WebPath + "/html/3d.html?id=" + item.id;
                            break;
                        }
                        //生成明细资源
                        //string resPath = System.IO.Path.Combine(partPath, string.Format("{0}_{1}_资源_{2}.png", chapter.name, part.name, item.title.Trim())).Trim();
                        string resPath = System.IO.Path.Combine(chapterPath, item.title.Trim() + ".png").Trim();

                        using (var ms = new MemoryStream())
                        {
                            QrCodeHelper.GetRQCodeCombin(resCode, ms, resPath, Server.MapPath(logoPath));
                        }
                    }
                    //}
                }

                //打包—下载
                FastZip fz = new FastZip();
                fz.CreateEmptyDirectories = true;
                fz.CreateZip(string.Format("{0}.zip", tempRootPath), tempRootPath, true, "");
                // ZFiles.DownLoadFile(Server.MapPath(string.Format("{0}.zip", virualRootPath)));
                ZFiles.DownloadFile(System.Web.HttpContext.Current, Server.MapPath(string.Format("{0}.zip", virualRootPath)), 1024 * 50);
            }
        }
Exemplo n.º 22
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = null;

            if (action == EnumCollection.ActionEnum.Add.ToString())                                    //添加
            {
                ChkAdminLevel("_classroom_video_materials", EnumCollection.ActionEnum.Add.ToString()); //检查权限

                #region 添加操作

                string[] files  = this.hdfVal.Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                string[] thumbs = this.hdfThumb.Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                string[] paths  = this.txtpath.Text.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                int      count  = 0;
                Model.common_resource maxModel = null;

                for (int i = 0; i < files.Length; i++)
                {
                    model = new Model.common_resource();

                    model.from_id     = (int)EnumCollection.resource_from.课堂;
                    model.group_id    = (int)EnumCollection.resource_group.公共资源;
                    model.type        = (int)EnumCollection.resource_type.视频资源;
                    model.school_id   = 0;
                    model.school_name = "";
                    model.data_id     = class_id;
                    model.user_id     = admin_info.id;

                    string file = files[i];

                    model.title      = getStr(file, 1);
                    model.cover      = thumbs[i];
                    model.path       = paths[i];
                    model.qrcode     = "";
                    model.file_name  = file;
                    model.extend     = getStr(file, 2);
                    model.likn_url   = "";
                    model.share_user = "";
                    model.add_time   = System.DateTime.Now;

                    maxModel = bll.GetModel(" from_id = " + model.from_id + " and group_id = " + model.group_id + " and type = " + model.type + " and data_id = " + class_id + " order by sort desc ");
                    if (maxModel != null)
                    {
                        model.sort = maxModel.sort + 1;
                    }
                    else
                    {
                        model.sort = 1;
                    }

                    int id = bll.Add(model);
                    if (id > 0)
                    {
                        model.id     = id;
                        model.qrcode = "/QrCode.aspx?type=re&id=" + id;
                        bll.Update(model);

                        AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加" + Enum.GetName(typeof(EnumCollection.resource_type), model.type) + "资源信息,主键:" + id); //记录日志
                        count++;
                    }

                    JscriptMsg("添加" + Enum.GetName(typeof(EnumCollection.resource_type), model.type) + "资源成功!总文件" + files.Length + "个,成功" + count + "个", "video_list.aspx?class_id=" + this.class_id);
                }
                #endregion
            }
        }
Exemplo n.º 23
0
        private bool DoEdit(int id)
        {
            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = bll.GetModel(id);

            model.from_id  = (int)EnumCollection.resource_from.精品微课;
            model.group_id = Convert.ToInt32(this.rbtnGroup.SelectedValue);
            model.type     = Convert.ToInt32(this.rbtnType.SelectedValue);
            if (model.group_id != (int)EnumCollection.resource_group.学校资源)
            {
                model.school_id   = 0;
                model.school_name = "";
            }
            else
            {
                model.school_id   = Convert.ToInt32(this.ddlSchool.SelectedValue);
                model.school_name = this.ddlSchool.SelectedItem.Text;
            }
            model.data_id = chapter;
            model.user_id = admin_info.id;

            if (model.type == (int)EnumCollection.resource_type.图文资源)
            {
                model.title     = Convert.ToString(txttitle.Text.Trim());
                model.cover     = "";
                model.path      = Convert.ToString(txtcontents.Text.Trim());
                model.qrcode    = "/QrCode.aspx?type=re&id=" + id;
                model.file_name = "";
                model.extend    = "";
                model.likn_url  = "";
            }
            else
            {
                string   fileNames = Utils.DelLastChar(this.hdfVal.Value, "|");
                string   path      = Utils.DelLastChar(this.txtpath.Text, "|");
                string[] files     = fileNames.Split('|');
                string[] paths     = path.Split('|');

                model.title     = getStr(files[0], 1);
                model.cover     = "";
                model.path      = paths[0];
                model.file_name = files[0];
                model.extend    = getStr(files[0], 2);
                model.likn_url  = "";
                model.qrcode    = "/QrCode.aspx?type=re&id=" + id;
            }

            string userids = string.Empty;

            for (int i = 0; i < ckbUser.Items.Count; i++)
            {
                if (ckbUser.Items[i].Selected)
                {
                    userids += "," + ckbUser.Items[i].Value + ",";
                }
            }
            model.share_user = userids;

            if (bll.Update(model))
            {
                AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改资源信息,主键:" + id); //记录日志
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 24
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_common_resource", EnumCollection.ActionEnum.Add.ToString()); //检查权限

            #region
            string strError = string.Empty;
            if (txtfrom_id.Text.Trim() == "" || txtfrom_id.Text.Trim().Length > 4)
            {
                strError += "归属 1微课 2课堂为空或超出长度![br]";
            }
            if (txtgroup_id.Text.Trim() == "" || txtgroup_id.Text.Trim().Length > 4)
            {
                strError += "分组ID为空或超出长度![br]";
            }
            if (txttype.Text.Trim() == "" || txttype.Text.Trim().Length > 4)
            {
                strError += "分类ID为空或超出长度![br]";
            }
            if (txtschool_id.Text.Trim() == "" || txtschool_id.Text.Trim().Length > 4)
            {
                strError += "学校ID为空或超出长度![br]";
            }
            if (txtschool_name.Text.Trim() == "" || txtschool_name.Text.Trim().Length > 50)
            {
                strError += "学校名称为空或超出长度![br]";
            }
            if (txtdata_id.Text.Trim() == "" || txtdata_id.Text.Trim().Length > 4)
            {
                strError += "数据关联ID为空或超出长度![br]";
            }
            if (txtuser_id.Text.Trim() == "" || txtuser_id.Text.Trim().Length > 4)
            {
                strError += "上传者为空或超出长度![br]";
            }
            if (txttitle.Text.Trim() == "" || txttitle.Text.Trim().Length > 50)
            {
                strError += "标题为空或超出长度![br]";
            }
            if (txtcover.Text.Trim() == "" || txtcover.Text.Trim().Length > 255)
            {
                strError += "封面图为空或超出长度![br]";
            }
            if (txtpath.Text.Trim() == "" || txtpath.Text.Trim().Length > 16)
            {
                strError += "路径为空或超出长度![br]";
            }
            if (txtqrcode.Text.Trim() == "" || txtqrcode.Text.Trim().Length > 500)
            {
                strError += "二维码为空或超出长度![br]";
            }
            if (txtfile_name.Text.Trim() == "" || txtfile_name.Text.Trim().Length > 50)
            {
                strError += "文件名为空或超出长度![br]";
            }
            if (txtextend.Text.Trim() == "" || txtextend.Text.Trim().Length > 50)
            {
                strError += "扩展名为空或超出长度![br]";
            }
            if (txtlikn_url.Text.Trim() == "" || txtlikn_url.Text.Trim().Length > 500)
            {
                strError += "链接为空或超出长度![br]";
            }
            if (txtshare_user.Text.Trim() == "" || txtshare_user.Text.Trim().Length > 16)
            {
                strError += "要分享给的用户ID为空或超出长度![br]";
            }
            if (txtsort.Text.Trim() == "" || txtsort.Text.Trim().Length > 4)
            {
                strError += "排序为空或超出长度![br]";
            }
            if (txtadd_time.Text.Trim() == "" || txtadd_time.Text.Trim().Length > 8)
            {
                strError += "上传时间为空或超出长度![br]";
            }
            if (txtis_del.Text.Trim() == "" || txtis_del.Text.Trim().Length > 4)
            {
                strError += "是否删除为空或超出长度![br]";
            }

            if (strError != string.Empty)
            {
                JscriptMsg(strError, "", "Error");
                return;
            }
            #endregion

            Model.common_resource model = new Model.common_resource();
            BLL.common_resource   bll   = new BLL.common_resource();

            model.from_id     = Convert.ToInt32(txtfrom_id.Text);
            model.group_id    = Convert.ToInt32(txtgroup_id.Text);
            model.type        = Convert.ToInt32(txttype.Text);
            model.school_id   = Convert.ToInt32(txtschool_id.Text);
            model.school_name = Convert.ToString(txtschool_name.Text);
            model.data_id     = Convert.ToInt32(txtdata_id.Text);
            model.user_id     = Convert.ToInt32(txtuser_id.Text);
            model.title       = Convert.ToString(txttitle.Text);
            model.cover       = Convert.ToString(txtcover.Text);
            model.path        = Convert.ToString(txtpath.Text);
            model.qrcode      = Convert.ToString(txtqrcode.Text);
            model.file_name   = Convert.ToString(txtfile_name.Text);
            model.extend      = Convert.ToString(txtextend.Text);
            model.likn_url    = Convert.ToString(txtlikn_url.Text);
            model.share_user  = Convert.ToString(txtshare_user.Text);
            model.sort        = Convert.ToInt32(txtsort.Text);
            model.add_time    = Convert.ToDateTime(txtadd_time.Text);
            model.is_del      = Convert.ToInt32(txtis_del.Text);

            int id = bll.Add(model);
            if (id > 0)
            {
                AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加资源信息信息,主键:" + id); //记录日志
                JscriptMsg("添加资源信息信息成功!", "Manage.aspx", "");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }
Exemplo n.º 25
0
        private void saveWordVoice()
        {
            int    id          = RequestHelper.GetFormInt("id");
            int    group       = RequestHelper.GetFormInt("group");
            int    school      = RequestHelper.GetFormInt("school");
            string school_name = RequestHelper.GetFormString("school_name");
            int    chapter     = RequestHelper.GetFormInt("chapter");
            string title       = RequestHelper.GetFormString("title");
            string userids     = RequestHelper.GetFormString("userids");
            string words       = RequestHelper.GetFormString("words");

            Appoa.Web.UI.ManagePage mngPage = new Web.UI.ManagePage();
            BLL.common_resource     bll     = new BLL.common_resource();
            Model.common_resource   model   = bll.GetModel(id);

            if (model != null)
            {
                model.group_id = group;
                if (model.group_id == (int)EnumCollection.resource_group.公共资源)
                {
                    model.school_id   = 0;
                    model.school_name = "";
                }
                else
                {
                    model.school_id   = school;
                    model.school_name = school_name;
                }

                model.data_id = chapter;
                model.user_id = mngPage.GetAdminInfo().id;

                model.title      = title;
                model.path       = words;
                model.share_user = userids;

                if (bll.Update(model))
                {
                    mngPage.AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改英文发音资源信息,主键:" + id); //记录日志

                    writeMsgSuccess("保存成功");
                }
                else
                {
                    writeMsgError("保存失败");
                }
            }
            else
            {
                model          = new Model.common_resource();
                model.from_id  = (int)EnumCollection.resource_from.精品微课;
                model.group_id = group;
                model.type     = (int)EnumCollection.resource_type.英文发音;

                if (model.group_id == (int)EnumCollection.resource_group.公共资源)
                {
                    model.school_id   = 0;
                    model.school_name = "";
                }
                else
                {
                    model.school_id   = school;
                    model.school_name = school_name;
                }
                model.data_id = chapter;
                model.user_id = mngPage.GetAdminInfo().id;

                model.title      = title;
                model.cover      = "";
                model.path       = words;
                model.qrcode     = "";
                model.file_name  = "";
                model.extend     = "";
                model.likn_url   = "";
                model.add_time   = System.DateTime.Now;
                model.share_user = userids;

                int row = bll.Add(model);
                if (row > 0)
                {
                    model.id     = row;
                    model.qrcode = "/QrCode.aspx?type=re&id=" + row;
                    bll.Update(model);

                    mngPage.AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加英文发音资源信息,主键:" + row); //记录日志

                    writeMsgSuccess("保存成功");
                }
                else
                {
                    writeMsgError("保存失败");
                }
            }
        }
Exemplo n.º 26
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            BLL.common_resource   bll   = new BLL.common_resource();
            Model.common_resource model = null;

            if (action == EnumCollection.ActionEnum.Modify.ToString())                        //修改
            {
                ChkAdminLevel("_resource_list", EnumCollection.ActionEnum.Modify.ToString()); //检查权限
                if (!DoEdit(this.id))
                {
                    JscriptMsg("保存过程中发生错误!", "");
                    return;
                }

                JscriptMsg("修改资源成功!", "resource_list.aspx?page=" + this.page + "&chapter=" + this.chapter + "&course_id=" + this.course_id);
            }
            else //添加
            {
                ChkAdminLevel("_resource_list", EnumCollection.ActionEnum.Add.ToString()); //检查权限

                #region 添加操作
                if (Convert.ToInt32(this.rbtnType.SelectedValue) == (int)EnumCollection.resource_type.图文资源)
                {
                    model = new Model.common_resource();

                    model.from_id  = (int)EnumCollection.resource_from.精品微课;
                    model.group_id = Convert.ToInt32(this.rbtnGroup.SelectedValue);
                    model.type     = Convert.ToInt32(this.rbtnType.SelectedValue);
                    if (model.group_id != (int)EnumCollection.resource_group.学校资源)
                    {
                        model.school_id   = 0;
                        model.school_name = "";
                    }
                    else
                    {
                        model.school_id   = Convert.ToInt32(this.ddlSchool.SelectedValue);
                        model.school_name = this.ddlSchool.SelectedItem.Text;
                    }
                    model.data_id   = chapter;
                    model.user_id   = admin_info.id;
                    model.title     = Convert.ToString(txttitle.Text.Trim());
                    model.cover     = "";
                    model.path      = Convert.ToString(txtcontents.Text.Trim());
                    model.qrcode    = "";
                    model.file_name = "";
                    model.extend    = "";
                    model.likn_url  = "";
                    model.add_time  = System.DateTime.Now;

                    Model.common_resource maxModel = bll.GetModel(" from_id = " + (int)EnumCollection.resource_from.精品微课 + " and data_id = " + chapter + " order by sort desc ");
                    if (maxModel != null)
                    {
                        model.sort = maxModel.sort + 1;
                    }
                    else
                    {
                        model.sort = 1;
                    }

                    string userids = string.Empty;
                    for (int i = 0; i < ckbUser.Items.Count; i++)
                    {
                        if (ckbUser.Items[i].Selected)
                        {
                            userids += "," + ckbUser.Items[i].Value + ",";
                        }
                    }
                    model.share_user = userids;

                    int id = bll.Add(model);
                    if (id > 0)
                    {
                        model.id     = id;
                        model.qrcode = "/QrCode.aspx?type=re&id=" + id;
                        bll.Update(model);

                        AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加图文资源信息,主键:" + id); //记录日志
                        JscriptMsg("添加图文资源成功!", "resource_list.aspx?chapter=" + this.chapter + "&course_id=" + this.course_id);
                    }
                    else
                    {
                        JscriptMsg("保存过程中发生错误!", "");
                        return;
                    }
                }
                else
                {
                    string   fileNames             = Utils.DelLastChar(this.hdfVal.Value, "|");
                    string   path                  = Utils.DelLastChar(this.txtpath.Text, "|");
                    string[] files                 = fileNames.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    string[] paths                 = path.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    int      count                 = 0;
                    Model.common_resource maxModel = null;

                    for (int i = 0; i < files.Length; i++)
                    {
                        model = new Model.common_resource();

                        model.from_id  = (int)EnumCollection.resource_from.精品微课;
                        model.group_id = Convert.ToInt32(this.rbtnGroup.SelectedValue);
                        model.type     = Convert.ToInt32(this.rbtnType.SelectedValue);
                        if (model.group_id == (int)EnumCollection.resource_group.公共资源)
                        {
                            model.school_id   = 0;
                            model.school_name = "";
                        }
                        else
                        {
                            model.school_id   = Convert.ToInt32(this.ddlSchool.SelectedValue);
                            model.school_name = this.ddlSchool.SelectedItem.Text;
                        }
                        model.data_id = chapter;
                        model.user_id = admin_info.id;

                        string file = files[i];

                        model.title     = getStr(file, 1);
                        model.cover     = "";
                        model.path      = paths[i];
                        model.qrcode    = "";
                        model.file_name = file;
                        model.extend    = getStr(file, 2);
                        model.likn_url  = "";
                        model.add_time  = System.DateTime.Now;

                        maxModel = bll.GetModel(" from_id = " + (int)EnumCollection.resource_from.精品微课 + " and data_id = " + chapter + " order by sort desc ");
                        if (maxModel != null)
                        {
                            model.sort = maxModel.sort + 1;
                        }
                        else
                        {
                            model.sort = 1;
                        }

                        string userids = string.Empty;
                        for (int j = 0; j < ckbUser.Items.Count; j++)
                        {
                            if (ckbUser.Items[j].Selected)
                            {
                                userids += "," + ckbUser.Items[j].Value + ",";
                            }
                        }
                        model.share_user = userids;

                        int id = bll.Add(model);
                        if (id > 0)
                        {
                            model.id     = id;
                            model.qrcode = "/QrCode.aspx?type=re&id=" + id;
                            bll.Update(model);

                            AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加" + Enum.GetName(typeof(EnumCollection.resource_type), model.type) + "资源信息,主键:" + id); //记录日志
                            count++;
                        }
                    }

                    JscriptMsg("添加" + Enum.GetName(typeof(EnumCollection.resource_type), model.type) + "资源成功!总文件" + files.Length + "个,成功" + count + "个", "resource_list.aspx?chapter=" + this.chapter + "&course_id=" + this.course_id);
                }
                #endregion
            }
        }
Exemplo n.º 27
0
        private void GetQrCode(string type)
        {
            string str      = string.Empty;
            string id       = Request.QueryString["id"];
            string logopath = string.Empty;
            bool   is_logo  = true;

            Model.course_info course = null;

            switch (type)
            {
            case "course":    //课程
                is_logo = true;
                course  = new BLL.course_info().GetModel(Convert.ToInt32(id));
                if (course != null)
                {
                    str      = WebPath + "/html/course_details.html?id=" + id;
                    logopath = course.qrcode_logo;
                }
                else
                {
                    return;
                }
                break;

            case "re":    //资源
                is_logo = true;
                Model.common_resource resource = new BLL.common_resource().GetModel(Convert.ToInt32(id));
                if (resource != null)
                {
                    course = new BLL.course_info().GetModel(" id = (select course_id from ybd_course_chapter where id = " + resource.data_id + ")");
                    if (course != null)
                    {
                        logopath = course.qrcode_logo;
                    }

                    switch (resource.type)
                    {
                    case (int)Appoa.Common.EnumCollection.resource_type.图文资源:
                        if (resource.from_id == (int)EnumCollection.resource_from.精品微课)
                        {
                            str = WebPath + "/html/article_details.html?id=" + id;
                        }
                        else
                        {
                            str = WebPath + "/html/knowledge_details.html?id=" + id;
                        }
                        break;

                    case (int)Appoa.Common.EnumCollection.resource_type.文档资源:
                        resource.path = resource.path.Substring(0, resource.path.LastIndexOf('.'));
                        //str = WebPath + resource.path + ".html";
                        str = WebPath + "/html/doc_detail.html?id=" + id;
                        break;

                    case (int)Appoa.Common.EnumCollection.resource_type.音频资源:
                        str = WebPath + "/html/video_details.html?id=" + id;
                        break;

                    case (int)Appoa.Common.EnumCollection.resource_type.视频资源:
                        str = WebPath + "/html/video_details.html?id=" + id;
                        break;

                    case (int)Appoa.Common.EnumCollection.resource_type.英文发音:
                        str = WebPath + "/html/voice_detail.html?id=" + id;
                        break;

                    case (int)Appoa.Common.EnumCollection.resource_type.维模型:
                        str = WebPath + "/html/3d.html?id=" + id;
                        break;
                    }
                }
                else
                {
                    return;
                }
                break;

            case "test":    //测验
                Model.common_examination exam = new BLL.common_examination().GetModel(Convert.ToInt32(id));
                if (exam != null)
                {
                    str     = WebPath + "/html/test.html?id=" + id;
                    is_logo = true;
                    //course = new BLL.course_info().GetModel(" id = (select course_id from ybd_course_chapter where id = " + exam.parent_id + ")");
                    //if (course != null)
                    //{
                    //    logopath = course.qrcode_logo;
                    //}
                }
                else
                {
                    return;
                }
                break;

            case "talk":    //讨论
                Model.common_article article = new BLL.common_article().GetModel(Convert.ToInt32(id));
                if (article != null)
                {
                    str     = WebPath + "/html/discuss_details.html?id=" + id;
                    is_logo = true;
                    //course = new BLL.course_info().GetModel(" id = (select course_id from ybd_course_chapter where user_id = 0 and id = " + article.category_id + ")");
                    //if (course != null)
                    //{
                    //    logopath = course.qrcode_logo;
                    //}
                }
                else
                {
                    return;
                }
                break;

            case "quest":    //心理测试
                str = WebPath + "/html/questionnaire.html?id=" + id;
                break;

            case "classroom":    //课堂
                str = WebPath + "/html/join_class.html?id=" + id;
                break;
            }

            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();

            qrCodeEncoder.QRCodeEncodeMode   = QRCodeEncoder.ENCODE_MODE.BYTE;
            qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
            qrCodeEncoder.QRCodeVersion      = 0;
            qrCodeEncoder.QRCodeScale        = 13;

            //将字符串生成二维码图片
            Bitmap image = qrCodeEncoder.Encode(str, Encoding.Default);

            //保存为PNG到内存流
            MemoryStream ms = new MemoryStream();

            image.Save(ms, ImageFormat.Png);

            if (is_logo)
            {
                if (string.IsNullOrEmpty(logopath))
                {
                    Model.common_albums defaultlogo = new BLL.common_albums().GetModel(" group_id = " + (int)Appoa.Common.EnumCollection.img_group.系统默认二维码logo);
                    if (defaultlogo != null)
                    {
                        logopath = defaultlogo.original_path;
                    }
                    else
                    {
                        logopath = "/html/images/Logo.png";
                    }
                }

                //logopath = "/html/images/Logo.png";

                MemoryStream ms1 = new MemoryStream();
                CombinImage(image, Server.MapPath("~" + logopath), 80).Save(ms1, System.Drawing.Imaging.ImageFormat.Png);

                //输出二维码图片
                Response.ClearContent();
                Response.ContentType = "image/Png";
                Response.BinaryWrite(ms1.ToArray());

                ms.Dispose();
                ms1.Dispose();

                Response.Flush();
                Response.End();
            }
            else
            {
                //输出二维码图片
                Response.ClearContent();
                Response.ContentType = "image/Png";
                Response.BinaryWrite(ms.ToArray());

                ms.Dispose();

                Response.Flush();
                Response.End();
            }
        }