Пример #1
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="acc">教师</param>
        /// <param name="expiresDay">登录时效,单位:天</param>
        public void Write(Song.Entities.Teacher acc, int expiresDay)
        {
            System.Web.HttpContext _context = System.Web.HttpContext.Current;
            //登录标识名
            string key    = WeiSha.Common.Login.Get["Teacher"].KeyName.String;
            string domain = WeiSha.Common.Request.Domain.TwoDomain;

            key = domain + "_" + key;
            if (Teacher.LoginPattern == LoginPatternEnum.Cookies)
            {
                System.Web.HttpCookie cookie = new System.Web.HttpCookie(key);
                cookie.Value = acc.Th_ID.ToString();
                string exp = WeiSha.Common.Login.Get["Teacher"].Expires.String;
                if (expiresDay <= 0)
                {
                    if (!exp.Equals("auto", StringComparison.CurrentCultureIgnoreCase))
                    {
                        cookie.Expires = DateTime.Now.AddMinutes(WeiSha.Common.Login.Get["Teacher"].Expires.Int32 ?? 10);
                    }
                }
                else
                {
                    cookie.Expires = DateTime.Now.AddDays(expiresDay);
                }
                _context.Response.Cookies.Add(cookie);
            }
            if (Teacher.LoginPattern == LoginPatternEnum.Session)
            {
                _context.Session[key] = acc.Th_ID;
            }
            this._register(acc);
        }
Пример #2
0
 /// <summary>
 /// 绑定导航
 /// </summary>
 private void bindTree()
 {
     //院系
     Song.Entities.Depart[] nc = Business.Do <IDepart>().GetAll(org.Org_ID, true, null);
     this.ddlDepart.DataSource     = nc;
     this.ddlDepart.DataTextField  = "dep_cnName";
     this.ddlDepart.DataValueField = "dep_id";
     this.ddlDepart.DataBind();
     //
     this.ddlDepart.Items.Insert(0, new ListItem(" -- 院系 -- ", "-1"));
     //如果是教师登录,则只显示所在院系
     if (Extend.LoginState.Accounts.IsLogin)
     {
         Song.Entities.Teacher th = Extend.LoginState.Accounts.Teacher;
         ListItem li = ddlDepart.Items.FindByValue(th.Dep_Id.ToString());
         if (li != null)
         {
             ddlDepart.SelectedIndex = -1;
             li.Selected             = true;
             ddlDepart.Enabled       = false;
         }
     }
     if (Extend.LoginState.Admin.IsAdmin && isAdmin)
     {
         ddlDepart.Enabled       = true;
         ddlDepart.SelectedIndex = 0;
     }
     ddlDepart_SelectedIndexChanged(null, null);
 }
Пример #3
0
        /// <summary>
        /// 绑定列表
        /// </summary>
        protected void BindData(object sender, EventArgs e)
        {
            //总记录数
            bool?isUse = null;
            List <Song.Entities.Course> eas = null;
            int sbjid = Convert.ToInt32(ddlSubject.SelectedValue);

            //当前教师
            Song.Entities.Teacher th = Extend.LoginState.Accounts.Teacher;
            eas = Business.Do <ICourse>().CourseCount(org.Org_ID, sbjid, th.Th_ID, -1, tbSear.Text, isUse, -1);
            foreach (Song.Entities.Course s in eas)
            {
                if (string.IsNullOrEmpty(s.Cou_Intro) || s.Cou_Intro.Trim() == "")
                {
                    continue;
                }
                if (s.Cou_Intro.Length > 20)
                {
                    s.Cou_Intro = s.Cou_Intro.Substring(0, 20) + "...";
                }
            }
            DataTable dt = WeiSha.WebControl.Tree.ObjectArrayToDataTable.To(eas.ToArray());

            WeiSha.WebControl.Tree.DataTableTree tree = new WeiSha.WebControl.Tree.DataTableTree();
            tree.IdKeyName       = "Cou_ID";
            tree.ParentIdKeyName = "Cou_PID";
            tree.TaxKeyName      = "Cou_Tax";
            tree.Root            = 0;
            dt = tree.BuilderTree(dt);


            GridView1.DataSource   = dt;
            GridView1.DataKeyNames = new string[] { "Cou_ID" };
            GridView1.DataBind();
        }
