Exemplo n.º 1
0
        public bool SpoolMessage(IMail message)
        {
            bool isValid = false;

            try
            {
                StringBuilder bodyBuilder = new StringBuilder(message.TextData.Text);

                foreach (MimeData attachment in message.Attachments)
                {
                    if (!string.IsNullOrEmpty(attachment.FileName) &&
                        ASGFileInfo.IsAsg(attachment.FileName))
                    {
                        isValid = true;

                        string turnLog = TurnLogger.LogTurn(attachment.FileName, message.From[0].Address, message.TextData.Text);

                        bodyBuilder.Append(StringHelper.CrLf);
                        bodyBuilder.Append(turnLog);
                    }
                }

                if (isValid)
                {
                    bodyBuilder.Append(StringHelper.CrLf);
                    bodyBuilder.Append(StringHelper.CrLf);
                    bodyBuilder.Append(string.Format(EMAIL_APPEND_TEXT, ConfigHelper.BuildVersion));

                    message.TextData.Text = bodyBuilder.ToString();

                    message.MessageID = Guid.NewGuid().ToString();

                    _message = message;
                }
                else
                {
                    _message = null;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                Trace.Flush();
            }

            return(isValid);
        }
Exemplo n.º 2
0
        protected int ProcessEmailAttachments(IMail email)
        {
            int count = 0;

            try
            {
                if (email != null &&
                    email.Attachments != null &&
                    email.Attachments.Count > 0)
                {
                    foreach (MimeData attachment in email.Attachments)
                    {
                        if (!string.IsNullOrEmpty(attachment.FileName) &&
                            ASGFileInfo.IsAsg(attachment.FileName))
                        {
                            count++;

                            using (ASGFileInfo theASG = new ASGFileInfo(attachment))
                            {
                                if (theASG.Length > 0)
                                {
                                    _gameManager.StoreDownloadFile(theASG, _saveFolder);

                                    TurnLogger.SaveLog(theASG.FileNameTrue, email.TextData.Text);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                Trace.Flush();
            }

            return(count);
        }