protected void GridTeachers_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HtmlAnchor  aPages = e.Row.Cells[0].FindControl("aPages") as HtmlAnchor;
            PlaceHolder ltTchs = e.Row.Cells[1].FindControl("ltTchs") as PlaceHolder;
            HtmlAnchor  aMore  = e.Row.Cells[0].FindControl("aMore") as HtmlAnchor;
            Field       fd     = e.Row.DataItem as Field;
            if (fd != null)
            {
                aPages.HRef = aMore.HRef = Utils.AbsoluteWebRoot + @"TeacherList.aspx?fid=" + fd.Id;
                int num = 0;
                foreach (MembershipUser user in Membership.GetAllUsers())
                {
                    AuthorProfile ap = AuthorProfile.GetProfile(user.UserName);
                    if (ap != null && ap.IsTeacher && !ap.IsAdmin && ap.IsPrivate && ap.Fields.Contains(fd.Id.ToString()) && num < 9)
                    {
                        HtmlAnchor aTch = new HtmlAnchor();
                        aTch.HRef      = Utils.AbsoluteWebRoot + @"Views\TeacherView.aspx?uid=" + ap.UserName;
                        aTch.Title     = ap.DisplayName;
                        aTch.InnerText = StripString(ap.DisplayName, 4);
                        //aTch.Style.Add(HtmlTextWriterStyle.Color, "#333333");
                        ltTchs.Controls.Add(aTch);

                        Literal lt = new Literal();
                        lt.Text = " ";
                        ltTchs.Controls.Add(lt);
                        num++;
                    }
                }
            }
        }
    }
예제 #2
0
    private void BindTeacher()
    {
        ddlObj.Items.Clear();
        ListItem dli = new ListItem("教师团", "教师团");

        ddlObj.Items.Add(dli);
        if (Page.User.IsInRole("administrators"))
        {
            foreach (MembershipUser user in Membership.GetAllUsers())
            {
                AuthorProfile ap = AuthorProfile.GetProfile(user.UserName);

                if (ap.IsTeacher || ap.IsOrgan)
                {
                    ListItem li = new ListItem(ap.DisplayName, user.UserName);
                    ddlObj.Items.Add(li);
                    ddlObj.SelectedValue = User.Identity.Name;
                }
            }
        }
        else
        {
            ListItem li = new ListItem(AuthorProfile.GetProfile(Page.User.Identity.Name).DisplayName, Page.User.Identity.Name);
            ddlObj.Items.Add(li);
            ddlObj.SelectedValue = User.Identity.Name;
        }
    }
    private void bindUL(string fieldId)
    {
        Field  fd   = Field.GetField(new Guid(fieldId));
        string tmpl = "<div style='display:block;'><div style='float:left'><a href=\"" + Utils.AbsoluteWebRoot + "Views/TrainingView.aspx?id={0}\"  title=\"{1}\">{2}</a></div><div style='float:right'><span style='color: #FF6600'>{3}</span>天&nbsp;{4}</div></div><div style='clear:both;height=0px;'/>";
        //Utils.AbsoluteWebRoot
        int liCount = 0;

        foreach (Training item in Training.Trainings)
        {
            if (item.Fields.Contains(fd) && item.IsPublished)
            {
                HtmlGenericControl li      = new HtmlGenericControl("li");
                string             tchName = item.Teacher;
                AuthorProfile      ap      = AuthorProfile.GetProfile(item.Teacher);
                if (ap != null)
                {
                    tchName = ap.DisplayName;
                }
                li.InnerHtml = string.Format(tmpl, item.Id.ToString(), item.Title, jup(item.Title), item.Days.ToString(), tchName);
                li.Style.Add(HtmlTextWriterStyle.Width, "99%");
                list.Controls.Add(li);
                liCount++;
                if (liCount >= 10)
                {
                    break;
                }
            }
        }
    }