Пример #4
0
        /// <summary>
        /// 注册某个用户到在线列表中
        /// </summary>
        /// <param name="acc"></param>
        private void _register(Song.Entities.Teacher acc)
        {
            if (acc == null)
            {
                return;
            }
            //登录时间,该时间不入数据库,仅为临时使用
            acc.Th_LastTime = DateTime.Now;
            //登录用户是否已经存在;
            bool isHav = false;

            for (int i = 0; i < this._onlineUser.Count; i++)
            {
                Song.Entities.Teacher e = this._onlineUser[i];
                if (e == null)
                {
                    continue;
                }
                if (e.Th_ID == acc.Th_ID)
                {
                    this._onlineUser[i] = acc;
                    isHav = true;
                    break;
                }
            }
            //如果未登录,则注册进去
            if (!isHav)
            {
                this._onlineUser.Add(acc);
            }
        }
Пример #5
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnEnter_Click(object sender, EventArgs e)
 {
     Song.Entities.TeacherHistory th =
         id == 0 ? new Song.Entities.TeacherHistory() : Business.Do <ITeacher>().HistorySingle(id);
     th = this.EntityFill(th) as Song.Entities.TeacherHistory;
     //如果没有填写结整时间,则为最大值
     if (Thh_EndTime.Text.Trim() == "")
     {
         th.Thh_EndTime = DateTime.MaxValue;
     }
     //所属教师
     Song.Entities.Teacher curth = Extend.LoginState.Accounts.Teacher;
     th.Th_ID   = curth.Th_ID;
     th.Th_Name = curth.Th_Name;
     try
     {
         if (id < 1)
         {
             Business.Do <ITeacher>().HistoryAdd(th);
         }
         else
         {
             Business.Do <ITeacher>().HistorySave(th);
         }
         Master.AlertCloseAndRefresh("操作成功!");
     }
     catch (Exception ex)
     {
         Master.Alert(ex.Message);
     }
 }
Пример #6
0
        /// <summary>
        /// 绑定列表
        /// </summary>
        protected void BindData(object sender, EventArgs e)
        {
            //总记录数
            bool?isUse = null;
            List <Song.Entities.Course> eas = null;
            int sbjid = Convert.ToInt32(ddlSubject.SelectedValue);

            //当前教师
            Song.Entities.Teacher th = Extend.LoginState.Accounts.Teacher;
            if (th == null)
            {
                return;
            }
            int count = 0;

            eas = Business.Do <ICourse>().CoursePager(org.Org_ID, sbjid, th.Th_ID, isUse, tbSear.Text.Trim(), "tax", Pager1.Size, Pager1.Index, out count);
            foreach (Song.Entities.Course s in eas)
            {
                if (string.IsNullOrEmpty(s.Cou_Intro) || s.Cou_Intro.Trim() == "")
                {
                    continue;
                }
                if (s.Cou_Intro.Length > 20)
                {
                    s.Cou_Intro = s.Cou_Intro.Substring(0, 20) + "...";
                }
            }

            GridView1.DataSource   = eas;
            GridView1.DataKeyNames = new string[] { "Cou_ID" };
            GridView1.DataBind();
            Pager1.RecordAmount = count;
        }
Пример #7
0
 /// <summary>
 /// 注册已经登录的在线用户,如果已经注册,则更新注册时间
 /// </summary>
 public void Register()
 {
     Song.Entities.Teacher ea = this.Read();
     if (ea != null)
     {
         _register(ea);
     }
 }
Пример #8
0
 public void TeacherDelete(string accname, int orgid)
 {
     Song.Entities.Teacher th = this.TeacherSingle(accname, orgid);
     if (th == null)
     {
         return;
     }
     this.TeacherDelete(th);
 }
Пример #9
0
 public void TeacherDelete(int identify)
 {
     Song.Entities.Teacher th = this.TeacherSingle(identify);
     if (th == null)
     {
         return;
     }
     this.TeacherDelete(th);
 }
Пример #10
0
 private void fill()
 {
     Song.Entities.Teacher th = Extend.LoginState.Accounts.Teacher;
     lbCurrName.Text       = th.Th_Name;
     imbCurrPhoto.ImageUrl = Upload.Get["Teacher"].Virtual + th.Th_Photo;
     //回复信息
     tbAns.Text      = mb.Mb_Answer;
     cbIshow.Checked = mb.Mb_IsShow;
 }
Пример #11
0
        protected override void InitPageTemplate(HttpContext context)
        {
            //所属教师
            Song.Entities.Teacher th = Extend.LoginState.Accounts.Teacher;
            //所属机构
            Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
            //当前教师负责的课程
            List <Song.Entities.Course> cous = Business.Do <ICourse>().CourseAll(org.Org_ID, -1, th.Th_ID, null);

            this.Document.SetValue("courses", cous);
            this.Document.SetValue("path", Upload.Get["Course"].Virtual);
        }
