Exemplo n.º 1
0
        public async Task <IActionResult> Get(string account, string region)
        {
            ObjectResult checkResult = GetCheckParams(StatusCode, account, region);

            if (checkResult != default)
            {
                return(checkResult);
            }

            (Client[] Clients, string[] Errors)clients;
            try {
                clients = await RegistrarDocuments.GetClientsFrom1CAccountAsync(_Service1C, _Secret1C, region, account);
            }
            catch (Exception exception) {
                _Logger.LogError(
                    exception,
                    "Ошибка получения списка контрагентов по договору {account1CCode}. Пользователь: {login}." +
                    "	 Ошибка: {exceptionMessage}, StackTrace: {StackTrace}.",
                    account, HelperASP.Login(User), exception.Message, exception.StackTrace);
                return(StatusCode(StatusCodes.Status500InternalServerError, exception.Message));
            }

            if (clients.Errors.Length > 0)
            {
                _Logger.LogError(
                    "Ошибка получения списка контрагентов по договору {account1CCode}. Пользователь: {login}," +
                    " ошибка: {errorMessage}.",
                    account, HelperASP.Login(User), string.Join(". ", clients.Errors));
                return(StatusCode(StatusCodes.Status500InternalServerError, string.Join(". ", clients.Errors)));
            }

            return(Ok(clients.Clients));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index(string account1CCode, string regionWebServiceListName, string[] orgs)
        {
            (Client[] Clients, string[] Errors)creditDocument = await RegistrarDocuments.GetClientsFrom1CAccountAsync(_Service1C, _Secret1Cs, regionWebServiceListName, account1CCode);

            RegistrarDocumentsIndex model = new RegistrarDocumentsIndex()
            {
                Clients                   = creditDocument.Clients,
                Errors                    = creditDocument.Errors,
                Account1CCode             = account1CCode,
                RegionsWebServiceListName = Secret1C.GetRegions(_Secret1Cs, Request.Cookies[Startup.WebService1CRegion] ?? _Secret1Cs.Servers.Keys.First())
            };

            ViewData["orgs"] = Organization.OrganizationsByLogin(User.Identity.Name, orgs);
            Response.Cookies.Append(Startup.WebService1CRegion, regionWebServiceListName);

            return(View(model));
        }