예제 #1
0
        public void ThenTheRequestShouldNotHaveBeenFinishedAtThePointWhenTheExceptionWasReported()
        {
            ExceptionDetail exception = this.GetSingleExceptionDetail();
            OperationDetail operation = this.GetSingleOperationDetail();

            Assert.AreSame(operation, exception.OperationInProgressAtTime);
        }
예제 #2
0
        //启动流程2
        public string Startdefinition2(string url, string formdata, string processName)
        {
            //例如:processName="ProcessShortTruck"
            try
            {
                Console.WriteLine("RestService - Startdefinition2()" + " - " + DateTime.Now.ToString());

                RestClient client = new RestClient();
                //url + "process-definition/key/ProcessShortTruck/start";
                client.EndPoint = string.Format(url + "process-definition/key/{0}/start", processName);
                client.Method   = HttpVerb.POST;
                string plyload = formdata;
                Console.WriteLine("formdata:");
                Console.WriteLine(formdata);
                client.PostData = plyload;
                string json = client.MakeRequest();
                Console.WriteLine(json);

                ProcessMessage process = (ProcessMessage)JsonConvert.DeserializeObject(json, typeof(ProcessMessage));
                Console.WriteLine("id:" + process.id.ToString());
                Console.WriteLine("definitionId:" + process.definitionId.ToString());
                Console.WriteLine("businessKey:" + process.businessKey.ToString());
                Console.WriteLine("ended:" + process.ended.ToString());
                Console.WriteLine("suspended:" + process.suspended.ToString());

                return(process.id);
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee.ToString() + ee.StackTrace);
                ExceptionDetail d = new ExceptionDetail(ee);
                Logger.Trace(ee.ToString());
                throw new FaultException <ExceptionDetail>(d, " RestService Startdefinition异常:" + ee.Message + ee.InnerException);
            }
        }
        //анализ входного исключения и формирование альтернативного сообщения об ошибке
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            //вызывается сразу после того, как происходит исключение
            //клиент будет находиться в состоянии ожидания до тех пор, пока этот метод не закончит свою работу
            //следует остерегаться длительного выполнения ProvideFault()

            //fault = null;//подавление любых ошибок в контракте
            //т.е. клиент не будет знать о неизвестной ошибке на сервисе
            //но данная ошибка вызовет разрушение коммуникационного канала

            //необходимость определять контракт ошибок отсутствует
            ExceptionDetail detail = new ExceptionDetail(error);

            throw new FaultException <ExceptionDetail>(detail, error.Message);

            /* Обработка ошибок сервиса на клиенте
             * try
             * { ... }
             * catch(FaultException<ExceptionDetail> ex)
             *  {
             *    MessageBox.Show(
             *      null,
             *      string.Format("{0}\n{1}\n{2}", ex.Detail.Type, ex.Detail.Message,
             *   ex.Detail.StackTrace),
             *      Application.ProductName,
             *      MessageBoxButtons.OK,
             *      MessageBoxIcon.Error,
             *      MessageBoxDefaultButton.Button1);
             *  }
             */
        }
예제 #4
0
        /// <summary>
        /// Function to delete a DataModelEntity from database.
        /// </summary>
        /// <param name="dataModelEntity">DataModelEntity to delete</param>
        /// <param name="session">User's session identifier.</param>
        /// <returns>null if the DataModelEntity was deleted successfully, the same DataModelEntity otherwise</returns>
        /// <exception cref="ArgumentNullException">
        /// if <paramref name="dataModelEntity"/> is null.
        /// </exception>
        /// <exception cref="UtnEmallBusinessLogicException">
        /// If an UtnEmallDataAccessException occurs in DataModel.
        /// </exception>
        public DataModelEntity Delete(DataModelEntity dataModelEntity, string session)
        {
            bool permited = ValidationService.Instance.ValidatePermission(session, "delete", "DataModel");

            if (!permited)
            {
                ExceptionDetail detail = new ExceptionDetail(new UtnEmall.Server.BusinessLogic.UtnEmallPermissionException("The user hasn't permissions to delete an entity"));
                throw new FaultException <ExceptionDetail>(detail);
            }

            if (dataModelEntity == null)
            {
                throw new ArgumentException("The argument can not be null or be empty");
            }
            try
            {
                // Check that the service is not deployed
                if (dataModelEntity.Deployed)
                {
                    dataModelEntity.Errors.Add(new Error("DataModel Deployed", "", "The data model is already deployed. Can not be deleted."));
                    return(dataModelEntity);
                }
                // Delete dataModelEntity using data access object

                datamodelDataAccess.Delete(dataModelEntity);
                return(null);
            }
            catch (UtnEmallDataAccessException utnEmallDataAccessException)
            {
                throw new UtnEmall.Server.BusinessLogic.UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException);
            }
        }
