Esempio n. 1
0
        public void testeMonitoramento()
        {
            string organizationName = ConfigurationManager.GetSettingValue("OrganizacaoIntelbras");

            Intelbras.CRM2013.Domain.Model.Tarefa      imagemTarefa = new Domain.Servicos.TarefaService(organizationName, false).BuscaTarefa(new Guid("463D2AC8-AF48-E411-93F5-00155D013E70"));
            Intelbras.CRM2013.Domain.Model.Tarefa      mTarefa      = new Domain.Model.Tarefa(organizationName, false);
            Domain.Servicos.CompromissosDoCanalService ServiceCompromissosDoCanal = new Domain.Servicos.CompromissosDoCanalService(organizationName, false);
            Domain.Servicos.StatusCompromissoService   StatusCompromissoService   = new Domain.Servicos.StatusCompromissoService(organizationName, false);
            //mTarefa = imagemTarefa;
            mTarefa.Resultado = null;

            if (imagemTarefa.TipoDeAtividade.Name.Contains("Checklist"))
            {
                if (mTarefa.Resultado.HasValue)
                {
                    switch (mTarefa.Resultado)
                    {
                    case (int)Domain.Enum.Tarefa.Resultado.Reprovada:
                        Domain.Model.CompromissosDoCanal mCompromissoCanal = ServiceCompromissosDoCanal.BuscarPorGuid(mTarefa.ReferenteA.Id);
                        if (mCompromissoCanal != null)
                        {
                            Domain.Model.StatusCompromissos statusComp = StatusCompromissoService.ObterPorNome("Não cumprido");
                            if (statusComp != null)
                            {
                                //Só atualiza o status do compromisso se ele for diferente do status que será mudado
                                if (mCompromissoCanal.StatusCompromisso.Id != statusComp.ID.Value)
                                {
                                    mCompromissoCanal.StatusCompromisso.Id = statusComp.ID.Value;
                                    ServiceCompromissosDoCanal.Atualizar(mCompromissoCanal);
                                }
                            }
                        }
                        break;

                    case (int)Domain.Enum.Tarefa.Resultado.Aprovada:
                        Domain.Model.CompromissosDoCanal mCompromissoCanalAprovado = ServiceCompromissosDoCanal.BuscarPorGuid(mTarefa.ReferenteA.Id);
                        if (mCompromissoCanalAprovado != null)
                        {
                            Domain.Model.StatusCompromissos statusComp = StatusCompromissoService.ObterPorNome("Cumprido");
                            if (statusComp != null)
                            {
                                //Só atualiza o status do compromisso se ele for diferente do status que será mudado
                                if (mCompromissoCanalAprovado.StatusCompromisso.Id != statusComp.ID.Value)
                                {
                                    mCompromissoCanalAprovado.StatusCompromisso.Id = statusComp.ID.Value;
                                    ServiceCompromissosDoCanal.Atualizar(mCompromissoCanalAprovado);
                                }
                            }
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        public List <T> ListarAtivosCumpridos(Intelbras.CRM2013.Domain.Enum.CompromissoPrograma.TipoMonitoramento tipoMonitoramento, Domain.Model.StatusCompromissos cumprido, Domain.Model.StatusCompromissos cumpridoForaPrazo)
        {
            var query = GetQueryExpression <T>(true);

            var statusCompromisso = new string[] { cumprido.ID.Value.ToString(), cumpridoForaPrazo.ID.Value.ToString() };

            query.Criteria.AddCondition("itbc_statuscompromissosid", Microsoft.Xrm.Sdk.Query.ConditionOperator.In, statusCompromisso);

            query.Criteria.AddCondition("statecode", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, (int)Domain.Enum.CompromissoCanal.Status.Ativo);

            query.AddLink("itbc_compromissos", "itbc_compdoprogid", "itbc_compromissosid")
            .LinkCriteria.AddCondition("itbc_tipodemonitoramento", ConditionOperator.Equal, (int)tipoMonitoramento);

            return((List <T>) this.RetrieveMultiple(query).List);
        }
Esempio n. 3
0
        public List <T> ListarAtivosVencidosCumpridos(Intelbras.CRM2013.Domain.Enum.CompromissoPrograma.TipoMonitoramento tipoMonitoramento, Domain.Model.StatusCompromissos cumprido, Domain.Model.StatusCompromissos cumpridoForaPrazo)
        {
            var query = GetQueryExpression <T>(true);

            string strFetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                              <entity name='itbc_compdocanal'>
                                <attribute name='itbc_compdocanalid' />
                                <attribute name='itbc_name' />
                                <attribute name='itbc_validade' />
                                <attribute name='itbc_statuscompromissosid' />
                                <attribute name='itbc_compdoprogid' />
                                <attribute name='itbc_canalid' />
                                <attribute name='itbc_businessunitid' />
                                <order attribute='itbc_name' descending='false' />
                                <filter type='and'>
                                  <condition attribute='statuscode' operator='eq' value='1' />
                                  <filter type='or'>
                                    <condition attribute='itbc_validade' operator='on-or-before' value='{3}' />
                                    <condition attribute='itbc_validade' operator='null' />
                                  </filter>
                                  <filter type='or'>
                                    <condition attribute='itbc_statuscompromissosid' operator='null' />
                                    <condition attribute='itbc_statuscompromissosid' operator='in'>
                                      <value uiname='Cumprido' uitype='itbc_statuscompromissos'>{1}</value>
                                      <value uiname='Cumprido Fora do Prazo' uitype='itbc_statuscompromissos'>{2}</value>
                                    </condition>
                                  </filter>
                                </filter>
                                <link-entity name='itbc_compromissos' from='itbc_compromissosid' to='itbc_compdoprogid' alias='aa'>
                                  <filter type='and'>
                                    <condition attribute='itbc_tipodemonitoramento' operator='eq' value='{0}' />
                                  </filter>
                                </link-entity>
                              </entity>
                            </fetch>";

            strFetchXml = string.Format(strFetchXml,
                                        (int)tipoMonitoramento,
                                        cumprido.ID.Value,
                                        cumpridoForaPrazo.ID.Value,
                                        DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd"));

            RetrieveMultipleRequest retrieveMultiple = new RetrieveMultipleRequest()
            {
                Query = new FetchExpression(strFetchXml.ToString())
            };

            return((List <T>) this.RetrieveMultiple(retrieveMultiple.Query).List);
        }