예제 #1
0
        public Entity GetEntityFromTercero()
        {
            Entity ter = new Entity("account");

            if (!Aen_claveintegracion.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_claveintegracionCRM] = Aen_claveintegracion;
            }
            if (!Aen_Acronimo.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_AcronimoCRM] = Aen_Acronimo;
            }
            ter[NombreCamposTercero.Aen_AlumnoCRM]      = Aen_Alumno;
            ter[NombreCamposTercero.Aen_ProfesorCRM]    = Aen_Profesor;
            ter[NombreCamposTercero.Aen_ResponsableCRM] = Aen_Responsable;
            if (!Aen_Apellidos.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_ApellidosCRM] = Aen_Apellidos;
            }
            //if (!Aen_Contactofacturacionid.Equals(Guid.Empty)) ter[NombreCamposTercero.Aen_ContactofacturacionidCRM] = new EntityReference("contact", Aen_Contactofacturacionid);
            //if (!Primarycontactid.Equals(Guid.Empty)) ter[NombreCamposTercero.PrimarycontactidCRM] = new EntityReference("contact", Primarycontactid);
            if (!Emailaddress1.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Emailaddress1CRM] = Emailaddress1;
            }
            if (!Parentaccountid.Equals(Guid.Empty))
            {
                ter[NombreCamposTercero.ParentaccountidCRM] = new EntityReference("account", Parentaccountid);
            }
            else
            {
                if (!string.IsNullOrEmpty(ParentaccountidSTR))
                {
                    Crm.TercerosAEmparentar.Add(new KeyValuePair <string, string>(Aen_claveintegracion, ParentaccountidSTR));
                }
            }
            if (!Aen_Delegacionid.Equals(Guid.Empty))
            {
                ter[NombreCamposTercero.Aen_DelegacionidCRM] = new EntityReference("aen_Delegacion", Aen_Delegacionid);
            }
            if (!Aen_Departamentoid.Equals(Guid.Empty))
            {
                ter[NombreCamposTercero.Aen_DepartamentoidCRM] = new EntityReference("aen_Departamento", Aen_Departamentoid);
            }
            if (!Aen_Paisdocumentoid.Equals(Guid.Empty))
            {
                ter[NombreCamposTercero.Aen_PaisdocumentoidCRM] = new EntityReference("aen_pais", Aen_Paisdocumentoid);
            }
            ter[NombreCamposTercero.TransactioncurrencyidCRM]           = new EntityReference("transactioncurrency", Transactioncurrencyid);
            ter[NombreCamposTercero.Aen_EscertificaciondeproductosCRM]  = Aen_Escertificaciondeproductos;
            ter[NombreCamposTercero.Aen_EscertificaciondesistemasCRM]   = Aen_Escertificaciondesistemas;
            ter[NombreCamposTercero.Aen_EscertificadopequeocomercioCRM] = Aen_Escertificadopequeocomercio;
            ter[NombreCamposTercero.Aen_EsclienteCRM]             = Aen_Escliente;
            ter[NombreCamposTercero.Aen_EsclientecertoolCRM]      = Aen_Esclientecertool;
            ter[NombreCamposTercero.Aen_EsclientelaboratorioCRM]  = Aen_Esclientelaboratorio;
            ter[NombreCamposTercero.Aen_EsclientewebCRM]          = Aen_Esclienteweb;
            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_EspotencialclientewebCRM] = Aen_Espotencialclienteweb;
            ter[NombreCamposTercero.Aen_EsclienteweberratumCRM]   = Aen_Esclienteweberratum;
            ter[NombreCamposTercero.Aen_EsproveedorCRM]           = Aen_Esproveedor;
            ter[NombreCamposTercero.Aen_EssuscriptorCRM]          = Aen_Essuscriptor;
            ter[NombreCamposTercero.Aen_RevistaaenorCRM]          = Aen_Revistaaenor;
            //ter["statecodeCRM] = Statecode.Equals("Activo") ? false : true;
            //TODO Revisar tipo de los campos aen_EstadoXXX (Que viene de oracle, para saber a que/ como convertir)
            //if (!Aen_Estadoclienteerp.Equals(string.Empty)) ter[NombreCamposTercero.Aen_EstadoclienteerpCRM] = new OptionSetValue(Aen_Estadoclienteerp.Equals("Activo")? 1: 0);
            //if (!Aen_Estadoempleadoerp.Equals(string.Empty)) ter[NombreCamposTercero.Aen_EstadoempleadoerpCRM] = new OptionSetValue(Aen_Estadoclienteerp.Equals("Activo") ? 1 : 0);
            //if (!Aen_Estadoproveedorerp.Equals(string.Empty)) ter[NombreCamposTercero.Aen_EstadoproveedorerpCRM] = new OptionSetValue(Aen_Estadoclienteerp.Equals("Activo") ? 1 : 0);
            if (!Aen_Estadosolicitudclienteerp.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_EstadosolicitudclienteerpCRM] = new OptionSetValue(Convert.ToInt32(Aen_Estadosolicitudclienteerp));
            }
            if (!Aen_Estadosolicitudempleadoerp.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_EstadosolicitudempleadoerpCRM] = new OptionSetValue(Convert.ToInt32(Aen_Estadosolicitudempleadoerp));
            }
            if (!Aen_Estadosolicitudproveedorerp.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_EstadosolicitudproveedorerpCRM] = new OptionSetValue(Convert.ToInt32(Aen_Estadosolicitudproveedorerp));
            }
            if (!Aen_Facturacionaenor.Value.Equals(decimal.MinValue))
            {
                Money factu = new Money(Aen_Facturacionaenor.Value);
                ter[NombreCamposTercero.Aen_FacturacionaenorCRM]      = factu;
                ter[NombreCamposTercero.Aen_Facturacionaenor_BaseCRM] = factu;
            }
            if (!Fax.Equals(string.Empty))
            {
                ter[NombreCamposTercero.FaxCRM] = Fax;
            }
            if (!Aen_Fechadealta.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_FechadealtaCRM] = DateTime.ParseExact(Aen_Fechadealta, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
            }
            if (!Aen_Fechadebaja.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_FechadebajaCRM] = DateTime.ParseExact(Aen_Fechadebaja, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
            }
            if (!Aen_Identificadortercero.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_IdentificadorterceroCRM] = Aen_Identificadortercero;
            }
            if (!Aen_Clienteerpid.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_ClienteerpidCRM] = Aen_Clienteerpid;
            }
            if (!Aen_Empleadoerpid.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_EmpleadoerpidCRM] = Aen_Empleadoerpid;
            }
            if (!Aen_Proveedorerpid.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_ProveedorerpidCRM] = Aen_Proveedorerpid;
            }
            if (!Aen_Industriaaenor.Equals(Guid.Empty))
            {
                ter[NombreCamposTercero.Aen_IndustriaaenorCRM] = new EntityReference("aen_industriaaenor", Aen_Industriaaenor);
            }
            if (!Revenue.Equals(decimal.MinValue))
            {
                Money reven = new Money(Revenue);
                ter[NombreCamposTercero.RevenueCRM]      = reven;
                ter[NombreCamposTercero.Revenue_BaseCRM] = reven;
            }
            if (!Aen_loginempleado.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_loginempleadoCRM] = Aen_loginempleado;
            }
            if (!Aen_Nombredelcliente.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_NombredelclienteCRM] = Aen_Nombredelcliente;
            }
            if (!Name.Equals(string.Empty))
            {
                ter[NombreCamposTercero.NameCRM] = Name;
            }
            if (!Aen_Numerodocumento.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_NumerodocumentoCRM] = Aen_Numerodocumento;
            }
            if (!Aen_Observaciones.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_ObservacionesCRM] = Aen_Observaciones;
            }
            if (!Aen_Origen.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_OrigenCRM] = new OptionSetValue(Convert.ToInt32(Aen_Origen));
            }
            if (!Aen_Riesgopagoaxesor.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_RiesgopagoaxesorCRM] = new OptionSetValue(Convert.ToInt32(Aen_Riesgopagoaxesor));
            }
            if (!Aen_Sectoraenor.Equals(Guid.Empty))
            {
                ter[NombreCamposTercero.Aen_SectoraenorCRM] = new EntityReference("aen_sectoraenor", Aen_Sectoraenor);
            }
            if (!Aen_Genero.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_GeneroCRM] = new OptionSetValue(Convert.ToInt32(Aen_Genero));
            }
            if (!Aen_Siglas.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_SiglasCRM] = Aen_Siglas;
            }
            if (!Websiteurl.Equals(string.Empty))
            {
                ter[NombreCamposTercero.WebsiteurlCRM] = Websiteurl;
            }
            if (!Aen_Subtipodetercero.Equals(Guid.Empty))
            {
                ter[NombreCamposTercero.Aen_SubtipodeterceroCRM] = new EntityReference("aen_subtipotercero", Aen_Subtipodetercero);
            }
            if (!Telephone1.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Telephone1CRM] = Telephone1;
            }
            if (!Aen_Tipodocumento.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_TipodocumentoCRM] = new OptionSetValue(Convert.ToInt32(Aen_Tipodocumento));
            }
            if (!Aen_Tipopersona.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_TipopersonaCRM] = new OptionSetValue(Convert.ToInt32(Aen_Tipopersona));
            }
            if (!Aen_Tipoproveedor.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_TipoproveedorCRM] = new OptionSetValue(Convert.ToInt32(Aen_Tipoproveedor));
            }
            if (!Aen_Observacionesmigracion.Equals(string.Empty))
            {
                ter[NombreCamposTercero.Aen_ObservacionesmigracionCRM] = Aen_Observacionesmigracion;
            }
            if (!Numberofemployees.Equals(string.Empty))
            {
                ter[NombreCamposTercero.NumberofemployeesCRM] = Convert.ToInt32(Numberofemployees);
            }

            return(ter);
        }
