Exemplo n.º 1
0
        private bool SendPinboardResponse(List <MessageReceiver> receivers, string messageSubject, string messageBody, MessageTypes messageType)
        {
            bool messageSent = true;

            // Send internal messages
            foreach (var receiver in receivers.FindAll(x => x.UserId.HasValue))
            {
                try
                {
                    DataAccess.Business.Message message = new DataAccess.Business.Message(_4screen.CSB.Common.SiteConfig.GetSiteContext(UserProfile.Current));
                    message.MsgID        = Guid.NewGuid();
                    message.FromUserID   = UserProfile.Current.UserId;
                    message.UserId       = receiver.UserId.Value;
                    message.TypOfMessage = (int)messageType;
                    message.Subject      = messageSubject;
                    message.MsgText      = messageBody;
                    message.ShowInInbox  = true;
                    message.ShowInOutbox = true;
                    if (!message.SendNormalMessage())
                    {
                        throw new Exception();
                    }
                }
                catch
                {
                    messageSent = false;
                }
            }

            return(messageSent);
        }
Exemplo n.º 2
0
        private bool SendInvitation(List <MessageReceiver> receivers, string messageSubject, string messageBody)
        {
            bool messageSent = true;

            // Send internal messages
            foreach (var receiver in receivers.FindAll(x => x.UserId.HasValue))
            {
                try
                {
                    DataAccess.Business.Message message = new DataAccess.Business.Message(_4screen.CSB.Common.SiteConfig.GetSiteContext(UserProfile.Current));
                    message.MsgID        = Guid.NewGuid();
                    message.FromUserID   = UserProfile.Current.UserId;
                    message.UserId       = receiver.UserId.Value;
                    message.TypOfMessage = (int)MessageTypes.InviteToCommunity;
                    message.Subject      = messageSubject;
                    message.MsgText      = messageBody;
                    message.XMLData      = string.Format("<root><communityid>{0}</communityid></root>", objectId);
                    message.ShowInInbox  = true;
                    message.ShowInOutbox = true;
                    if (!message.SendInviteMessage())
                    {
                        throw new Exception();
                    }
                }
                catch
                {
                    messageSent = false;
                }
            }

            return(messageSent);
        }
Exemplo n.º 3
0
        private bool SendRecommendation(List <MessageReceiver> receivers, string url, string messageSubject, string messageBody)
        {
            bool messageSent = true;

            // Send internal messages
            foreach (var receiver in receivers.FindAll(x => x.UserId.HasValue))
            {
                try
                {
                    DataAccess.Business.Message message = new DataAccess.Business.Message(_4screen.CSB.Common.SiteConfig.GetSiteContext(UserProfile.Current));
                    message.MsgID        = Guid.NewGuid();
                    message.FromUserID   = UserProfile.Current.UserId;
                    message.UserId       = receiver.UserId.Value;
                    message.TypOfMessage = (int)MessageTypes.NormalMessage;
                    message.Subject      = messageSubject;
                    message.MsgText      = Regex.Replace(messageBody, "<.html>|<.body>", "");
                    message.ShowInInbox  = true;
                    message.ShowInOutbox = true;
                    if (!message.SendNormalMessage())
                    {
                        throw new Exception();
                    }
                }
                catch
                {
                    messageSent = false;
                }
            }

            // Send emails
            List <MailAddress> emailReceivers = new List <MailAddress>();

            foreach (var receiver in receivers.FindAll(x => !string.IsNullOrEmpty(x.EmailAddress)))
            {
                emailReceivers.Add(new MailAddress(receiver.EmailAddress));
            }
            if (emailReceivers.Count > 0)
            {
                try
                {
                    if (!DataAccess.Business.Message.SendEmail(emailReceivers, _4screen.CSB.Common.SiteConfig.SiteName + " " + messageSubject, messageBody, true))
                    {
                        throw new Exception();
                    }
                }
                catch
                {
                    messageSent = false;
                }
            }

            return(messageSent);
        }
