Пример #1
0
        public void InitializeMedicationMap_Test()
        {
            PostInitializeMedicationMapRequest request = new PostInitializeMedicationMapRequest
            {
                ContractNumber = contractNumber,
                UserId         = userId,
                Version        = version,
                MedicationMap  = new MedicationMap {
                    FullName = "ibup_sneh1"
                }
            };

            JsonServiceClient.HttpWebRequestFilter = x =>
                                                     x.Headers.Add(string.Format("{0}: {1}", "Token", token));

            // [Route("/{Version}/{ContractNumber}/MedicationMap/Initialize", "POST")]
            PostInitializeMedicationMapResponse response = client.Post <PostInitializeMedicationMapResponse>(string.Format("{0}/{1}/{2}/MedicationMap/Initialize", url, version, contractNumber), request);

            Assert.IsNotNull(response);
        }
Пример #2
0
        public PostInitializeMedicationMapResponse Post(PostInitializeMedicationMapRequest request)
        {
            PostInitializeMedicationMapResponse response = new PostInitializeMedicationMapResponse();
            ValidateTokenResponse result = null;

            try
            {
                if (base.Request != null)
                {
                    request.Token = base.Request.Headers["Token"] as string;
                }
                result = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber);
                if (result.UserId.Trim() != string.Empty)
                {
                    request.UserId         = result.UserId;
                    response.MedicationMap = MedicationManager.InitializeMedicationMap(request);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    MedicationManager.LogException(ex);
                }
            }
            finally
            {
                if (result != null)
                {
                    string browser     = (base.Request != null) ? base.Request.UserAgent : unknownBrowserType;
                    string hostAddress = (base.Request != null) ? base.Request.UserHostAddress : unknownUserHostAddress;
                    AuditUtil.LogAuditData(request, result.SQLUserId, null, browser, hostAddress, request.GetType().Name);
                }
            }
            return(response);
        }