コード例 #1
0
ファイル: Generales.cs プロジェクト: jsantise/Formulario
        public static EntityCollection TraerCarreraTecnica()
        {
            ServicioCRM_modulo   conect   = new ServicioCRM_modulo();
            IOrganizationService _Service = conect.ObtenerOrganization();
            ColumnSet            col      = new ColumnSet(true);

            ConditionExpression condicion2 = new ConditionExpression();

            condicion2.AttributeName = "statecode";
            condicion2.Operator      = ConditionOperator.Equal;
            condicion2.Values.Add(0);

            ConditionExpression condicion4 = new ConditionExpression();

            condicion4.AttributeName = "new_niveldeformacion";
            condicion4.Operator      = ConditionOperator.Equal;
            condicion4.Values.Add("0");

            FilterExpression filtro = new FilterExpression();

            filtro.AddCondition(condicion2);
            filtro.AddCondition(condicion4);

            QueryExpression query = new QueryExpression();

            query.EntityName = "new_carrera";
            query.Criteria   = filtro;
            query.ColumnSet  = col;
            query.AddOrder("new_name", OrderType.Ascending);

            return(_Service.RetrieveMultiple(query));
        }
コード例 #2
0
ファイル: Generales.cs プロジェクト: jsantise/Formulario
        public static EntityCollection TraerCarreraVesp()
        {
            ServicioCRM_modulo   conect   = new ServicioCRM_modulo();
            IOrganizationService _Service = conect.ObtenerOrganization();
            ColumnSet            col      = new ColumnSet(true);

            ConditionExpression condicion2 = new ConditionExpression();

            condicion2.AttributeName = "statecode";
            condicion2.Operator      = ConditionOperator.Equal;
            condicion2.Values.Add(0);

            string jornadaid = "8878451A-4D44-E611-80C1-000C299AB360"; //Jornada Vespertina produccion

            ConditionExpression condicion3 = new ConditionExpression();

            condicion3.AttributeName = "new_jornadaid";
            condicion3.Operator      = ConditionOperator.Equal;
            condicion3.Values.Add(jornadaid);

            //MOSTRAR SOLO LAS CARRERAS PROFESIONALES EN VESPERTINO

            /* ConditionExpression condicion4 = new ConditionExpression();
             * condicion4.AttributeName = "new_niveldeformacion";
             * condicion4.Operator = ConditionOperator.Equal;
             * condicion4.Values.Add("1"); */

            FilterExpression filtro = new FilterExpression();

            filtro.AddCondition(condicion2);
            filtro.AddCondition(condicion3);
            //filtro.AddCondition(condicion4);

            QueryExpression query = new QueryExpression();

            query.EntityName = "new_carrera";
            query.Criteria   = filtro;
            query.ColumnSet  = col;
            query.AddOrder("new_name", OrderType.Ascending);

            return(_Service.RetrieveMultiple(query));
        }
