Exemplo n.º 1
0
    public static List <UserLink> getUserLinks(String username)
    {
        List <UserLink> links = new List <UserLink>();                                                                                                       //list to hold results of query

        String database = System.Configuration.ConfigurationManager.ConnectionStrings["programaholics_anonymous_databaseConnectionString"].ConnectionString; //connection string for db

        OleDbConnection sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + database);                                     //db connection

        sqlConn.Open();                                                                                                                                      //connect to db

        //sql select string
        String select = "SELECT [links].path, [links].textValue FROM [links] INNER JOIN [users] ON [users].accessLevel = [links].accessLevel WHERE username = @username";

        OleDbCommand cmd = new OleDbCommand(select, sqlConn);

        //add parameters to command
        cmd.Parameters.Add("userName", OleDbType.VarChar, 255).Value = username;
        cmd.Prepare();

        //create data reader
        OleDbDataReader dr = cmd.ExecuteReader();

        //add results of query to links list
        while (dr.Read())
        {
            String   path      = dr["path"].ToString();
            String   textValue = dr["textValue"].ToString();
            UserLink link      = new UserLink(path, textValue);
            links.Add(link);
        }
        //close all resources and return list to calling method
        dr.Close();
        sqlConn.Close();
        return(links);
    }
Exemplo n.º 2
0
        // Follow User
        public void FollowUser(string currentUserId, string followingUserId)
        {
            try
            {
                using (BlogDbContext context = new BlogDbContext())
                {
                    var followEntry = (from p in context.UserLinks
                                       select p).Where(x => x.FolloweeId.Equals(currentUserId) && x.FollowerId.Equals(followingUserId)).FirstOrDefault();

                    if (followEntry != null)
                    {
                        context.Entry(followEntry).State = EntityState.Deleted;
                        context.SaveChanges();
                    }

                    else
                    {
                        UserLink returnedfollowEntry = new UserLink
                        {
                            FolloweeId = currentUserId,
                            FollowerId = followingUserId,
                        };
                        context.UserLinks.Add(returnedfollowEntry);
                        context.SaveChanges();
                    }
                }
            }
            catch (NullReferenceException)
            {
            }
        }
    //add the nav links to the placeholder
    private void writeNavLink(UserLink link)
    {
        String         element  = "<a href='" + link.getPath() + "'><div class='nav-item'>" + link.getTextValue() + "</div></a>";
        LiteralControl userLink = new LiteralControl(element);

        PlaceHolder1.Controls.Add(userLink);
    }
Exemplo n.º 4
0
        public StrongJsonResult <UserViewModel> LinkUserToUserByEmail(int?fromUserId, string toEmail)
        {
            using (var db = new MyCalendarDbContext())
            {
                var fromUser = db.Users.FirstOrDefault(u => u.UserId == fromUserId);
                if (fromUser != null)
                {
                    var toUser = db.Users.FirstOrDefault(u => u.Email == toEmail && u.UserId != fromUser.UserId);
                    if (toUser != null)
                    {
                        var link = db.UserLinks.FirstOrDefault(l => l.FromUserId == fromUserId &&
                                                               l.ToUserId == toUser.UserId);
                        if (link == null)
                        {
                            link = new UserLink(fromUserId, toUser.UserId);
                            db.UserLinks.Add(link);
                            db.SaveChanges();
                            return(StrongJsonResult.From(new UserViewModel(toUser, toUser.Events)));
                        }
                    }
                }

                return(null);
            }
        }
    //add the nav links to the placeholder
    private void writeNavLink(UserLink link)
    {
        String element = "<a href='" + link.getPath() + "'><div class='nav-item'>" + link.getTextValue() + "</div></a>";
        LiteralControl userLink = new LiteralControl(element);

        PlaceHolder1.Controls.Add(userLink);
    }
