コード例 #1
0
        public void Criar(PotencialdoSupervisor mPotencialdoSupervisor, List <Model.OrcamentoDetalhado> lstOrcamentoDetalhado)
        {
            //PotencialdoSupervisorporSegmento mPotencialdoSupervisorporSegmento;
            //var lstOrcamentoporSegmento = (from x in lstOrcamentoDetalhado
            //                               group x by string.Format("{0}", x.Segmento.Id));

            //foreach (var OrcaSegmento in lstOrcamentoporSegmento)
            //{
            //    mPotencialdoSupervisorporSegmento = RepositoryService.PotencialdoSupervisorporSegmento.Obter(mPotencialdoSupervisor.ID.Value, OrcaSegmento.First().Canal.Id, mPotencialdoSupervisor.Trimestre.Value, OrcaSegmento.First().Segmento.Id);
            //    if (mPotencialdoSupervisorporSegmento == null)
            //    {
            //        mPotencialdoSupervisorporSegmento = new PotencialdoSupervisorporSegmento(RepositoryService.NomeDaOrganizacao, RepositoryService.IsOffline, RepositoryService.Provider);
            //        mPotencialdoSupervisorporSegmento.ID = Guid.NewGuid();
            //        mPotencialdoSupervisorporSegmento.Nome = mPotencialdoSupervisor.Nome + " - " + OrcaSegmento.First().Segmento.Name;
            //        mPotencialdoSupervisorporSegmento.UnidadedeNegocios = mPotencialdoSupervisor.UnidadedeNegocio;
            //        mPotencialdoSupervisorporSegmento.Ano = mPotencialdoSupervisor.Ano;
            //        mPotencialdoSupervisorporSegmento.Supervisor = new Lookup(OrcaSegmento.First().Canal.Id, SDKore.Crm.Util.Utility.GetEntityName<Model.Usuario>());
            //        //mPotencialdoSupervisorporSegmento.Trimestre = mPotencialdoSupervisor.Trimestre;
            //        mPotencialdoSupervisorporSegmento.Segmento = new Lookup(OrcaSegmento.First().Segmento.Id, SDKore.Crm.Util.Utility.GetEntityName<Model.Segmento>());
            //        mPotencialdoSupervisorporSegmento.PotencialdoTrimestreSupervisor = new Lookup(mPotencialdoSupervisor.ID.Value, SDKore.Crm.Util.Utility.GetEntityName<Model.PotencialdoSupervisor>());

            //        RepositoryService.PotencialdoSupervisorporSegmento.Create(mPotencialdoSupervisorporSegmento);
            //    }
            //    ServicePotencialdoSupervisorporFamilia.Criar(mPotencialdoSupervisorporSegmento, OrcaSegmento.ToList());
            //}
        }
コード例 #2
0
        public List <PotencialdoSupervisor> ListarValoresPorUnidadeNegocio(Guid unidadeNegocioId, int ano)
        {
            var lista = new List <PotencialdoSupervisor>();

            string fetch = @"<fetch aggregate='true' no-lock='true' >
                              <entity name='itbc_metadokaporsegmento' >
                                <attribute name='itbc_metaplanejada' alias='valor_planejado' aggregate='sum' />
                                <attribute name='itbc_metarealizada' alias='valor_realizado' aggregate='sum' />
                                <attribute name='itbc_supervisorid' alias='supervisor' groupby='true' />
                                <filter type='and'>
                                  <condition attribute='itbc_ano' operator='eq' value='{0}' />
                                  <condition attribute='itbc_unidadedenegocioid' operator='eq' value='{1}' />
                                </filter>
                              </entity>
                            </fetch>";

            fetch = string.Format(fetch, ano, unidadeNegocioId);

            var retrieveMultiple = new RetrieveMultipleRequest()
            {
                Query = new FetchExpression(fetch)
            };

            EntityCollection collection = ((RetrieveMultipleResponse)this.Execute(retrieveMultiple)).EntityCollection;

            foreach (var item in collection.Entities)
            {
                var supervisor = ((EntityReference)((AliasedValue)item.Attributes["supervisor"]).Value);

                var potencial = new PotencialdoSupervisor(OrganizationName, IsOffline, Provider)
                {
                    PotencialPlanejado = ((Money)((AliasedValue)item.Attributes["valor_planejado"]).Value).Value,
                    PotencialRealizado = ((Money)((AliasedValue)item.Attributes["valor_realizado"]).Value).Value,
                    Supervisor         = new SDKore.DomainModel.Lookup(supervisor.Id, supervisor.Name, supervisor.LogicalName)
                };

                lista.Add(potencial);
            }

            return(lista);
        }