public void OnResolverError( string message, HotChocolateRequest request, IEnumerable <HotChocolateError> errors) { if (IsEnabled()) { AttachmentId attachmentId = AttachmentId.NewId(); IAttachment requestAttachment = AttachmentFactory .Create <HotChocolateRequestAttachment, HotChocolateRequest>( attachmentId, nameof(request), request); HotChocolateErrorsAttachment errorAttachments = AttachmentFactory .Create <HotChocolateErrorsAttachment, IEnumerable <HotChocolateError> >( attachmentId, nameof(errors), errors); AttachmentDispatcher.Instance.Dispatch( errorAttachments, requestAttachment); OnResolverError( Application.Id, ActivityStack.Id, attachmentId, message); } }
public void Dispatch_HttpRequest_BodyEmpty() { // arrange int callCount = 0; AttachmentId id = AttachmentId.NewId(); Mock <ITelemetryAttachmentTransmitter> transmitter = new Mock <ITelemetryAttachmentTransmitter>(); transmitter .Setup(t => t.Enqueue(It.IsAny <AttachmentDescriptor>())) .Callback((AttachmentDescriptor d) => { if (d.Id == id) { Interlocked.Increment(ref callCount); } }); HashSet <ITelemetryAttachmentTransmitter> transmitters = new HashSet <ITelemetryAttachmentTransmitter> { transmitter.Object }; AttachmentDispatcher dispatcher = new AttachmentDispatcher(transmitters); string payloadName = "Name-4141"; HttpRequest payloadValue = new HttpRequest(); // act Action verify = () => dispatcher.Dispatch(id, payloadName, payloadValue); // assert Assert.Null(Record.Exception(verify)); Assert.Equal(1, callCount); }
public async Task Dispatch_Stream_Success() { using (MemoryStream payloadValue = new MemoryStream()) using (StreamWriter writer = new StreamWriter(payloadValue)) { // arrange ObjectAttachment attachment = null; AttachmentId correlationId = AttachmentId.NewId(); string payloadName = "Name-919"; await writer.WriteAsync("Value-919"); await writer.FlushAsync(); // act Action verify = () => attachment = AttachmentFactory .Create <ObjectAttachment>(correlationId, payloadName, payloadValue); // assert Assert.Null(Record.Exception(verify)); Assert.NotNull(attachment); Assert.IsType <ObjectAttachment>(attachment); Assert.Equal("\"Value-919\"", Encoding.UTF8.GetString(attachment.Value)); } }
private void MarkInlineAttachment(string srcValue) { string contentId = HtmlUpdateBodyCallback.GetContentId(srcValue); if (contentId == null) { ExTraceGlobals.CommonAlgorithmTracer.TraceDebug <string>((long)this.GetHashCode(), "HtmlUpdateBodyCallback.MarkInlineAttachment. Content ID is empty for {0}", srcValue); return; } AttachmentId attachmentId = this.FindAttachmentId(contentId); if (attachmentId == null) { ExTraceGlobals.CommonAlgorithmTracer.TraceDebug <string>((long)this.GetHashCode(), "HtmlUpdateBodyCallback.MarkInlineAttachment. Attachment ID not found for {0}", srcValue); return; } AttachmentLink attachmentLink = base.FindAttachmentByIdOrContentId(attachmentId, contentId); if (attachmentLink == null) { ExTraceGlobals.CommonAlgorithmTracer.TraceDebug <string>((long)this.GetHashCode(), "HtmlUpdateBodyCallback.MarkInlineAttachment. No attachment link found for {0}", srcValue); return; } attachmentLink.MarkInline(true); }
public InlineAttachmentInfo(AttachmentId id, string contentId, int renderingPosition, bool isInline) { this.Id = id; this.ContentId = contentId; this.RenderingPosition = new int?(renderingPosition); this.IsInline = new bool?(isInline); }
// Token: 0x06000433 RID: 1075 RVA: 0x00023EB8 File Offset: 0x000220B8 private void RemoveAttachments() { char[] separator = ",".ToCharArray(); ArrayList arrayList = new ArrayList(); string[] array = base.Request.Form["dLst"].Split(separator); int num = array.Length; for (int i = 0; i < num; i++) { AttachmentId attachmentId = AttachmentId.Deserialize(array[i]); if (base.Item.AttachmentCollection.Contains(attachmentId)) { arrayList.Add(attachmentId); } } if (arrayList.Count > 0) { AttachmentUtility.RemoveAttachment(base.Item, arrayList); base.Item.Save(SaveMode.ResolveConflicts); if (Globals.ArePerfCountersEnabled) { OwaSingleCounters.ItemsUpdated.Increment(); } } base.Item.Load(); this.changeKeyString = base.Item.Id.ChangeKeyAsBase64String(); }
public void Initialize_Success() { // arrange var transmitterMock = new Mock <ITelemetryAttachmentTransmitter>(); transmitterMock.Setup(t => t.Enqueue(It.IsAny <AttachmentDescriptor>())); var transmitter = transmitterMock.Object; var transmitters = new[] { transmitter }; var initializer = new AttachmentTransmissionInitializer(transmitters); // act initializer.Initialize(); // assert var attachment = new ExceptionAttachment { Id = AttachmentId.NewId(), Name = "Foo", Value = new byte[] { 1, 2, 3 } }; AttachmentDispatcher.Instance.Dispatch(attachment); transmitterMock.Verify( t => t.Enqueue(It.IsAny <AttachmentDescriptor>()), Times.Once()); AttachmentDispatcher.Instance.Detach(transmitter); }
public virtual string ToStringId(AttachmentId attachementId) { return(IdConverter.GetHierarchicalAttachmentStringId(new List <AttachmentId> { attachementId })); }
// Token: 0x0600150A RID: 5386 RVA: 0x0004ABF4 File Offset: 0x00048DF4 private static AttachmentIdType[] ConvertAttachmentIdsToAttachmentIdTypes(string[] attachmentIds, Item item, PolicyTipRequestLogger policyTipRequestLogger) { if (attachmentIds == null || attachmentIds.Length == 0) { return(null); } List <AttachmentIdType> list = new List <AttachmentIdType>(); foreach (string text in attachmentIds) { AttachmentId item2 = null; try { item2 = AttachmentId.Deserialize(text); } catch (CorruptDataException) { policyTipRequestLogger.AppendData("InvalidAttachment", text); } AttachmentIdType item3 = new AttachmentIdType(new IdAndSession(item.Id, item.Session, new List <AttachmentId> { item2 }).GetConcatenatedId().Id); list.Add(item3); } return(list.ToArray()); }
public override int GetHashCode() { int hashCode = 13; hashCode = (hashCode * 7) + RequisitionId.GetHashCode(); hashCode = (hashCode * 7) + AttachmentId.GetHashCode(); return(hashCode); }
public void NewId_Success() { // act AttachmentId id = AttachmentId.NewId(); // assert Assert.NotEqual(AttachmentId.Empty, id); }
public void NewId_Unique() { // act AttachmentId id = AttachmentId.NewId(); // assert Assert.NotEqual(AttachmentId.NewId(), id); }
public void Start(Guid activityId, HttpRequest request) { if (IsEnabled()) { AttachmentId id = AttachmentId.NewId(); Start(Application.Id, activityId, request.Method, request.Uri, id); AttachmentDispatcher.Instance.Dispatch(id, nameof(request), request); } }
private bool ValidateParameters(CodeActivityContext executionContext) { Boolean Logging = EnableLogging.Get(executionContext); string LogFilePath = LogFile.Get(executionContext); EntityReference Attachment = AttachmentId.Get(executionContext); string entityName = EntityName.Get(executionContext); string recordId = RecordId.Get(executionContext); return(true); }
/// <summary> /// CRUD operation for item attachments /// </summary> /// <param name="exchangeService"></param> public static void CreateReadUpdateDeleteItemAttachment(ExchangeService exchangeService) { DateTime startTime = TestHelpers.GetFormattedDateTime(); DateTime endTime = TestHelpers.GetFormattedDateTime(2); string timeZone = "Central European Standard Time"; Message msg = new Message(exchangeService); msg.Subject = "Test item attachment"; ItemAttachment attach = new ItemAttachment() { Name = "Attached message", Item = new Message() { Body = new ItemBody() { ContentType = BodyType.HTML, Content = "Lets meet up" }, ToRecipients = new List <Recipient>() { new Recipient() { EmailAddress = new EmailAddress() { Address = "*****@*****.**" } } } } }; msg.Attachments.Add(attach); msg.Save(WellKnownFolderName.Inbox); AttachmentId attachId = new AttachmentId( msg.Attachments[0].Id, msg.ItemId, AppConfig.MailboxA); Attachment attachment = exchangeService.GetAttachment(attachId); Assert.IsInstanceOfType( attachment, typeof(ItemAttachment)); attachment = exchangeService.GetAttachment(attachId, new ExpandQuery("Microsoft.OutlookServices.ItemAttachment/Item")); ItemAttachment itemAttachment = (ItemAttachment)attachment; Assert.IsNotNull(itemAttachment.Item); Assert.IsInstanceOfType(itemAttachment.Item, typeof(Message)); }
public void Empty() { // arrange string expectedResult = $"{default(DateTime):yyyyMMdd}-{default(Guid):N}"; // act AttachmentId id = AttachmentId.Empty; // assert Assert.Equal(AttachmentId.Empty, id); Assert.Equal(expectedResult, id); }
public void Stop(Guid activityId, HttpResponse response) { if (IsEnabled()) { AttachmentId id = AttachmentId.NewId(); int statusCode = response?.StatusCode ?? 0; Guid userId = response?.UserId ?? Guid.Empty; Stop(Application.Id, activityId, userId, statusCode, statusCode.GetHttpStatusText(), id); AttachmentDispatcher.Instance.Dispatch(id, nameof(response), response); } }
public void InternalServerErrorOccurred(Exception exception) { if (IsEnabled()) { AttachmentId attachmentId = AttachmentId.NewId(); ExceptionAttachment attachment = AttachmentFactory.Create(attachmentId, nameof(exception), exception); AttachmentDispatcher.Instance.Dispatch(attachment); InternalServerErrorOccurred(Application.Id, ActivityStack.Id, attachmentId); } }
public void RetrieveObjectInfo(int id, RequestInformation info) { if (IsEnabled()) { var attachmentId = AttachmentId.NewId(); RetrieveObjectInfo(Application.Id, ActivityStack.Id, attachmentId, id); AttachmentDispatcher.Instance.Dispatch( AttachmentFactory.Create(attachmentId, "info", info) ); } }
public void Start(Guid activityId, HotChocolateRequest request) { if (IsEnabled()) { AttachmentId attachmentId = AttachmentId.NewId(); IAttachment attachment = AttachmentFactory .Create <HotChocolateRequestAttachment, HotChocolateRequest>( attachmentId, nameof(request), request); AttachmentDispatcher.Instance.Dispatch(attachment); Start(Application.Id, activityId, attachmentId); } }
public void Dispatch_HttpResponse_DispatcherNull() { // arrange AttachmentId id = AttachmentId.NewId(); AttachmentDispatcher dispatcher = null; string payloadName = "Name-7272"; HttpResponse payloadValue = new HttpResponse(); // act Action verify = () => dispatcher.Dispatch(id, payloadName, payloadValue); // assert Assert.Null(Record.Exception(verify)); }
public void Dispatch_HttpRequest_IdEmpty() { // arrange AttachmentId id = AttachmentId.Empty; AttachmentDispatcher dispatcher = AttachmentDispatcher.Instance; string payloadName = "Name-6161"; HttpRequest payloadValue = new HttpRequest(); // act Action verify = () => dispatcher.Dispatch(id, payloadName, payloadValue); // assert Assert.Null(Record.Exception(verify)); }
public void Dispatch_HttpRequest_PayloadValueNull() { // arrange AttachmentId id = AttachmentId.NewId(); AttachmentDispatcher dispatcher = AttachmentDispatcher.Instance; string payloadName = "Name-5151"; HttpRequest payloadValue = null; // act Action verify = () => dispatcher.Dispatch(id, payloadName, payloadValue); // assert Assert.Null(Record.Exception(verify)); }
public void TestAttachmentIdProperties() { AttachmentId attachmentId = new AttachmentId( "attachId", new MessageId("itemId", "me"), "me"); Assert.AreEqual( "messages/itemId/attachments/attachId", attachmentId.IdPath); Assert.AreEqual( "attachId", attachmentId.Id); }
protected override void Execute(CodeActivityContext executionContext) { Boolean Logging = EnableLogging.Get(executionContext); string LogFilePath = LogFile.Get(executionContext); EntityReference Attachment = AttachmentId.Get(executionContext); string entityName = EntityName.Get(executionContext); string recordId = RecordId.Get(executionContext); try { if (Logging) { Log("Workflow Execution Start", LogFilePath); } if (ValidateParameters(executionContext)) { // Create a CRM Service in Workflow. IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); if (Logging) { Log("Attaching Attachment", LogFilePath); } // Create an attachment. Entity UpdatedAttachment = new Entity("annotation"); UpdatedAttachment.Id = Attachment.Id; UpdatedAttachment.Attributes.Add("objectid", new EntityReference(entityName, new Guid(recordId))); service.Update(UpdatedAttachment); if (Logging) { Log("Attachment linked successfully", LogFilePath); } if (Logging) { Log("Workflow Executed Successfully", LogFilePath); } } } catch (Exception ex) { Log(ex.Message, LogFilePath); } }
public void Dispatch_Exception_PayloadValueNull() { // arrange ExceptionAttachment attachment = null; AttachmentId correlationId = AttachmentId.NewId(); string payloadName = "Name-567"; Exception payloadValue = null; // act Action verify = () => attachment = AttachmentFactory .Create(correlationId, payloadName, payloadValue); // assert Assert.Null(Record.Exception(verify)); Assert.Null(attachment); }
public void Create_Exception_PayloadNameNull() { // arrange ExceptionAttachment attachment = null; AttachmentId correlationId = AttachmentId.NewId(); string payloadName = null; Exception payloadValue = new ArgumentNullException("Value-426"); // act Action verify = () => attachment = AttachmentFactory .Create(correlationId, payloadName, payloadValue); // assert Assert.Null(Record.Exception(verify)); Assert.Null(attachment); }
public void Create_Object_CorrelationIdNull() { // arrange ObjectAttachment attachment = null; AttachmentId correlationId = AttachmentId.Empty; string payloadName = "Name-627"; object payloadValue = "Value-627"; // act Action verify = () => attachment = AttachmentFactory .Create(correlationId, payloadName, payloadValue); // assert Assert.Null(Record.Exception(verify)); Assert.Null(attachment); }
private AttachmentId FindAttachmentId(string contentId) { AttachmentId result = null; foreach (AttachmentHandle handle in this.item.AttachmentCollection) { using (Attachment attachment = this.item.AttachmentCollection.Open(handle)) { if (attachment.ContentId.Equals(contentId, StringComparison.OrdinalIgnoreCase)) { result = attachment.Id; } } } return(result); }
public void OnQueryError(Exception exception) { if (IsEnabled()) { AttachmentId attachmentId = AttachmentId.NewId(); ExceptionAttachment attachment = AttachmentFactory .Create(attachmentId, nameof(exception), exception); AttachmentDispatcher.Instance.Dispatch(attachment); OnQueryError( Application.Id, ActivityStack.Id, attachmentId, exception.Message); } }