Exemplo n.º 6
0
        public async Task Get_a_user()
        {
            var homeLink = _linkFactory.CreateLink <HomeLink>(new Uri("https://api.github.com"));

            await _httpClient.FollowLinkAsync(homeLink);

            var userLink = _clientstate.HomeDocument.GetLink <UserLink>();

            userLink.User = "******";

            await _httpClient.FollowLinkAsync(userLink);

            var userDoc         = _clientstate.LastDocument;
            var followersCount2 = _clientstate.CurrentUser.Followers;
            var followersCount  = (int)userDoc.Properties["followers"];

            var followersLink = userDoc.GetLink <FollowersLink>();
            await _httpClient.FollowLinkAsync(followersLink);

            var followers = _clientstate.LastDocument;

            _clientstate.ClearList();
            foreach (var doc in followers.Items)
            {
                var itemLink = doc.GetLink <ItemLink>();
                await _httpClient.FollowLinkAsync(itemLink);
            }
            var results = _clientstate.List.Select(s => UserLink.InterpretResponse(s)).Where(u => u.Hireable && u.Followers > 50).ToList();
        }
Exemplo n.º 7
0
 public void DiscordGuildConnected(object s, DiscordGuildConnectedEventArgs e)
 {
     if (e.Guild.Id == Config.DiscordServer.GuildId)
     {
         foreach (var channel in e.Guild.Channels)
         {
             var link = Config.DiscordServer.ChannelMapping.FirstOrDefault(x => x.Discord == channel.Id);
             if (link != null)
             {
                 var users = channel.Users;
                 foreach (var user in users.Where(x => !x.Roles.Select(y => y.Name).Intersect(Config.DiscordServer.IgnoredUserRoles).Any()))
                 {
                     JoinDiscordUserToIrcChannel(user, link);
                 }
             }
         }
         foreach (var user in e.Guild.Users)
         {
             if (!DiscordUserConsideredOnline(user.Status) && UserLinks.ContainsKey(user.Username))
             {
                 UserLink thisLink = UserLinks[user.Username];
                 IrcLink.SetAway(thisLink.IrcUid, true);
             }
         }
     }
 }
Exemplo n.º 8
0
        public override IQueryable <UserLink> GetUserLinks()
        {
            List <UserLink> links = new List <UserLink>();
            //This could be slow if there are a lot of potential users.
            int pageIndex = 0;
            List <MembershipUser> users = CobaltWebApi.GetUsers(CobaltWebApi.MAX_NUMBER_OF_RECORDS, pageIndex);

            while (users.Count > 0)
            {
                foreach (MembershipUser user in users)
                {
                    foreach (string role in user.UserGroups.Select(r => r.Name).Union(user.UserRoles.Select(r => r.Name)))
                    {
                        Role     userRole = this.GetRoles().Where(r => r.Name == role).FirstOrDefault();
                        UserLink link     = new UserLink()
                        {
                            ApplicationName = base.ApplicationName, Id = Guid.NewGuid(), Role = userRole, UserId = user.Id
                        };
                        links.Add(link);
                        linkLookup[user.Id.ToString() + userRole.Id.ToString()] = link;
                    }
                }
                pageIndex++;
                users = CobaltWebApi.GetUsers(CobaltWebApi.MAX_NUMBER_OF_RECORDS, pageIndex);
            }
            return(links.AsQueryable());
        }
Exemplo n.º 9
0
        public UserLinks GetLinkUsers(string userKey)
        {
            UserLinks         links = new UserLinks();
            DataRowCollection rows  = getLinks(userKey, 1).Rows;

            foreach (DataRow row in rows)
            {
                object[] item   = row.ItemArray;
                UserLink usrLnk = new UserLink()
                {
                    LinkId = int.Parse(item[0].ToString()),
                    Id     = int.Parse(item[5].ToString()),
                    Key    = item[6].ToString(),
                    Name   = item[7].ToString(),
                    Status = int.Parse(item[4].ToString())
                };
                try
                {
                    Geolocation loc = new Geolocation()
                    {
                        Lat = double.Parse(item[8].ToString()),
                        Lng = double.Parse(item[9].ToString())
                    };
                    usrLnk.At = loc;
                }
                catch { }
                try
                {
                    usrLnk.On = DateTime.Parse(item[11].ToString());
                }
                catch { }
                links.Users.Add(usrLnk);
            }
            return(links);
        }
