Exemple #1
0
        public static bool Delete(string fieldName, int templateId)
        {
            if (GetFieldInfoByFieldName(templateId, fieldName).FieldLevel == 0)
            {
                return(false);
            }
            XmlManage manage   = XmlManage.Instance(ModelTemplate.GetField(templateId), XmlType.Content);
            string    nodeName = "/ArrayOfFieldInfo/FieldInfo[@Id=\"" + fieldName.ToLower() + "\"]";

            manage.Remove(nodeName);
            return(ModelTemplate.UpdateField(templateId, manage.Xml));
        }
Exemple #2
0
        public static bool Add(ModelInfo modelInfo, int modelTemplateId, ModelType type)
        {
            bool flag = false;

            if ((modelTemplateId == 0) && (type == ModelType.Content))
            {
                modelInfo.Field = AddDefaultField();
            }
            else
            {
                modelInfo.Field = ModelTemplate.GetField(modelTemplateId);
            }
            if (type == ModelType.Shop)
            {
                CreateCommonListPageTemplate(modelInfo, true);
            }
            if (dal.Add(modelInfo))
            {
                flag = true;
                if (modelTemplateId != 0)
                {
                    List <FieldInfo> list = new Serialize <FieldInfo>().DeserializeFieldList(modelInfo.Field);
                    if (list != null)
                    {
                        list.Sort(new FieldInfoComparer());
                    }
                    foreach (FieldInfo info in list)
                    {
                        if (info.FieldLevel != 0)
                        {
                            dal.AddFieldToTable(info, modelInfo.TableName);
                        }
                        if (info.FieldType == FieldType.ContentType)
                        {
                            FieldInfo fieldInfo = new FieldInfo();
                            fieldInfo.FieldName  = info.Settings[2];
                            fieldInfo.FieldType  = FieldType.ContentType;
                            fieldInfo.FieldLevel = 1;
                            AddTableField(fieldInfo, modelInfo.ModelId);
                            FieldInfo info3 = new FieldInfo();
                            info3.FieldName  = info.Settings[5];
                            info3.FieldType  = FieldType.ContentType;
                            info3.FieldLevel = 1;
                            AddTableField(info3, modelInfo.ModelId);
                        }
                    }
                }
            }
            RemoveCache();
            return(flag);
        }
Exemple #3
0
        public static FieldInfo GetFieldInfoByFieldName(int templateId, string fieldName)
        {
            string    str2 = XmlManage.Instance(ModelTemplate.GetField(templateId), XmlType.Content).SelectNode("/ArrayOfFieldInfo/FieldInfo[@Id=\"" + fieldName.ToLower() + "\"]");
            FieldInfo info = null;

            if (!string.IsNullOrEmpty(str2))
            {
                TextReader    textReader = new StringReader(str2);
                XmlSerializer serializer = new XmlSerializer(typeof(FieldInfo));
                info = (FieldInfo)serializer.Deserialize(textReader);
                textReader.Close();
            }
            return(info);
        }