예제 #2
0
        public bool Equals(IAccount other)
        {
            if (!AccountID.Equals(other.AccountID))
            {
                Error.AddMessage("Account " + UID + " AccountID: " + AccountID + " is not equal to other: " + other.AccountID);
                return(false);
            }

            if (!BirthCountry.Equals(other.BirthCountry))
            {
                Error.AddMessage("Account " + UID + " BirthCountry: " + BirthCountry + " is not equal to other: " + other.BirthCountry);
                return(false);
            }

            if (!Birthday.Equals(other.Birthday))
            {
                Error.AddMessage("Account " + UID + " Birthday: " + Birthday + " is not equal to other: " + other.Birthday);
                return(false);
            }

            if (!BirthPlace.Equals(other.BirthPlace))
            {
                Error.AddMessage("Account " + UID + " BirthPlace: " + BirthPlace + " is not equal to other: " + other.BirthPlace);
                return(false);
            }

            if (!City.Equals(other.City))
            {
                Error.AddMessage("Account " + UID + " City: " + City + " is not equal to other: " + other.City);
                return(false);
            }

            if (!Country.Equals(other.Country))
            {
                Error.AddMessage("Account " + UID + " Country: " + Country + " is not equal to other: " + other.Country);
                return(false);
            }

            if (!ExtraNames.Equals(other.ExtraNames))
            {
                Error.AddMessage("Account " + UID + " ExtraNames: " + ExtraNames + " is not equal to other: " + other.ExtraNames);
                return(false);
            }

            if (!Fax.Equals(other.Fax))
            {
                Error.AddMessage("Account " + UID + " Fax: " + Fax + " is not equal to other: " + other.Fax);
                return(false);
            }

            if (!Gender.Equals(other.Gender))
            {
                Error.AddMessage("Account " + UID + " Gender: " + Gender + " is not equal to other: " + other.Gender);
                return(false);
            }

            if (!GivenName.Equals(other.GivenName))
            {
                Error.AddMessage("Account " + UID + " GivenName: " + GivenName + " is not equal to other: " + other.GivenName);
                return(false);
            }

            if (!Group.Equals(other.Group))
            {
                Error.AddMessage("Account " + UID + " Group: " + Group + " is not equal to other: " + other.Group);
                return(false);
            }

            if (!HomePhone.Equals(other.HomePhone))
            {
                Error.AddMessage("Account " + UID + " HomePhone: " + HomePhone + " is not equal to other: " + other.HomePhone);
                return(false);
            }

            if (!HouseNumber.Equals(other.HouseNumber))
            {
                Error.AddMessage("Account " + UID + " HouseNumber: " + HouseNumber + " is not equal to other: " + other.HouseNumber);
                return(false);
            }

            if (!HouseNumberAdd.Equals(other.HouseNumberAdd))
            {
                Error.AddMessage("Account " + UID + " HouseNumberAdd: " + HouseNumberAdd + " is not equal to other: " + other.HouseNumberAdd);
                return(false);
            }

            if (!Initials.Equals(other.Initials))
            {
                Error.AddMessage("Account " + UID + " Initials: " + Initials + " is not equal to other: " + other.Initials);
                return(false);
            }

            if (!Mail.Equals(other.Mail))
            {
                Error.AddMessage("Account " + UID + " Mail: " + Mail + " is not equal to other: " + other.Mail);
                return(false);
            }

            if (!MailAlias.Equals(other.MailAlias))
            {
                Error.AddMessage("Account " + UID + " MailAlias: " + MailAlias + " is not equal to other: " + other.MailAlias);
                return(false);
            }

            if (!MobilePhone.Equals(other.MobilePhone))
            {
                Error.AddMessage("Account " + UID + " MobilePhone: " + MobilePhone + " is not equal to other: " + other.MobilePhone);
                return(false);
            }

            if (!PostalCode.Equals(other.PostalCode))
            {
                Error.AddMessage("Account " + UID + " PostalCode: " + PostalCode + " is not equal to other: " + other.PostalCode);
                return(false);
            }

            if (!RegisterID.Equals(other.RegisterID))
            {
                Error.AddMessage("Account " + UID + " RegisterID: " + RegisterID + " is not equal to other: " + other.RegisterID);
                return(false);
            }

            if (!Role.Equals(other.Role))
            {
                Error.AddMessage("Account " + UID + " Role: " + Role + " is not equal to other: " + other.Role);
                return(false);
            }

            if (!StemID.Equals(other.StemID))
            {
                Error.AddMessage("Account " + UID + " StemID: " + StemID + " is not equal to other: " + other.StemID);
                return(false);
            }

            if (!Street.Equals(other.Street))
            {
                Error.AddMessage("Account " + UID + " Street: " + Street + " is not equal to other: " + other.Street);
                return(false);
            }

            if (!SurName.Equals(other.SurName))
            {
                Error.AddMessage("Account " + UID + " SurName: " + SurName + " is not equal to other: " + other.SurName);
                return(false);
            }

            if (!UID.Equals(other.UID))
            {
                Error.AddMessage("Account " + UID + " UID: " + UID + " is not equal to other: " + other.UID);
                return(false);
            }

            if (!UntisID.Equals(other.UntisID))
            {
                Error.AddMessage("Account " + UID + " UntisID: " + UntisID + " is not equal to other: " + other.UntisID);
                return(false);
            }

            return(true);
        }
