Пример #1
0
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            this.HRef = "";

            DataRow memberRow = DataBinder.Eval(this.NamingContainer, "DataItem") as DataRow;

            if (memberRow == null)
            {
                DataRowView drv = DataBinder.Eval(this.NamingContainer, "DataItem") as DataRowView;
                if (drv == null)
                {
                    this.HRef = "";
                    return;
                }
                memberRow = drv.Row;
            }

            int privacy  = (int)memberRow["Privacy"];
            int MemberId = (int)memberRow["MemberId"];

            PrivacySettingsManager psMgr = new PrivacySettingsManager();

            if (psMgr.CanAccess(memberRow, "VisitorsAccess", this))
            {
                Config cfg = new Config();

                this.HRef = string.Format("{0}/{1}/{2}",
                                          WebContext.Root,
                                          cfg.GetKey(MembersSettings.ProfilesDirectory),
                                          memberRow["UserName"]);
                this.Title = string.Format("{0}", memberRow["Name"]);
            }
            base.DataBind();
        }
Пример #2
0
        public override void DataBind()
        {
            if (_bound)
            {
                return;
            }
            _bound = true;
            DataRow memberRow = DataBinder.Eval(this.NamingContainer, "DataItem") as DataRow;

            if (memberRow == null)
            {
                DataRowView memberRowView = DataBinder.Eval(this.NamingContainer, "DataItem") as DataRowView;
                if (memberRowView != null)
                {
                    memberRow = memberRowView.Row;
                }
            }
            if (memberRow == null)
            {
                return;
            }

            int privacy = (int)memberRow["Privacy"];

            if (memberRow == null)
            {
                DataRowView drv = DataBinder.Eval(this.NamingContainer, "DataItem") as DataRowView;
                if (drv == null)
                {
                    ErrorContext.Add("invalid-dataitem", "Invalid Container for: " + Property);
                    this.Visible = false;
                    return;
                }
                memberRow = drv.Row;
            }
            object obj = null;

            if (memberRow.Table.Columns.Contains(Property))
            {
                obj = memberRow[Property];
            }

            PrivacySettingsManager psMgr = new PrivacySettingsManager();

            this.Visible = psMgr.CanAccess(memberRow, Property, this);

            if (!this.Visible)
            {
                return;
            }

            int MemberId = (int)memberRow["MemberId"];

            switch (Property)
            {
            /*case "Network":
             *      MemberNetworksManager nMgr = new MemberNetworksManager();
             *      IQueryable<MemberNetworksView> networks = nMgr.GetMemberNetworksView((int)memberRow["MemberId"]);
             *      if (networks.Count() > 0)
             *      {
             *              obj = networks.First().Name;
             *      }
             *      break;
             */
            case "Gender":
                if (memberRow["Gender"] != DBNull.Value && memberRow["Gender"] != null)
                {
                    Gender gender = (Gender)Enum.Parse(typeof(Gender), memberRow["Gender"].ToString());
                    obj = gender.ToString();
                }
                break;

            case "Email":
                break;

            case "StudentID":
                if (MemberId != WebContext.Profile.UserId)
                {
                    this.Visible = false;
                }
                break;

            default:
                break;
            }

            if (obj != null && obj.ToString().Trim() != "")
            {
                obj = string.Format(Format, obj);

                this.Text = StringUtils.AddSup(obj.ToString());
            }
            base.DataBind();

            _iVisible = this.Visible && !String.IsNullOrWhiteSpace(this.Text);
        }