Пример #1
0
        private void WriteToAzureTable(BrokeredMessage message)
        {
            try
            {
                EventPoint.Common.EventMessage eventMsg = message.GetBody <EventPoint.Common.EventMessage>();
                //var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
                EventMessageDataSource ds = new EventMessageDataSource();

                EventPoint.Data.EventMessage dataMsg = new EventPoint.Data.EventMessage();
                dataMsg.ID = new Random().Next(10000000);
                // assign a RowKey that will show entries in reverse chronological order, with the Event.ID tacked on
                dataMsg.RowKey = string.Format("{0:10}_{1}", DateTime.MaxValue.Ticks - DateTime.Now.Ticks, dataMsg.ID);

                // convert format
                dataMsg.Link       = eventMsg.Link;
                dataMsg.Message    = eventMsg.Message;
                dataMsg.Originator = eventMsg.Originator;
                dataMsg.Priority   = eventMsg.Priority;
                dataMsg.Title      = eventMsg.Title;

                // add message to table storage
                ds.AddEventMessage(dataMsg);
                message.Complete();
            }
            catch (Exception)
            {
                message.Abandon();
            }
            finally
            {
                message.Dispose();
            }
        }
Пример #2
0
 public void DeleteEventMessage(EventMessage msg)
 {
     context.AttachTo(context.EventMessageTableName, msg, "*");
     context.DeleteObject(msg);
     context.SaveChanges();
 }