protected void CorrectNameValue(FormFieldsData formFieldsData)
        {
            var editedColumn = NameValueCorrector.GetCorrectNameValue(formFieldsData.name, formFieldsData.value);

            formFieldsData.name  = editedColumn.Key;
            formFieldsData.value = editedColumn.Value;
        }
Ejemplo n.º 2
0
        protected Guid SetUpNewEntityId(FormData formData)
        {
            Guid           entityId = Guid.NewGuid();
            var            values   = formData.formFieldsData.ToList();
            FormFieldsData idData   = values.FirstOrDefault(field => field.name.ToLower().Equals("id"));

            if (idData == null)
            {
                idData = new FormFieldsData {
                    name  = "Id",
                    value = entityId.ToString()
                };
                values.Add(idData);
            }
            else
            {
                if (idData.value.IsValidGuid())
                {
                    entityId = Guid.Parse(idData.value);
                }
                else
                {
                    idData.value = entityId.ToString();
                }
            }
            formData.formFieldsData = values.ToArray();
            return(entityId);
        }
        /// <summary>
        /// Creates and returns new field for form fields data.
        /// </summary>
        /// <param name="columnName">Column name to create</param>
        /// <returns>Created column</returns>
        private FormFieldsData CreateField(string columnName)
        {
            var field = new FormFieldsData {
                name = columnName
            };

            return(field);
        }
Ejemplo n.º 4
0
        protected virtual void CreateContactEntity(Guid contactId, FormFieldsData contactNameField)
        {
            EntitySchema contactSchema = _userConnection.EntitySchemaManager.GetInstanceByName(ContactSchemaName);
            Entity       contact       = contactSchema.CreateEntity(_userConnection);

            contact.SetDefColumnValues();
            contact.SetColumnValue("Id", contactId);
            contact.SetColumnValue("Name", contactNameField.value);
            contact.Save(false);
        }
        protected void CorrectGeographicalColumns(FormFieldsData formFieldsData)
        {
            if (!WebFormHelper.IsGeographicalColumn(formFieldsData.name))
            {
                return;
            }
            var column = WebFormHelper.GetGeographicalUnitColumn(formFieldsData.name,
                                                                 formFieldsData.value,
                                                                 UserConnection);

            formFieldsData.name  = column.Key;
            formFieldsData.value = column.Value;
        }
Ejemplo n.º 6
0
        protected void ProcessGeneratedWebFormField(FormData formData)
        {
            Guid webFormId;

            if (Guid.TryParse(formData.formId, out webFormId))
            {
                if (CheckGeneratedWebFormExists(webFormId))
                {
                    FormFieldsData webFormIdField = GetWebFormIdField() ?? CreateWebFormIdField();
                    webFormIdField.value = webFormId.ToString();
                    _fieldsData.Add(webFormIdField);
                }
            }
        }
Ejemplo n.º 7
0
        protected void ProcessContactField()
        {
            Guid           contactId      = Guid.NewGuid();
            FormFieldsData contactIdField = GetContactIdField();

            if (contactIdField != null && contactIdField.value.IsValidGuid())
            {
                contactId = Guid.Parse(contactIdField.value);
            }
            if (!CheckContactExists(contactId))
            {
                FormFieldsData contactNameField = GetContactNameField();
                if (contactNameField == null || contactNameField.value.IsNullOrEmpty())
                {
                    return;
                }
                if (contactIdField == null)
                {
                    CreateContactIdField(contactId);
                }
                _fieldsData.Add(contactIdField);
                CreateContactEntity(contactId, contactNameField);
            }
        }
Ejemplo n.º 8
0
 private void SetEntityColumnValue(Entity linkedEntity, EntitySchemaColumn linkedEntityColumn, FormFieldsData columnValue)
 {
     if (linkedEntityColumn.IsLookupType)
     {
         Guid idValue = WebFormHelper.GetItemIdFromDictionary(linkedEntityColumn.ReferenceSchema.Name,
                                                              columnValue.value, _userConnection);
         if (!idValue.Equals(Guid.Empty))
         {
             linkedEntity.SetColumnValue(linkedEntityColumn, idValue);
         }
     }
     else
     {
         linkedEntity.SetColumnValue(linkedEntityColumn, columnValue.value);
     }
 }