예제 #5
0
        public JsonResult ThrowJsonError(String message, Exception ex)
        {
            bool logged        = false;
            Type exceptionType = ex.GetType();

            if (exceptionType.IsGenericType && exceptionType.GetGenericTypeDefinition() == typeof(FaultException <>))
            {
                PropertyInfo    prop   = exceptionType.GetProperty("Detail");
                ExceptionDetail detail = (ExceptionDetail)prop.GetValue(ex, null);
                if (detail.Type == (typeof(BusinessException)).UnderlyingSystemType.FullName)
                {
                    if (!string.IsNullOrEmpty(detail.Message))
                    {
                        logged = true;
                        logWriter.WriteErrorLog(ex, SessaoUtil.UsuarioLogin);
                        message = detail.Message;
                    }
                }
            }

            if (!logged)
            {
                logWriter.WriteErrorLog(new Exception(message, ex), SessaoUtil.UsuarioLogin);
            }

            return(Json(new { Erro = true, Message = message }, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        public static void AddErrorLogs(Exception exception, ILogger logger, string message = "")
        {
            ExceptionDetail exceptionDetail = new ExceptionDetail();

            if (!string.IsNullOrEmpty(message))
            {
                exceptionDetail.Message = message;
            }

            exceptionDetail.Source     = exception.Source;
            exceptionDetail.StackTrace = exception.StackTrace;

            if (exception.InnerException != null)
            {
                exceptionDetail.InnerException = exception.InnerException.ToString();
            }

            if (exception.HelpLink != null)
            {
                exceptionDetail.HelpLink = exception.HelpLink;
            }

            var requestClass  = exception.TargetSite != null ? exception.TargetSite.ReflectedType.FullName : null;
            var requestMethod = exception.TargetSite != null ? exception.TargetSite.Name : null;
            var timeUtc       = DateTime.Now;

            exceptionDetail.RequestClass  = requestClass;
            exceptionDetail.RequestMethod = requestMethod;
            exceptionDetail.TimeUtc       = timeUtc.ToString();

            logger.LogError("API Exception Logs :" + JsonConvert.SerializeObject(exceptionDetail));
        }
예제 #7
0
        AggregateException ExtractException(ExceptionDetail detail)
        {
            AggregateException innerException = null;

            if (detail.InnerException != null)
            {
                innerException = ExtractException(detail.InnerException);
            }

            AggregateException exception = null;

            if (innerException is AggregateException)
            {
                exception = innerException;
            }
            else
            {
                Type            type       = FindExceptionType(detail.Type);
                Type[]          parameters = { typeof(string), typeof(Exception) };
                ConstructorInfo info       = type.GetConstructor(parameters);
                Debug.Assert(info != null, "Exception type " + detail.Type + " does not have suitable constructor");

                Exception temp       = Activator.CreateInstance(type, detail.Message, innerException) as Exception;
                FieldInfo stackTrace = typeof(Exception).GetField("_stackTraceString", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                if (stackTrace != null)
                {
                    stackTrace.SetValue(temp, detail.StackTrace);
                }

                exception = new AggregateException(temp);
                Debug.Assert(exception != null);
            }
            return(exception);
        }
예제 #8
0
        /// <summary>
        /// 根据字典得到这个进程的任务
        /// </summary>
        /// <param name="url"></param>
        /// <param name="requrl"></param>
        /// <returns></returns>
        public BPMTask[] GetGateTaskUrl(string url, string requrl)
        {
            //例如:processDefinitionName="短驳运输流程",name="异常原因"
            try
            {
                Console.WriteLine("RestService - GetGateTaskUrl()" + " - " + DateTime.Now.ToString());
                Console.WriteLine("url:" + url);
                Console.WriteLine("requrl:" + requrl);
                //
                var client = new RestClient();
                client.EndPoint = url + "task";
                client.Method   = HttpVerb.GET;

                var json = client.MakeRequest(requrl);
                //Console.WriteLine("tasks json:" + json.ToString());
                BPMTask[] tasks = (BPMTask[])JsonConvert.DeserializeObject(json, typeof(BPMTask[]));
                //tasks
                if (tasks.Count() > 0)
                {
                    Console.WriteLine("BPMTask Count:" + tasks.Count());
                    foreach (BPMTask task in tasks)
                    {
                        Console.WriteLine(string.Format("taskid:{0},name:{1},des:{2}", task.id, task.name, task.description));
                    }
                }
                return(tasks);
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee.ToString());
                ExceptionDetail d = new ExceptionDetail(ee);
                Logger.Trace(ee.ToString());
                throw new FaultException <ExceptionDetail>(d, " RestService GetGateTask异常:" + ee.Message + ee.InnerException);
            }
        }
예제 #9
0
        Message CreateSimpleFaultMessage(Exception error, MessageVersion version)
        {
            OperationContext ctx = OperationContext.Current;
            // FIXME: support more fault code depending on the exception type.
            FaultCode fc = null;

            if (error is EndpointNotFoundException)
            {
                fc = new FaultCode(
                    "DestinationUnreachable",
                    version.Addressing.Namespace);
            }
            else
            {
                fc = new FaultCode(
                    "FIXME_InternalError",
                    version.Addressing.Namespace);
            }

            // FIXME: set correct fault reason.
            if (ctx.EndpointDispatcher.ChannelDispatcher.IncludeExceptionDetailInFaults)
            {
                ExceptionDetail detail = new ExceptionDetail(error);
                return(Message.CreateMessage(version, fc,
                                             "error occured", detail, ctx.IncomingMessageHeaders != null ? ctx.IncomingMessageHeaders.Action : null));
            }
            return(Message.CreateMessage(version, fc, "error occured", ctx.IncomingMessageHeaders.Action));
        }
예제 #10
0
        /// <summary>
        /// Function to delete a ServiceEntity from database.
        /// </summary>
        /// <param name="serviceEntity">ServiceEntity to delete</param>
        /// <param name="session">User's session identifier.</param>
        /// <returns>null if the ServiceEntity was deleted successfully, the same ServiceEntity otherwise</returns>
        /// <exception cref="ArgumentNullException">
        /// if <paramref name="serviceEntity"/> is null.
        /// </exception>
        /// <exception cref="UtnEmallBusinessLogicException">
        /// If an UtnEmallDataAccessException occurs in DataModel.
        /// </exception>
        public ServiceEntity Delete(ServiceEntity serviceEntity, string session)
        {
            bool permited = ValidationService.Instance.ValidatePermission(session, "delete", "Service");

            if (!permited)
            {
                ExceptionDetail detail = new ExceptionDetail(new UtnEmall.Server.BusinessLogic.UtnEmallPermissionException("The user hasn't permissions to delete an entity"));
                throw new FaultException <ExceptionDetail>(detail);
            }

            if (serviceEntity == null)
            {
                throw new ArgumentException("The argument can not be null or be empty");
            }
            try
            {
                // Delete serviceEntity using data access object
                serviceDataAccess.Delete(serviceEntity);
                return(null);
            }
            catch (UtnEmallDataAccessException utnEmallDataAccessException)
            {
                throw new UtnEmall.Server.BusinessLogic.UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException);
            }
        }
예제 #11
0
        /// <summary>
        /// Function to save a UserEntity to the database.
        /// </summary>
        /// <param name="userEntity">UserEntity to save</param>
        /// <param name="session">User's session identifier.</param>
        /// <returns>null if the UserEntity was saved successfully, the same UserEntity otherwise</returns>
        /// <exception cref="ArgumentNullException">
        /// if <paramref name="userEntity"/> is null.
        /// </exception>
        /// <exception cref="UtnEmallBusinessLogicException">
        /// If an UtnEmallDataAccessException occurs in DataModel.
        /// </exception>
        public UserEntity Save(UserEntity userEntity, string session)
        {
            bool permited = ValidationService.Instance.ValidatePermission(session, "save", "User");

            if (!permited)
            {
                ExceptionDetail detail = new ExceptionDetail(new UtnEmall.Server.BusinessLogic.UtnEmallPermissionException("The user hasn't permissions to save an entity"));
                throw new FaultException <ExceptionDetail>(detail);
            }

            if (!Validate(userEntity))
            {
                return(userEntity);
            }
            try
            {
                // Save userEntity using data access object
                userDataAccess.Save(userEntity);
                return(null);
            }
            catch (UtnEmallDataAccessException utnEmallDataAccessException)
            {
                throw new UtnEmall.Server.BusinessLogic.UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException);
            }
        }
예제 #12
0
 void ICalculationCallback.ErrorOccurred(ExceptionDetail a_Exception)
 {
     if (this.m_OnErrorOccurred != null)
     {
         this.m_OnErrorOccurred(a_Exception);
     }
 }
예제 #13
0
        /// <summary>
        /// Function to delete a CategoryEntity from database.
        /// </summary>
        /// <param name="categoryEntity">CategoryEntity to delete</param>
        /// <param name="session">User's session identifier.</param>
        /// <returns>null if the CategoryEntity was deleted successfully, the same CategoryEntity otherwise</returns>
        /// <exception cref="ArgumentNullException">
        /// if <paramref name="categoryEntity"/> is null.
        /// </exception>
        /// <exception cref="UtnEmallBusinessLogicException">
        /// If an UtnEmallDataAccessException occurs in DataModel.
        /// </exception>
        public CategoryEntity Delete(CategoryEntity categoryEntity, string session)
        {
            bool permited = ValidationService.Instance.ValidatePermission(session, "delete", "Category");

            if (!permited)
            {
                ExceptionDetail detail = new ExceptionDetail(new UtnEmall.Server.BusinessLogic.UtnEmallPermissionException("The user hasn't permissions to delete an entity"));
                throw new FaultException <ExceptionDetail>(detail);
            }

            if (categoryEntity == null)
            {
                throw new ArgumentException("The argument can not be null or be empty");
            }
            try
            {
                // Delete categoryEntity using data access object
                categoryDataAccess.Delete(categoryEntity);
                // Delete related customers' preference

                PreferenceDataAccess preferenceDataAccess = new PreferenceDataAccess();
                foreach (PreferenceEntity preferenceEntity in preferenceDataAccess.LoadWhere(PreferenceEntity.DBIdCategory, categoryEntity.Id, false, OperatorType.Equal))
                {
                    preferenceDataAccess.Delete(preferenceEntity);
                }
                return(null);
            }
            catch (UtnEmallDataAccessException utnEmallDataAccessException)
            {
                throw new UtnEmall.Server.BusinessLogic.UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException);
            }
        }
        void IErrorHandler.ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (error.GetType().IsGenericType&& error is FaultException)
            {
                Debug.Assert(error.GetType().GetGenericTypeDefinition() == typeof(FaultException <>));
                return;
            }

            try
            {
                Type   detailType = null;
                object detail     = null;

                //Always return details. The channel invoker translates them into an exception hierarchy.
                ExceptionDetail newDetail = new ExceptionDetail(error);
                detailType = newDetail.GetType();
                detail     = newDetail;

                Type           faultUnboundedType = typeof(FaultException <>);
                Type           faultBoundedType   = faultUnboundedType.MakeGenericType(detailType);
                FaultException faultException     = (FaultException)Activator.CreateInstance(faultBoundedType, detail, error.Message);
                MessageFault   messageFault       = faultException.CreateMessageFault();
                fault = Message.CreateMessage(version, messageFault, faultException.Action);
            }
            catch
            {}
        }
