예제 #1
0
        private void AtenderISOL()
        {
            if (!Ocorrencia.DataDeConclusao.HasValue)
            {
                if (Ocorrencia.RazaoStatus != null && Ocorrencia.RazaoStatus.Value == (int)StatusDaOcorrencia.Fechada)
                {
                    throw new ArgumentException("Preencha o campo Data de Conclusão para alterar o Status para fechado!");
                }
            }
            else if (Ocorrencia.DataOrigem != null && Ocorrencia.DataOrigem.HasValue && Ocorrencia.DataDeConclusao != null && Ocorrencia.DataDeConclusao.Value < Ocorrencia.DataOrigem)
            {
                throw new ArgumentException("A Data de Conclusão não pode ser menor que a Data de Abertura da Ocorrência!");
            }

            if (Ocorrencia.DataDeConclusao != null && Ocorrencia.VeiculoId != null)
            {
                var veiculo = new CRM2013.Domain.Servicos.RepositoryService(RepositoryService.NomeDaOrganizacao, RepositoryService.IsOffline).Veiculo.Retrieve(Ocorrencia.VeiculoId.Id);
                if (veiculo != null && veiculo.DataDeInstalacao == null)
                {
                    veiculo.DataDeInstalacao = Ocorrencia.DataDeConclusao;
                    var veiculoTemp = new Domain.Servicos.VeiculoService(RepositoryService.NomeDaOrganizacao, RepositoryService.IsOffline).Persistir(veiculo);
                }
            }

            this.CalculaSLADaISOL();
            this.ValidaVigenciaContrato();
        }
예제 #2
0
        private List <PagamentoServico> ListarValidarDespesas()
        {
            int quantidade = 0;
            var lista      = new List <PagamentoServico>();

            while (!string.IsNullOrEmpty(Request.Form["tipodespesa" + quantidade]) && !string.IsNullOrEmpty(Request.Form["valordespesa" + quantidade]))
            {
                decimal valorDespesa;
                if (!decimal.TryParse(Request.Form["valordespesa" + quantidade], out valorDespesa))
                {
                    throw new ArgumentException("O valor da despesa é inválido!");
                }
                //if (!int.TryParse(Request.Form["tipodespesa" + quantidade], out tipoDespesa))
                //{
                //    throw new ArgumentException("O tipo da despesa é inválido!");
                //}

                var result = JsonConvert.DeserializeObject <TipoPagamentoServico>(Request.Form["tipodespesa" + quantidade]);

                TipoPagamento pagamentoServico = new CRM2013.Domain.Servicos.RepositoryService().TipoPagamento.ObterPorNome(result.text);
                lista.Add(new PagamentoServico()
                {
                    OcorrenciaId    = new Lookup(OcorrenciaId, "incident"),
                    Valor           = valorDespesa,
                    Tipo            = result.val,
                    TipoPagamentoId = new Lookup(pagamentoServico.Id, "new_pagamento_servico")
                });
                quantidade++;
            }
            return(lista);
        }
예제 #3
0
 private void VerificaDataDeIntalacao(Ocorrencia ocorrencia, IPluginExecutionContext context, object service)
 {
     if (ocorrencia.DataDeConclusao != null && ocorrencia.VeiculoId != null)
     {
         var veiculo = new CRM2013.Domain.Servicos.RepositoryService(context.OrganizationName, false, service).Veiculo.Retrieve(ocorrencia.VeiculoId.Id);
         if (veiculo != null && veiculo.DataDeInstalacao == null)
         {
             veiculo.DataDeInstalacao = ocorrencia.DataDeConclusao;
             var veiculoTemp = new Domain.Servicos.VeiculoService(context.OrganizationName, false, service).Persistir(veiculo);
         }
     }
     return;
 }
