コード例 #1
0
        public AcessoUsuarioController AcessoUsuarioPlano(string chaveUsuario, string cnpjParceiro, string senhaParceiro)
        {
            try
            {
                var cpfUsuario = RecuperarCpfUsuario(chaveUsuario);

                var ehParceiro = new ParceiroDAO().ValidarParceiro(cnpjParceiro, senhaParceiro);
                if (!ehParceiro)
                {
                    throw new Exception("Parceiro não encontrado.");
                }

                var usuario = new PortalUsuarioDAO().ConsultaUsuario(cpfUsuario);
                if (usuario.TB013_id <= 0)
                {
                    throw new Exception("Usuário do portal não encontrado.");
                }

                var planos = new ContratosDAO().ConsultaPlanoCorporativoUsuario(usuario.TB013_id);
                return(new AcessoUsuarioController
                {
                    CpfCnpjUsuario = usuario.TB013_CPFCNPJ,
                    NomeUsuario = usuario.TB013_NomeCompleto,
                    CnpjPlanos = planos
                });
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #2
0
        private async Task <bool> ImportContratosAsync()
        {
            var dao = new ContratosDAO();

            dao.OpenDatabase();

            try
            {
                var rstMain         = dao.GetRecordSet();
                var processDataList = new List <ProcessData>();
                var uploadFileList  = new List <string>();

                while (!rstMain.EOF)
                {
                    processDataList.Add(ContratosHelper.CreateClienteDataField(rstMain.Fields["Cliente"].Value.ToString()));
                    processDataList.Add(ContratosHelper.CreateTipoContratoDataField(rstMain.Fields["Tipo de contrato"].Value.ToString()));
                    processDataList.Add(ContratosHelper.CreateNIFDataField(rstMain.Fields["NIF"].Value.ToString()));
                    processDataList.Add(ContratosHelper.CreateNumeroContratoDataField(rstMain.Fields["Número crto"].Value.ToString()));
                    processDataList.Add(ContratosHelper.CreateUbicacionDataField(rstMain.Fields["Ubicación"].Value.ToString()));

                    var dataId = string.Empty;

                    try
                    {
                        dataId = await AddContratosProcessData(token, processDataList.ToArray());
                    }
                    catch (RestResponseException ex)
                    {
                        LogFactory.CreateLog().LogError(ex);
                        continue;
                    }

                    // Export files from first column
                    var rstAttach = RecordsetHelper.GetRecordset2("Datos adjuntos", rstMain);

                    try
                    {
                        uploadFileList.AddRange(ExportFilesFromRecordset(rstAttach));
                    }
                    finally
                    {
                        rstAttach.Close();
                    }

                    foreach (var fileName in uploadFileList)
                    {
                        try
                        {
                            await AddContratosProcessFiles(token, dataId, new FileInfo(fileName));
                        }
                        catch (RestResponseException ex)
                        {
                            LogFactory.CreateLog().LogError(ex);
                            continue;
                        }
                    }

                    processDataList.Clear();
                    uploadFileList.Clear();
                    rstMain.MoveNext();
                }
            }
            finally
            {
                dao.CloseDatabase();
                dao = null;
            }

            return(true);
        }