예제 #4
0
        public static AuthorProfile GetProfile(string id)
        {
            if (!Utils.StringIsNullOrWhitespace(id))
            {
                bool canEditRoles;
                if (!CanUserEditProfile(id, out canEditRoles))
                {
                    return(null);
                }

                return(AuthorProfile.GetProfile(id) ?? new AuthorProfile()
                {
                    DisplayName = string.Empty,
                    FirstName = string.Empty,
                    MiddleName = string.Empty,
                    LastName = string.Empty,
                    Birthday = new DateTime(1001, 1, 1),
                    PhotoUrl = string.Empty,
                    EmailAddress = string.Empty,
                    PhoneMobile = string.Empty,
                    PhoneMain = string.Empty,
                    PhoneFax = string.Empty,
                    CityTown = string.Empty,
                    RegionState = string.Empty,
                    Country = string.Empty,
                    AboutMe = string.Empty
                });
            }

            return(null);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        gridComments.PageSize = 10;

        string confirm = "return confirm('{0}');";
        string msg     = "";

        if (Request.Path.ToLower().Contains("approved.aspx"))
        {
            btnAction.Text          = "允许发布";
            msg                     = string.Format(labels.areYouSure, "发布", "选中的精彩展示");
            btnAction.OnClientClick = string.Format(confirm, msg);
        }
        else if (Request.Path.ToLower().Contains("default.aspx"))
        {
            btnAction.Text    = "新增";
            btnAction.ToolTip = "增加新的培训现场";
            if (!AuthorProfile.GetProfile(Page.User.Identity.Name).IsPrivate)
            {
                btnAction.Enabled = false;
                btnDelete.Enabled = false;
            }
            else
            {
                btnAction.OnClientClick = GetEditHtml((Guid.NewGuid()).ToString(), "Editor.aspx", 600, 460);
            }
        }

        if (!Page.IsPostBack)
        {
            BindGrid();
        }
    }
예제 #6
0
        public static JsonProfile GetProfile(string id)
        {
            if (!Utils.StringIsNullOrWhitespace(id))
            {
                bool canEditRoles;
                if (!CanUserEditProfile(id, out canEditRoles))
                {
                    return(null);
                }

                var pf = AuthorProfile.GetProfile(id);

                if (pf == null)
                {
                    pf              = new AuthorProfile(id);
                    pf.Birthday     = DateTime.Parse("01/01/1900");
                    pf.DisplayName  = id;
                    pf.EmailAddress = Utils.GetUserEmail(id);
                    pf.FirstName    = id;
                    pf.Private      = true;
                    pf.Save();
                }

                return(AuthorProfile.ToJson(id));
            }

            return(null);
        }
예제 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        gridComments.PageSize = 10;

        string confirm = "return confirm('{0}');";
        string msg     = "";

        if (Request.Path.ToLower().Contains("approved.aspx"))
        {
            btnAction.Text          = "允许发布";
            msg                     = string.Format(labels.areYouSure, "发布", "选中的资料");
            btnAction.OnClientClick = string.Format(confirm, msg);
        }
        else if (Request.Path.ToLower().Contains("default.aspx"))
        {
            if (!AuthorProfile.GetProfile(Page.User.Identity.Name).IsPrivate)
            {
                btnAdd.Enabled    = false;
                btnDelete.Enabled = false;
            }

            btnAction.Visible = false;
        }

        if (!Page.IsPostBack)
        {
            BindGrid();
        }
    }
예제 #8
0
    private void BindWellcom()
    {
        string aType = "";

        if (User.IsInRole("students"))
        {
            aType = "学员";
        }
        if (User.IsInRole("teachers"))
        {
            aType = "授课讲师";
        }
        if (User.IsInRole("organs"))
        {
            aType = "培训机构";
        }
        if (User.IsInRole("administrators"))
        {
            aType = "管理员";
        }


        AuthorProfile ap      = AuthorProfile.GetProfile(User.Identity.Name);
        string        state   = ap.IsPrivate && ap.NoMess != string.Empty ? "<font color='green'>已通过审核</font>" : "<font color='red'>审核不通过,请联系管理员</font>";
        string        wellcom = "<font color='green'>" + AuthorProfile.GetProfile(User.Identity.Name).DisplayName + "</font>,欢迎您回来! ";

        if (aType != "管理员")
        {
            wellcom += "您现有积分:<font color='#3265C3'>" + ap.Points + "</font>点 会员类别:<font color='green'>" + aType + "</font> ";
            wellcom += " 会员级别:<font color='green'>普通会员</font> 帐户状态:" + state;
        }

        ltWellcom.Text = wellcom;
    }
    private void BindGrid()
    {
        List <AuthorProfile> aps = new List <AuthorProfile>();

        foreach (MembershipUser user in Membership.GetAllUsers())
        {
            AuthorProfile ap = AuthorProfile.GetProfile(user.UserName);
            if (ap != null && ap.IsOrgan && !ap.IsAdmin && ap.IsPrivate)
            {
                aps.Add(ap);
            }
        }
        int iCount = aps.Count;

        if (iCount >= 10)
        {
            for (int i = iCount; i > 10; i--)
            {
                aps.RemoveAt(i - 1);
            }
        }

        GridView1.DataSource = aps;
        GridView1.DataBind();
    }
