/// <summary> /// B2B call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void BackToBackCallEstablishCompleted(IAsyncResult asyncResult) { var b2bCall = asyncResult.AsyncState as BackToBackCall; Debug.Assert(null != b2bCall, "Async state is null"); Exception exceptionCaught = null; bool exceptionEncountered = true; try { b2bCall.EndEstablish(asyncResult); //If the call establishment is successful, stamp the b2b call in the web conversation. this.WebConversation.BackToBackCall = b2bCall; exceptionEncountered = false; } catch (RealTimeException rte) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte)); exceptionCaught = rte; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } else { AudioVideoCallContext avCallContext = b2bCall.Call1.ApplicationContext as AudioVideoCallContext; Debug.Assert(null != avCallContext, "Av call context is null"); Debug.Assert(null != avCallContext.WebAvcall, "Av call in av call context is null"); EstablishAudioVideoCallResponse response = new EstablishAudioVideoCallResponse(m_establishAvCallRequest, avCallContext.WebAvcall); this.CompleteEstablishOperationSuccessfully(response); } } }
/// <inheritdoc /> public bool Execute() { try { if (!Directory.Exists(DestinationFolder)) { Directory.CreateDirectory(DestinationFolder); } AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomain_ReflectionOnlyAssemblyResolve; LoadDependentAssemblies(SourceAssemblyPath, GetIgnoreFiles()); //load target assembly var assembly = Assembly.ReflectionOnlyLoadFrom(SourceAssemblyPath); var types = GetTypesWithSqlTypeAttribute(assembly); var headerText = GetHeaderText(); foreach (var type in types) { var generatedType = SqlGenerator.GenerateUserType(type.UserType, type.SqlUserTypeAttributeData); var generatedSql = BuildSqlText(generatedType); var targetFile = Path.ChangeExtension(Path.Combine(DestinationFolder, GetSafeFilename(generatedType.TypeName)), "sql"); File.WriteAllText(targetFile, headerText + generatedSql, Encoding.UTF8); } return(true); } catch (ReflectionTypeLoadException exc) { var msg = FaultHelper.GetMessage(exc); BuildEngine.LogErrorEvent(FaultHelper.CreateErrorEvent(FaultHelper.AssemblyLoadError, SourceAssemblyPath, msg)); } catch (Exception exc) { var msg = FaultHelper.GetMessageCore(exc); BuildEngine.LogErrorEvent(FaultHelper.CreateErrorEvent(FaultHelper.GeneralError, SourceAssemblyPath, msg)); } return(false); }
/// <summary> /// Establishes av call directly to the destination. /// </summary> private void EstablishAvCallDirectly() { bool exceptionEncountered = true; Exception exceptionCaught = null; try { CallEstablishOptions establishOptions = new CallEstablishOptions(); //Add custom MIME parts based on conversation context. if (m_cutomMimePart != null) { establishOptions.CustomMimeParts.Add(m_cutomMimePart); } //Construct the destination uri, if needed. m_avCall.BeginEstablish(m_destinationUri, establishOptions, this.AudioVideoCallEstablishCompleted, null /*state*/); exceptionEncountered = false; } catch (ArgumentException ae) { Helper.Logger.Error("Exception = {0}", EventLogger.ToString(ae)); exceptionCaught = ae; } catch (InvalidOperationException ioe) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe)); exceptionCaught = ioe; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Overridden process method. /// </summary> public override void Process() { bool exceptionEncountered = true; try { //First terminate all calls and then terminate the conversation. this.TerminateInstantMessagingCall(); exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteTerminateConversationOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Overridden process method. /// </summary> public override void Process() { bool exceptionEncountered = true; try { this.EstablishClickToCall(); exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Overridden process method. /// </summary> public override void Process() { bool exceptionEncountered = true; try { //If callback number is not specified then establish audio call directly to the destination. this.EstablishAvCallDirectly(); exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Im call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void InstantMessagingCallEstablishCompleted(IAsyncResult asyncResult) { Exception exceptionCaught = null; bool exceptionEncountered = true; try { m_imCall.EndEstablish(asyncResult); exceptionEncountered = false; } catch (RealTimeException rte) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte)); exceptionCaught = rte; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } else { InstantMessagingCallContext imCallContext = m_imCall.ApplicationContext as InstantMessagingCallContext; Debug.Assert(null != imCallContext, "Im call context is null"); Debug.Assert(null != imCallContext.WebImcall, "Im call in Imcall context is null"); //Stamp im call. m_webConversation.WebImCall = imCallContext.WebImcall; EstablishInstantMessagingCallResponse response = new EstablishInstantMessagingCallResponse(m_establishImCallRequest, imCallContext.WebImcall); this.CompleteEstablishOperationSuccessfully(response); } } }
/// <summary> /// Callback Av call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void CallbackAudioVideoCallEstablishCompleted(IAsyncResult asyncResult) { Exception exceptionCaught = null; bool exceptionEncountered = true; try { m_callbackCall.EndEstablish(asyncResult); //If establish operation succeeds immediately trigger a self transfer. m_callbackCall.BeginTransfer(m_callbackCall, null /*transferOptions*/, this.SelfTransferCompleted, null /*asyncState*/); exceptionEncountered = false; } catch (InvalidOperationException ioe) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe)); exceptionCaught = ioe; } catch (RealTimeException rte) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte)); exceptionCaught = rte; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Establish call by first calling the phone number and then doing self transfer and then back to backing with the destination. /// </summary> private void EstablishClickToCall() { bool exceptionEncountered = true; Exception exceptionCaught = null; try { string callbackPhoneUri = Helper.GetCallbackPhoneUri(m_establishAvCallRequest.CallbackPhoneNumber); m_callbackCall.BeginEstablish(callbackPhoneUri, null /*establishOptions*/, this.CallbackAudioVideoCallEstablishCompleted, null /*state*/); exceptionEncountered = false; } catch (ArgumentException ae) { Helper.Logger.Error("Exception = {0}", EventLogger.ToString(ae)); exceptionCaught = ae; } catch (InvalidOperationException ioe) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe)); exceptionCaught = ioe; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Conversation terminated callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void ConversationTerminated(IAsyncResult asyncResult) { bool exceptionEncountered = true; try { Conversation conv = asyncResult.AsyncState as Conversation; conv.EndTerminate(asyncResult); //Invoke all done. this.TerminationWorkCompleted(); exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteTerminateConversationOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Av call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void AudioVideoCallTerminated(IAsyncResult asyncResult) { bool exceptionEncountered = true; try { AudioVideoCall avCall = asyncResult.AsyncState as AudioVideoCall; avCall.EndTerminate(asyncResult); //Now try to terminate b2bcall. this.TerminateBackToBackCall(); exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteTerminateConversationOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
private void LoadDependentAssemblies(string sourceAssemblyPath, HashSet <string> ignoredFiles) { //load all assemblies in project output folder to reflection-only context var directoryName = Path.GetDirectoryName(sourceAssemblyPath); var files = Directory.GetFiles(directoryName) .Where(f => StringHelper.IsEqualStrings(Path.GetExtension(f), ".dll")) .Where(x => !ignoredFiles.Contains(Path.GetFileName(x))); foreach (var file in files) { try { Assembly.ReflectionOnlyLoadFrom(file); } // ignore native dll loading errors catch (BadImageFormatException exc) { var msg = FaultHelper.GetMessageCore(exc); BuildEngine.LogErrorEvent(FaultHelper.CreateErrorEvent(FaultHelper.AssemblyLoadError, file, msg)); } } }
/// <summary> /// Im call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void InstantMessagingSendMessageCompleted(IAsyncResult asyncResult) { Exception exceptionCaught = null; bool exceptionEncountered = true; try { m_imFlow.EndSendInstantMessage(asyncResult); exceptionEncountered = false; } catch (RealTimeException rte) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte)); exceptionCaught = rte; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteSendMessageOperationWithException(new FaultException <OperationFault>(operationFault)); } else { SendInstantMessageResponse response = new SendInstantMessageResponse(m_sendImMessageRequest); this.CompleteSendMessageOperationSuccessfully(response); } } }