Exemplo n.º 4
0
 private void SendMessage(Guid userId, string subject, string messageTxt)
 {
     DataAccess.Business.Message message = new DataAccess.Business.Message(_4screen.CSB.Common.SiteConfig.GetSiteContext(UserProfile.Current));
     message.MsgID        = Guid.NewGuid();
     message.FromUserID   = UserProfile.Current.UserId;
     message.UserId       = userId;
     message.TypOfMessage = (int)MessageTypes.NormalMessage;
     message.Subject      = subject;
     message.MsgText      = messageTxt;
     message.ShowInInbox  = true;
     message.ShowInOutbox = true;
     message.SendNormalMessage();
 }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _4screen.CSB.Extensions.Business.TrackingManager.TrackEventPage(null, null, IsPostBack, LogSitePageType.Messaging);

            this.messageId = Request.QueryString["MsgId"];

            DataAccess.Business.Message message = DataAccess.Business.Message.LoadMessage(new Guid(messageId), _4screen.CSB.Common.SiteConfig.GetSiteContext(UserProfile.Current));

            Guid   userId;
            string username = string.Empty;

            if (message.UserId == UserProfile.Current.UserId) // Inbox
            {
                userId   = message.FromUserID;
                username = message.FromUserName;
                this.LitSenderReceiver.Text = string.Format("{0}:", language.GetString("LableRequestSender"));

                if (message.TypOfMessage != 5)
                {
                    this.REPLYLINK.Visible     = true;
                    this.REPLYLINK.NavigateUrl = string.Format("/Pages/Popups/MessageSend.aspx?MsgType=Msg&MsgMode=Reply&RecId={0}&MsgId={1}", message.FromUserID, message.MsgID);
                }

                if (!FriendHandler.IsBlocked(UserProfile.Current.UserId, message.FromUserID))
                {
                    this.LbtnBlockUser.CommandArgument = message.FromUserID.ToString();
                    this.LbtnBlockUser.Visible         = true;
                }
            }
            else // Outbox
            {
                userId   = message.UserId;
                username = message.UserName;
                this.LitSenderReceiver.Text = string.Format("{0}:", language.GetString("LableRequestReceiver"));
            }
            Control control = this.LoadControl("/UserControls/Templates/SmallOutputUser2.ascx");

            ((SmallOutputUser2)control).DataObjectUser = DataObject.Load <DataObjectUser>(userId);
            this.YMREC.Text = ((SmallOutputUser2)control).GetHtml();

            this.MSGSUB.Text = message.Subject;
            this.MSGCNT.Text = message.MsgText;
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _4screen.CSB.Extensions.Business.TrackingManager.TrackEventPage(null, null, IsPostBack, LogSitePageType.Friends);

            this.msgType = Request.QueryString["MsgType"];
            this.msgMode = Request.QueryString["MsgMode"];
            this.msgId   = Request.QueryString["MsgId"];

            this.message = DataAccess.Business.Message.LoadMessage(new Guid(msgId), _4screen.CSB.Common.SiteConfig.GetSiteContext(UserProfile.Current));

            if (message.UserId == UserProfile.Current.UserId)
            {
                DataAccess.Business.Message.SetRead(new Guid(msgId));
                this.userId = message.FromUserID;
            }
            else
            {
                this.userId = message.UserId;
            }
            Control control = this.LoadControl("/UserControls/Templates/SmallOutputUser2.ascx");

            ((SmallOutputUser2)control).DataObjectUser = DataObject.Load <DataObjectUser>(userId);
            this.YMREC.Text = ((SmallOutputUser2)control).GetHtml();

            this.MSGCNT.Text = message.MsgText;

            if (msgMode == "Accept")
            {
                this.MSGREPLYTITLE.Text = string.Format("{0}:", language.GetString("TitleRequestAccept"));
                this.YMTYPEPAN.Visible  = true;
                this.YMBLOCKPAN.Visible = false;
                this.YMBIRTH.Visible    = true;
            }
            else
            {
                this.MSGREPLYTITLE.Text = string.Format("{0}:", language.GetString("TitleRequestDeny"));
                this.YMTYPEPAN.Visible  = false;
                this.YMBLOCKPAN.Visible = true;
                this.YMBIRTH.Visible    = false;
                this.YMBIRTH.Checked    = false;
            }
        }