예제 #15
0
        public RequestReponse ProcessXML([FromBody] string values)
        {
            RequestReponse result = new RequestReponse();

            try
            {
                using (DataSet dsRequest = new DataSet())
                {
                    using (var strReader = new StringReader(values))
                    {
                        dsRequest.ReadXml(strReader);

                        if (dsRequest.Tables.Contains("Shipment") || dsRequest.Tables.Contains("CurrencyExchangeRate"))
                        {
                            OrderController orderController = new OrderController();
                            result = orderController.Post(values);
                        }
                        else
                        {
                            AccountingController accountingController = new AccountingController();
                            result = accountingController.UpdateInvoicePaymentDetails(values);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success       = false;
                result.Message       = ex.Message;
                result.MessageDetail = ExceptionDetail.GetExceptionFullMessage(ex);
            }

            return(result);
        }
예제 #16
0
        /// <summary>
        /// Function to save a CategoryEntity to the database.
        /// </summary>
        /// <param name="categoryEntity">CategoryEntity to save</param>
        /// <param name="session">User's session identifier.</param>
        /// <returns>null if the CategoryEntity was saved successfully, the same CategoryEntity otherwise</returns>
        /// <exception cref="ArgumentNullException">
        /// if <paramref name="categoryEntity"/> is null.
        /// </exception>
        /// <exception cref="UtnEmallBusinessLogicException">
        /// If an UtnEmallDataAccessException occurs in DataModel.
        /// </exception>
        public CategoryEntity Save(CategoryEntity categoryEntity, string session)
        {
            bool permited = ValidationService.Instance.ValidatePermission(session, "save", "Category");

            if (!permited)
            {
                ExceptionDetail detail = new ExceptionDetail(new UtnEmall.Server.BusinessLogic.UtnEmallPermissionException("The user hasn't permissions to save an entity"));
                throw new FaultException <ExceptionDetail>(detail);
            }

            if (!Validate(categoryEntity))
            {
                return(categoryEntity);
            }
            try
            {
                if (categoryEntity.IsNew)
                {
                    categoryDataAccess.Save(categoryEntity);
                    UtnEmall.Server.BusinessLogic.PreferenceDecorator.AddNewPreferencesDueToNewCategory(categoryEntity);
                }
                else
                {
                    categoryDataAccess.Save(categoryEntity);
                }
                return(null);
            }
            catch (UtnEmallDataAccessException utnEmallDataAccessException)
            {
                throw new UtnEmall.Server.BusinessLogic.UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException);
            }
        }
            private void ThrowIfFaultMessage(Message wcfMessage)
            {
                Exception exception;

                if (wcfMessage.IsFault)
                {
                    MessagingClientEtwProvider.TraceClient(() => {
                    });
                    string         action       = wcfMessage.Headers.Action;
                    MessageFault   messageFault = MessageFault.CreateFault(wcfMessage, 65536);
                    FaultConverter property     = this.innerChannel.GetProperty <FaultConverter>();
                    if (property == null || !property.TryCreateException(wcfMessage, messageFault, out exception))
                    {
                        if (!messageFault.HasDetail)
                        {
                            throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsWarning(new FaultException(messageFault, action), null);
                        }
                        ExceptionDetail detail = messageFault.GetDetail <ExceptionDetail>();
                        if (!this.clientMode && string.Equals(detail.Type, typeof(CommunicationException).FullName, StringComparison.Ordinal))
                        {
                            MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteRuntimeChannelFaulting(this.innerChannel.GetType().Name, this.innerChannel.LocalAddress.Uri.AbsoluteUri, this.innerChannel.RemoteAddress.Uri.AbsoluteUri, this.innerChannel.Via.AbsoluteUri, this.innerChannel.Session.Id, string.Concat("ThrowIfFaultMessage: Received CommunicationException as fault message. ", detail.ToString())));
                            base.Fault();
                        }
                        if (!this.includeExceptionDetails)
                        {
                            throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsInformation(new FaultException <ExceptionDetailNoStackTrace>(new ExceptionDetailNoStackTrace(detail, true), messageFault.Reason, messageFault.Code, action), null);
                        }
                        throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsInformation(new FaultException <ExceptionDetail>(detail, messageFault.Reason, messageFault.Code, action), null);
                    }
                    throw Fx.Exception.AsWarning(exception, null);
                }
            }
        public DepartmentAllWrapper GetDepartmentAllWrapper()
        {
            try
            {
                DepartmentAllWrapper returnWrapper = null;
                IDepartmentManager   con           = this.ForwardRequestToDepartmentManager;
                returnWrapper = con.GetDepartmentAllWrapper();

                /* start temp code */
                if (null != returnWrapper)
                {
                    if (null != returnWrapper.Departments)
                    {
                        returnWrapper.Departments.Add(new Department()
                        {
                            DepartmentUUID = Guid.NewGuid(), DepartmentName = "DepartmentCreatedViaWcfBusinessServiceTemp", CreateDate = new DateTime(2002, 2, 2), TheVersionProperty = new byte[8] {
                                0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
                            }
                        });
                    }
                }

                /* end temp code */

                return(returnWrapper);
            }
            catch (Exception ex)
            {
                ExceptionDetail detail = new ExceptionDetail(ex);
                throw new FaultException <ExceptionDetail>(detail, ex.Message);
            }
        }
예제 #19
0
        /// <summary>
        /// Function to save a ServiceEntity to the database.
        /// </summary>
        /// <param name="serviceEntity">ServiceEntity to save</param>
        /// <param name="session">User's session identifier.</param>
        /// <returns>null if the ServiceEntity was saved successfully, the same ServiceEntity otherwise</returns>
        /// <exception cref="ArgumentNullException">
        /// if <paramref name="serviceEntity"/> is null.
        /// </exception>
        /// <exception cref="UtnEmallBusinessLogicException">
        /// If an UtnEmallDataAccessException occurs in DataModel.
        /// </exception>
        public ServiceEntity Save(ServiceEntity serviceEntity, string session)
        {
            bool permited = ValidationService.Instance.ValidatePermission(session, "save", "Service");

            if (!permited)
            {
                ExceptionDetail detail = new ExceptionDetail(new UtnEmall.Server.BusinessLogic.UtnEmallPermissionException("The user hasn't permissions to save an entity"));
                throw new FaultException <ExceptionDetail>(detail);
            }

            if (!Validate(serviceEntity))
            {
                return(serviceEntity);
            }
            try
            {
                // Check that the service is not deployed
                if (serviceEntity.Deployed)
                {
                    serviceEntity.Errors.Add(new Error("Service Deployed", "", "The service is already deployed. Can not be saved."));
                    return(serviceEntity);
                }

                serviceDataAccess.Save(serviceEntity);
                return(null);
            }
            catch (UtnEmallDataAccessException utnEmallDataAccessException)
            {
                throw new UtnEmall.Server.BusinessLogic.UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException);
            }
        }