예제 #4
0
        public void EnviaEmailRegistroProjeto(ClientePotencial clientepotencial, bool duplicado)
        {
            //Envia e-mail e salva como tarefa no CRM
            try
            {
                Email email = new Email(OrganizationName, IsOffline);
                email.ReferenteAId   = clientepotencial.Id;
                email.ReferenteAType = "lead";
                email.ReferenteAName = clientepotencial.NomeDaEmpresa;
                email.ReferenteA     = new Lookup(clientepotencial.Id, clientepotencial.NomeDaEmpresa, "lead");
                email.Assunto        = "Projeto " + clientepotencial.NumeroProjeto + " enviado";
                if (duplicado)
                {
                    string corpoEmail = @"<style type=""text/css""> pre.mscrmpretag {  font-family: Tahoma, Verdana, Arial; style=""word-wrap: break-word;"" }</style>
                    <FONT size=2 face=Calibri>Prezado(a), <br /><br />
                    No sistema já há um registro para esse cliente final, sua solicitação será avaliada e em breve terá um retorno.
                    <br /><br />Pedimos que aguarde 48hs para receber o parecer se o projeto foi aceito ou não.
                    <br /><br />Registro de Projetos<br /><br />Soluções e Projetos<br /><br />intelbras.com.br</FONT>";
                    email.Mensagem = corpoEmail;
                }
                else
                {
                    string corpoEmail = @"<style type=""text/css""> pre.mscrmpretag {  font-family: Tahoma, Verdana, Arial; style=""word-wrap: break-word;"" }</style>
                    <FONT size=2 face=Calibri>Prezado(a), <br /><br />
                    Sua solicitação foi enviada com sucesso para área de Registro de Projetos.
                    <br /><br />Pedimos que aguarde 48hs para receber o parecer se o projeto foi aceito ou não.
                    <br /><br />Registro de Projetos<br /><br />Soluções e Projetos<br /><br />intelbras.com.br</FONT>";
                    email.Mensagem = corpoEmail;
                }
                email.De = new Lookup[] { new Lookup(new Guid(SDKore.Configuration.ConfigurationManager.GetSettingValue("ID_EMAIL_CORPORATIVO")), "systemuser") };

                if (duplicado)
                {
                    email.Para    = new Lookup[4];
                    email.Para[0] = new Lookup {
                        Id = clientepotencial.RevendaIntegrador.Id, Type = "account"
                    };
                    email.Para[1] = new Lookup {
                        Id = clientepotencial.Distribuidor.Id, Type = "account"
                    };
                    email.Para[2] = new Lookup {
                        Id = clientepotencial.Executivo.Id, Type = "contact"
                    };
                    Usuario proprietario = new CRM2013.Domain.Servicos.RepositoryService().Usuario.BuscarProprietario("lead", "leadid", clientepotencial.Id);
                    if (proprietario != null)
                    {
                        email.Para[3] = new Lookup {
                            Id = proprietario.Id, Type = "systemuser"
                        };
                    }
                }
                else
                {
                    email.Para    = new Lookup[3];
                    email.Para[0] = new Lookup {
                        Id = clientepotencial.RevendaIntegrador.Id, Type = "account"
                    };
                    email.Para[1] = new Lookup {
                        Id = clientepotencial.Distribuidor.Id, Type = "account"
                    };
                    email.Para[2] = new Lookup {
                        Id = clientepotencial.Executivo.Id, Type = "contact"
                    };
                }


                email.Direcao = false;
                email.ID      = (new CRM2013.Domain.Servicos.RepositoryService()).Email.Create(email);

                (new CRM2013.Domain.Servicos.RepositoryService()).Email.EnviarEmail(email.ID.Value);
            }
            catch (Exception ex)
            {
                SDKore.Helper.Log.Logar("emailprojetoduplicado.txt", ex.Message + ex.StackTrace);
            }
        }