Exemplo n.º 7
0
        private bool SendMessage(List <MessageReceiver> receivers, string messageSubject, string messageBody)
        {
            bool messageSent = true;

            // Send internal messages
            foreach (var receiver in receivers.FindAll(x => x.UserId.HasValue))
            {
                try
                {
                    DataAccess.Business.Message message = new DataAccess.Business.Message(_4screen.CSB.Common.SiteConfig.GetSiteContext(UserProfile.Current));
                    message.MsgID        = Guid.NewGuid();
                    message.FromUserID   = UserProfile.Current.UserId;
                    message.UserId       = receiver.UserId.Value;
                    message.TypOfMessage = (int)MessageTypes.NormalMessage;
                    message.Subject      = messageSubject;
                    message.MsgText      = messageBody;
                    message.ShowInInbox  = true;
                    message.ShowInOutbox = true;
                    if (messageMode.ToLower() == "reply")
                    {
                        DataAccess.Business.Message.SetAnswered(new Guid(messageId));
                    }
                    if (messageMode.ToLower() == "forward")
                    {
                        DataAccess.Business.Message.SetForwarded(new Guid(messageId));
                    }
                    if (!message.SendNormalMessage())
                    {
                        throw new Exception();
                    }
                }
                catch
                {
                    messageSent = false;
                }
            }

            // Send emails
            List <MailAddress> emailReceivers = new List <MailAddress>();

            foreach (var receiver in receivers.FindAll(x => !string.IsNullOrEmpty(x.EmailAddress)))
            {
                emailReceivers.Add(new MailAddress(receiver.EmailAddress));
            }
            if (emailReceivers.Count > 0)
            {
                try
                {
                    if (!DataAccess.Business.Message.SendEmail(emailReceivers, messageSubject, messageBody, true))
                    {
                        throw new Exception();
                    }
                }
                catch
                {
                    messageSent = false;
                }
            }

            return(messageSent);
        }