예제 #20
0
        public void ShouldNotCreateOpportunityResponse()
        {
            const int    opportunityId     = 10000000;
            const string comment           = "Fail Test Comment";
            const int    mockParticipantId = 7777;

            _participantService.Setup(m => m.GetParticipantRecord(It.IsAny <string>()))
            .Returns(new MpParticipant {
                ParticipantId = mockParticipantId
            });

            const string opportunityResponsePageKey = "OpportunityResponses";
            var          exceptionDetail            =
                new ExceptionDetail(new Exception("The creator of this fault did not specify a Reason."));
            var faultException = new FaultException <ExceptionDetail>(exceptionDetail);

            _ministryPlatformService.Setup(
                m =>
                m.CreateRecord(opportunityResponsePageKey,
                               It.IsAny <Dictionary <string, object> >(),
                               It.IsAny <string>(),
                               true))
            .Throws(faultException);

            Assert.Throws <FaultException <ExceptionDetail> >(
                () => _fixture.RespondToOpportunity(It.IsAny <string>(), opportunityId, comment));

            _participantService.Verify(m => m.GetParticipantRecord(It.IsAny <string>()), Times.Once);
            _ministryPlatformService.VerifyAll();
        }
 void ICallbackForProcessWithCallbackService.ErrorOccurred(ExceptionDetail a_Exception)
 {
     if (this.m_OnErrorOccurred != null)
     {
         this.m_OnErrorOccurred(a_Exception);
     }
 }