예제 #5
0
        protected override void Execute(IPluginExecutionContext context, IOrganizationServiceFactory serviceFactory, IOrganizationService adminService, IOrganizationService userService)
        {
            switch (EnumConverter <MessageName>(context.MessageName.ToLower()))
            {
                #region Create

            case MessageName.Create:

                var e = context.GetContextEntity();
                var entityTargetCreate = (Entity)context.InputParameters["Target"];
                // Proprietário do Portal Astec
                var    usuario      = new Guid(SDKore.Configuration.ConfigurationManager.GetSettingValue("guid_proprietario_portal_astec"));
                string proprietario = "";
                if (entityTargetCreate.Attributes.Contains("ownerid"))
                {
                    proprietario = entityTargetCreate.Attributes["ownerid"].ToString();
                }
                var diagnosticoCreate = e.Parse <Diagnostico>(context.OrganizationName, context.IsExecutingOffline);

                // Verificar se vem do Portal Astec
                if (proprietario == "")
                {
                    entityTargetCreate.Attributes["ownerid"] = new EntityReference("systemuser", usuario);

                    if (diagnosticoCreate.OcorrenciaId != null && diagnosticoCreate.ProdutoId != null && diagnosticoCreate.SolucaoId != null && diagnosticoCreate.DefeitoId != null &&
                        new RepositoryService(context.OrganizationName, context.IsExecutingOffline).Diagnostico.ObterDuplicidade(diagnosticoCreate.OcorrenciaId.Id, diagnosticoCreate.ProdutoId.Id,
                                                                                                                                 diagnosticoCreate.SolucaoId.Id, diagnosticoCreate.DefeitoId.Id, diagnosticoCreate.NumeroNotaFiscal, diagnosticoCreate.SerieNotaFiscal, Guid.Empty) != null)
                    {
                        throw new InvalidPluginExecutionException("Operação não realizada. Foi identificado diagnóstico redundante. Verifique 'Ocorrência', 'Produto', 'Serviço', 'Defeito', 'Nota Fiscal', 'Série NF'.");
                    }
                }

                ValidaStatusDoDiagnostico(ref e);
                break;

                #endregion

                #region Update

            case MessageName.Update:

                var  entityMerge                   = context.PreEntityImages["imagem"];
                var  entityTargetUpdate            = (Entity)context.InputParameters["Target"];
                var  diagnosticoUpdate             = entityTargetUpdate.Parse <Diagnostico>(context.OrganizationName, context.IsExecutingOffline);
                Guid proprietarioPortalAstecUpdate = new Guid(SDKore.Configuration.ConfigurationManager.GetSettingValue("guid_proprietario_portal_astec"));     // Proprietário do Portal Astec

                Diagnostico diagnostico = new RepositoryService(context.OrganizationName, context.IsExecutingOffline).Diagnostico.Retrieve(diagnosticoUpdate.Id);

                Usuario usuarioProp = new CRM2013.Domain.Servicos.RepositoryService().Usuario.BuscarProprietario("new_diagnostico_ocorrencia", "new_diagnostico_ocorrenciaid", diagnosticoUpdate.Id);

                if (usuarioProp.Id == proprietarioPortalAstecUpdate)
                {
                    if (diagnosticoUpdate.OcorrenciaId != null && diagnosticoUpdate.ProdutoId != null && diagnosticoUpdate.SolucaoId != null && diagnosticoUpdate.DefeitoId != null &&
                        new RepositoryService(context.OrganizationName, context.IsExecutingOffline).Diagnostico.ObterDuplicidade(diagnosticoUpdate.OcorrenciaId.Id, diagnosticoUpdate.ProdutoId.Id,
                                                                                                                                 diagnosticoUpdate.SolucaoId.Id, diagnosticoUpdate.DefeitoId.Id, diagnosticoUpdate.NumeroNotaFiscal, diagnosticoUpdate.SerieNotaFiscal, diagnosticoUpdate.Id) != null)
                    {
                        throw new InvalidPluginExecutionException("Operação não realizada. Foi identificado diagnóstico redundante. Verifique 'Ocorrência', 'Produto', 'Serviço', 'Defeito', 'Nota Fiscal', 'Série NF'.");
                    }
                }

                Ocorrencia ocor = (new Domain.Servicos.RepositoryService()).Ocorrencia.Retrieve(diagnostico.OcorrenciaId.Id);
                if ((diagnosticoUpdate.RazaoStatus == 4 || diagnostico.RazaoStatus == 4) && ocor.DataDeConsertoInformada != null)
                {
                    entityTargetUpdate.Attributes["statuscode"] = new OptionSetValue(5);     // Conserto Realizado
                }
                break;

                #endregion
            }
        }