Пример #12
0
        /// <summary>
        /// 修改是否显示的状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void sbUse_Click(object sender, EventArgs e)
        {
            StateButton ub    = (StateButton)sender;
            int         index = ((GridViewRow)(ub.Parent.Parent)).RowIndex;
            int         id    = int.Parse(this.GridView1.DataKeys[index].Value.ToString());

            //
            Song.Entities.Teacher entity = Business.Do <ITeacher>().TeacherSingle(id);
            entity.Th_IsUse = !entity.Th_IsUse;
            Business.Do <ITeacher>().TeacherSave(entity);
            BindData(null, null);
        }
Пример #13
0
        /// <summary>
        /// 绑定课程
        /// </summary>
        private void bindTree()
        {
            //当前教师
            Song.Entities.Teacher       th  = Extend.LoginState.Accounts.Teacher;
            List <Song.Entities.Course> eas = null;

            eas = Business.Do <ICourse>().CourseCount(org.Org_ID, -1, th.Th_ID, -1, null, null, -1);
            ddlCourse.DataSource     = eas;
            ddlCourse.DataTextField  = "Cou_Name";
            ddlCourse.DataValueField = "Cou_ID";
            ddlCourse.DataBind();
            //this.ddlCourse.Items.Insert(0, new ListItem(" -- 我的所有课程 -- ", "-1"));
        }
Пример #14
0
        /// <summary>
        /// 验证账号是否已经存在
        /// </summary>
        /// <param name="source"></param>
        /// <param name="args"></param>
        protected void cusv_ServerValidate(object source, ServerValidateEventArgs args)
        {
            Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
            Song.Entities.Teacher      th  = Business.Do <ITeacher>().TeacherSingle(id);
            if (th == null)
            {
                th = new Entities.Teacher();
            }
            th.Org_ID = org.Org_ID;
            //判断是否通过验证
            bool isAccess = Business.Do <ITeacher>().IsTeacherExist(org.Org_ID, th);

            args.IsValid = !isAccess;
        }
Пример #15
0
 private void fill()
 {
     Song.Entities.Teacher th = id == 0 ? new Song.Entities.Teacher() : Business.Do <ITeacher>().TeacherSingle(id);
     if (id > 0)
     {
         this.EntityBind(th);
     }
     //出生年月
     Th_Birthday.Text = th.Th_Birthday < DateTime.Now.AddYears(-100) ? "" : th.Th_Birthday.ToString("yyyy-MM-dd");
     //个人照片
     if (!string.IsNullOrEmpty(th.Th_Photo) && th.Th_Photo.Trim() != "")
     {
         this.imgShow.Src = Upload.Get[_uppath].Virtual + th.Th_Photo;
     }
 }
Пример #16
0
        /// <summary>
        /// 获取当前登录用户的对象
        /// </summary>
        /// <returns></returns>
        public Song.Entities.Teacher Read()
        {
            int accid = this.CurrentUserId;

            if (accid < 1)
            {
                return(null);
            }

            Song.Entities.Teacher acc = this.CurrentUser;
            if (acc == null)
            {
                acc = Business.Do <ITeacher>().TeacherSingle(accid);
            }
            return(acc);
        }
Пример #17
0
 public Song.Entities.Teacher ForID(int id)
 {
     if (id <= 0)
     {
         return(null);
     }
     Song.Entities.Teacher teacher = Business.Do <ITeacher>().TeacherSingle(id);
     if (teacher != null)
     {
         if (System.IO.File.Exists(Upload.Get["Teacher"].Physics + teacher.Th_Photo))
         {
             teacher.Th_Photo = Upload.Get["Teacher"].Virtual + teacher.Th_Photo;
         }
         else
         {
             teacher.Th_Photo = "";
         }
     }
     return(teacher);
 }
