private void SendMail() { Setup(); var credentials = new NetworkCredential(mySenGridData.UserName, mySenGridData.Pswd); // Create the email object first, then add the properties. SendGridMessage myMessage = new SendGridMessage(); myMessage.AddTo(mySenGridData.To); myMessage.From = new MailAddress(mySenGridData.FromMail, mySenGridData.FromName); myMessage.Subject = string.Format("Butler Media Process {0} inctance {1}",myRequest.ProcessTypeId,myRequest.ProcessInstanceId); _MediaServiceContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey); IAsset x = _MediaServiceContext.Assets.Where(xx => xx.Id == myRequest.AssetId).FirstOrDefault(); AssetInfo ai = new AssetInfo(x); StringBuilder AssetInfoResume = ai.GetStatsTxt(); AssetInfoResume.AppendLine(""); AssetInfoResume.AppendLine("Media Butler Process LOG " + DateTime.Now.ToString()); foreach (string txt in myRequest.Log) { AssetInfoResume.AppendLine(txt); } AssetInfoResume.AppendLine("-----------------------------"); myMessage.Html = AssetInfoResume.Replace(" ", " ").Replace(Environment.NewLine, "<br />").ToString(); var transportWeb = new Web(credentials); transportWeb.Deliver(myMessage); }
private void SendMessage() { string qName = MediaButler.Common.Configuration.ButlerSuccessQueue; CloudStorageAccount storageAccount = CloudStorageAccount.Parse(myRequest.ProcessConfigConn); CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); //TODO: queue info CloudQueue queue = queueClient.GetQueueReference(qName); MediaButler.Common.ButlerResponse myButlerResponse = new Common.ButlerResponse(); myButlerResponse.MezzanineFiles = myRequest.ButlerRequest.MezzanineFiles; //Add to Mezzamine Files the control File URL if it exist //Becouse it is needed to move/delete the control file from processing to succes or fail if (!string.IsNullOrEmpty(myRequest.ButlerRequest.ControlFileUri)) { myButlerResponse.MezzanineFiles.Add(myRequest.ButlerRequest.ControlFileUri); } myButlerResponse.TimeStampProcessingCompleted = DateTime.Now.ToString(); myButlerResponse.TimeStampProcessingStarted = myRequest.TimeStampProcessingStarted.ToString(); myButlerResponse.WorkflowName = myRequest.ProcessTypeId; myButlerResponse.MessageId = myRequest.ButlerRequest.MessageId; myButlerResponse.TimeStampRequestSubmitted = myRequest.ButlerRequest.TimeStampUTC; myButlerResponse.StorageConnectionString = myRequest.ButlerRequest.StorageConnectionString; CloudMediaContext _MediaServiceContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey); IAsset x = _MediaServiceContext.Assets.Where(xx => xx.Id == myRequest.AssetId).FirstOrDefault(); AssetInfo ai = new AssetInfo(x); StringBuilder AssetInfoResume = ai.GetStatsTxt(); AssetInfoResume.AppendLine(""); AssetInfoResume.AppendLine("Media Butler Process LOG " + DateTime.Now.ToString()); foreach (string txt in myRequest.Log) { AssetInfoResume.AppendLine(txt); } AssetInfoResume.AppendLine("-----------------------------"); myButlerResponse.Log = AssetInfoResume.ToString(); CloudQueueMessage responseMessae = new CloudQueueMessage(Newtonsoft.Json.JsonConvert.SerializeObject(myButlerResponse)); queue.AddMessage(responseMessae); Trace.TraceInformation("Return Butler Message sent to queue"); }
private string GetStringMessage() { IAsset x = _MediaServiceContext.Assets.Where(xx => xx.Id == myRequest.AssetId).FirstOrDefault(); AssetInfo ai = new AssetInfo(x); StringBuilder xxx = ai.GetStatsTxt(); xxx.AppendLine(""); xxx.AppendLine("Media Butler Process LOG " + DateTime.Now.ToString()); foreach (string txt in myRequest.Log) { xxx.AppendLine(txt); } xxx.AppendLine("-----------------------------"); return xxx.ToString(); }