示例#1
0
        public Entity GetEntityFromContacto()
        {
            Entity ent = new Entity("contact");

            ent[NombreCamposContacto.Aen_ClaveIntegracionCRM]       = Aen_ClaveIntegracion;
            ent[NombreCamposContacto.Aen_CargoprincipalIdCRM]       = Aen_CargoprincipalId.Equals(Guid.Empty) ? null : new EntityReference("aen_tiposdecargo", Aen_CargoprincipalId);
            ent[NombreCamposContacto.Aen_NumerodocumentoCRM]        = Aen_Numerodocumento.Equals(string.Empty) ? string.Empty : Aen_Numerodocumento;
            ent[NombreCamposContacto.Aen_TipodocumentoCRM]          = Aen_Tipodocumento.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Tipodocumento));
            ent[NombreCamposContacto.Aen_TratamientoCRM]            = Aen_Tratamiento.Equals(string.Empty) ? null : Aen_Tratamiento;
            ent[NombreCamposContacto.Aen_ObservacionesCRM]          = Aen_Observaciones.Equals(string.Empty) ? string.Empty : Aen_Observaciones;
            ent[NombreCamposContacto.Aen_ObservacionesmigracionCRM] = Aen_Observacionesmigracion.Equals(string.Empty) ? string.Empty : Aen_Observacionesmigracion;
            if (!Donotsendmm.Equals(string.Empty))
            {
                if (Donotsendmm == "1")
                {
                    ent[NombreCamposContacto.DonotsendmmCRM] = true;
                }
                else if (Donotsendmm == "0")
                {
                    ent[NombreCamposContacto.DonotsendmmCRM] = false;
                }
            }
            else
            {
                ent[NombreCamposContacto.DonotsendmmCRM] = false;
            }
            ent[NombreCamposContacto.Emailaddress1CRM]             = Emailaddress1.Equals(string.Empty) ? string.Empty: Emailaddress1;
            ent[NombreCamposContacto.FirstnameCRM]                 = Firstname.Equals(string.Empty) ? string.Empty : Firstname;
            ent[NombreCamposContacto.LastnameCRM]                  = Lastname.Equals(string.Empty) ? string.Empty : Lastname;
            ent[NombreCamposContacto.GendercodeCRM]                = Gendercode.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Gendercode));
            ent[NombreCamposContacto.MobilephoneCRM]               = Mobilephone.Equals(string.Empty) ? string.Empty : Mobilephone;
            ent[NombreCamposContacto.Telephone1CRM]                = Telephone1.Equals(string.Empty) ? string.Empty : Telephone1;
            ent[NombreCamposContacto.Aen_OrigenCRM]                = Aen_Origen.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Origen));
            ent[NombreCamposContacto.Aen_IdentificadorcontactoCRM] = Aen_Identificadorcontacto.Equals(string.Empty) ? null : Aen_Identificadorcontacto;

            if (Contactid != Guid.Empty)
            {
                ent["contactid"] = Contactid;
                ent.Id           = Contactid;
            }

            if (Statecode.Equals("Activo"))
            {
                ent[NombreCamposContacto.StatecodeCRM]  = new OptionSetValue(0);
                ent[NombreCamposContacto.StatuscodeCRM] = new OptionSetValue(1);
            }
            else if (Statecode.Equals("Inactivo") && Contactid != Guid.Empty && Contactid != null)
            {
                ent[NombreCamposContacto.StatecodeCRM]  = new OptionSetValue(1);
                ent[NombreCamposContacto.StatuscodeCRM] = new OptionSetValue(2);
            }

            //Para saltar plugins de envío de datos a NEXO
            //ent["aen_vienedeintegracion"] = true;

            return(ent);
        }
