public static ContactInfo Insert(string sessionId, Contact jsonObject)
        {
            if (PrimaveraEngine.InitializeCompany() == false)
            {
                throw new DatabaseConnectionException();
            }

            var contactInfo   = new CrmBEContacto();
            var contactId     = PrimaveraEngine.GenerateName(jsonObject.Nome);
            var contactsTable = PrimaveraEngine.Engine.CRM.Contactos;

            if (contactsTable.Existe(contactId))
            {
                throw new EntityExistsException("contacto", false);
            }

            contactInfo.set_Contacto(contactId);
            contactInfo.set_CriadoPor(sessionId);
            contactInfo.set_DataUltContacto(DateTime.Now);
            contactInfo.set_ID(PrimaveraEngine.generateGUID());
            SetFields(contactInfo, jsonObject);
            contactsTable.Actualiza(contactInfo);

            return(GenerateContact(contactInfo));
        }
示例#2
0
        public static ActivityInfo Insert(string sessionId, Activity jsonObject)
        {
            if (PrimaveraEngine.InitializeCompany() == false)
            {
                throw new DatabaseConnectionException();
            }

            var activityInfo    = new CrmBEActividade();
            var activityId      = PrimaveraEngine.generateGUID();
            var activitiesTable = PrimaveraEngine.Engine.CRM.Actividades;

            if (activitiesTable.Existe(activityId))
            {
                throw new EntityExistsException("actividade", true);
            }

            activityInfo.set_ID(activityId);
            activityInfo.set_Estado("0");
            activityInfo.set_CriadoPor(sessionId);
            activityInfo.set_DataCriacao(DateTime.Now);
            activityInfo.set_DataUltAct(DateTime.Now);
            SetFields(activityInfo, jsonObject);
            activityInfo = activitiesTable.PreencheDadosRelacionados(activityInfo);
            activitiesTable.Actualiza(activityInfo);

            return(GenerateActivity(activityInfo));
        }