예제 #6
0
파일: OS.aspx.cs 프로젝트: ertprs/crm_fonte
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (this.OcorrenciaId == Guid.Empty)
                {
                    throw new ArgumentNullException("OcorrenciaId", "Não foi informado o parametro!");
                }

                Ocorrencia ocorrenciaIsol = new CRM2013.Domain.Servicos.RepositoryService().Ocorrencia.ObterImpressaoOcorrenciaIsol(this.OcorrenciaId);
                Usuario    proprietario   = new CRM2013.Domain.Servicos.RepositoryService().Usuario.BuscarProprietario("incident", "incidentid", ocorrenciaIsol.Id);

                if (ocorrenciaIsol == null)
                {
                    throw new ArgumentException("Ocorrência não encontrada!");
                }

                // String
                txt_numeroOs.Text = ocorrenciaIsol.Numero;
                txt_rec.Text      = ocorrenciaIsol.OsCliente;
                txt_contato.Text  = ocorrenciaIsol.ContatoVisita;
                txt_kilometragemPercorrida.Text = ocorrenciaIsol.KilometragemPercorrida;
                txt_defeitoAlegado.Text         = ocorrenciaIsol.DefeitoAlegado;
                txt_atividadeExecultada.Text    = ocorrenciaIsol.AtividadeExecutada;
                txt_numeroNfFatura.Text         = ocorrenciaIsol.NumeroNotaFiscalDeCompra;

                //Coloca empresa executante sempre como Intelbras, chamado 138030
                txt_nomeEmpresaExecutante.Text     = "INTELBRAS S A IND DE TELEC ELET BRAS";
                txt_nomeEmpresaExecutante.ReadOnly = true;

                //Coloca o texto dos TextBox em negrito
                txt_defeitoAlegado.Font.Bold         = true;
                txt_equipamentosInstalados.Font.Bold = true;
                txt_atividadeExecultada.Font.Bold    = true;
                txt_obs.Font.Bold = true;

                if (ocorrenciaIsol.Contrato != null)
                {
                    var clienteParticipanteContrato = (new CRM2013.Domain.Servicos.RepositoryService()).ClienteParticipanteDoContrato.ListarPor(ocorrenciaIsol.Contrato);
                    foreach (var cliente in clienteParticipanteContrato)
                    {
                        bool infClientePArticipante = false;
                        if (ocorrenciaIsol.ClienteId.Id == cliente.Cliente.Id)
                        {
                            var enderecos = (new CRM2013.Domain.Servicos.RepositoryService()).ClienteParticipanteDoEndereco.ListarPor(cliente);
                            foreach (var endereco in enderecos)
                            {
                                if (!string.IsNullOrEmpty(endereco.ProdutoEndereco))
                                {
                                    txt_equipamentosInstalados.Text += Regex.Replace(endereco.ProdutoEndereco, " {2,}", "");
                                }
                                else if (!string.IsNullOrEmpty(cliente.Descricao) && !infClientePArticipante)
                                {
                                    txt_equipamentosInstalados.Text += Regex.Replace(cliente.Descricao, " {2,}", "");
                                    infClientePArticipante           = true;
                                }
                            }
                        }
                    }
                }
                if (ocorrenciaIsol.Contrato != null)
                {
                    txt_obs.Text = ocorrenciaIsol.Contrato.ObservacaoOs;
                }

                if (ocorrenciaIsol.DataDeReagendamentoVisita.HasValue)
                {
                    txt_dataPrevistaParaVisita.Text = ocorrenciaIsol.DataDeReagendamentoVisita.Value.ToLocalTime().ToString();
                }
                else
                {
                    if (ocorrenciaIsol.DataPrevistaParaVisita != null)
                    {
                        txt_dataPrevistaParaVisita.Text = ocorrenciaIsol.DataPrevistaParaVisita.Value.ToLocalTime().ToString();
                    }
                }

                if (proprietario.NomeCompleto != null)
                {
                    txt_criadoPor.Text = proprietario.NomeCompleto;
                }

                if (ocorrenciaIsol.TipoDeOcorrencia != null)
                {
                    txt_tipoOcorrencia.Text = ((TipoDeOcorrencia)ocorrenciaIsol.TipoDeOcorrencia.Value).ToString();
                }

                if (ocorrenciaIsol.Cliente != null)
                {
                    txt_nomeCliente.Text             = ocorrenciaIsol.Cliente.RazaoSocial;
                    txt_localDeIntelacaoCliente.Text = ocorrenciaIsol.Cliente.NomeFantasia;

                    txt_telefoneCliente.Text = ocorrenciaIsol.Cliente.Telefone;
                }

                if (!string.IsNullOrEmpty(ocorrenciaIsol.SolicitantePortal))
                {
                    txt_nomeSolicitante.Text = ocorrenciaIsol.SolicitantePortal;
                }
                else if (ocorrenciaIsol.Solicitante != null)
                {
                    txt_nomeSolicitante.Text     = ocorrenciaIsol.Solicitante.Nome;
                    txt_telefoneSolicitante.Text = ocorrenciaIsol.Solicitante.TelefoneComercial;
                }

                if (ocorrenciaIsol.ProdutosDoCliente == null)
                {
                    panel_produtosDoCliente.Visible = false;
                }
                else
                {
                    txt_produtosDoCliente.Text = ocorrenciaIsol.ProdutosDoCliente;
                }

                if (ocorrenciaIsol.TecnicoDaVisita != null)
                {
                    txt_nomeTecnicoExecutante.Text      = ocorrenciaIsol.TecnicoDaVisita.Nome;
                    txt_telefoneTecnicoExecultante.Text = ocorrenciaIsol.TecnicoDaVisita.TelefoneComercial;
                    txt_rgTecnicoExecultante.Text       = ocorrenciaIsol.TecnicoDaVisita.DocIdentidade;
                }

                if (ocorrenciaIsol.TecnicoResponsavel != null)
                {
                    txt_nomeTecnicoResponsavel.Text     = ocorrenciaIsol.TecnicoResponsavel.Nome;
                    txt_telefoneTecnicoResponsavel.Text = ocorrenciaIsol.TecnicoResponsavel.TelefoneComercial;
                    txt_rgTecnicoResponsavel.Text       = ocorrenciaIsol.TecnicoResponsavel.DocIdentidade;
                }

                // Endereco
                if (ocorrenciaIsol.EnderecoId != null)
                {
                    /*
                     * No campo new_guid_enredeco na ocorrencia esta salvando pelo CRM,
                     * o id do endereco e pelo portal esta salvando o new_cliente_participanteid
                     * precisa corrigir o portal.
                     */
                    var clienteParticipanteEndereco = new ClienteParticipanteEndereco()
                    {
                        Id = new Guid(ocorrenciaIsol.EnderecoId)
                    };
                    CRM2013.Domain.Model.Endereco endereco = new CRM2013.Domain.Servicos.RepositoryService().Endereco.ObterPor(clienteParticipanteEndereco);
                    PreencherEndereco(endereco);
                }

                #region Obter NFs
                CRM2013.Domain.Model.Fatura notaFiscalRemessa = null;
                CRM2013.Domain.Model.Fatura notaFiscalFatura  = null;

                if (ocorrenciaIsol.Contrato != null && ocorrenciaIsol.Cliente != null)
                {
                    notaFiscalRemessa = new CRM2013.Domain.Servicos.RepositoryService().Fatura.ObterRemessaPor(ocorrenciaIsol.Contrato, ocorrenciaIsol.Cliente);

                    if (notaFiscalRemessa == null)
                    {
                        notaFiscalRemessa = ocorrenciaIsol.Contrato.NotaFiscalRemessa;
                    }

                    notaFiscalFatura = new CRM2013.Domain.Servicos.RepositoryService().Fatura.ObterFaturaPor(ocorrenciaIsol.Contrato, ocorrenciaIsol.Cliente);
                }
                #endregion

                if (notaFiscalRemessa != null)
                {
                    txt_numeroNfRemessa.Text = notaFiscalRemessa.IDFatura;
                }


                if (notaFiscalFatura != null)
                {
                    txt_numeroNfFatura.Text = notaFiscalFatura.IDFatura;

                    var listaProdutos = new CRM2013.Domain.Servicos.RepositoryService().Fatura.ListarItensDaNotaFiscalPor(notaFiscalFatura.Id);

                    var listaProdutosGrid = (from item in listaProdutos
                                             select new { Código = item.Produto.Codigo, Descrição = item.Produto.Nome, Quantidade = item.Quantidade }).Skip(0).Take(10);

                    tb_produtos.DataSource = listaProdutosGrid;
                    tb_produtos.DataBind();
                }
                CriarQRCode(ocorrenciaIsol.Id);
            }
            catch (Exception ex)
            {
                //string mensagem = LogHelper.Process(ex, ClassificacaoLog.PaginaOcorrencia);
                Response.Write("<script>alert('" + ex.Message + "');window.close()</script>");
            }
        }