示例#2
0
        public bool ContactosIguales(Contactos contCRM, ref Entity contSalida)
        {
            bool retorna = false;

            if (!Aen_ClaveIntegracionParent.Equals(contCRM.Aen_ClaveIntegracionParent))
            {
                retorna = true;
            }
            if (!Aen_CargoprincipalId.Equals(contCRM.Aen_CargoprincipalId))
            {
                retorna = true;
            }
            if (!Aen_Numerodocumento.Equals(contCRM.Aen_Numerodocumento))
            {
                retorna = true;
            }
            if (!Aen_Tipodocumento.Equals(contCRM.Aen_Tipodocumento))
            {
                retorna = true;
            }
            if (!Aen_Tratamiento.Equals(contCRM.Aen_Tratamiento))
            {
                retorna = true;
            }
            if (!Aen_Observaciones.Equals(contCRM.Aen_Observaciones))
            {
                retorna = true;
            }
            if (!Aen_Observacionesmigracion.Equals(contCRM.Aen_Observacionesmigracion))
            {
                retorna = true;
            }
            if (!Donotsendmm.Equals(contCRM.Donotsendmm) && Donotsendmm != "2")
            {
                retorna = true;
            }
            if (!Emailaddress1.Equals(contCRM.Emailaddress1))
            {
                retorna = true;
            }
            if (!Firstname.Equals(contCRM.Firstname))
            {
                retorna = true;
            }
            if (!Gendercode.Equals(contCRM.Gendercode))
            {
                retorna = true;
            }
            if (!Lastname.Equals(contCRM.Lastname))
            {
                retorna = true;
            }
            if (!Mobilephone.Equals(contCRM.Mobilephone))
            {
                retorna = true;
            }
            if (!Statecode.Equals(contCRM.Statecode))
            {
                retorna = true;
            }
            if (!Telephone1.Equals(contCRM.Telephone1))
            {
                retorna = true;
            }
            if (!Aen_Origen.Equals(contCRM.Aen_Origen))
            {
                retorna = true;
            }
            if (!Aen_Identificadorcontacto.Equals(contCRM.Aen_Identificadorcontacto))
            {
                retorna = true;
            }
            //var decimalString = auxTerCRM.Revenue_Base.ToString("#,####");

            if (retorna)
            {
                Contactid  = contCRM.Contactid;
                contSalida = GetEntityFromContacto();
            }

            return(retorna);
        }