コード例 #3
0
ファイル: Generales.cs プロジェクト: jsantise/Formulario
        public static void Contacto(string rut, string nombre, string apellidos, string email, string telefono, string carreraid, string mensaje)
        {
            try
            {
                ServicioCRM_modulo   conect   = new ServicioCRM_modulo();
                IOrganizationService _Service = conect.ObtenerOrganization();
                Entity Contacto = new Entity("contact");
                Entity cWeb     = new Entity("new_prepostulacion");

                bool existe = false;

                //Busca en los prospectos
                Entity contacto = BuscaRutPorTipoProspecto(rut, 0, _Service);

                if (contacto == null)
                {
                    //Busca en los contactos
                    contacto = BuscaRutPorContactos(rut, _Service);

                    if (contacto == null)
                    {
                        existe   = false;
                        contacto = new Entity("contact");
                    }
                    else
                    {
                        existe = true;
                    }
                }
                else
                {
                    existe = true;
                }

                if (!existe)
                {
                    if (rut != null && rut.Trim() != "")
                    {
                        Contacto.Attributes["new_rut"] = rut.ToString();
                    }
                }

                if (nombre != null && nombre.Trim() != "")
                {
                    Contacto.Attributes["firstname"] = nombre.ToString();
                }
                if (apellidos != null && apellidos.Trim() != "")
                {
                    Contacto.Attributes["lastname"] = apellidos.ToString();
                }

                if (email != null && email.Trim() != "")
                {
                    Contacto.Attributes["emailaddress1"] = email.ToString();
                }
                if (telefono != null && telefono.Trim() != "")
                {
                    Contacto.Attributes["mobilephone"] = telefono.ToString();
                }



                if (carreraid != null && carreraid.Trim() != "")
                {
                    Contacto.Attributes["cmtxucen_preferenciacarrera1id"] = new EntityReference("new_carrera", new Guid(carreraid));
                }


                //SE DECLARA LA VARIABLE PERIODO AL COMIENZO DEL METODO

                Entity periodoid = Periodo("2018-1", _Service);
                Contacto.Attributes["cmtxucen_periodoid"] = new EntityReference(periodoid.LogicalName, periodoid.Id);


                if (mensaje != null && mensaje.Trim() != "")
                {
                    Contacto.Attributes["description"] = mensaje.ToString();
                }

                Entity prospecto  = OrigenProspecto("Formulario de contacto web", _Service);
                Guid   ContactoId = new Guid();
                if (!existe)
                {
                    Contacto.Attributes["cmtxucen_leadsourcecode"] = new EntityReference(prospecto.LogicalName, prospecto.Id);
                    ContactoId = _Service.Create(Contacto);
                }
                else
                {
                    Contacto.Id = contacto.Id;
                    _Service.Update(Contacto);
                    ContactoId = Contacto.Id;
                }


                #region CREAR PREPOSTULACIÓN (CONSULTA WEB)

                if (!existe)
                {
                    if (rut != null && rut.Trim() != "")
                    {
                        cWeb.Attributes["new_rut"] = rut.ToString();
                    }

                    if (nombre != null && nombre.Trim() != "")
                    {
                        cWeb.Attributes["new_nombres"] = nombre.ToString();
                    }
                    if (apellidos != null && apellidos.Trim() != "")
                    {
                        cWeb.Attributes["new_apellidopaterno"] = apellidos.ToString();
                    }

                    if (email != null && email.Trim() != "")
                    {
                        cWeb.Attributes["new_correoelectronico"] = email.ToString();
                    }
                    if (telefono != null && telefono.Trim() != "")
                    {
                        cWeb.Attributes["new_telefonomovil"] = telefono.ToString();
                    }

                    if (carreraid != null && carreraid.Trim() != "")
                    {
                        cWeb.Attributes["new_carrera1"] = new EntityReference("new_carrera", new Guid(carreraid));
                    }

                    if (mensaje != null && mensaje.Trim() != "")
                    {
                        cWeb.Attributes["new_consulta"] = mensaje.ToString();
                    }

                    if (!String.IsNullOrEmpty(nombre) && !String.IsNullOrEmpty(apellidos))
                    {
                        cWeb.Attributes["subject"] = "Prospecto WEB " + nombre.ToString() + " " + apellidos.ToString();
                    }

                    cWeb.Attributes["regardingobjectid"] = new EntityReference(Contacto.LogicalName, ContactoId);

                    _Service.Create(cWeb);

                    //CREAR ACTIVIDAD DE IMPACTO
                    Entity actim = new Entity("cmtxucen_actividadimpacto");

                    actim.Attributes["regardingobjectid"]           = new EntityReference(Contacto.LogicalName, ContactoId);
                    actim.Attributes["cmtxucen_actividaddeimpacto"] = new EntityReference(prospecto.LogicalName, prospecto.Id);
                    actim.Attributes["subject"]   = "Prospecto WEB " + nombre.ToString() + " " + apellidos.ToString();
                    actim.Attributes["statecode"] = 1;
                    actim.Attributes["statecode"] = 2;

                    _Service.Create(actim);
                }
                else
                {
                    if (rut != null && rut.Trim() != "")
                    {
                        cWeb.Attributes["new_rut"] = rut.ToString();
                    }

                    if (nombre != null && nombre.Trim() != "")
                    {
                        cWeb.Attributes["new_nombres"] = nombre.ToString();
                    }
                    if (apellidos != null && apellidos.Trim() != "")
                    {
                        cWeb.Attributes["new_apellidopaterno"] = apellidos.ToString();
                    }

                    if (email != null && email.Trim() != "")
                    {
                        cWeb.Attributes["new_correoelectronico"] = email.ToString();
                    }
                    if (telefono != null && telefono.Trim() != "")
                    {
                        cWeb.Attributes["new_telefonomovil"] = telefono.ToString();
                    }

                    if (carreraid != null && carreraid.Trim() != "")
                    {
                        cWeb.Attributes["new_carrera1"] = new EntityReference("new_carrera", new Guid(carreraid));
                    }

                    if (mensaje != null && mensaje.Trim() != "")
                    {
                        cWeb.Attributes["new_consulta"] = mensaje.ToString();
                    }

                    if (!String.IsNullOrEmpty(nombre) && !String.IsNullOrEmpty(apellidos))
                    {
                        cWeb.Attributes["subject"] = "Prospecto WEB " + nombre.ToString() + " " + apellidos.ToString();
                    }

                    cWeb.Attributes["regardingobjectid"] = new EntityReference(Contacto.LogicalName, ContactoId);

                    _Service.Create(cWeb);

                    //CREAR ACTIVIDAD DE IMPACTO
                    Entity actim = new Entity("cmtxucen_actividadimpacto");

                    actim.Attributes["regardingobjectid"]           = new EntityReference(Contacto.LogicalName, ContactoId);
                    actim.Attributes["cmtxucen_actividaddeimpacto"] = new EntityReference(prospecto.LogicalName, prospecto.Id);
                    actim.Attributes["subject"]   = "Prospecto WEB " + nombre.ToString() + " " + apellidos.ToString();
                    actim.Attributes["statecode"] = 1;
                    actim.Attributes["statecode"] = 2;

                    _Service.Create(actim);
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
        }