Exemplo n.º 10
0
        /// <summary>
        /// The render.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected override void Render(HtmlTextWriter writer)
        {
            var userName = this.Parameters["inner"];

            if (userName.IsNotSet() || userName.Length > 50)
            {
                return;
            }

            var userId = this.Get <IUserDisplayName>().GetId(userName.Trim());

            if (userId.HasValue)
            {
                var userLink = new UserLink
                {
                    UserID      = userId.ToType <int>(),
                    CssClass    = "btn btn-outline-primary",
                    BlankTarget = true,
                    ID          = $"UserLinkBBCodeFor{userId}"
                };

                writer.Write("<!-- BEGIN userlink -->");
                writer.Write(@"<span>");
                userLink.RenderControl(writer);

                writer.Write("</span>");
                writer.Write("<!-- END userlink -->");
            }
            else
            {
                writer.Write(this.HtmlEncode(userName));
            }
        }
Exemplo n.º 11
0
    public static List<UserLink> getUserLinks(String username)
    {
        List<UserLink> links = new List<UserLink>(); //list to hold results of query

        String database = System.Configuration.ConfigurationManager.ConnectionStrings["programaholics_anonymous_databaseConnectionString"].ConnectionString; //connection string for db

        OleDbConnection sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + database); //db connection

        sqlConn.Open(); //connect to db

        //sql select string
        String select = "SELECT [links].path, [links].textValue FROM [links] INNER JOIN [users] ON [users].accessLevel = [links].accessLevel WHERE username = @username";

        OleDbCommand cmd = new OleDbCommand(select, sqlConn);

        //add parameters to command
        cmd.Parameters.Add("userName", OleDbType.VarChar, 255).Value = username;
        cmd.Prepare();

        //create data reader
        OleDbDataReader dr = cmd.ExecuteReader();

        //add results of query to links list
        while (dr.Read())
        {
            String path = dr["path"].ToString();
            String textValue = dr["textValue"].ToString();
            UserLink link = new UserLink(path, textValue);
            links.Add(link);
        }
        //close all resources and return list to calling method
        dr.Close();
        sqlConn.Close();
        return links;
    }
Exemplo n.º 12
0
        public async Task <UserLink> CreateUserLink(UserLink newuserLink)
        {
            await _unitOfWork.UserLinks.AddAsync(newuserLink);

            await _unitOfWork.CommitAsync();

            return(newuserLink);
        }
Exemplo n.º 13
0
        public async Task AddLinkAsync(string jsonFilePath, UserLink userLink)
        {
            // read existing links into a list, add link, save list back to the file

            var existingLinks = await _userLinkJsonReader.GetUserLinksFromFileAsync(jsonFilePath);

            existingLinks.Add(userLink);
            await _userLinkJsonWriter.WriteUserLinksToFileAsync(jsonFilePath, existingLinks);
        }
Exemplo n.º 14
0
 /// <summary>Snippet for GetUserLink</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetUserLink()
 {
     // Create client
     AnalyticsAdminServiceClient analyticsAdminServiceClient = AnalyticsAdminServiceClient.Create();
     // Initialize request argument(s)
     string name = "accounts/[ACCOUNT]/userLinks/[USER_LINK]";
     // Make the request
     UserLink response = analyticsAdminServiceClient.GetUserLink(name);
 }
Exemplo n.º 15
0
 /// <summary>Snippet for UpdateUserLink</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void UpdateUserLink()
 {
     // Create client
     AnalyticsAdminServiceClient analyticsAdminServiceClient = AnalyticsAdminServiceClient.Create();
     // Initialize request argument(s)
     UserLink userLink = new UserLink();
     // Make the request
     UserLink response = analyticsAdminServiceClient.UpdateUserLink(userLink);
 }