예제 #10
0
    /// <summary>
    /// Handles the RowDeleting event of the grid control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewDeleteEventArgs"/> instance containing the event data.</param>
    void grid_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string username = (string)gridUsers.DataKeys[e.RowIndex].Value;

        string[] roles = Roles.GetRolesForUser(username);
        Membership.DeleteUser(username);

        if (roles.Length > 0)
        {
            Roles.RemoveUserFromRoles(username, roles);
        }

        AuthorProfile profile = AuthorProfile.GetProfile(username);

        if (profile != null)
        {
            profile.Delete();
        }

        if (HttpContext.Current.User.Identity.Name.Equals(username, StringComparison.OrdinalIgnoreCase))
        {
            FormsAuthentication.SignOut();
        }

        Response.Redirect(Request.RawUrl);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Params["id"] != null)
            {
                lbID.Text = Request.Params["id"];
            }
            ap = AuthorProfile.GetProfile(lbID.Text);
            //机构名称
            lbTitle.Text = ap.Company;
            strTitle     = ap.Company;
            strCity      = ap.Address;
            strGSJS      = ap.AboutMe;
            strFWGKH     = ap.Description1;
            this.Title   = ap.Company;


            if (Request.Cookies["OrgansViewCount_" + lbID.Text] == null)
            {
                HttpCookie MyCookie = new HttpCookie("OrgansViewCount_" + lbID.Text);
                DateTime   now      = DateTime.Now;

                MyCookie["IP"]   = Request.UserHostAddress;
                MyCookie["tid"]  = lbID.Text;
                MyCookie.Expires = now.AddHours(1);

                Response.Cookies.Add(MyCookie);
                ap.ViewCount++;
                ap.Save();
            }
        }
    }
예제 #12
0
    private void SetDDLUser()
    {
        int count = 0;

        foreach (MembershipUser user in Membership.GetAllUsers())
        {
            ListItem li = new ListItem(user.UserName, user.UserName);
            if (Request.Params["p"] != null)
            {
                AuthorProfile ap = AuthorProfile.GetProfile(user.UserName);
                if (ap == null || (!ap.IsPrivate && ap.NoMess == string.Empty))
                {
                    ddlUserList.Items.Add(li);
                    count++;
                }
            }
            else
            {
                ddlUserList.Items.Add(li);
                count++;
            }
        }
        if (count == 0)
        {
            Response.Redirect(Utils.RelativeWebRoot + "admin/pages/default.aspx");
        }
        ddlUserList.SelectedValue = User.Identity.Name;
    }
예제 #13
0
 /// <summary>
 /// Gets the current user's profile.
 /// </summary>
 /// <returns>
 /// An Author Profile.
 /// </returns>
 protected AuthorProfile UserProfile()
 {
     try
     {
         return(AuthorProfile.GetProfile(Security.CurrentUser.Identity.Name));
     }
     catch (Exception e)
     {
         Utils.Log(e.Message);
         return(null);
     }
 }
예제 #14
0
 protected AuthorProfile AdminProfile()
 {
     try
     {
         return(AuthorProfile.GetProfile(System.Threading.Thread.CurrentPrincipal.Identity.Name));
     }
     catch (Exception e)
     {
         Utils.Log(e.Message);
         return(null);
     }
 }
예제 #15
0
    protected void btnNo_Click(object sender, EventArgs e)
    {
        string        userProfileToSave = ViewState["selectedProfile"] as string;
        AuthorProfile pc = AuthorProfile.GetProfile(userProfileToSave);

        if (pc == null)
        {
            pc = new AuthorProfile(userProfileToSave);
        }
        pc.IsPrivate = false;
        pc.NoMess    = txtNoMess.Text;
        pc.Save();
    }
    private string GetProfileHtml(string name)
    {
        AuthorProfile ap = AuthorProfile.GetProfile(name);

        if (ap != null)
        {
            return(Utils.AbsoluteWebRoot + @"Views\TeacherView.aspx?uid=" + name);
        }
        else
        {
            return("javascript:void(0);");
        }
    }
    public string GetTeacherDisplayName(string name)
    {
        AuthorProfile ap = AuthorProfile.GetProfile(name);

        if (ap != null)
        {
            return(ap.DisplayName);
        }
        else
        {
            return(name);
        }
    }