예제 #22
0
 void ISizeCheckCallback.ErrorOccurred(ExceptionDetail a_Exception)
 {
     if (this.m_OnErrorOccurred != null)
     {
         this.m_OnErrorOccurred(a_Exception);
     }
 }
예제 #23
0
파일: Trade.cs 프로젝트: srowlison/bbiller
        // TO DO: Add this method to SellBitcoins
        private async void GetQuote()
        {
            try
            {
                // Gets a quote for bitcoins - Not a balance.  Bad Method Name - TODO

                FiatAmount = Convert.ToDecimal(txtAmount.Text);

                // TODO: Refresh Service Reference
                //      BitcoinAmount = await client.GetBitcoinAmountAsync(FiatAmount, "AUD");

                Price = BitcoinAmount / FiatAmount;

                txtBitcoins.Text = BitcoinAmount.ToString();

                txtRate.Text = Price.ToString();
            }
            catch (FaultException ex)
            {
                string       msg   = "FaultException: " + ex.Message;
                MessageFault fault = ex.CreateMessageFault();
                if (fault.HasDetail == true)
                {
                    System.Xml.XmlReader reader = fault.GetReaderAtDetailContents();
                    if (reader.Name == "ExceptionDetail")
                    {
                        ExceptionDetail detail = fault.GetDetail <ExceptionDetail>();
                        msg += "\n\nStack Trace: " + detail.StackTrace;
                    }
                }
                MessageBox.Show(msg);
            }
        }
 private bool GenerateBIPToken()
 {
     try
     {
         using (BSW.APIToken.Token t = new BSW.APIToken.Token())
         {
             var result = t.GenerateToken("1", "Landsea-XMLAPIService", 10, "Landsea - XMLAPIService", "");
             if (result.Successful)
             {
                 bipToken = result.UserToken;
             }
             else
             {
                 bipToken = string.Empty;
             }
         }
     }
     catch (Exception ex)
     {
         ProcessLogs.logFilePath = logFilePath;
         ProcessLogs.WriteToLogFile("Generating BIP Token:" + ExceptionDetail.GetExceptionFullMessage(ex));
         return(false);
     }
     return(true);
 }