Exemplo n.º 16
0
 /// <summary>Snippet for GetUserLink</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetUserLinkResourceNames()
 {
     // Create client
     AnalyticsAdminServiceClient analyticsAdminServiceClient = AnalyticsAdminServiceClient.Create();
     // Initialize request argument(s)
     UserLinkName name = UserLinkName.FromAccountUserLink("[ACCOUNT]", "[USER_LINK]");
     // Make the request
     UserLink response = analyticsAdminServiceClient.GetUserLink(name);
 }
Exemplo n.º 17
0
        public static UserAction RecordUserPassedTest(int hostID, User user)
        {
            UserAction userAction = Create(hostID, user.UserID, ActionType.UserPassedTest);
            UserLink   userLink   = new UserLink(user);

            userAction.Message = String.Format("passed the knowledge test, congratulations!", ControlHelper.RenderControl(userLink));
            userAction.Save();
            return(userAction);
        }
Exemplo n.º 18
0
        public static UserAction RecordShout(int hostID, User user, User toUser)
        {
            UserAction userAction = Create(hostID, user.UserID, ActionType.Shout);
            UserLink   userLink   = new UserLink(toUser);

            userAction.Message = String.Format("shouted something on {0}'s profile", ControlHelper.RenderControl(userLink));
            userAction.Save();
            return(userAction);
        }
 /// <summary>Snippet for CreateUserLink</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CreateUserLinkResourceNames1()
 {
     // Create client
     AnalyticsAdminServiceClient analyticsAdminServiceClient = AnalyticsAdminServiceClient.Create();
     // Initialize request argument(s)
     AccountName parent   = AccountName.FromAccount("[ACCOUNT]");
     UserLink    userLink = new UserLink();
     // Make the request
     UserLink response = analyticsAdminServiceClient.CreateUserLink(parent, userLink);
 }
Exemplo n.º 20
0
 /// <summary>Snippet for CreateUserLink</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CreateUserLinkResourceNames2()
 {
     // Create client
     AnalyticsAdminServiceClient analyticsAdminServiceClient = AnalyticsAdminServiceClient.Create();
     // Initialize request argument(s)
     PropertyName parent   = PropertyName.FromProperty("[PROPERTY]");
     UserLink     userLink = new UserLink();
     // Make the request
     UserLink response = analyticsAdminServiceClient.CreateUserLink(parent, userLink);
 }
Exemplo n.º 21
0
        public void Delete(Guid userId, Guid raceId)
        {
            CheckIfRaceExsists(userId, raceId);
            UserLink userLink = CheckUserIsAuthorizedForRace(userId, raceId, RaceAccessLevel.Owner);

            _unitOfWork.UserLinkRepository.Delete(userLink);
            _unitOfWork.RaceRepository.Delete(raceId);

            _unitOfWork.Save();
        }
Exemplo n.º 22
0
        /// <summary>Snippet for UpdateUserLinkAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task UpdateUserLinkAsync()
        {
            // Create client
            AnalyticsAdminServiceClient analyticsAdminServiceClient = await AnalyticsAdminServiceClient.CreateAsync();

            // Initialize request argument(s)
            UserLink userLink = new UserLink();
            // Make the request
            UserLink response = await analyticsAdminServiceClient.UpdateUserLinkAsync(userLink);
        }
 /// <summary>Snippet for CreateUserLink</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CreateUserLink()
 {
     // Create client
     AnalyticsAdminServiceClient analyticsAdminServiceClient = AnalyticsAdminServiceClient.Create();
     // Initialize request argument(s)
     string   parent   = "accounts/[ACCOUNT]";
     UserLink userLink = new UserLink();
     // Make the request
     UserLink response = analyticsAdminServiceClient.CreateUserLink(parent, userLink);
 }
        public void AOSLogin(string username, string password)
        {
            string CurrentWindow = driver.CurrentWindowHandle;

            UserLink.Click();
            System.Threading.Thread.Sleep(3000);
            driver.SwitchTo().Window(driver.WindowHandles.Last());
            UserNameField.SendKeys(username);
            PasswordField.SendKeys(password);
            SignInButton.Click();
        }