예제 #3
0
        private int count_nb_bytes()
        {
            /* All the ASCII strings in the VCard must be separated by 0x0D0A, which represent 2 characters */
            int NbBytes = 0;

            NbBytes  = "BEGIN:VCARD".Length + 2 + "VERSION:3.0".Length + 2;
            NbBytes += "FN:".Length + First_name.Length + 1 + Family_name.Length + 2;                           /* 1 is for "space"	*/

            if (!Nickname.Equals(""))
            {
                NbBytes += "NICKNAME:".Length + Nickname.Length + 2;
            }

            /* Birthday with 8 characters: yyyymmdd	*/
            DateTime dateBirthday;

            if ((!Birthday.Equals("")) && (DateTime.TryParse(Birthday, out dateBirthday)))
            {
                NbBytes += "BDAY:".Length + 8 + 2;
            }

            /* Home address in 6 fields, separated by a ';'						*/
            /* The PO Box is discarded, which explains the first ';'	*/
            if (!(Address1.Equals("")) ||
                !(Address2.Equals("")) ||
                !(Town.Equals("")) ||
                !(Region_State.Equals("")) ||
                !(Post_Code.Equals("")) ||
                !(Country.Equals(""))
                )
            {
                NbBytes += "ADR:;".Length
                           + Address1.Length + 1
                           + Address2.Length + 1
                           + Town.Length + 1
                           + Region_State.Length + 1
                           + Post_Code.Length + 1
                           + Country.Length + 2;
            }

            /* Work address in 6 fields, separated by a ';'						*/
            /* The PO Box is discarded, which explains the first ';'	*/
            if (!(Pro_Address1.Equals("")) ||
                !(Pro_Address2.Equals("")) ||
                !(Pro_Town.Equals("")) ||
                !(Pro_Region_State.Equals("")) ||
                !(Pro_Post_Code.Equals("")) ||
                !(Pro_Country.Equals(""))
                )
            {
                NbBytes += "ADR;TYPE=work:;".Length
                           + Pro_Address1.Length + 1
                           + Pro_Address2.Length + 1
                           + Pro_Town.Length + 1
                           + Pro_Region_State.Length + 1
                           + Pro_Post_Code.Length + 1
                           + Pro_Country.Length + 2;
            }

            if (!Home_phone.Equals(""))
            {
                NbBytes += "TEL;TYPE=home:".Length + Home_phone.Length + 2;
            }

            if (!Business_phone.Equals(""))
            {
                NbBytes += "TEL;TYPE=work:".Length + Business_phone.Length + 2;
            }

            if (!Cell_phone.Equals(""))
            {
                NbBytes += "TEL;TYPE=cell:".Length + Cell_phone.Length + 2;
            }

            if (!Fax.Equals(""))
            {
                NbBytes += "TEL;TYPE=fax:".Length + Fax.Length + 2;
            }

            if (!Pager.Equals(""))
            {
                NbBytes += "TEL;TYPE=pager:".Length + Pager.Length + 2;
            }

            if (!Email.Equals(""))
            {
                if (Email_alternative.Equals(""))
                {
                    NbBytes += "EMAIL:".Length + Email.Length + 2;
                }
                else
                {
                    /* TWO EMAILS : PREF=1 and PREF=2	*/
                    NbBytes += "EMAIL;PREF=1:".Length + Email.Length + 2 + "EMAIL;PREF=2:".Length + Email_alternative.Length + 2;
                }
            }

            if (!Title.Equals(""))
            {
                NbBytes += "TITLE:".Length + Title.Length + 2;
            }

            if (!Role.Equals(""))
            {
                NbBytes += "ROLE:".Length + Role.Length + 2;
            }

            if (!Company.Equals(""))
            {
                NbBytes += "ORG:".Length + Company.Length + 2;
            }

            if (!_photo.Equals(""))
            {
                NbBytes += "PHOTO;ENCODING=BASE64;TYPE=JPEG:".Length + _photo.Length + 2;
            }

            NbBytes += "END:VCARD".Length + 2;

            return(NbBytes);
        }