예제 #18
0
        static bool UpdateUserProfile(BlogUser user)
        {
            if (user == null || string.IsNullOrEmpty(user.UserName))
            {
                return(false);
            }

            var pf = AuthorProfile.GetProfile(user.UserName)
                     ?? new AuthorProfile(user.UserName);

            try
            {
                pf.DisplayName  = user.Profile.DisplayName;
                pf.FirstName    = user.Profile.FirstName;
                pf.MiddleName   = user.Profile.MiddleName;
                pf.LastName     = user.Profile.LastName;
                pf.EmailAddress = user.Email; // user.Profile.EmailAddress;

                DateTime date;
                if (user.Profile.Birthday.Length == 0)
                {
                    user.Profile.Birthday = "1/1/1001";
                }

                if (DateTime.TryParse(user.Profile.Birthday, out date))
                {
                    pf.Birthday = date;
                }

                pf.PhotoUrl = user.Profile.PhotoUrl.Replace("\"", "");
                pf.Private  = user.Profile.Private;

                pf.PhoneMobile = user.Profile.PhoneMobile;
                pf.PhoneMain   = user.Profile.PhoneMain;
                pf.PhoneFax    = user.Profile.PhoneFax;

                pf.CityTown    = user.Profile.CityTown;
                pf.RegionState = user.Profile.RegionState;
                pf.Country     = user.Profile.Country;
                pf.AboutMe     = user.Profile.AboutMe;

                pf.Save();
                UpdateProfileImage(pf);
            }
            catch (Exception ex)
            {
                Utils.Log("Error editing profile", ex);
                return(false);
            }
            return(true);
        }
예제 #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Table table = new Table();
            table.Style.Add(HtmlTextWriterStyle.Width, "100%");
            table.Style.Add(HtmlTextWriterStyle.BorderWidth, "0");

            PlaceHolder.Controls.Add(table);
            TableRow tr = new TableRow();
            table.Rows.Add(tr);
            List <AuthorProfile> aplist = new List <AuthorProfile>();
            foreach (MembershipUser user in Membership.GetAllUsers())
            {
                AuthorProfile ap = AuthorProfile.GetProfile(user.UserName);
                if (ap == null)
                {
                    continue;
                }
                aplist.Add(ap);
            }
            aplist.Sort(delegate(AuthorProfile a1, AuthorProfile a2)
            {
                return(a2.ViewCount.CompareTo(a1.ViewCount));
            });
            int num          = 0;
            int rowCellCount = 0;
            for (int i = 0; i < aplist.Count; i++)
            {
                AuthorProfile ap = aplist[i];
                if (ap.IsTeacher && !ap.IsAdmin && ap.IsPrivate && num < 9)
                {
                    TableCell tc = new TableCell();
                    tc.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
                    tc.Text = "<div><img style='border: 1px solid #C0C0C0' width='70px' height='72px' src='" + SetImageUrl(ap.PhotoURL) + "'  /></div><div><a href='" + Utils.AbsoluteWebRoot + @"Views\TeacherView.aspx?uid=" + ap.UserName + "'>" + ap.DisplayName + "</a></div>";
                    if (rowCellCount < 3)
                    {
                        tr.Cells.Add(tc);
                        rowCellCount++;
                        num++;
                    }
                    if (rowCellCount == 3 && num != 9)
                    {
                        tr = new TableRow();
                        table.Rows.Add(tr);
                        rowCellCount = 0;
                    }
                }
            }
        }
    }