Exemplo n.º 25
0
        public static UserAction RecordUserUnBan(int hostID, User user, User moderator)
        {
            UserAction userAction = Create(hostID, moderator.UserID, ActionType.UserUnBan);

            userAction.ToUserID = user.UserID;
            UserLink userLink = new UserLink(user);

            userAction.Message = String.Format(" un-banned {0}", ControlHelper.RenderControl(userLink));
            userAction.Save();
            return(userAction);
        }
Exemplo n.º 26
0
 public ActionResult AddLink(UserLink otherUser)
 {
     try
     {
         _treeService.AddLink(otherUser);
         return(RedirectToAction("GetIndividuals", "Family", new { fid = otherUser.familyID }));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 27
0
 public ActionResult EditLink(int lid, UserLink obj)
 {
     try
     {
         _treeService.EditLink(obj);
         return(RedirectToAction("GetLinkedUsers", new { fid = obj.familyID, controller = "Family" }));
     }
     catch
     {
         return(RedirectToAction("GetLinkedUsers", new { fid = obj.familyID, controller = "Family" }));
     }
 }
 /// <summary>Snippet for GetUserLink</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetUserLinkRequestObject()
 {
     // Create client
     AnalyticsAdminServiceClient analyticsAdminServiceClient = AnalyticsAdminServiceClient.Create();
     // Initialize request argument(s)
     GetUserLinkRequest request = new GetUserLinkRequest
     {
         UserLinkName = UserLinkName.FromAccountUserLink("[ACCOUNT]", "[USER_LINK]"),
     };
     // Make the request
     UserLink response = analyticsAdminServiceClient.GetUserLink(request);
 }
Exemplo n.º 29
0
        /// <summary>
        /// Renders the UserLink
        /// </summary>
        /// <param name="item">
        /// The item.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        protected string UserLink([NotNull] PagedEventLog item)
        {
            var userLink = new UserLink
            {
                UserID      = item.UserID,
                Suspended   = item.Suspended,
                Style       = item.UserStyle,
                ReplaceName = this.PageContext.BoardSettings.EnableDisplayName ? item.DisplayName : item.Name
            };

            return(userLink.RenderToString());
        }
Exemplo n.º 30
0
 public IHttpActionResult FollowUser([FromBody] UserLink userLinkObj)
 {
     if (userLinkObj.FolloweeId != null && userLinkObj.FollowerId != null)
     {
         userBusinessLogic.Follow(userLinkObj.FolloweeId, userLinkObj.FollowerId);
         return(Ok());
     }
     else
     {
         return(NotFound());
     }
 }
Exemplo n.º 31
0
        //Enables a user to edit the username they input into the database
        //Only really useful if they misspelled the email address
        public void EditLink(UserLink linkObject)
        {
            IQueryable <UserLink> _link;

            _link = from link in _context.UserLinks
                    where link.Id == linkObject.Id
                    select link;
            UserLink linkEdit = _link.First();

            linkEdit.enabledUserName = linkObject.enabledUserName;
            _context.SaveChanges();
        }
 /// <summary>Snippet for UpdateUserLink</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void UpdateUserLinkRequestObject()
 {
     // Create client
     AnalyticsAdminServiceClient analyticsAdminServiceClient = AnalyticsAdminServiceClient.Create();
     // Initialize request argument(s)
     UpdateUserLinkRequest request = new UpdateUserLinkRequest
     {
         UserLink = new UserLink(),
     };
     // Make the request
     UserLink response = analyticsAdminServiceClient.UpdateUserLink(request);
 }
 partial void UpdateUserLink(UserLink instance);
 partial void DeleteUserLink(UserLink instance);
 partial void InsertUserLink(UserLink instance);
Exemplo n.º 36
0
        /// <summary>
        /// Renders the MostActiveUsers class.
        /// </summary>
        /// <param name="writer">
        /// </param>
        protected override void Render([NotNull] HtmlTextWriter writer)
        {
            string actRank = string.Empty;

            DataTable rankDt = this.Get<IDataCache>().GetOrSet(
              Constants.Cache.MostActiveUsers,
              () =>
              LegacyDb.user_activity_rank(
                this.PageContext.PageBoardID, DateTime.UtcNow.AddDays(-this.LastNumOfDays), this.DisplayNumber),
              TimeSpan.FromMinutes(5));

            writer.BeginRender();

            var html = new StringBuilder();

            html.AppendFormat(@"<div id=""{0}"" class=""yaf_activeuser"">", this.ClientID);
            html.AppendFormat(@"<h2 class=""yaf_header"">{0}</h2>", "Most Active Users");
            html.AppendFormat(@"<h4 class=""yaf_subheader"">Last {0} Days</h4>", this.LastNumOfDays);

            html.AppendLine("<ol>");

            // flush...
            writer.Write(html.ToString());

            foreach (DataRow row in rankDt.Rows)
            {
                writer.WriteLine("<li>");

                // render UserLink...
                var userLink = new UserLink { UserID = row.Field<int>("ID"), };
                userLink.RenderControl(writer);

                // render online image...
                var onlineStatusImage = new OnlineStatusImage { UserID = row.Field<int>("ID") };
                onlineStatusImage.RenderControl(writer);

                writer.WriteLine(" ");
                writer.WriteLine(@"<span class=""NumberOfPosts"">({0})</span>".FormatWith(row.Field<int>("NumOfPosts")));
                writer.WriteLine("</li>");
            }

            writer.WriteLine("</ol>");
            writer.WriteLine("</div>");
            writer.EndRender();
        }
Exemplo n.º 37
0
        void AccountContactManage_DeleteLink(object sender, EventArgs e)
        {
            AuthoriseRequestSid();

            long linkId = core.Functions.RequestLong("id", 0);

            try
            {
                UserLink link = new UserLink(core, linkId);

                if (link.Delete() > 0)
                {
                    SetRedirectUri(BuildUri());
                    core.Display.ShowMessage("Link Deleted", "The link has been deleted from the database.");
                    return;
                }
                else
                {
                    core.Display.ShowMessage("Error", "Could not delete the link.");
                    return;
                }
            }
            catch (PageNotFoundException)
            {
                core.Display.ShowMessage("Error", "Could not delete the link.");
                return;
            }
        }
Exemplo n.º 38
0
        void AccountContactManage_AddLink_save(object sender, EventArgs e)
        {
            AuthoriseRequestSid();

            switch (core.Http.Form["mode"])
            {
                case "add-link":
                    string linkAddress = core.Http.Form["link-address"];
                    string linkTitle = core.Http.Form["link-title"];

                    try
                    {
                        UserLink.Create(core, linkAddress, linkTitle);

                        SetRedirectUri(BuildUri());
                        core.Display.ShowMessage("Link Saved", "Your link has been saved in the database.");
                    }
                    catch (InvalidUserEmailException)
                    {
                    }
                    return;
                case "edit-link":
                    long linkId = core.Functions.FormLong("id", 0);
                    UserLink link = null;

                    try
                    {
                        link = new UserLink(core, linkId);
                    }
                    catch (InvalidUserPhoneNumberException)
                    {
                        return;
                    }

                    //link.LinkAddress = core.Http.Form["link-address"];
                    link.Title = core.Http.Form["link-title"];
                    link.Update();

                    SetRedirectUri(BuildUri());
                    core.Display.ShowMessage("Link Saved", "Your link has been saved in the database.");
                    return;
                default:
                    DisplayError("Error - no mode selected");
                    return;
            }
        }
Exemplo n.º 39
0
        void AccountContactManage_AddLink(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_link_edit");

            /**/
            TextBox linkAddressTextBox = new TextBox("link-address");

            /* */
            TextBox linkTitleTextBox = new TextBox("link-title");

            switch (e.Mode)
            {
                case "add-link":
                    break;
                case "edit-link":
                    long linkId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0));
                    UserLink link = null;

                    if (linkId > 0)
                    {
                        try
                        {
                            link = new UserLink(core, linkId);

                            //phoneNumberTextBox.IsDisabled = true;
                            linkAddressTextBox.Value = link.LinkAddress;
                            linkAddressTextBox.IsDisabled = true;
                            linkTitleTextBox.Value = link.Title;

                            template.Parse("S_ID", link.Id.ToString());
                        }
                        catch (InvalidUserLinkException)
                        {
                        }
                    }

                    template.Parse("EDIT", "TRUE");
                    break;
            }

            template.Parse("S_LINK", linkAddressTextBox);
            template.Parse("S_TITLE", linkTitleTextBox);
        }