Пример #18
0
 /// <summary>
 /// 教师登录
 /// </summary>
 /// <param name="acc">账号</param>
 /// <param name="pw">密码,明文字符</param>
 /// <returns></returns>
 public Song.Entities.Teacher Login(string acc, string pw)
 {
     Song.Entities.Accounts account = Business.Do <IAccounts>().AccountsLogin(acc, pw, true);
     if (account == null)
     {
         return(null);
     }
     if (!account.Ac_IsTeacher)
     {
         return(null);
     }
     //
     Song.Entities.Teacher teacher = Business.Do <ITeacher>().TeacherSingle(account.Ac_AccName, -1);
     if (teacher != null)
     {
         teacher.Th_Photo = WeiSha.Common.Upload.Get["Accounts"].Virtual + account.Ac_Photo;
         teacher.Th_Pw    = string.Empty;
     }
     return(teacher);
 }
Пример #19
0
        /// <summary>
        /// 教师登录
        /// </summary>
        /// <param name="acc">账号,或身份证,或手机</param>
        /// <param name="pw">密码</param>
        /// <param name="orgid"></param>
        /// <returns></returns>
        public Teacher TeacherLogin(string acc, string pw, int orgid)
        {
            WhereClip wc = Teacher._.Org_ID == orgid && Teacher._.Th_IsUse == true && Teacher._.Th_IsPass == true;

            wc.And(Teacher._.Th_Pw == new WeiSha.Common.Param.Method.ConvertToAnyValue(pw).MD5);
            Song.Entities.Teacher entity = null;
            if (entity == null)
            {
                entity = Gateway.Default.From <Teacher>().Where(wc && Teacher._.Th_AccName == acc).ToFirst <Teacher>();
            }
            if (entity == null)
            {
                entity = Gateway.Default.From <Teacher>().Where(wc && Teacher._.Th_PhoneMobi == acc).ToFirst <Teacher>();
            }
            if (entity == null)
            {
                entity = Gateway.Default.From <Teacher>().Where(wc && Teacher._.Th_IDCardNumber == acc).ToFirst <Teacher>();
            }
            return(entity);
        }
Пример #20
0
        /// <summary>
        /// 绑定列表
        /// </summary>
        protected void BindData(object sender, EventArgs e)
        {
            //所属教师
            Song.Entities.Teacher th = Extend.LoginState.Accounts.Teacher;
            //所属机构
            Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
            //当前教师负责的课程
            List <Song.Entities.Course> cous = Business.Do <ICourse>().CourseAll(org.Org_ID, -1, th.Th_ID, null);

            foreach (Song.Entities.Course c in cous)
            {
                //课程图片
                if (!string.IsNullOrEmpty(c.Cou_LogoSmall) && c.Cou_LogoSmall.Trim() != "")
                {
                    c.Cou_LogoSmall = Upload.Get[_uppath].Virtual + c.Cou_LogoSmall;
                    c.Cou_Logo      = Upload.Get[_uppath].Virtual + c.Cou_Logo;
                }
            }
            rptCourse.DataSource = cous;
            rptCourse.DataBind();
        }
Пример #21
0
        protected void ddlSubject_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddlCourse.Items.Clear();
            //总记录数
            bool?isUse = null;

            Song.Entities.Teacher       th  = Extend.LoginState.Accounts.Teacher;
            List <Song.Entities.Course> eas = null;
            int sbjid = Convert.ToInt32(ddlSubject.SelectedValue);

            eas = Business.Do <ICourse>().CourseCount(org.Org_ID, sbjid, -1, -1, null, isUse, -1);
            ddlCourse.DataSource     = eas;
            ddlCourse.DataTextField  = "Cou_Name";
            ddlCourse.DataValueField = "Cou_ID";
            ddlCourse.DataBind();
            if (ddlCourse.Items.Count < 1)
            {
                ddlCourse.Items.Insert(0, new ListItem(" -- 没有课程 -- ", "0"));
            }
            ddlCourse.Items.Insert(0, new ListItem(" -- 课程 -- ", "-1"));
            ddlCourse_SelectedIndexChanged(null, null);
        }
Пример #22
0
 protected void btnEnter_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         mb.Mb_AnsTime = DateTime.Now;
         mb.Mb_Answer  = tbAns.Text.Trim();
         mb.Mb_IsShow  = cbIshow.Checked;
         mb.Mb_IsAns   = true;
         //当前教师
         Song.Entities.Teacher teacher = Extend.LoginState.Accounts.Teacher;
         if (teacher != null)
         {
             mb.Th_ID = teacher.Th_ID;
         }
         Business.Do <IMessageBoard>().ThemeSave(mb);
         Master.AlertCloseAndRefresh("操作成功!");
     }
     catch (Exception ex)
     {
         Master.Alert(ex.Message);
     }
 }