예제 #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lbID.Text = Request.Params["id"];
        string fid = Request.Params["fid"];
        string cid = Request.Params["cid"];

        if (fid != null && fid != string.Empty)
        {
            paramString = "fid=" + fid;
            paramName   = Field.GetField(new Guid(fid)).FieldName;
        }
        else if (cid != null && cid != string.Empty)
        {
            paramString = "cid=" + cid;
            paramName   = Category.GetCategory(new Guid(cid)).Title;
        }
        else
        {
            paramName = paramString = string.Empty;
        }
        cTraining  = Training.GetTraining(new Guid(lbID.Text));
        this.Title = cTraining.Title;
        AuthorProfile ap = AuthorProfile.GetProfile(cTraining.Teacher);

        if (ap != null)
        {
            TeacherString  = "<a href='./TeacherView.aspx?uid=" + ap.UserName + "'>" + ap.DisplayName + "</a>";
            TeacherDes     = ap.AboutMe;
            pnltch.Visible = true;
        }
        else
        {
            pnltch.Visible = false;
            TeacherString  = cTraining.Teacher;
        }
        if (Request.Cookies["TrainViewCount_" + lbID.Text] == null)
        {
            HttpCookie MyCookie = new HttpCookie("TrainViewCount_" + lbID.Text);
            DateTime   now      = DateTime.Now;

            MyCookie["IP"]   = Request.UserHostAddress;
            MyCookie["tid"]  = lbID.Text;
            MyCookie.Expires = now.AddHours(1);

            Response.Cookies.Add(MyCookie);
            cTraining.ViewCount++;
            cTraining.UpdateViewCount();
        }
    }
    void BindGrid()
    {
        List <AuthorProfile> aps = new List <AuthorProfile>();

        foreach (MembershipUser user in Membership.GetAllUsers())
        {
            AuthorProfile ap = AuthorProfile.GetProfile(user.UserName);
            if (ap != null && ap.IsOrgan && ap.IsPrivate && !ap.IsAdmin)
            {
                aps.Add(ap);
            }
        }
        GridList.DataSource = aps;
        GridList.DataBind();
    }
    void BindGrid()
    {
        List <AuthorProfile> aps = new List <AuthorProfile>();

        foreach (MembershipUser user in Membership.GetAllUsers())
        {
            AuthorProfile ap = AuthorProfile.GetProfile(user.UserName);
            if (ap != null && ap.IsTeacher && ap.IsPrivate && !ap.IsAdmin && ap.Fields.Contains(Request["fid"]))
            {
                aps.Add(ap);
            }
        }
        GridList.DataSource = aps;
        GridList.DataBind();
    }
예제 #23
0
    private void SetProfile(string name)
    {
        AuthorProfile pc = AuthorProfile.GetProfile(name);

        if (pc != null)
        {
            cbIsPublic.Checked = pc.IsPrivate;
            tbDisplayName.Text = pc.DisplayName;
            tbFirstName.Text   = pc.FirstName;
            tbMiddleName.Text  = pc.MiddleName;
            tbLastName.Text    = pc.LastName;

            if (pc.Birthday != DateTime.MinValue)
            {
                tbBirthdate.Text = pc.Birthday.ToString("yyyy-MM-dd");
            }

            tbPhotoUrl.Text          = pc.PhotoURL;
            tbPhoneMain.Text         = pc.PhoneMain;
            tbPhoneMobile.Text       = pc.PhoneMobile;
            tbPhoneFax.Text          = pc.PhoneFax;
            tbEmailAddress.Text      = pc.EmailAddress;
            tbCityTown.Text          = pc.CityTown;
            tbRegionState.Text       = pc.RegionState;
            ddlCountry.SelectedValue = pc.Country;
            tbCompany.Text           = pc.Company;
            tbAboutMe.Text           = pc.AboutMe;
        }
        else
        {
            // Clear any data in the form controls remaining from the last profile selected.
            ClearFormControls();
        }

        // Sync the dropdownlist user with the selected profile user.  This is
        // particularily needed on the initial page load (!IsPostBack).
        ListItem SelectedUser = FindItemInListControlByValue(ddlUserList, name);

        if (SelectedUser != null)
        {
            SelectedUser.Selected = true;
        }

        // Store the selected profile name so changes are saved to this
        // profile and not another profile the user may later select and
        // forget to click the lbChangeUserProfile button for.
        ViewState["selectedProfile"] = name;
    }