Exemplo n.º 40
0
    /// <summary>
    /// Renders the MostActiveUsers class.
    /// </summary>
    /// <param name="writer">
    /// </param>
    protected override void Render([NotNull] HtmlTextWriter writer)
    {
      int currentRank = 1;
      string actRank = string.Empty;

      DataTable rankDt = this.Get<IDataCache>().GetOrSet(
        Constants.Cache.MostActiveUsers,
        () =>
        LegacyDb.user_activity_rank(
          this.PageContext.PageBoardID, DateTime.UtcNow.AddDays(-this.LastNumOfDays), this.DisplayNumber),
        TimeSpan.FromMinutes(5));

      //// create XML data document...
      // XmlDocument xml = new XmlDocument();

      // rankDt.TableName = "UserActivityRank";
      // xml.LoadXml( rankDt.DataSet.GetXml() );

      //// transform using the MostActiveUser xslt...
      // const string xsltFile = "YAF.Controls.Statistics.MostActiveUser.xslt";

      // using ( Stream resourceStream = Assembly.GetAssembly( this.GetType() ).GetManifestResourceStream( xsltFile ) )
      // {
      // if ( resourceStream != null )
      // {
      // XslCompiledTransform myXslTrans = new XslCompiledTransform();

      // //load the Xsl 
      // myXslTrans.Load( XmlReader.Create( resourceStream ) );
      // myXslTrans.Transform( xml.CreateNavigator(), xslArgs, writer );
      // }
      // }
      writer.BeginRender();

      var html = new StringBuilder();

      html.AppendFormat(@"<div id=""{0}"" class=""yaf_activeuser"">", this.ClientID);
      html.AppendFormat(@"<h2 class=""yaf_header"">{0}</h2>", "Most Active Users");
      html.AppendFormat(@"<h4 class=""yaf_subheader"">Last {0} Days</h4>", this.LastNumOfDays);

      html.AppendLine("<ol>");

      // flush...
      writer.Write(html.ToString());

      foreach (DataRow row in rankDt.Rows)
      {
        writer.WriteLine("<li>");

        // render UserLink...
        var userLink = new UserLink { UserID = row.Field<int>("ID"), };
        userLink.RenderControl(writer);

        // render online image...
        var onlineStatusImage = new OnlineStatusImage { UserID = row.Field<int>("ID") };
        onlineStatusImage.RenderControl(writer);

        writer.WriteLine(" ");
        writer.WriteLine(@"<span class=""NumberOfPosts"">({0})</span>".FormatWith(row.Field<int>("NumOfPosts")));
        writer.WriteLine("</li>");
      }

      writer.WriteLine("</ol>");
      writer.EndRender();
    }