Пример #23
0
 /// <summary>
 /// 重置密码
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnPw_Click(object sender, EventArgs e)
 {
     try
     {
         if (!Extend.LoginState.Admin.IsAdmin)
         {
             throw new Exception("非管理员无权此操作权限!");
         }
         if (id == 0)
         {
             throw new Exception("当前信息不存在!");
         }
         Song.Entities.Teacher obj = Business.Do <ITeacher>().TeacherSingle(id);
         if (obj == null)
         {
             throw new Exception("当前信息不存在!");
         }
         Song.Entities.Accounts acc = Business.Do <IAccounts>().AccountsSingle(obj.Ac_ID);
         //员工登录密码,为空
         if (tbPw1.Text.Trim() != "")
         {
             obj.Th_Pw = tbPw1.Text.Trim();
             if (acc != null)
             {
                 acc.Ac_Pw = new WeiSha.Common.Param.Method.ConvertToAnyValue(obj.Th_Pw).MD5;
             }
         }
         obj.Th_Pw = new WeiSha.Common.Param.Method.ConvertToAnyValue(obj.Th_Pw).MD5;
         Business.Do <IAccounts>().AccountsSave(acc);
         Business.Do <ITeacher>().TeacherSave(obj);
         Master.AlertCloseAndRefresh("操作成功!");
     }
     catch (Exception ex)
     {
         Master.Alert(ex.Message);
     }
 }
Пример #24
0
        protected override void InitPageTemplate(HttpContext context)
        {
            //当前课程信息
            int id = WeiSha.Common.Request.QueryString["id"].Int32 ?? 0;

            Song.Entities.Course cou = Business.Do <ICourse>().CourseSingle(id);
            if (cou != null)
            {
                if ((WeiSha.Common.Request.Cookies["Course_" + cou.Cou_ID].Int32 ?? 0) == 0)
                {
                    cou.Cou_ViewNum++;
                    Business.Do <ICourse>().CourseSave(cou);
                    context.Response.Cookies["Course_" + cou.Cou_ID].Value = cou.Cou_ID.ToString();
                }
                cou.Cou_Logo      = string.IsNullOrWhiteSpace(cou.Cou_Logo) ? "" : Upload.Get["Course"].Virtual + cou.Cou_Logo;
                cou.Cou_LogoSmall = string.IsNullOrWhiteSpace(cou.Cou_LogoSmall) ? "" : Upload.Get["Course"].Virtual + cou.Cou_LogoSmall;
                this.Document.Variables.SetValue("course", cou);
            }
            //是否学习当前课程
            if (this.Account != null)
            {
                //是否购买
                isBuy = Business.Do <ICourse>().StudyIsCourse(this.Account.Ac_ID, cou.Cou_ID);
                this.Document.Variables.SetValue("isStudy", isBuy);
                //是否在试用中
                bool istry = Business.Do <ICourse>().IsTryout(cou.Cou_ID, this.Account.Ac_ID);
                this.Document.Variables.SetValue("isTry", istry);
            }
            //课程章节列表
            outline = Business.Do <IOutline>().OutlineAll(cou.Cou_ID, true);
            this.Document.Variables.SetValue("Outline", outline);
            //树形章节输出
            this.Document.Variables.SetValue("olTree", buildOutlineHtml(outline, 0, 0, ""));
            //课程公告
            Song.Entities.Guide[] guides = Business.Do <IGuide>().GuideCount(-1, cou.Cou_ID, -1, 20);
            this.Document.Variables.SetValue("guides", guides);
            //当前课程的主讲老师
            Song.Entities.Teacher teacher = Business.Do <ITeacher>().TeacherSingle(cou.Th_ID);
            if (teacher != null)
            {
                teacher.Th_Photo = Upload.Get["Teacher"].Virtual + teacher.Th_Photo;
                this.Document.Variables.SetValue("th", teacher);
            }
            //所有资源库的分类
            Song.Entities.KnowledgeSort[] ncs = Business.Do <IKnowledge>().GetSortAll(Organ.Org_ID, id, true);
            WeiSha.WebControl.MenuTree    mt  = new WeiSha.WebControl.MenuTree();
            mt.Title           = "全部";
            mt.DataTextField   = "Kns_Name";
            mt.IdKeyName       = "Kns_Id";
            mt.ParentIdKeyName = "Kns_PID";
            mt.TaxKeyName      = "Kns_Tax";
            mt.SourcePath      = "/manage/Images/tree";
            //mt.TypeKeyName = "Kns_Type";
            mt.IsUseKeyName = "Kns_IsUse";
            //mt.IsShowKeyName = "Nc_IsShow";
            mt.DataSource = ncs;
            mt.DataBind();
            this.Document.Variables.SetValue("tree", mt.HTML);
            //上级专业
            List <Subject> sbjs = Business.Do <ISubject>().Parents(cou.Sbj_ID, true);

            this.Document.Variables.SetValue("parentsbjs", sbjs);
            //当前课程的学员
            Tag stTag = this.Document.GetChildTagById("students");

            if (stTag != null)
            {
                int count = int.Parse(stTag.Attributes.GetValue("count", "5"));
                Song.Entities.Accounts[] eas = null;
                eas = Business.Do <ICourse>().Student4Course(cou.Cou_ID, null, null, count, 1, out count);
                this.Document.SetValue("students", eas);
            }
        }