예제 #24
0
        /// <summary>
        /// Writes the author.
        /// </summary>
        /// <param name="stream">
        /// The stream.
        /// </param>
        /// <param name="authorName">
        /// Name of the author.
        /// </param>
        private static void WriteAuthor(Stream stream, string authorName)
        {
            var xmlWriter = GetWriter(stream);

            WriteFoafDocument(xmlWriter, "user", GetSiocAuthorUrl(authorName));

            var user = Membership.GetUser(authorName);
            var ap   = AuthorProfile.GetProfile(authorName);

            // FOAF:Person
            xmlWriter.WriteStartElement("foaf", "Person", null);
            xmlWriter.WriteAttributeString("rdf", "about", null, GetSiocAuthorUrl(authorName));

            xmlWriter.WriteElementString("foaf", "Name", null, authorName);
            if (ap != null && !ap.Private && ap.FirstName != String.Empty)
            {
                xmlWriter.WriteElementString("foaf", "firstName", null, ap.FirstName);
            }

            if (ap != null && !ap.Private && ap.LastName != String.Empty)
            {
                xmlWriter.WriteElementString("foaf", "surname", null, ap.LastName);
            }

            xmlWriter.WriteElementString(
                "foaf", "mbox_sha1sum", null, (user != null) ? CalculateSha1(user.Email, Encoding.UTF8) : string.Empty);
            xmlWriter.WriteStartElement("foaf", "homepage", null);
            xmlWriter.WriteAttributeString("rdf", "resource", null, Utils.AbsoluteWebRoot.ToString());
            xmlWriter.WriteEndElement(); // foaf:homepage

            xmlWriter.WriteStartElement("foaf", "holdsAccount", null);
            xmlWriter.WriteAttributeString("rdf", "resource", null, GetBlogAuthorUrl(authorName));
            xmlWriter.WriteEndElement(); // foaf:holdsAccount

            xmlWriter.WriteEndElement(); // foaf:Person

            // SIOC:User
            xmlWriter.WriteStartElement("sioc", "User", null);
            xmlWriter.WriteAttributeString("rdf", "about", null, GetBlogAuthorUrl(authorName));
            xmlWriter.WriteElementString("foaf", "accountName", null, authorName);
            xmlWriter.WriteElementString("sioc", "name", null, authorName);

            // xmlWriter.WriteElementString("dcterms", "created", null, "TODO:" + authorName);
            xmlWriter.WriteEndElement(); // sioc:User

            CloseWriter(xmlWriter);
        }
예제 #25
0
    protected void lbSaveProfile_Click(object sender, EventArgs e)
    {
        string        userProfileToSave = ViewState["selectedProfile"] as string;
        AuthorProfile pc = AuthorProfile.GetProfile(userProfileToSave);

        if (pc == null)
        {
            pc = new AuthorProfile(userProfileToSave);
        }

        pc.IsPrivate   = cbIsPublic.Checked;
        pc.IsVip       = cbIsVIP.Checked;
        pc.IsGoldTch   = cbIsGoldTch.Checked;
        pc.DisplayName = tbDisplayName.Text;


        //pc.PhotoURL = tbPhotoUrl.Text;
        pc.PhoneMain   = tbPhoneMain.Text;
        pc.PhoneMobile = tbPhoneMobile.Text;
        pc.PhoneFax    = tbPhoneFax.Text;
        //pc.EmailAddress = tbEmailAddress.Text;
        pc.CityTown = tbCityTown.Text;
        string fields = string.Empty;

        foreach (ListItem item in cblFields.Items)
        {
            if (item.Selected == true)
            {
                fields += item.Value + "|";
            }
        }
        pc.Fields  = fields.TrimEnd('|');
        pc.Pay     = tbPay.Text;
        pc.Company = tbCompany.Text;
        pc.Address = tbAddress.Text;

        pc.AboutMe      = tbAboutMe.Text;
        pc.Description1 = tbAbout1.Text;
        pc.Description2 = tbAbout2.Text;

        pc.PhotoURL = lbUpPicId.Text;
        pc.NoMess   = txtNoMess.Text;
        pc.Save();
    }
예제 #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lbID.Text  = Request.Params["uid"];
        tch        = AuthorProfile.GetProfile(lbID.Text);
        this.Title = tch.DisplayName;
        if (Request.Cookies["tchViewCount_" + lbID.Text] == null)
        {
            HttpCookie MyCookie = new HttpCookie("tchViewCount_" + lbID.Text);
            DateTime   now      = DateTime.Now;

            MyCookie["IP"]   = Request.UserHostAddress;
            MyCookie["tid"]  = lbID.Text;
            MyCookie.Expires = now.AddHours(1);

            Response.Cookies.Add(MyCookie);
            tch.ViewCount++;
            tch.Save();
        }
    }