예제 #25
0
        public void OnException(ExceptionContext context)
        {
            var response = new ErrorResponse();

            response.Message = "An error occurred. Try it again.";
            var exceptionDetail = new ExceptionDetail();

            exceptionDetail.ExceptionMessage      = context.Exception.Message;
            exceptionDetail.StackTrace            = context.Exception.StackTrace;
            exceptionDetail.InnerExceptionMessage = context.Exception.InnerException != null ? context.Exception.InnerException.Message : string.Empty;
            exceptionDetail.InnerExceptionMessage = context.Exception.InnerException != null ? context.Exception.InnerException.StackTrace : string.Empty;

            string customeErrorMessageString = JsonConvert.SerializeObject(exceptionDetail);

            logger.LogError(new EventId(context.Exception.HResult),
                            context.Exception, customeErrorMessageString
                            );
            if (env.IsDevelopment())
            {
                response.ExceptionDetail = exceptionDetail;
            }
            context.Result = new InternalServerErrorObjectResult(response);
            context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            //}
            context.ExceptionHandled = true;
        }
예제 #26
0
        protected override async Task <string> GetOpenIdConfigurationEndpointAsync(
            string userPrincipalName,
            RequestContext requestContext)
        {
            if (ValidateAuthority)
            {
                var drsResponse = await GetMetadataFromEnrollmentServerAsync(
                    userPrincipalName,
                    requestContext)
                                  .ConfigureAwait(false);

                if (!string.IsNullOrEmpty(drsResponse.Error))
                {
                    MsalExceptionFactory.GetServiceException(
                        drsResponse.Error,
                        drsResponse.ErrorDescription,
                        ExceptionDetail.FromDrsResponse(drsResponse));
                }

                if (drsResponse.IdentityProviderService?.PassiveAuthEndpoint == null)
                {
                    throw MsalExceptionFactory.GetServiceException(
                              CoreErrorCodes.MissingPassiveAuthEndpoint,
                              CoreErrorMessages.CannotFindTheAuthEndpont,
                              ExceptionDetail.FromDrsResponse(drsResponse));
                }

                string resource     = string.Format(CultureInfo.InvariantCulture, CanonicalAuthority);
                string webfingerUrl = string.Format(
                    CultureInfo.InvariantCulture,
                    "https://{0}/adfs/.well-known/webfinger?rel={1}&resource={2}",
                    drsResponse.IdentityProviderService.PassiveAuthEndpoint.Host,
                    DefaultRealm,
                    resource);

                var httpResponse =
                    await ServiceBundle.HttpManager.SendGetAsync(new Uri(webfingerUrl), null, requestContext).ConfigureAwait(false);

                if (httpResponse.StatusCode != HttpStatusCode.OK)
                {
                    throw MsalExceptionFactory.GetServiceException(
                              CoreErrorCodes.InvalidAuthority,
                              CoreErrorMessages.AuthorityValidationFailed,
                              httpResponse);
                }

                var wfr = OAuth2Client.CreateResponse <AdfsWebFingerResponse>(httpResponse, requestContext, false);
                if (wfr.Links.FirstOrDefault(
                        a => a.Rel.Equals(DefaultRealm, StringComparison.OrdinalIgnoreCase) &&
                        a.Href.Equals(resource, StringComparison.OrdinalIgnoreCase)) == null)
                {
                    throw MsalExceptionFactory.GetClientException(
                              CoreErrorCodes.InvalidAuthority,
                              CoreErrorMessages.InvalidAuthorityOpenId);
                }
            }

            return(GetDefaultOpenIdConfigurationEndpoint());
        }