Пример #25
0
 /// <summary>
 /// 将已经登录入的用户,写入seesion
 /// </summary>
 /// <param name="acc"></param>
 public void Write(Song.Entities.Teacher acc)
 {
     this.Write(acc, -1);
 }
Пример #26
0
 /// <summary>
 /// 写入当前用户
 /// </summary>
 public void Write()
 {
     //先读取当前用户,再写入
     Song.Entities.Teacher ea = this.Read();
     this.Write(ea);
 }
Пример #27
0
        /// <summary>
        /// 获取列表
        /// </summary>
        private void list()
        {
            //int couid = WeiSha.Common.Request.Form["couid"].Int32 ?? 0;
            int size  = WeiSha.Common.Request.Form["size"].Int32 ?? 10; //每页多少条
            int index = WeiSha.Common.Request.Form["index"].Int32 ?? 1; //第几页

            int sumcount = 0;

            Song.Entities.MessageBoard[] msgBoards = Business.Do <IMessageBoard>().ThemePager(Organ.Org_ID, couid, false, true, "", size, index, out sumcount);
            //冒泡排序
            Song.Entities.MessageBoard temp = null;
            for (int i = 0; i < msgBoards.Length; i++)
            {
                for (int j = i + 1; j < msgBoards.Length; j++)
                {
                    if (msgBoards[j].Mb_CrtTime > msgBoards[i].Mb_CrtTime)
                    {
                        temp         = msgBoards[j];
                        msgBoards[j] = msgBoards[i];
                        msgBoards[i] = temp;
                    }
                }
            }
            string json = "{\"size\":" + size + ",\"index\":" + index + ",\"sumcount\":" + sumcount + ",";

            json += "\"items\":[";
            for (int n = 0; n < msgBoards.Length; n++)
            {
                Song.Entities.MessageBoard mb = msgBoards[n];
                mb.Mb_Content = WeiSha.Common.HTML.ClearTag(mb.Mb_Content);
                if (string.IsNullOrWhiteSpace(mb.Mb_Answer))
                {
                    mb.Mb_IsAns = false;
                }

                if (!mb.Mb_IsAns || string.IsNullOrWhiteSpace(mb.Mb_Answer) || mb.Mb_Answer.Trim() == "")
                {
                    json += mb.ToJson() + ",";
                    continue;
                }
                //如果教师进行了回复,则增加教师相关输出
                if (mb.Mb_IsAns)
                {
                    //增加输出项
                    Dictionary <string, object> addParas = new Dictionary <string, object>();
                    Song.Entities.Teacher       th       = Business.Do <ITeacher>().TeacherSingle(mb.Th_ID);
                    if (th != null)
                    {
                        addParas.Add("Th_Name", th.Th_Name);
                        addParas.Add("Th_Photo", th.Th_Photo);
                        json += mb.ToJson(null, null, addParas) + ",";
                    }
                }
            }
            if (json.EndsWith(","))
            {
                json = json.Substring(0, json.Length - 1);
            }
            json += "]}";
            Response.Write(json);
            Response.End();
        }
        /// <summary>
        /// 复制教师信息
        /// </summary>
        private void copyTeacher(Song.Entities.Teacher th)
        {
            bool isExist = false;

            Song.Entities.Accounts acc = Business.Do <IAccounts>().IsAccountsExist(th.Th_AccName);
            isExist = acc != null;
            //如果在整个系统都不存在
            if (!isExist)
            {
                acc            = new Song.Entities.Accounts();
                acc.Ac_AccName = th.Th_AccName;
                acc.Ac_UID     = WeiSha.Common.Request.UniqueID();
            }
            else
            {
                //如果存在,但在当前机构不存在
                acc     = Business.Do <IAccounts>().IsAccountsExist(th.Org_ID, th.Th_AccName);
                isExist = acc != null;
                if (!isExist)
                {
                    Song.Entities.Organization org = Business.Do <IOrganization>().OrganSingle(th.Org_ID);
                    if (org == null)
                    {
                        org = Business.Do <IOrganization>().OrganDefault();
                    }
                    acc            = new Song.Entities.Accounts();
                    acc.Ac_AccName = th.Th_AccName + "-" + org.Org_TwoDomain;
                    acc.Ac_UID     = WeiSha.Common.Request.UniqueID();
                }
            }
            acc.Ac_IsTeacher    = true;
            acc.Ac_Pw           = th.Th_Pw;
            acc.Ac_Qus          = th.Th_Qus;
            acc.Ac_Ans          = th.Th_Anwser;
            acc.Ac_Name         = th.Th_Name;
            acc.Ac_Pinyin       = th.Th_Pinyin;
            acc.Ac_Age          = th.Th_Age;
            acc.Ac_Birthday     = th.Th_Birthday;
            acc.Ac_IDCardNumber = th.Th_IDCardNumber;
            acc.Ac_Sex          = th.Th_Sex;
            acc.Ac_Tel          = th.Th_Phone;
            acc.Ac_IsOpenTel    = th.Th_IsOpenPhone;
            acc.Ac_MobiTel1     = acc.Ac_MobiTel2 = th.Th_PhoneMobi;
            acc.Ac_Email        = th.Th_Email;
            acc.Ac_Qq           = th.Th_Qq;
            acc.Ac_Weixin       = th.Th_Weixin;
            acc.Ac_RegTime      = th.Th_RegTime;
            acc.Ac_IsUse        = th.Th_IsUse;
            acc.Ac_IsPass       = th.Th_IsPass;
            acc.Org_ID          = th.Org_ID;
            //移动照片
            if (!string.IsNullOrWhiteSpace(th.Th_Photo))
            {
                string             photo = Upload.Get["Teacher"].Physics + th.Th_Photo;
                System.IO.FileInfo fi    = new System.IO.FileInfo(photo);
                if (fi.Exists)
                {
                    fi.CopyTo(Upload.Get["Accounts"].Physics + th.Th_Photo, true);
                }
                acc.Ac_Photo = th.Th_Photo;
            }
            if (!isExist)
            {
                Business.Do <IAccounts>().AccountsAdd(acc);
            }
            else
            {
                Business.Do <IAccounts>().AccountsSave(acc);
            }
            th.Ac_ID  = acc.Ac_ID;
            th.Ac_UID = acc.Ac_UID;
            Business.Do <ITeacher>().TeacherSave(th);
        }