예제 #27
0
        /// <summary>
        /// Add item
        /// </summary>
        /// <param name="item">Comment</param>
        /// <returns>Comment object</returns>
        public CommentItem Add(CommentDetail item)
        {
            if (!Security.IsAuthorizedTo(Rights.CreateComments))
            {
                throw new UnauthorizedAccessException();
            }

            var c = new Comment();

            try
            {
                var post = Post.Posts.Where(p => p.Id == item.PostId).FirstOrDefault();

                c.Id         = Guid.NewGuid();
                c.ParentId   = item.ParentId;
                c.IsApproved = true;
                c.Content    = HttpUtility.HtmlAttributeEncode(item.Content);

                c.Author = Security.CurrentUser.Identity.Name;
                var profile = AuthorProfile.GetProfile(c.Author);
                if (profile != null && !string.IsNullOrEmpty(profile.DisplayName))
                {
                    c.Author = profile.DisplayName;
                }

                c.Email       = Membership.Provider.GetUser(Security.CurrentUser.Identity.Name, true).Email;
                c.IP          = Utils.GetClientIP();
                c.DateCreated = DateTime.Now;
                c.Parent      = post;

                post.AddComment(c);
                post.Save();

                var newComm = post.Comments.Where(cm => cm.Content == c.Content).FirstOrDefault();
                return(Json.GetComment(newComm, post.Comments));
            }
            catch (Exception ex)
            {
                Utils.Log("Core.Data.CommentsRepository.Add", ex);
                return(null);
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        gridComments.PageSize = 10;

        string confirm = "return confirm('{0}');";
        string msg     = "";

        if (Request.Path.ToLower().Contains("approved.aspx"))
        {
            btnAction.Text          = "允许发布";
            msg                     = string.Format(labels.areYouSure, "发布", "选中的课程");
            btnAction.OnClientClick = string.Format(confirm, msg);
            btnSetGold.Visible      = true;
        }
        else if (Request.Path.ToLower().Contains("default.aspx"))
        {
            btnAction.Text    = "新增";
            btnAction.ToolTip = "增加新的课程";
            if (!AuthorProfile.GetProfile(Page.User.Identity.Name).IsPrivate)
            {
                btnAction.Enabled = false;
                btnDelete.Enabled = false;
            }
            else
            {
                btnAction.OnClientClick = GetEditHtml((Guid.NewGuid()).ToString(), "Editor.aspx", 1000, 560);
            }

            btnSetGold.Visible = false;
        }

        if (!Page.IsPostBack)
        {
            if (!String.IsNullOrEmpty(Request.QueryString["delete"]) && Request.QueryString["delete"].Length == 36)
            {
                Guid id = new Guid(Request.QueryString["delete"]);
                DeleteInfo(id);
            }
            BindGrid();
        }
    }
    private void bindGrid()
    {
        List <AuthorProfile> tchs = new List <AuthorProfile>();
        int count = 0;

        foreach (MembershipUser user in Membership.GetAllUsers())
        {
            AuthorProfile ap = AuthorProfile.GetProfile(user.UserName);
            if (ap != null && ap.IsTeacher && !ap.IsAdmin && ap.IsPrivate && ap.IsGoldTch)
            {
                tchs.Add(ap);
                count++;
                if (count == 3)
                {
                    break;
                }
            }
        }
        GridTeachers.DataSource = tchs;
        GridTeachers.DataBind();
    }
예제 #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Form.Enctype = "multipart/form-data";
            if (Page.IsPostBack)
            {
                try
                {
                    HttpPostedFile file = Request.Files["file"];

                    if (file != null && file.ContentLength > 0)
                    {
                        string id    = Request.QueryString["id"];
                        string login = string.IsNullOrEmpty(id) ? HttpContext.Current.User.Identity.Name : id;
                        string dir   = Server.MapPath(Path.Combine(BlogConfig.StorageLocation, "files/Avatars", Blog.CurrentInstance.Name, login));

                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }

                        string fname = Path.GetFileName(file.FileName);
                        fname = Path.Combine(dir, fname);

                        file.SaveAs(fname);

                        var pf = AuthorProfile.GetProfile(login) ?? new AuthorProfile(login);
                        pf.PhotoUrl = Blog.CurrentInstance.Name + "/" + login + "/" + file.FileName;

                        pf.Save();

                        Master.SetStatus("success", "File saved");
                    }
                }
                catch (Exception ex)
                {
                    Master.SetStatus("warning", ex.Message);
                }
            }
        }