예제 #4
0
        public override bool Encode(ref byte[] buffer)
        {
            /* First : determine the total number of characters	*/
            int NbBytes = count_nb_bytes();

            /* Second : create the whole byte array                         */
            int index = 0;
            int new_index;

            byte[] pl = new byte[NbBytes];

            new_index = AddLine(pl, pl.Length, index, "BEGIN:VCARD", "");
            if (new_index < 0)
            {
                Trace.WriteLine("Error generating 'VCard' object: after 'BEGIN'");
                return(false);
            }
            index = new_index;

            new_index = AddLine(pl, pl.Length, index, "VERSION:3.0", "");
            if (new_index < 0)
            {
                Trace.WriteLine("Error generating 'VCard' object: after 'VERSION'");
                return(false);
            }
            index = new_index;

            string name = _first_name + " " + _family_name;

            new_index = AddLine(pl, pl.Length, index, "FN:", name);
            if (new_index < 0)
            {
                Trace.WriteLine("Error generating 'VCard' object: after 'FN'");
                return(false);
            }
            index = new_index;


            if (!Nickname.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "NICKNAME:", Nickname);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'Nickname'");
                    return(false);
                }
                index = new_index;
            }

            DateTime dateBirthday;

            if ((!Birthday.Equals("")) && (DateTime.TryParse(Birthday, out dateBirthday)))
            {
                string Bday = convert_into_vcard_date(Birthday);
                new_index = AddLine(pl, pl.Length, index, "BDAY:", Bday);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'Birthday'");
                    return(false);
                }
                index = new_index;
            }

            if (!(Address1.Equals("")) ||
                !(Address2.Equals("")) ||
                !(Town.Equals("")) ||
                !(Region_State.Equals("")) ||
                !(Post_Code.Equals("")) ||
                !(Country.Equals(""))
                )
            {
                string addr_line = Address1 + ";" + Address2 + ";" + Town + ";"
                                   + Region_State + ";" + Post_Code + ";" + Country;
                new_index = AddLine(pl, pl.Length, index, "ADR:;", addr_line);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'Address'");
                    return(false);
                }
                index = new_index;
            }

            if (!(Pro_Address1.Equals("")) ||
                !(Pro_Address2.Equals("")) ||
                !(Pro_Town.Equals("")) ||
                !(Pro_Region_State.Equals("")) ||
                !(Pro_Post_Code.Equals("")) ||
                !(Pro_Country.Equals(""))
                )
            {
                string pro_addr_line = Pro_Address1 + ";" + Pro_Address2 + ";" + Pro_Town + ";"
                                       + Pro_Region_State + ";" + Pro_Post_Code + ";" + Pro_Country;
                new_index = AddLine(pl, pl.Length, index, "ADR;TYPE=work:;", pro_addr_line);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'Professional Address'");
                    return(false);
                }
                index = new_index;
            }

            if (!Home_phone.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=home:", Home_phone);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=home'");
                    return(false);
                }
                index = new_index;
            }


            if (!Business_phone.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=work:", Business_phone);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=work'");
                    return(false);
                }
                index = new_index;
            }

            if (!Cell_phone.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=cell:", Cell_phone);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=cell'");
                    return(false);
                }
                index = new_index;
            }

            if (!Pager.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=pager:", Pager);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=pager'");
                    return(false);
                }
                index = new_index;
            }

            if (!Fax.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=fax:", Fax);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=fax'");
                    return(false);
                }
                index = new_index;
            }

            if (!Email.Equals(""))
            {
                if (Email_alternative.Equals(""))
                {
                    new_index = AddLine(pl, pl.Length, index, "EMAIL:", Email);
                    if (new_index < 0)
                    {
                        Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL'");
                        return(false);
                    }
                    index = new_index;
                }
                else
                {
                    /*	Two E-mails to add */
                    new_index = AddLine(pl, pl.Length, index, "EMAIL;PREF=1:", Email);
                    if (new_index < 0)
                    {
                        Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL;PREF=1'");
                        return(false);
                    }
                    index = new_index;

                    new_index = AddLine(pl, pl.Length, index, "EMAIL;PREF=2:", Email_alternative);
                    if (new_index < 0)
                    {
                        Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL;PREF=2'");
                        return(false);
                    }
                    index = new_index;
                }
            }

            if (!Title.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TITLE:", Title);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TITLE'");
                    return(false);
                }
                index = new_index;
            }

            if (!Role.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "ROLE:", Role);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'ROLE'");
                    return(false);
                }
                index = new_index;
            }

            if (!Company.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "ORG:", Company);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'ORG'");
                    return(false);
                }
                index = new_index;
            }

            if (!_photo.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "PHOTO;ENCODING=BASE64;TYPE=JPEG:", _photo);

                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'PHOTO'");
                    return(false);
                }

                index = new_index;
            }

            new_index = AddLine(pl, pl.Length, index, "END:VCARD", "");
            _payload  = pl;

            return(base.Encode(ref buffer));
        }
예제 #5
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);
        }