Пример #29
0
 /// <summary>
 /// 保存当前课程
 /// </summary>
 /// <returns></returns>
 private Song.Entities.Course Save()
 {
     Song.Entities.Course cou = couid < 1 ? new Song.Entities.Course() : Business.Do <ICourse>().CourseSingle(couid);
     if (cou == null)
     {
         return(null);
     }
     //名称
     cou.Cou_Name = Cou_Name.Text.Trim();
     //所属专业
     cou.Sbj_ID   = Convert.ToInt32(ddlSubject.SelectedValue);
     cou.Sbj_Name = ddlSubject.SelectedText;
     //上级
     cou.Cou_PID = Convert.ToInt32(ddlTree.SelectedValue);
     //简介,学习目标
     cou.Cou_Intro  = tbIntro.Text;
     cou.Cou_Target = tbTarget.Text;
     //主图片
     if (fuLoad.PostedFile.FileName != "")
     {
         try
         {
             fuLoad.UpPath       = _uppath;
             fuLoad.IsMakeSmall  = true;
             fuLoad.IsConvertJpg = true;
             fuLoad.SmallWidth   = 400;
             fuLoad.SmallHeight  = 226;
             fuLoad.SaveAndDeleteOld(cou.Cou_Logo);
             //fuLoad.File.Server.ChangeSize(640, 362, true);
             cou.Cou_Logo      = fuLoad.File.Server.FileName;
             cou.Cou_LogoSmall = fuLoad.File.Server.SmallFileName;
             //
             imgShow.Src = fuLoad.File.Server.VirtualPath;
         }
         catch (Exception ex)
         {
             this.Alert(ex.Message);
         }
     }
     cou.Cou_IsUse = cbIsUse.Checked;    //启用
     cou.Cou_IsRec = cbIsRec.Checked;    //推荐
     cou.Cou_UID   = getUID();
     try
     {
         if (couid < 1)
         {
             //所属老师
             if (Extend.LoginState.Accounts.IsLogin)
             {
                 Song.Entities.Teacher th = Extend.LoginState.Accounts.Teacher;
                 if (th != null)
                 {
                     cou.Th_ID   = th.Th_ID;
                     cou.Th_Name = th.Th_Name;
                 }
             }
             Business.Do <ICourse>().CourseAdd(cou);
         }
         else
         {
             Business.Do <ICourse>().CourseSave(cou);
         }
         this.Alert("操作成功");
     }
     catch
     {
         throw;
     }
     return(cou);
 }