Exemplo n.º 8
0
        private void SetSubjectAndBody()
        {
            if (!IsPostBack)
            {
                if (messageType.ToLower() == "rec")
                {
                    txtSubject.Text = language.GetString("LableMessageRecommedation");
                    string perparedLink = rawLink;
                    if (!rawLink.ToLower().StartsWith("http"))
                    {
                        perparedLink = _4screen.CSB.Common.SiteConfig.HostName + rawLink;
                    }

                    string mailBody = GuiLanguage.GetGuiLanguage("Templates").GetString("EmailRecommendation");
                    mailBody = mailBody.Replace("<%SITE_URL%>", _4screen.CSB.Common.SiteConfig.SiteURL);
                    if (UserDataContext.GetUserDataContext().IsAuthenticated)
                    {
                        DataObjectUser user = DataObject.Load <DataObjectUser>(UserProfile.Current.UserId);
                        mailBody = mailBody.Replace("<%FROM_USERNAME%>", user.Vorname);
                    }
                    else
                    {
                        mailBody = mailBody.Replace("<%FROM_USERNAME%>", string.Empty);
                    }
                    mailBody            = mailBody.Replace("<%LINK%>", perparedLink);
                    txtBody.Content     = mailBody;
                    txtSubject.ReadOnly = true;
                }
                else if (messageType.ToLower() == "msg")
                {
                    txtSubject.Text = language.GetString("LableMessagePrivateMessage");
                }
                else if (messageType.ToLower() == "ymr")
                {
                    txtSubject.Text     = languageShared.GetString("CommandFriendshipQuery");
                    txtSubject.ReadOnly = true;
                }
                else if (messageType.ToLower() == "invite")
                {
                    txtSubject.Text     = language.GetString("LableMessageInviteToCommunity");
                    txtSubject.ReadOnly = true;
                }
                else if (messageType.ToLower() == "rep")
                {
                    if (objectType == Helper.GetObjectTypeNumericID("User"))
                    {
                        txtSubject.Text = languageShared.GetString("CommandUserReport");
                    }
                    else if (objectType == Helper.GetObjectTypeNumericID("Community"))
                    {
                        txtSubject.Text = languageShared.GetString("CommandCommunityReport");
                    }
                    else if (objectType.HasValue)
                    {
                        txtSubject.Text = string.Format(languageShared.GetString("CommandObjectReport"), Helper.GetObjectName(objectType.Value, true));
                    }
                    else
                    {
                        txtSubject.Text = languageShared.GetString("CommandPageReport");
                    }
                    txtSubject.ReadOnly = true;
                }
                else if (messageType.ToLower() == "pbs" && objectId.HasValue)
                {
                    DataObjectPinboardSearch pinboardSearch = DataObject.Load <DataObjectPinboardSearch>(objectId);
                    if (pinboardSearch.State != ObjectState.Added)
                    {
                        txtSubject.Text     = language.GetString("TextPinboardSearch") + " '" + pinboardSearch.Title + "'";
                        txtSubject.ReadOnly = true;
                    }
                }
                else if (messageType.ToLower() == "pbo" && objectId.HasValue)
                {
                    DataObjectPinboardOffer pinboardOffer = DataObject.Load <DataObjectPinboardOffer>(objectId);
                    if (pinboardOffer.State != ObjectState.Added)
                    {
                        txtSubject.Text     = language.GetString("TextPinboardOffer") + " '" + pinboardOffer.Title + "'";
                        txtSubject.ReadOnly = true;
                    }
                }
                if (receiverType.ToLower() == "member" && objectId.HasValue)
                {
                    bool isOwner  = false;
                    bool isMember = false;
                    if (UserProfile.Current.UserId != Guid.Empty)
                    {
                        isOwner = Community.GetIsUserOwner(UserProfile.Current.UserId, objectId.Value, out isMember);
                    }
                    if (!isOwner)
                    {
                        receiverType = string.Empty;
                    }
                }


                if (messageMode.ToLower() == "reply")
                {
                    DataAccess.Business.Message message = DataAccess.Business.Message.LoadMessage(new Guid(messageId), _4screen.CSB.Common.SiteConfig.GetSiteContext(UserProfile.Current));
                    if (Regex.IsMatch(message.Subject, "^Re.*?:"))
                    {
                        Match match = Regex.Match(message.Subject, @"^Re\[(\d*?)\]:");
                        if (match.Groups.Count == 2) // Other replies
                        {
                            int replyNumber;
                            int.TryParse(match.Groups[1].ToString(), out replyNumber);
                            replyNumber++;
                            txtSubject.Text = Regex.Replace(message.Subject, @"^Re\[\d*?\]:", "Re[" + replyNumber + "]:");
                        }
                        else // Second reply
                        {
                            txtSubject.Text = Regex.Replace(message.Subject, @"^Re:", "Re[2]:");
                        }
                    }
                    else // First reply
                    {
                        txtSubject.Text = "Re: " + message.Subject;
                    }
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "SetTitle", "GetRadWindow().SetTitle('" + language.GetString("LableMessageAnswer").StripForScript() + "');", true);
                    DataObjectUser doUser = DataObject.Load <DataObjectUser>(message.FromUserID);
                    if (!message.MsgText.StartsWith("<i>"))
                    {
                        message.MsgText = string.Format("<i>{0}</i>", message.MsgText);
                    }
                    txtBody.Content = string.Format("<br/><i><b>{0} {1}: </i></b><br>{2}", doUser.Nickname, language.GetString("LableMessageWrote"), message.MsgText);
                }
                else if (messageMode.ToLower() == "forward")
                {
                    DataAccess.Business.Message message = DataAccess.Business.Message.LoadMessage(new Guid(messageId), _4screen.CSB.Common.SiteConfig.GetSiteContext(UserProfile.Current));
                    txtSubject.Text = "Fw: " + message.Subject.Replace("Fw: ", string.Empty);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "SetTitle", "GetRadWindow().SetTitle('" + language.GetString("LableMessageForward").StripForScript() + "');", true);
                    DataObjectUser doUser = DataObject.Load <DataObjectUser>(message.FromUserID);
                    if (!message.MsgText.StartsWith("<i>"))
                    {
                        message.MsgText = string.Format("<i>{0}</i>", message.MsgText);
                    }
                    txtBody.Content = string.Format("<br/><i><b>{0} {1}: </i></b><br>{2}", doUser.Nickname, language.GetString("LableMessageWrote"), message.MsgText);
                }
            }
        }