예제 #27
0
 public void Error(ExceptionDetail e)
 {
     if (!ErrorEnabled)
     {
         return;
     }
     AddNotification(LogLevel.ERROR, e);
 }
예제 #28
0
 public void Warn(ExceptionDetail e)
 {
     if (!WarnEnabled)
     {
         return;
     }
     AddNotification(LogLevel.WARN, e);
 }
예제 #29
0
 public void Warn(String message, ExceptionDetail e)
 {
     if (!WarnEnabled)
     {
         return;
     }
     AddNotification(LogLevel.WARN, message, e);
 }
예제 #30
0
 public void Error(String message, ExceptionDetail e)
 {
     if (!ErrorEnabled)
     {
         return;
     }
     AddNotification(LogLevel.ERROR, message, e);
 }
예제 #31
0
 private void ProvideWellKnownFault(Exception e, FaultConverter faultConverter, ref ErrorHandlerFaultInfo faultInfo)
 {
     Message faultMessage;
     if (faultConverter != null && faultConverter.TryCreateFaultMessage(e, out faultMessage))
     {
         faultInfo.Fault = faultMessage;
         return;
     }
     else if (e is NetDispatcherFaultException)
     {
         NetDispatcherFaultException ndfe = e as NetDispatcherFaultException;
         if (_debug)
         {
             ExceptionDetail detail = new ExceptionDetail(ndfe);
             faultInfo.Fault = Message.CreateMessage(_messageVersion, MessageFault.CreateFault(ndfe.Code, ndfe.Reason, detail), ndfe.Action);
         }
         else
         {
             faultInfo.Fault = Message.CreateMessage(_messageVersion, ndfe.CreateMessageFault(), ndfe.Action);
         }
     }
 }