Пример #30
0
        protected override void InitPageTemplate(HttpContext context)
        {
            //当前课程信息
            int id = WeiSha.Common.Request.QueryString["id"].Int32 ?? 0;

            Song.Entities.Course cou = Business.Do <ICourse>().CourseSingle(id);
            if (cou == null || !cou.Cou_IsUse)
            {
                return;
            }
            if (cou != null)
            {
                if ((WeiSha.Common.Request.Cookies["Course_" + cou.Cou_ID].Int32 ?? 0) == 0)
                {
                    Business.Do <ICourse>().CourseViewNum(cou, 1);
                    context.Response.Cookies["Course_" + cou.Cou_ID].Value = cou.Cou_ID.ToString();
                }
                //图片路径
                cou.Cou_Logo = string.IsNullOrWhiteSpace(cou.Cou_Logo) ? "" : Upload.Get["Course"].Virtual + cou.Cou_Logo;
                if (!System.IO.File.Exists(WeiSha.Common.Server.MapPath(cou.Cou_Logo)))
                {
                    cou.Cou_Logo = "";
                }
                cou.Cou_LogoSmall = string.IsNullOrWhiteSpace(cou.Cou_LogoSmall) ? "" : Upload.Get["Course"].Virtual + cou.Cou_LogoSmall;
                if (!System.IO.File.Exists(WeiSha.Common.Server.MapPath(cou.Cou_LogoSmall)))
                {
                    cou.Cou_LogoSmall = "";
                }
                //是否免费,或是限时免费
                if (cou.Cou_IsLimitFree)
                {
                    DateTime freeEnd = cou.Cou_FreeEnd.AddDays(1).Date;
                    if (!(cou.Cou_FreeStart <= DateTime.Now && freeEnd >= DateTime.Now))
                    {
                        cou.Cou_IsLimitFree = false;
                    }
                }
                this.Document.Variables.SetValue("course", cou);
            }
            //是否学习当前课程
            if (this.Account != null)
            {
                //是否购买
                isBuy = Business.Do <ICourse>().StudyIsCourse(this.Account.Ac_ID, cou.Cou_ID);
                this.Document.Variables.SetValue("isStudy", isBuy);
            }
            //课程章节列表
            outline = Business.Do <IOutline>().OutlineAll(cou.Cou_ID, true);
            this.Document.Variables.SetValue("Outline", outline);
            //树形章节输出
            if (outline.Length > 0)
            {
                this.Document.Variables.SetValue("olTree", Business.Do <IOutline>().OutlineTree(outline));
            }
            //课程公告
            Song.Entities.Guide[] guides = Business.Do <IGuide>().GuideCount(-1, cou.Cou_ID, -1, 20);
            this.Document.Variables.SetValue("guides", guides);
            //当前课程的主讲老师
            Song.Entities.Teacher teacher = Business.Do <ITeacher>().TeacherSingle(cou.Th_ID);
            if (teacher != null)
            {
                teacher.Th_Photo = Upload.Get["Teacher"].Virtual + teacher.Th_Photo;
                this.Document.Variables.SetValue("th", teacher);
            }
            //上级专业
            List <Subject> sbjs = Business.Do <ISubject>().Parents(cou.Sbj_ID, true);

            this.Document.Variables.SetValue("parentsbjs", sbjs);
            //当前课程的学员
            Tag stTag = this.Document.GetChildTagById("students");

            if (stTag != null)
            {
                int count = int.Parse(stTag.Attributes.GetValue("count", "5"));
                Song.Entities.Accounts[] eas = null;
                eas = Business.Do <ICourse>().Student4Course(cou.Cou_ID, null, null, count, 1, out count);
                this.Document.SetValue("students", eas);
            }
        }