示例#3
0
        public Entity GetEntityFromTercero()
        {
            Entity ter = new Entity("account");

            ter[NombreCamposTercero.Aen_claveintegracionCRM] = Aen_claveintegracion;
            ter[NombreCamposTercero.Aen_AcronimoCRM]         = Aen_Acronimo.Equals(string.Empty) ? string.Empty : Aen_Acronimo;
            if (!Aen_An8.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_An8CRM] = Convert.ToInt32(Aen_An8);
            }
            else
            {
                ter[NombreCamposTercero.Aen_An8CRM] = default(int);
            }
            ter[NombreCamposTercero.Aen_AlumnoCRM]      = Aen_Alumno;
            ter[NombreCamposTercero.Aen_ProfesorCRM]    = Aen_Profesor;
            ter[NombreCamposTercero.Aen_ResponsableCRM] = Aen_Responsable;
            ter[NombreCamposTercero.Aen_ApellidosCRM]   = Aen_Apellidos.Equals(string.Empty) ? string.Empty : Aen_Apellidos;
            ter[NombreCamposTercero.Emailaddress1CRM]   = Emailaddress1.Equals(string.Empty) ? string.Empty : Emailaddress1;
            if (!Parentaccountid.Equals(Guid.Empty)) //Emparentable (viene por update)
            {
                ter[NombreCamposTercero.ParentaccountidCRM] = new EntityReference("account", Parentaccountid);
            }
            else
            {
                if (!string.IsNullOrEmpty(ParentaccountidSTR)) //Emparentable (viene por create)
                {
                    Crm.TercerosAEmparentar.Add(new KeyValuePair <string, string>(Aen_claveintegracion, ParentaccountidSTR));
                }
                else //viene a vacío, se pone a null
                {
                    ter[NombreCamposTercero.ParentaccountidCRM] = null;
                }
            }
            ter[NombreCamposTercero.Aen_DelegacionidCRM]                = Aen_Delegacionid.Equals(Guid.Empty) ? null : new EntityReference("aen_delegacion", Aen_Delegacionid);
            ter[NombreCamposTercero.Aen_DepartamentoidCRM]              = Aen_Departamentoid.Equals(Guid.Empty) ? null : new EntityReference("aen_departamento", Aen_Departamentoid);
            ter[NombreCamposTercero.Aen_PaisdocumentoidCRM]             = Aen_Paisdocumentoid.Equals(Guid.Empty) ? null : new EntityReference("aen_pais", Aen_Paisdocumentoid);
            ter[NombreCamposTercero.Aen_EsclienteCRM]                   = Aen_Escliente;
            ter[NombreCamposTercero.Aen_EsclientecertoolCRM]            = Aen_Esclientecertool;
            ter[NombreCamposTercero.Aen_EsclientelaboratorioCRM]        = Aen_Esclientelaboratorio;
            ter[NombreCamposTercero.Aen_EsclienteweberratumCRM]         = Aen_Esclienteweberratum;
            ter[NombreCamposTercero.Aen_EscompradordenormasCRM]         = Aen_Escompradordenormas;
            ter[NombreCamposTercero.Aen_EsempleadoCRM]                  = Aen_Esempleado;
            ter[NombreCamposTercero.Aen_EslibreriaCRM]                  = Aen_Eslibreria;
            ter[NombreCamposTercero.Aen_EsmiembroctcCRM]                = Aen_Esmiembroctc;
            ter[NombreCamposTercero.Aen_EsmiembrouneCRM]                = Aen_Esmiembroune;
            ter[NombreCamposTercero.Aen_EsorganismoCRM]                 = Aen_Esorganismo;
            ter[NombreCamposTercero.Aen_EspotencialclienteCRM]          = Aen_Espotencialcliente;
            ter[NombreCamposTercero.Aen_EsproveedorCRM]                 = Aen_Esproveedor;
            ter[NombreCamposTercero.Aen_EssuscriptorCRM]                = Aen_Essuscriptor;
            ter[NombreCamposTercero.Aen_RevistaaenorCRM]                = Aen_Revistaaenor;
            ter[NombreCamposTercero.Aen_BloqueadoclienteCRM]            = Aen_Bloqueadocliente.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt16(Aen_Bloqueadocliente));
            ter[NombreCamposTercero.Aen_BloqueadoproveedorCRM]          = Aen_Bloqueadoproveedor.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt16(Aen_Bloqueadoproveedor));
            ter[NombreCamposTercero.Aen_EstadosolicitudclienteerpCRM]   = Aen_Estadosolicitudclienteerp.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Estadosolicitudclienteerp));
            ter[NombreCamposTercero.Aen_EstadosolicitudempleadoerpCRM]  = Aen_Estadosolicitudempleadoerp.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Estadosolicitudempleadoerp));
            ter[NombreCamposTercero.Aen_EstadosolicitudproveedorerpCRM] = Aen_Estadosolicitudproveedorerp.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Estadosolicitudproveedorerp));
            ter[NombreCamposTercero.FaxCRM] = Fax.Equals(string.Empty) ? string.Empty : Fax;
            if (!Aen_Fechadealta.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_FechadealtaCRM] = DateTime.ParseExact(Aen_Fechadealta, "dd/MM/yy", System.Globalization.CultureInfo.InvariantCulture);
            }
            else
            {
                ter[NombreCamposTercero.Aen_FechadealtaCRM] = null;
            }
            if (!Aen_Fechadebaja.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_FechadebajaCRM] = DateTime.ParseExact(Aen_Fechadebaja, "dd/MM/yy", System.Globalization.CultureInfo.InvariantCulture);
            }
            else
            {
                ter[NombreCamposTercero.Aen_FechadebajaCRM] = null;
            }
            ter[NombreCamposTercero.Aen_IdentificadorterceroCRM] = Aen_Identificadortercero.Equals(string.Empty) ? string.Empty : Aen_Identificadortercero;
            ter[NombreCamposTercero.Aen_ClienteerpidCRM]         = Aen_Clienteerpid.Equals(string.Empty) ? string.Empty : Aen_Clienteerpid;
            ter[NombreCamposTercero.Aen_EmpleadoerpidCRM]        = Aen_Empleadoerpid.Equals(string.Empty) ? string.Empty : Aen_Empleadoerpid;
            ter[NombreCamposTercero.Aen_ProveedorerpidCRM]       = Aen_Proveedorerpid.Equals(string.Empty) ? string.Empty : Aen_Proveedorerpid;
            ter[NombreCamposTercero.Aen_IndustriaaenorCRM]       = Aen_Industriaaenor.Equals(Guid.Empty) ? null : new EntityReference("aen_industriaaenor", Aen_Industriaaenor);
            if (!Revenue.Equals(decimal.MinValue))
            {
                Money reven = new Money(Convert.ToDecimal(Revenue));
                ter[NombreCamposTercero.RevenueCRM] = reven;
            }
            else
            {
                //Money reven = new Money();
                ter[NombreCamposTercero.RevenueCRM] = null;
            }
            ter[NombreCamposTercero.Aen_loginempleadoCRM]    = Aen_loginempleado.Equals(string.Empty) ? string.Empty : Aen_loginempleado;
            ter[NombreCamposTercero.Aen_NombredelclienteCRM] = Aen_Nombredelcliente.Equals(string.Empty) ? string.Empty : Aen_Nombredelcliente;
            ter[NombreCamposTercero.NameCRM] = Name.Equals(string.Empty) ? string.Empty : Name;
            ter[NombreCamposTercero.Aen_NumerodocumentoCRM]  = Aen_Numerodocumento.Equals(string.Empty) ? string.Empty : Aen_Numerodocumento;
            ter[NombreCamposTercero.Aen_ObservacionesCRM]    = Aen_Observaciones.Equals(string.Empty) ? string.Empty : Aen_Observaciones;
            ter[NombreCamposTercero.Aen_OrigenCRM]           = Aen_Origen.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Origen));
            ter[NombreCamposTercero.Aen_RiesgopagoaxesorCRM] = Aen_Riesgopagoaxesor.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Riesgopagoaxesor));
            ter[NombreCamposTercero.Aen_SectoraenorCRM]      = Aen_Sectoraenor.Equals(Guid.Empty) ? null : new EntityReference("aen_sectoraenor", Aen_Sectoraenor);
            ter[NombreCamposTercero.Aen_GeneroCRM]           = Aen_Genero.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Genero));
            ter[NombreCamposTercero.Aen_SiglasCRM]           = Aen_Siglas.Equals(string.Empty) ? string.Empty : Aen_Siglas;
            ter[NombreCamposTercero.WebsiteurlCRM]           = Websiteurl.Equals(string.Empty) ? string.Empty : Websiteurl;
            ter[NombreCamposTercero.Aen_SubtipodeterceroCRM] = Aen_Subtipodetercero.Equals(Guid.Empty) ? null : new EntityReference("aen_subtipotercero", Aen_Subtipodetercero);
            ter[NombreCamposTercero.Telephone1CRM]           = Telephone1.Equals(string.Empty) ? string.Empty : Telephone1;
            ter[NombreCamposTercero.Aen_TipodocumentoCRM]    = Aen_Tipodocumento.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Tipodocumento));
            ter[NombreCamposTercero.Aen_TipopersonaCRM]      = Aen_Tipopersona.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Tipopersona));
            //ter[NombreCamposTercero.Aen_TipoproveedorCRM] = Aen_Tipoproveedor.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Tipoproveedor));
            ter[NombreCamposTercero.Aen_ObservacionesmigracionCRM] = Aen_Observacionesmigracion.Equals(string.Empty) ? string.Empty : Aen_Observacionesmigracion;

            if (!Numberofemployees.Equals(string.Empty))
            {
                ter[NombreCamposTercero.NumberofemployeesCRM] = Convert.ToInt32(Numberofemployees);
            }
            else
            {
                ter[NombreCamposTercero.NumberofemployeesCRM] = default(int);
            }

            if (Accountid != Guid.Empty)
            {
                ter["accountid"] = Accountid;
                ter.Id           = Accountid;
            }

            if (Statecode.Equals("Activo"))
            {
                ter[NombreCamposTercero.StatecodeCRM]  = new OptionSetValue(0);
                ter[NombreCamposTercero.StatuscodeCRM] = new OptionSetValue(1);
            }
            else if (Statecode.Equals("Inactivo") && Accountid != Guid.Empty && Accountid != null)
            {
                ter[NombreCamposTercero.StatecodeCRM]  = new OptionSetValue(1);
                ter[NombreCamposTercero.StatuscodeCRM] = new OptionSetValue(2);
            }

            if (!Transactioncurrencyid.Equals(Guid.Empty))
            {
                EntityReference curr = new EntityReference();
                curr.Id          = Transactioncurrencyid;
                curr.LogicalName = "transactioncurrency";
                ter.Attributes.Add(NombreCamposTercero.TransactioncurrencyidCRM, curr);
            }
            else
            {
                Guid defaultCurrency = Guid.Empty;
                bool ooook           = Crm.MaestroTransactionCurrency.TryGetValue("EUR", out defaultCurrency);
                ter.Attributes.Add(NombreCamposTercero.TransactioncurrencyidCRM, new EntityReference("transactioncurrency", defaultCurrency));
            }
            ter[NombreCamposTercero.Aen_WebcorporativaCRM]               = Aen_Webcorporativa.Equals(string.Empty) ? string.Empty : Aen_Webcorporativa;
            ter[NombreCamposTercero.Aen_TelefonocorporativoCRM]          = Aen_Telefonocorporativo.Equals(string.Empty) ? string.Empty : Aen_Telefonocorporativo;
            ter[NombreCamposTercero.Aen_CorreoelectronicocorporativoCRM] = Aen_Correoelectronicocorporativo.Equals(string.Empty) ? string.Empty : Aen_Correoelectronicocorporativo;
            ter[NombreCamposTercero.Aen_CondicionesdepagoidCRM]          = Aen_Condicionesdepagoid.Equals(Guid.Empty) ? null : new EntityReference("aen_condicionesdepago", Aen_Condicionesdepagoid);
            ter[NombreCamposTercero.Aen_FormasdepagoidCRM]               = Aen_Formasdepagoid.Equals(Guid.Empty) ? null : new EntityReference("aen_formadepago", Aen_Formasdepagoid);
            ter[NombreCamposTercero.Aen_EntradadelclienteCRM]            = Aen_Entradadelcliente.Equals(string.Empty) ? null: new OptionSetValue(Convert.ToInt32(Aen_Entradadelcliente));
            ter[NombreCamposTercero.Aen_EvaluaciondelaconformidadCRM]    = Aen_Evaluaciondelaconformidad;
            ter[NombreCamposTercero.Aen_EscompradordelibrosCRM]          = Aen_Escompradordelibros;
            ter[NombreCamposTercero.Aen_TipodocumentoempleadoCRM]        = Aen_Tipodocumentoempleado.Equals(string.Empty) ? null : new OptionSetValue(Convert.ToInt32(Aen_Tipodocumentoempleado));
            ter[NombreCamposTercero.Aen_NumerodocumentoempleadoCRM]      = Aen_Numerodocumentoempleado.Equals(string.Empty) ? string.Empty : Aen_Numerodocumentoempleado;

            //Para saltar plugins de envío de datos a NEXO
            //ter["aen_vienedeintegracion"] = true;

            return(ter);
        }