客户端异常处理

时间:2022-08-29 08:34:05


 try

                {

                    service.AddOperateLog(mol);

                }

                catch (Exception ex)

                {

                    if (service.InnerChannel.State == System.ServiceModel.CommunicationState.Faulted)

                    {

                        service = new QhrServiceClient();

                        MyExceptionRecord my = new MyExceptionRecord();

                        my.Id = System.Guid.NewGuid().ToString();

                        my.OccurrenceTime = DateTime.Now;

                        my.ExceptionType = "Operation";

                        my.OperationName = "AddOperateLog";

                        my.ExceptionMessage = ex.Message;

                        my.Status = 1;

 

                        service.CreateExceptionRecord(my);

                    }

                }