public CustomFieldBaseWrapper(CustomField customField)
     : base(customField.ID)
 {
     EntityId = customField.EntityID;
     Label = customField.Label;
     FieldValue = customField.Value;
     FieldType = customField.FieldType;
     Position = customField.Position;
     Mask = customField.Mask;
 }
예제 #2
0
 public void EditItem(CustomField customField)
 {
     if (HaveRelativeLink(customField.ID))
     {
         using (var db = GetDb())
         {
             db.ExecuteNonQuery(
                Update("crm_field_description")
                .Set("label", customField.Label)
                .Where(Exp.Eq("id", customField.ID)));
         }
     }
     else
     {
         var resultMask = GetValidMask(customField.FieldType, customField.Mask);
         using (var db = GetDb())
         {
             db.ExecuteNonQuery(
                Update("crm_field_description")
                .Set("label", customField.Label)
                .Set("type", (int)customField.FieldType)
                .Set("mask", resultMask)
                .Where(Exp.Eq("id", customField.ID)));
         }
     }
 }
 private CustomFieldWrapper ToCustomFieldWrapper(CustomField customField)
 {
     var result = new CustomFieldWrapper(customField);
     result.RelativeItemsCount = DaoFactory.GetCustomFieldDao().GetContactLinkCount(customField.EntityType, customField.ID);
     return result;
 }
 private CustomFieldBaseWrapper ToCustomFieldBaseWrapper(CustomField customField)
 {
     return new CustomFieldBaseWrapper(customField);
 }
        public CustomFieldWrapper UpdateCustomFieldValue(
            int id,
            String entityType,
            String label,
            int fieldType,
            int position,
            String mask)
        {

            if (id <= 0)
                throw new ArgumentException();

             if (!DaoFactory.GetCustomFieldDao().IsExist(id))
                 throw new ItemNotFoundException();


            var customField = new CustomField
                                  {
                                      EntityType = ToEntityType(entityType),
                                      FieldType = (CustomFieldType)fieldType,
                                      ID = id,
                                      Mask = mask,
                                      Label = label,
                                      Position = position
                                  };


            DaoFactory.GetCustomFieldDao().EditItem(customField);


            return ToCustomFieldWrapper(DaoFactory.GetCustomFieldDao().GetFieldDescription(id));

        }
예제 #6
0
        public void EditItem(CustomField customField)
        {
            if (HaveRelativeLink(customField.ID))
            {
                using (var db = GetDb())
                {
                    try
                    {
                        var resultMask = "";

                        var row = db.ExecuteList(Query("crm_field_description")
                        .Where(Exp.Eq("id", customField.ID))
                        .Select("type", "mask")).FirstOrDefault();

                        var fieldType = (CustomFieldType)Convert.ToInt32(row[0]);
                        var oldMask = Convert.ToString(row[1]);

                        if (fieldType == CustomFieldType.SelectBox)
                        {
                            if (oldMask == customField.Mask || customField.Mask == "")
                            {
                                resultMask = oldMask;
                            }
                            else
                            {
                                var maskObjOld = JToken.Parse(oldMask);
                                var maskObjNew =JToken.Parse(customField.Mask);

                                if (!(maskObjOld is JArray && maskObjNew is JArray))
                                {
                                    throw new ArgumentException("Mask is not valid");
                                }
                                var inm = (((JArray)maskObjNew).ToList()).Intersect(((JArray)maskObjOld).ToList()).ToList();
                                if (inm.Count == ((JArray)maskObjOld).ToList().Count)
                                {
                                    resultMask = customField.Mask;
                                }
                                else
                                { 
                                    throw new ArgumentException("Mask is not valid");
                                }
                            }
                        }
                        else
                        {
                            resultMask = GetValidMask(fieldType, customField.Mask);
                        }

                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

                    db.ExecuteNonQuery(
                       Update("crm_field_description")
                       .Set("label", customField.Label)
                       .Set("mask", customField.Mask)
                       .Where(Exp.Eq("id", customField.ID)));
                }
            }
            else
            {
                var resultMask = GetValidMask(customField.FieldType, customField.Mask);
                using (var db = GetDb())
                {
                    db.ExecuteNonQuery(
                       Update("crm_field_description")
                       .Set("label", customField.Label)
                       .Set("type", (int)customField.FieldType)
                       .Set("mask", resultMask)
                       .Where(Exp.Eq("id", customField.ID)));
                }
            }
        }
         public CustomFieldWrapper(CustomField customField)
            : base(customField)
        {

         }
예제 #8
0
        public void EditItem(CustomField customField)
        {

            if (HaveRelativeLink(customField.ID))
                throw new ArgumentException();

            DbManager.ExecuteNonQuery(
                Update("crm_field_description")
                .Set("label", customField.Label)
                .Set("type", (int)customField.FieldType)
                .Set("mask", customField.Mask)
                .Where(Exp.Eq("id", customField.ID)));
        }
        public CustomFieldWrapper UpdateCustomFieldValue(int id, string entityType, string label, int fieldType, int position, string mask)
        {
            if (id <= 0) throw new ArgumentException();
            if (!DaoFactory.GetCustomFieldDao().IsExist(id)) throw new ItemNotFoundException();

            var entityTypeObj = ToEntityType(entityType);

            var customField = new CustomField
                {
                    EntityType = entityTypeObj,
                    FieldType = (CustomFieldType)fieldType,
                    ID = id,
                    Mask = mask,
                    Label = label,
                    Position = position
                };

            DaoFactory.GetCustomFieldDao().EditItem(customField);

            var wrapper = ToCustomFieldWrapper(DaoFactory.GetCustomFieldDao().GetFieldDescription(id));

            var messageAction = GetCustomFieldUpdatedAction(entityTypeObj);
            MessageService.Send(_context, messageAction, wrapper.Label);

            return wrapper;
        }