protected void Page_Load(object sender, EventArgs e) { try { if (Session["UserCode"] == null) { this.Visible = false; } UserCode = Convert.ToInt32(Session["UserCode"]); if (!Page.IsPostBack) { LoadComments(rptComments, _itemCode); UtilDataContext dc = new UtilDataContext(); if (dc.UserItemLikes.Where(p => p.UserCode.Equals(UserCode) && p.ItemCode.Equals(_itemCode)).Count() == 1) { btnLike.ImageUrl = "~/images/dislike.png"; } else { btnLike.ImageUrl = "~/images/like.png"; } } else if (_loadOnPostBack) { LoadComments(rptComments, _itemCode); } } catch (Exception exp) { BOLErrorLogs ErrorLogsBOL = new BOLErrorLogs(); ErrorLogsBOL.Insert(exp.Message, DateTime.Now, Request.Url.AbsolutePath, "CommentLiks::Load"); } }
protected void btnLike_Click(object sender, EventArgs e) { UserCode = Convert.ToInt32(Session["UserCode"]); UtilDataContext dc = new UtilDataContext(); UserItemLikes NewLike = new UserItemLikes(); NewLike = new UserItemLikes(); NewLike.UserCode = UserCode; NewLike.HCItemTypeCode = _hCItemTypeCode; NewLike.ItemCode = _itemCode; if (btnLike.ImageUrl == "/images/like.png") { dc.UserItemLikes.InsertOnSubmit(NewLike); lblLikeCaption.Text = "شما به این مطلب اطعار علاقه کرده اید"; btnLike.ImageUrl = "~/images/dislike.png"; pnlLikes.Visible = true; } else { dc.UserItemLikes.DeleteAllOnSubmit(dc.UserItemLikes.Where(p => p.ItemCode.Equals(_itemCode) && p.UserCode.Equals(UserCode))); lblLikeCaption.Text = ""; btnLike.ImageUrl = "~/images/like.png"; pnlLikes.Visible = false; } dc.SubmitChanges(); }
protected void LoadComments(Repeater rptComments, int ItemCode) { UtilDataContext dc = new UtilDataContext(); rptComments.DataSource = dc.vUserItemComments.Where(p => p.ItemCode.Equals(ItemCode) && p.HCItemTypeCode.Equals(_hCItemTypeCode)); rptComments.DataBind(); }
protected void btnSendComment_Click(object sender, EventArgs e) { UtilDataContext dc = new UtilDataContext(); UserItemComments NewComment = new UserItemComments(); dc.UserItemComments.InsertOnSubmit(NewComment); NewComment.ItemCode = _itemCode; NewComment.UserCode = UserCode; NewComment.HCItemTypeCode = _hCItemTypeCode; NewComment.Comment = txtComment.Text; NewComment.CommentDate = DateTime.Now; NewComment.ID = Tools.GetRandID(); dc.SubmitChanges(); txtComment.Text = ""; string SiteDomain = ConfigurationSettings.AppSettings["SiteDomain"]; if (_hCItemTypeCode == 3)//Photos { UsersDataContext dcUser = new UsersDataContext(); Users OwnerUser = dcUser.Users.SingleOrDefault(p => p.Code.Equals(_ownerUserCode)); string OwnerUserFullName = OwnerUser.FirstName + " " + OwnerUser.LastName; if (OwnerUser != null) { } BOLUserActions UserActionsBOL = new BOLUserActions(); UserActionsBOL.NewAction(UserCode, "<a href='" + SiteDomain + "Users/Profile.aspx?ID=" + Session["UserID"] + "'>" + Session["FirstName"] + " " + Session["LastName"] + "</a> نظر جدیدی روی عکس <a href='" + SiteDomain + "Users/Profile.aspx?ID=" + OwnerUser.ID + "'>" + OwnerUserFullName + "</a> <a href='Users/ShowPhoto.aspx?ID=" + _params + "'>" + " ارسال کرده است.</a>", 7); } LoadComments(rptComments, _itemCode); }
protected void HandleRepeaterCommand(object source, RepeaterCommandEventArgs e) { string CommentID = ""; UtilDataContext dc = new UtilDataContext(); LinkButton btnDeleteComment = (LinkButton)e.Item.Controls[1].FindControl("btnDeleteComment"); int UserCode = Convert.ToInt32(Session["UserCode"]); LinkButton hplTitle = (LinkButton)e.Item.Controls[1].FindControl("hplTitle"); #region DeleteComment if (e.CommandName == "DeleteComment") { CommentID = btnDeleteComment.Attributes["CommentID"]; UserItemComments CurItemComment = dc.UserItemComments.SingleOrDefault(p => p.ID.Equals(CommentID)); if (CurItemComment != null) { dc.UserItemComments.DeleteAllOnSubmit(dc.UserItemComments.Where(p => p.Code.Equals(CurItemComment.Code))); dc.SubmitChanges(); LoadComments((Repeater)source, (int)CurItemComment.ItemCode); } } #endregion }
public bool SendAddFriendMessage(Users FromUser, Users ToUser) { bool SendResult = false; if (Tools.GetValue(ToUser.IAddMeAsFriend)) { UtilDataContext dcUtil = new UtilDataContext(); UsersDataContext dcUser = new UsersDataContext(); EmailTemplates CurTemplate = dcUtil.EmailTemplates.SingleOrDefault(p => p.Title.Equals("AddFriend")); if (CurTemplate != null) { string UserImageUrl; string SiteDomain = ConfigurationSettings.AppSettings["SiteDomain"]; Tools tools = new Tools(); string MsgBody = CurTemplate.Template; string MessageUrl = SiteDomain + "Default.aspx?AF=1"; if (FromUser.PicFile == null || FromUser.PicFile == "") { UserImageUrl = SiteDomain + "Files/Users/man_icon.gif"; } else { UserImageUrl = SiteDomain + "Files/Users/" + FromUser.PicFile; } string RemoveEmailUrl = SiteDomain + "Users/Setting.aspx"; if (CurTemplate != null) { int FriendCount = dcUser.UserFriends.Where(p => p.UserCode.Equals(FromUser.Code)).Count(); int PhotoCount = dcUser.vUserAlbumPhotos.Where(p => p.UserCode.Equals(FromUser.Code)).Count(); MsgBody = CurTemplate.Template; MsgBody = MsgBody.Replace("[UserFullName]", FromUser.FirstName + " " + FromUser.LastName); MsgBody = MsgBody.Replace("[UserFirstName]", FromUser.FirstName); MsgBody = MsgBody.Replace("[UserEmail]", FromUser.Email); MsgBody = MsgBody.Replace("[MessageUrl]", MessageUrl); MsgBody = MsgBody.Replace("[RecFirstName]", ToUser.FirstName); MsgBody = MsgBody.Replace("[UserUrl]", SiteDomain + "Users/Profile.aspx?ID=" + FromUser.ID); MsgBody = MsgBody.Replace("[ImageUrl]", UserImageUrl); MsgBody = MsgBody.Replace("[RemoveEmailUrl]", RemoveEmailUrl); MsgBody = MsgBody.Replace("[FriendCount]", FriendCount.ToString()); MsgBody = MsgBody.Replace("[PhotoCount]", PhotoCount.ToString()); } string MsgSubject = FromUser.FirstName + " " + FromUser.LastName + " تقاضای دوستی با شما را دارد"; SendResult = tools.SendEmail(MsgBody, MsgSubject, "*****@*****.**", ToUser.Email, "", ""); BOLEmails EmailsBOL = new BOLEmails(); EmailsBOL.Insert(ToUser.Email, 3, MsgBody); } } return(SendResult); }
public void Insert(string Keyword, int HCSiteSectionCode, string IP, int ReturnCount, DateTime SearchDate) { UtilDataContext dc = new UtilDataContext(); SearchedKeywords NewKeyword = new SearchedKeywords(); dc.SearchedKeywords.InsertOnSubmit(NewKeyword); NewKeyword.IP = IP; NewKeyword.ReturnCount = ReturnCount; NewKeyword.Keyword = Keyword; NewKeyword.HCSiteSectionCode = HCSiteSectionCode; NewKeyword.SearchDate = SearchDate; dc.SubmitChanges(); }
public string LoadTemplate(string Title) { UtilDataContext dc = new UtilDataContext(); EmailTemplates CurTemplate = dc.EmailTemplates.SingleOrDefault(p => p.Title.Equals(Title)); if (CurTemplate != null) { return(CurTemplate.Template); } else { return(null); } }
public bool SendInvitationMessage(Users FromUser, string Email) { bool SendResult = false; UtilDataContext dcUtil = new UtilDataContext(); UsersDataContext dcUser = new UsersDataContext(); EmailTemplates CurTemplate = dcUtil.EmailTemplates.SingleOrDefault(p => p.Title.Equals("Invitation")); if (CurTemplate != null) { string UserImageUrl; string SiteDomain = ConfigurationSettings.AppSettings["SiteDomain"]; Tools tools = new Tools(); string MsgBody = CurTemplate.Template; string MessageUrl = SiteDomain + "?Invited=1&Email=" + Email; if (FromUser.PicFile == null || FromUser.PicFile == "") { UserImageUrl = SiteDomain + "Files/Users/man_icon.gif"; } else { UserImageUrl = SiteDomain + "Files/Users/" + FromUser.PicFile; } string RemoveEmailUrl = SiteDomain + "Users/Setting.aspx"; if (CurTemplate != null) { MsgBody = CurTemplate.Template; MsgBody = MsgBody.Replace("[UserFullName]", FromUser.FirstName + " " + FromUser.LastName); MsgBody = MsgBody.Replace("[UserEmail]", FromUser.Email); MsgBody = MsgBody.Replace("[MessageUrl]", MessageUrl); MsgBody = MsgBody.Replace("[ImageUrl]", UserImageUrl); MsgBody = MsgBody.Replace("[RemoveEmailUrl]", RemoveEmailUrl); MsgBody = MsgBody.Replace("[UserUrl]", SiteDomain + "Users/Profile.aspx?ID=" + FromUser.ID); int FriendCount = dcUser.UserFriends.Where(p => p.UserCode.Equals(FromUser.Code)).Count(); int PhotoCount = dcUser.vUserAlbumPhotos.Where(p => p.UserCode.Equals(FromUser.Code)).Count(); MsgBody = MsgBody.Replace("[FriendCount]", FriendCount.ToString()); MsgBody = MsgBody.Replace("[PhotoCount]", PhotoCount.ToString()); } string MsgSubject = FromUser.FirstName + " " + FromUser.LastName + " برای شما یک پیام در پارست ارسال کرده است."; SendResult = tools.SendEmail(MsgBody, MsgSubject, "<*****@*****.**>", Email, "", ""); BOLEmails EmailsBOL = new BOLEmails(); EmailsBOL.Insert(Email, 3, MsgBody); } return(SendResult); }
public bool SendLikeMessage(Users UserWhoLikes, Users UserWhoCommented, string CommentID) { bool SendResult = false; UtilDataContext dcUtil = new UtilDataContext(); UsersDataContext dcUser = new UsersDataContext(); EmailTemplates CurTemplate = dcUtil.EmailTemplates.SingleOrDefault(p => p.Title.Equals("LikeComment")); if (CurTemplate != null) { string UserImageUrl; string CommentUrl = ""; string SiteDomain = ConfigurationSettings.AppSettings["SiteDomain"]; Tools tools = new Tools(); string MsgBody = CurTemplate.Template; if (UserWhoLikes.PicFile == null || UserWhoLikes.PicFile == "") { UserImageUrl = SiteDomain + "Files/Users/man_icon.gif"; } else { UserImageUrl = SiteDomain + "Files/Users/" + UserWhoLikes.PicFile; } CommentUrl = SiteDomain + "Users/Home.aspx?CommentID=" + CommentID; if (CurTemplate != null) { MsgBody = CurTemplate.Template; MsgBody = MsgBody.Replace("[RecFirstName]", UserWhoCommented.FirstName); MsgBody = MsgBody.Replace("[UserUrl]", SiteDomain + "Users/Profile.aspx?ID=" + UserWhoLikes.ID); MsgBody = MsgBody.Replace("[UserFullName]", UserWhoLikes.FirstName + " " + UserWhoLikes.LastName); MsgBody = MsgBody.Replace("[UserFirstName]", UserWhoLikes.FirstName); MsgBody = MsgBody.Replace("[UserEmail]", UserWhoLikes.Email); MsgBody = MsgBody.Replace("[ImageUrl]", UserImageUrl); MsgBody = MsgBody.Replace("[CommentUrl]", CommentUrl); int FriendCount = dcUser.UserFriends.Where(p => p.UserCode.Equals(UserWhoLikes.Code)).Count(); int PhotoCount = dcUser.vUserAlbumPhotos.Where(p => p.UserCode.Equals(UserWhoLikes.Code)).Count(); MsgBody = MsgBody.Replace("[FriendCount]", FriendCount.ToString()); MsgBody = MsgBody.Replace("[PhotoCount]", PhotoCount.ToString()); } string MsgSubject = UserWhoLikes.FirstName + " " + UserWhoLikes.LastName + " به مطلب ارسالی شما در پارست اظهار علاقه کرده است."; SendResult = tools.SendEmail(MsgBody, MsgSubject, "<*****@*****.**>", UserWhoCommented.Email, "", ""); BOLEmails EmailsBOL = new BOLEmails(); EmailsBOL.Insert(UserWhoCommented.Email, 3, MsgBody); } return(SendResult); }
protected void btnInviteFriends_Click(object sender, EventArgs e) { int UserCode = Convert.ToInt32(Session["UserCode"]); string FriendList = txtFriendList.Text.Trim().Replace("\n", ""); if (FriendList.Trim() == "") { msg.Text = "لطفا ایمیل دوستتان را وارد کنید"; return; } else { string SiteDomain = ConfigurationSettings.AppSettings["SiteDomain"]; Tools tools = new Tools(); UtilDataContext dc = new UtilDataContext(); UsersDataContext dcUser = new UsersDataContext(); Users CurUser = dcUser.Users.SingleOrDefault(p => p.Code.Equals(UserCode)); string[] FriendListArray = FriendList.Split(','); EmailTools emailTools = new EmailTools(); bool SendResult = emailTools.SendEmailToFriends(CurUser.Code, FriendListArray); if (SendResult) { //btnInviteFriends.Visible = false; if (FriendListArray.Length > 1) { msg.Text = "تمام ایمیلها با موف ارسال شدند"; } else { msg.Text = "ایمیل با موفقیت ارسال شد."; } } else { msg.Text = "هنگام ارسال ایمیل خطایی رخ داده است."; } } }
protected void btnSendMessage_Click(object source, EventArgs e) { string UserImageUrl; int UserCode = (int)Session["UserCode"]; UsersDataContext dc = new UsersDataContext(); UserMessages NewMessage = new UserMessages(); NewMessage.HCStatusCode = 2; NewMessage.Message = txtMessageContent.Text; NewMessage.FromUserCode = UserCode; NewMessage.SendDate = DateTime.Now; NewMessage.Title = txtMessageSubject.Text; NewMessage.ID = Tools.GetRandID(); NewMessage.ToUserCode = ToUserCode; dc.UserMessages.InsertOnSubmit(NewMessage); dc.SubmitChanges(); string jsScript = @"$('#divSendMessage').modal('hide');"; ScriptManager.RegisterStartupScript(_upanel, _upanel.GetType(), "divSendMessage", jsScript, true); #region Send Email UtilDataContext dcUtil = new UtilDataContext(); Users ToUser = dc.Users.SingleOrDefault(p => p.Code.Equals(ToUserCode)); EmailTemplates CurTemplate = dcUtil.EmailTemplates.SingleOrDefault(p => p.Title.Equals("SendMessage")); if (Tools.GetValue(ToUser.ISendMessage)) { if (CurTemplate != null) { string SiteDomain = ConfigurationSettings.AppSettings["SiteDomain"]; Users FromUser = dc.Users.SingleOrDefault(p => p.Code.Equals(UserCode)); Tools tools = new Tools(); string MsgBody = CurTemplate.Template; string MessageUrl = SiteDomain + "Users/Messages.aspx?ID=" + NewMessage.ID; if (FromUser.PicFile == null || FromUser.PicFile == "") { UserImageUrl = SiteDomain + "Files/Users/man_icon.gif"; } else { UserImageUrl = SiteDomain + "Files/Users/" + FromUser.PicFile; } string RemoveEmailUrl = SiteDomain + "Users/Setting.aspx"; MsgBody = MsgBody.Replace("[UserFullName]", Session["FirstName"].ToString() + " " + Session["LastName"].ToString()); MsgBody = MsgBody.Replace("[UserEmail]", FromUser.Email); MsgBody = MsgBody.Replace("[MessageUrl]", MessageUrl); MsgBody = MsgBody.Replace("[ImageUrl]", UserImageUrl); MsgBody = MsgBody.Replace("[RemoveEmailUrl]", RemoveEmailUrl); MsgBody = MsgBody.Replace("[RecFirstName]", ToUser.FirstName); MsgBody = MsgBody.Replace("[UserUrl]", SiteDomain + "Users/Profile.aspx?ID=" + FromUser.ID); MsgBody = MsgBody.Replace("[UserFirstName]", FromUser.FirstName); int FriendCount = dc.UserFriends.Where(p => p.UserCode.Equals(FromUser.Code)).Count(); int PhotoCount = dc.vUserAlbumPhotos.Where(p => p.UserCode.Equals(FromUser.Code)).Count(); MsgBody = MsgBody.Replace("[FriendCount]", FriendCount.ToString()); MsgBody = MsgBody.Replace("[PhotoCount]", PhotoCount.ToString()); string MsgSubject = Session["FirstName"].ToString() + " " + Session["LastName"].ToString() + " برای شما یک پیام در پارست ارسال کرده است"; bool SendResult = tools.SendEmail(MsgBody, MsgSubject, "<*****@*****.**>", ToUser.Email, "*****@*****.**", ""); } } #endregion pnlSendMessage.Visible = false; }