Esempio n. 1
0
        private static Field MapField(FieldModel apiField)
        {
            if (apiField.Type.Equals("image"))
            {
                var value = (JObject)apiField.Value;

                return new ImageField(apiField.Key,
                    apiField.Type,
                    apiField.Id,
                    value["Alt"].Value<string>(),
                    value["Url"].Value<string>());
            }

            if (apiField.Type.Equals("general link"))
            {
                var value = (JObject)apiField.Value;

                return new LinkField(apiField.Key,
                    apiField.Type,
                    apiField.Id, value["Description"].Value<string>(),
                    value["TargetUrl"].Value<string>(),
                    Guid.Parse(value["TargetId"].Value<string>()));
            }

            return new Field(apiField.Key, apiField.Key, apiField.Id, apiField.Value as string);
        }
Esempio n. 2
0
        public Field(Tile[] tiles, int fieldSize)
        {
            Contract.Requires(tiles != null);
            Contract.Requires(tiles.Length == fieldSize * fieldSize);
            Contract.Requires(fieldSize > 2);

            _fieldSize = fieldSize;
            _model = new FieldModel<Tile>(tiles, fieldSize);
        }
        public static FieldBinding CreateBindingField(FieldModel fieldModel, string fieldName = null, TrackerContext context = null, MainForm owner = null)
        {
            if (fieldModel is StringFieldModel)
            {
                StringFieldModel strModel = fieldModel as StringFieldModel;
                return new TextBoxBinding(new TextBox(), readOnly: fieldModel.ReadOnly, nullable: fieldModel.Nullable, longText: strModel.LongText);
            }
            else if (fieldModel is DateTimeFieldModel)
            {
                DateTimePicker picker = new DateTimePicker();

                if (fieldName != null && fieldName.Contains("_gte"))
                    picker.Value = picker.MinDate;
                else
                    picker.Value = DateTime.Now;

                return new DateTimePickerBinding(picker, readOnly: fieldModel.ReadOnly, nullable: fieldModel.Nullable);
            }
            else if (fieldModel is BooleanFieldModel)
                return new CheckBoxBinding(new CheckBox(), readOnly: fieldModel.ReadOnly);
            else if (fieldModel is EnumFieldModel)
                return new ComboBoxBinding(new ComboBox(), fieldModel.FieldType, readOnly: fieldModel.ReadOnly);
            else if (fieldModel is MoneyFieldModel)
                return new MoneyFieldBinding(new TextBox(), readOnly: fieldModel.ReadOnly, allowNull: fieldModel.Nullable);
            else if (fieldModel is EntityFieldModel)
            {
                EntityFieldModel entityField = fieldModel as EntityFieldModel;
                EntitySelector selector = new EntitySelector()
                {
                    Owner = owner,
                    UseSelectionCache = DonationModels.IsCachingEntity(entityField.ModelName),
                };
                if (context != null)
                    selector.Initialize(context, entityField.ModelName);
                else
                    throw new Exception("Error, trying to create entity selector without context");
                return new EntitySelectorBinding(selector);
            }
            else
                throw new Exception("Unknown model type");
        }
 private static bool IsLargeField(FieldModel fieldModel)
 {
     if (fieldModel is StringFieldModel)
     {
         return (fieldModel as StringFieldModel).LongText;
     }
     else
     {
         return false;
     }
 }
Esempio n. 5
0
        private SiteContentEditModel Transform(DynamicSiteContent site)
        {
            var type = App.SiteTypes.GetById(site.TypeId);

            var model = new SiteContentEditModel
            {
                Id        = site.Id,
                TypeId    = site.TypeId,
                Title     = site.Title,
                UseBlocks = false
            };

            foreach (var regionType in type.Regions)
            {
                var region = new RegionModel
                {
                    Meta = new RegionMeta
                    {
                        Id           = regionType.Id,
                        Name         = regionType.Title,
                        Description  = regionType.Description,
                        Placeholder  = regionType.ListTitlePlaceholder,
                        IsCollection = regionType.Collection,
                        Expanded     = regionType.ListExpand,
                        Icon         = regionType.Icon,
                        Display      = regionType.Display.ToString().ToLower()
                    }
                };
                var regionListModel = ((IDictionary <string, object>)site.Regions)[regionType.Id];

                if (!regionType.Collection)
                {
                    var regionModel = (IRegionList)Activator.CreateInstance(typeof(RegionList <>).MakeGenericType(regionListModel.GetType()));
                    regionModel.Add(regionListModel);
                    regionListModel = regionModel;
                }

                foreach (var regionModel in (IEnumerable)regionListModel)
                {
                    var regionItem = new RegionItemModel();

                    foreach (var fieldType in regionType.Fields)
                    {
                        var appFieldType = App.Fields.GetByType(fieldType.Type);

                        var field = new FieldModel
                        {
                            Meta = new FieldMeta
                            {
                                Id          = fieldType.Id,
                                Name        = fieldType.Title,
                                Component   = appFieldType.Component,
                                Placeholder = fieldType.Placeholder,
                                IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth),
                                Description = fieldType.Description
                            }
                        };

                        if (typeof(SelectFieldBase).IsAssignableFrom(appFieldType.Type))
                        {
                            foreach (var item in ((SelectFieldBase)Activator.CreateInstance(appFieldType.Type)).Items)
                            {
                                field.Meta.Options.Add(Convert.ToInt32(item.Value), item.Title);
                            }
                        }

                        if (regionType.Fields.Count > 1)
                        {
                            field.Model = (IField)((IDictionary <string, object>)regionModel)[fieldType.Id];

                            if (regionType.ListTitleField == fieldType.Id)
                            {
                                regionItem.Title        = field.Model.GetTitle();
                                field.Meta.NotifyChange = true;
                            }
                        }
                        else
                        {
                            field.Model             = (IField)regionModel;
                            field.Meta.NotifyChange = true;
                            regionItem.Title        = field.Model.GetTitle();
                        }
                        regionItem.Fields.Add(field);
                    }

                    if (string.IsNullOrWhiteSpace(regionItem.Title))
                    {
                        regionItem.Title = "...";
                    }

                    region.Items.Add(regionItem);
                }
                model.Regions.Add(region);
            }
            return(model);
        }
Esempio n. 6
0
        public ActionResult UpdateCompanyForAreaCode(RequestData data)
        {
            string levelId  = data.Get("LevelId");
            string areaCode = data.Get("areaCode");
            bool   isCheck  = bool.Parse(data.Get("isCheck"));
            string entGuid  = data.Get("entGuid");
            string peakId   = data.Get("peakId");

            if (!string.IsNullOrEmpty(areaCode))
            {
                string[] arrayArea = areaCode.Split(',');
                for (int i = 0; i < arrayArea.Length; i++)
                {
                    arrayArea[i] = "'" + arrayArea[i] + "'";
                }
                areaCode = string.Join(",", arrayArea);
            }


            /*思路: 根据等级和区域获取相关企业
             *       获取企业关联表ent
             *       遍历企业表
             *       如果check为false就删除
             *       查找关联表如果表中不存在相关企业进行插入
             */
            T_THEPEAK_ENT_SUB_LISTModel modelEnt = new T_THEPEAK_ENT_SUB_LISTModel();

            modelEnt.GUID = entGuid;

            FieldModel where = null;
            where           &= T_THEPEAK_LEVEL_CONFIG.PEAK_LEVE_ID == levelId;
            if (!string.IsNullOrEmpty(areaCode))
            {
                where &= T_BASE_COMPANY.AREA.In(areaCode);
            }


            var dynmaicSql2 = SqlModel.SelectAll(
                T_SYS_AREA.AREA_TEXT.As("AREA_TEXT")
                , T_SYS_AREA.AREA_CODE
                // , T_BASE_COMPANY.ID.As("T_COMPANY_ID")
                , T_THEPEAK_LEVEL_LIST_INFO.ID.As("LEVEL_ID")
                , T_THEPEAK_LEVEL_CONFIG.IS_STOP
                , T_THEPEAK_LEVEL_CONFIG.LIMIT_TYPE
                , T_THEPEAK_LEVEL_CONFIG.PEAK_LEVE_ID
                )
                              .From(DB.T_BASE_COMPANY)
                              .LeftJoin(DB.T_SYS_AREA).On(T_BASE_COMPANY.AREA == T_SYS_AREA.AREA_CODE)
                              .LeftJoin(DB.T_THEPEAK_LEVEL_CONFIG).On(T_THEPEAK_LEVEL_CONFIG.COMPANY_ID == T_BASE_COMPANY.ID)
                              .LeftJoin(DB.T_THEPEAK_LEVEL_LIST_INFO).On(T_THEPEAK_LEVEL_LIST_INFO.ID == T_THEPEAK_LEVEL_CONFIG.PEAK_LEVE_ID)
                              // .LeftJoin(DB.T_THEPEAK_ENT_SUB_LIST).On(T_THEPEAK_ENT_SUB_LIST.COMPANY_ID == T_BASE_COMPANY.ID & T_THEPEAK_LEVEL_LIST_INFO.ID == T_THEPEAK_ENT_SUB_LIST.LEVEL_ID)
                              .Where(where);


            var dynmaicSql = SqlModel.SelectAll(
                T_SYS_AREA.AREA_TEXT.As("AREA_TEXT")
                , T_SYS_AREA.AREA_CODE
                // , T_BASE_COMPANY.ID.As("T_COMPANY_ID")
                , T_THEPEAK_LEVEL_LIST_INFO.ID.As("LEVEL_ID")
                , T_THEPEAK_LEVEL_CONFIG.IS_STOP
                , T_THEPEAK_LEVEL_CONFIG.LIMIT_TYPE
                , T_THEPEAK_LEVEL_CONFIG.PEAK_LEVE_ID
                )
                             .From(DB.T_BASE_COMPANY)
                             .LeftJoin(DB.T_SYS_AREA).On(T_BASE_COMPANY.AREA == T_SYS_AREA.AREA_CODE)
                             .LeftJoin(DB.T_THEPEAK_LEVEL_CONFIG).On(T_THEPEAK_LEVEL_CONFIG.COMPANY_ID == T_BASE_COMPANY.ID)
                             .LeftJoin(DB.T_THEPEAK_LEVEL_LIST_INFO).On(T_THEPEAK_LEVEL_LIST_INFO.ID == T_THEPEAK_LEVEL_CONFIG.PEAK_LEVE_ID)
                             // .LeftJoin(DB.T_THEPEAK_ENT_SUB_LIST).On(T_THEPEAK_ENT_SUB_LIST.COMPANY_ID == T_BASE_COMPANY.ID & T_THEPEAK_LEVEL_LIST_INFO.ID == T_THEPEAK_ENT_SUB_LIST.LEVEL_ID)
                             .Where(where).ExecToDynamicList();

            //var configEnt = SqlModel.SelectAll().From(DB.T_THEPEAK_ENT_SUB_LIST).Where(T_THEPEAK_ENT_SUB_LIST.LEVEL_ID == decimal.Parse(levelId)& T_THEPEAK_ENT_SUB_LIST.GUID== entGuid).ExecToDynamicList();

            if (!isCheck)
            {
                //删除
                dynmaicSql.ForEach(
                    m => {
                    modelEnt           = new T_THEPEAK_ENT_SUB_LISTModel();
                    modelEnt.IS_SELECT = 0;
                    modelEnt.Update(T_THEPEAK_ENT_SUB_LIST.COMPANY_ID == m["ID"] & T_THEPEAK_ENT_SUB_LIST.LEVEL_ID == m["LEVEL_ID"] & T_THEPEAK_ENT_SUB_LIST.GUID == entGuid);
                }); //&modelEnt.GUID== entGuid
            }
            else
            {
                //往企业关系表插入值
                dynmaicSql.ForEach(
                    m =>
                {
                    modelEnt.IS_SELECT = 1;
                    modelEnt.Update(T_THEPEAK_ENT_SUB_LIST.COMPANY_ID == m["ID"] & T_THEPEAK_ENT_SUB_LIST.LEVEL_ID == m["LEVEL_ID"] & T_THEPEAK_ENT_SUB_LIST.GUID == entGuid);
                });
            }



            return(Json(dynmaicSql));
        }
Esempio n. 7
0
 public override IRuntimeField CreateRuntimeField(FieldModel fieldModel)
 {
     return(new FLOAT32RuntimeField(fieldModel));
 }
Esempio n. 8
0
        private PageEditModel Transform(DynamicPage page, bool isDraft)
        {
            var config = new Config(_api);
            var type   = App.PageTypes.GetById(page.TypeId);
            var route  = type.Routes.FirstOrDefault(r => r.Route == page.Route) ?? type.Routes.FirstOrDefault();

            var model = new PageEditModel
            {
                Id                     = page.Id,
                SiteId                 = page.SiteId,
                ParentId               = page.ParentId,
                OriginalId             = page.OriginalPageId,
                SortOrder              = page.SortOrder,
                TypeId                 = page.TypeId,
                Title                  = page.Title,
                NavigationTitle        = page.NavigationTitle,
                Slug                   = page.Slug,
                MetaTitle              = page.MetaTitle,
                MetaKeywords           = page.MetaKeywords,
                MetaDescription        = page.MetaDescription,
                MetaIndex              = page.MetaIndex,
                MetaFollow             = page.MetaFollow,
                MetaPriority           = page.MetaPriority,
                OgTitle                = page.OgTitle,
                OgDescription          = page.OgDescription,
                OgImage                = page.OgImage,
                PrimaryImage           = page.PrimaryImage,
                Excerpt                = page.Excerpt,
                IsHidden               = page.IsHidden,
                IsScheduled            = page.Published.HasValue && page.Published.Value > DateTime.Now,
                Published              = page.Published.HasValue ? page.Published.Value.ToString("yyyy-MM-dd") : null,
                PublishedTime          = page.Published.HasValue ? page.Published.Value.ToString("HH:mm") : null,
                RedirectUrl            = page.RedirectUrl,
                RedirectType           = page.RedirectType.ToString(),
                EnableComments         = page.EnableComments,
                CloseCommentsAfterDays = page.CloseCommentsAfterDays,
                CommentCount           = page.CommentCount,
                State                  = page.GetState(isDraft),
                UseBlocks              = type.UseBlocks,
                UsePrimaryImage        = type.UsePrimaryImage,
                UseExcerpt             = type.UseExcerpt,
                UseHtmlExcerpt         = config.HtmlExcerpt,
                SelectedRoute          = route == null ? null : new RouteModel
                {
                    Title = route.Title,
                    Route = route.Route
                },
                Permissions = App.Permissions
                              .GetPublicPermissions()
                              .Select(p => new KeyValuePair <string, string>(p.Name, p.Title))
                              .ToList(),
                SelectedPermissions = page.Permissions
            };

            foreach (var r in type.Routes)
            {
                model.Routes.Add(new RouteModel {
                    Title = r.Title,
                    Route = r.Route
                });
            }

            foreach (var regionType in type.Regions)
            {
                var region = new RegionModel
                {
                    Meta = new RegionMeta
                    {
                        Id           = regionType.Id,
                        Name         = regionType.Title,
                        Description  = regionType.Description,
                        Placeholder  = regionType.ListTitlePlaceholder,
                        IsCollection = regionType.Collection,
                        Expanded     = regionType.ListExpand,
                        Icon         = regionType.Icon,
                        Display      = regionType.Display.ToString().ToLower(),
                        Width        = regionType.Width.ToString().ToLower()
                    }
                };
                var regionListModel = ((IDictionary <string, object>)page.Regions)[regionType.Id];

                if (!regionType.Collection)
                {
                    var regionModel = (IRegionList)Activator.CreateInstance(typeof(RegionList <>).MakeGenericType(regionListModel.GetType()));
                    regionModel.Add(regionListModel);
                    regionListModel = regionModel;
                }

                foreach (var regionModel in (IEnumerable)regionListModel)
                {
                    var regionItem = new RegionItemModel();

                    foreach (var fieldType in regionType.Fields)
                    {
                        var appFieldType = App.Fields.GetByType(fieldType.Type);

                        var field = new FieldModel
                        {
                            Meta = new FieldMeta
                            {
                                Id          = fieldType.Id,
                                Name        = fieldType.Title,
                                Component   = appFieldType.Component,
                                Placeholder = fieldType.Placeholder,
                                IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth),
                                Description = fieldType.Description,
                                Settings    = fieldType.Settings
                            }
                        };

                        if (typeof(SelectFieldBase).IsAssignableFrom(appFieldType.Type))
                        {
                            foreach (var item in ((SelectFieldBase)Activator.CreateInstance(appFieldType.Type)).Items)
                            {
                                field.Meta.Options.Add(Convert.ToInt32(item.Value), item.Title);
                            }
                        }

                        if (regionType.Fields.Count > 1)
                        {
                            field.Model = (IField)((IDictionary <string, object>)regionModel)[fieldType.Id];

                            if (regionType.ListTitleField == fieldType.Id)
                            {
                                regionItem.Title        = field.Model.GetTitle();
                                field.Meta.NotifyChange = true;
                            }
                        }
                        else
                        {
                            field.Model             = (IField)regionModel;
                            field.Meta.NotifyChange = true;
                            regionItem.Title        = field.Model.GetTitle();
                        }
                        regionItem.Fields.Add(field);
                    }

                    if (string.IsNullOrWhiteSpace(regionItem.Title))
                    {
                        regionItem.Title = "...";
                    }

                    region.Items.Add(regionItem);
                }
                model.Regions.Add(region);
            }

            foreach (var block in page.Blocks)
            {
                var blockType = App.Blocks.GetByType(block.Type);

                if (block is BlockGroup)
                {
                    var group = new BlockGroupModel
                    {
                        Id   = block.Id,
                        Type = block.Type,
                        Meta = new BlockMeta
                        {
                            Name        = blockType.Name,
                            Icon        = blockType.Icon,
                            Component   = blockType.Component,
                            Width       = blockType.Width.ToString().ToLower(),
                            IsGroup     = true,
                            IsReadonly  = page.OriginalPageId.HasValue,
                            isCollapsed = config.ManagerDefaultCollapsedBlocks,
                            ShowHeader  = !config.ManagerDefaultCollapsedBlockGroupHeaders
                        }
                    };

                    group.Fields = ContentUtils.GetBlockFields(block);

                    bool firstChild = true;
                    foreach (var child in ((BlockGroup)block).Items)
                    {
                        blockType = App.Blocks.GetByType(child.Type);

                        if (!blockType.IsGeneric)
                        {
                            // Regular block item model
                            group.Items.Add(new BlockItemModel
                            {
                                IsActive = firstChild,
                                Model    = child,
                                Meta     = new BlockMeta
                                {
                                    Name      = blockType.Name,
                                    Title     = child.GetTitle(),
                                    Icon      = blockType.Icon,
                                    Component = blockType.Component,
                                    Width     = blockType.Width.ToString().ToLower()
                                }
                            });
                        }
                        else
                        {
                            // Generic block item model
                            group.Items.Add(new BlockGenericModel
                            {
                                Id       = child.Id,
                                IsActive = firstChild,
                                Model    = ContentUtils.GetBlockFields(child),
                                Type     = child.Type,
                                Meta     = new BlockMeta
                                {
                                    Name      = blockType.Name,
                                    Title     = child.GetTitle(),
                                    Icon      = blockType.Icon,
                                    Component = blockType.Component,
                                    Width     = blockType.Width.ToString().ToLower()
                                }
                            });
                        }
                        firstChild = false;
                    }
                    model.Blocks.Add(group);
                }
                else
                {
                    if (!blockType.IsGeneric)
                    {
                        // Regular block item model
                        model.Blocks.Add(new BlockItemModel
                        {
                            Model = block,
                            Meta  = new BlockMeta
                            {
                                Name        = blockType.Name,
                                Title       = block.GetTitle(),
                                Icon        = blockType.Icon,
                                Component   = blockType.Component,
                                Width       = blockType.Width.ToString().ToLower(),
                                IsReadonly  = page.OriginalPageId.HasValue,
                                isCollapsed = config.ManagerDefaultCollapsedBlocks
                            }
                        });
                    }
                    else
                    {
                        // Generic block item model
                        model.Blocks.Add(new BlockGenericModel
                        {
                            Id    = block.Id,
                            Model = ContentUtils.GetBlockFields(block),
                            Type  = block.Type,
                            Meta  = new BlockMeta
                            {
                                Name        = blockType.Name,
                                Title       = block.GetTitle(),
                                Icon        = blockType.Icon,
                                Component   = blockType.Component,
                                Width       = blockType.Width.ToString().ToLower(),
                                IsReadonly  = page.OriginalPageId.HasValue,
                                isCollapsed = config.ManagerDefaultCollapsedBlocks
                            }
                        });
                    }
                }
            }

            // Custom editors
            foreach (var editor in type.CustomEditors)
            {
                model.Editors.Add(new EditorModel
                {
                    Component = editor.Component,
                    Icon      = editor.Icon,
                    Name      = editor.Title
                });
            }
            return(model);
        }
Esempio n. 9
0
 public abstract override IRuntimeField CreateRuntimeField(FieldModel fieldModel);
Esempio n. 10
0
        public ActionResult FieldSetting(long formId, FieldModel item, byte?oldRepeatLimit)
        {
            item.ParentID = formId;

            FormModel form = FormDAO.GetItem(formId);

            if (!string.IsNullOrWhiteSpace(item.Template))
            {
                ResourceFilesModels fileModel = JsonConvert.DeserializeObject <ResourceFilesModels>(item.Template);
                if (fileModel.Id == 0)   // 新上傳的檔案
                {
                    HttpPostedFileBase postedFile = Request.Files["fTemplate"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.Template = string.Empty;
                    }
                    else
                    {
                        item.Template = Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, (long)form.SiteID, formDesignFileDir);
                    }
                }
                else
                {
                    item.Template = fileModel.FileInfo;
                }
            }

            if (!string.IsNullOrWhiteSpace(item.Image))
            {
                ResourceImagesModels imgModel = JsonConvert.DeserializeObject <ResourceImagesModels>(item.Image);
                if (imgModel.ID == 0)   // 新上傳的圖片
                {
                    HttpPostedFileBase postedFile = Request.Files["fImage"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.Image = string.Empty;
                    }
                    else
                    {
                        item.Image = Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, (long)form.SiteID, formDesignFileDir);
                    }
                }
                else
                {
                    item.Image = imgModel.Img;
                }
            }

            if (!string.IsNullOrWhiteSpace(item.VideoCustomPhoto))
            {
                ResourceImagesModels imgModel = JsonConvert.DeserializeObject <ResourceImagesModels>(item.VideoCustomPhoto);
                if (imgModel.ID == 0)
                { // 新上傳的圖片
                    HttpPostedFileBase postedFile = Request.Files["youtubeCustomImg"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.VideoCustomPhoto = string.Empty;
                    }
                    else
                    {
                        item.VideoCustomPhoto = Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, (long)form.SiteID, formDesignFileDir);
                    }
                }
                else
                {
                    item.VideoCustomPhoto = imgModel.Img;
                }
            }

            FieldDAO.SetItem(item);

            ViewBag.UploadUrl    = Golbal.UpdFileInfo.GetVPathBySiteID((long)form.SiteID, formDesignFileDir).TrimEnd('/');
            ViewBag.SiteID       = form.SiteID;
            ViewBag.MenuID       = form.SourceID;
            ViewBag.FormID       = formId;
            ViewBag.CustomFolder = formDesignFileDir;
            ViewBag.Exit         = true;
            if (item.TypeID == "input" && oldRepeatLimit == (byte)FieldRepeatLimit.可任意報名 && item.RepeatLimit != (byte)FieldRepeatLimit.可任意報名)
            {
                ViewBag.IsFirst = true;
            }

            return(View($"Field{ item.TypeID }", item));
        }
Esempio n. 11
0
        public static DataTable GetDTFromMVC(DataTable dt, HttpRequest req, bool flag = true)
        {
            B_ModelField mfieldBll = new B_ModelField();

            dt.DefaultView.RowFilter = "IsCopy <>-1";
            dt = dt.DefaultView.ToTable();
            DataTable table = new DataTable();

            table.Columns.Add(new DataColumn("FieldName", typeof(string)));
            table.Columns.Add(new DataColumn("FieldType", typeof(string)));
            table.Columns.Add(new DataColumn("FieldValue", typeof(string)));
            table.Columns.Add(new DataColumn("FieldAlias", typeof(string)));
            foreach (DataRow dr in dt.Rows)
            {
                DataRow fdr = table.NewRow();
                try
                {
                    fdr[0] = dr["FieldName"].ToString();
                    fdr[1] = dr["FieldType"].ToString();
                    fdr[3] = DataConverter.CStr(dr["FieldAlias"]);
                    if (dr["FieldType"].ToString() == "DoubleDateType")
                    {
                        DateTime ti1 = DataConverter.CDate(req.Form["txt" + dr["FieldName"].ToString()]);
                        DateTime ti2 = DataConverter.CDate(req.Form["txt_" + dr["FieldName"].ToString()]);
                        fdr[2] = ti1.ToShortDateString() + "|" + ti2.ToShortDateString();
                    }
                    else
                    {
                        if (DataConverter.CBool(dr["IsNotNull"].ToString()) && flag)
                        {
                            if (string.IsNullOrEmpty(req.Form["txt_" + dr["FieldName"].ToString()]))
                            {
                                throw new Exception("[" + dr["FieldAlias"] + "]不能为空!");
                            }
                        }
                        string[] Sett = dr["Content"].ToString().Split(new char[] { ',' });
                        switch (dr["FieldType"].ToString())
                        {
                        case "FileType":    //其与MultiPicType一样,都是读页面上的隐藏控件,而非<select>中的值,存在一个隐藏字段中
                            #region
                            //ChkFileSize=0,FileSizeField=,MaxFileSize=1024,UploadFileExt=rar|zip|docx|pdf:::是否保存文件大小,保存在大小的字段名,文件上传限制,上传后缀名限制
                            bool   chksize   = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]);
                            string sizefield = Sett[1].Split(new char[] { '=' })[1];
                            //if (chksize && sizefield != "")
                            //{
                            //    fdr[0] = sizefield;
                            //    fdr[1] = "FileSize";
                            //    fdr[2] = req.Form["txt_" + sizefield];
                            //    fdr[3] = dr["FieldAlias"];
                            //}
                            //信息由JS控制放置入txt_中
                            fdr[2] = req.Form["txt_" + dr["FieldName"]];
                            #endregion
                            break;

                        case "MultiPicType":
                            #region
                            //ChkThumb=0,ThumbField=,Warter=0,MaxPicSize=1024,PicFileExt=jpg|png|gif|bmp|jpeg:::是否保存缩略图地址,缩略点路径,水印,大小,后缀名限制
                            bool   chkthumb   = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]);
                            string ThumbField = Sett[1].Split(new char[] { '=' })[1];
                            if (chkthumb && ThumbField != "")    //存储缩图
                            {
                                DataRow row2 = table.NewRow();
                                if (DataConverter.CBool(dr["IsNotNull"].ToString()) && string.IsNullOrEmpty(req.Form["txt_" + ThumbField]))
                                {
                                    throw new Exception(dr["FieldAlias"].ToString() + "的缩略图不能为空!");
                                }
                                row2[0] = ThumbField;
                                row2[1] = "ThumbField";
                                row2[2] = req.Form["txt_" + ThumbField];
                                row2[3] = dr["FieldAlias"];
                                table.Rows.Add(row2);
                            }
                            {
                                fdr[0] = dr["FieldName"];
                                fdr[1] = "MultiPicType";
                                fdr[2] = req.Form["txt_" + dr["FieldName"]];
                                fdr[3] = dr["FieldAlias"];
                            }
                            #endregion
                            break;

                        case "TableField":    //库选字段
                            string tableval = req.Form["txt_" + dr["FieldName"].ToString()];
                            if (!string.IsNullOrEmpty(tableval))
                            {
                                string[] temparr = tableval.Split(',');
                                tableval = string.Join("$", temparr);
                            }
                            fdr[2] = tableval;
                            break;

                        case "NumType":
                            #region
                            double value = DataConverter.CDouble(string.IsNullOrEmpty(GetParam(req, "txt_" + dr["FieldName"])) ? "0" : GetParam(req, "txt_" + dr["FieldName"]));   //避免空字符串报错
                            //TitleSize=35,NumberType=1,DefaultValue=50,NumSearchType=0,NumRangType=1,NumSearchRang=0-100,NumLenght=0
                            string[] conArr    = dr["Content"].ToString().Split(',');
                            string   NumLenght = "f" + conArr[6].Split('=')[1]; //小数点位数
                            if (conArr[4].Split('=')[1].Equals("1"))            //指定了上限与下限检测,则检测
                            {
                                string range = conArr[5].Split('=')[1];
                                if (!string.IsNullOrEmpty(range) && range.Split('-').Length == 2)    //范围不为空,并正确填了值,才做判断
                                {
                                    double minValue = Convert.ToDouble(range.Split('-')[0]);
                                    double maxValue = Convert.ToDouble(range.Split('-')[1]);
                                    if (value < minValue || value > maxValue)
                                    {
                                        throw new Exception(dr["FieldAlias"] + ":的值不正确,必须大于" + minValue + ",并且小于" + maxValue);
                                    }
                                }
                            }
                            fdr[2] = value.ToString(NumLenght);
                            #endregion
                            break;

                        case "Images":    //组图
                            fdr[2] = (GetParam(req, "txt_" + dr["FieldName"].ToString()) ?? "").Trim(',');
                            break;

                        case "CameraType":
                            fdr[2] = req.Form[dr["FieldName"] + "_hid"].ToString();
                            break;

                        case "SqlType":    //文件入库,图片入库,,,图片与文件base64存数据库,一个单独字段标识其
                        {
                            fdr[2] = req.Form["FIT_" + dr["FieldName"]];
                        }
                        break;

                        case "SqlFile":
                        {
                            fdr[2] = req.Form["FIT_" + dr["FieldName"]];
                        }
                        break;

                        case "MapType":
                        {
                            fdr[2] = req.Form["txt_" + dr["FieldName"].ToString()];
                        }
                        break;

                        case "autothumb":
                        {
                            FieldModel fieldMod = new FieldModel(dr["Content"].ToString());
                            string     thumb    = req.Form["txt_" + dr["FieldName"].ToString()];
                            string     topimg   = req.Form["ThumImg_Hid"];
                            //如thumb为空,但topimg不为空,则生成缩图
                            fdr[0] = dr["FieldName"].ToString();
                            fdr[1] = "auththumb";
                            fdr[2] = "";
                        }
                        break;

                        case "api_qq_mvs":
                        {
                            fdr[2] = req.Form["UpMvs_" + dr["FieldName"].ToString()];
                        }
                        break;

                        case "PicType":
                        {
                            string fvalue = DataConverter.CStr(req.Form[dr["FieldName"] + "_t"]);
                            fdr[2] = fvalue.Replace(SiteConfig.SiteOption.UploadDir, "");
                        }
                        break;

                        default:
                            #region
                        {
                            string fvalue = req.Form["txt_" + dr["FieldName"].ToString()];
                            switch (dr["FieldType"].ToString())
                            {
                            //case "Random":
                            //    fvalue = req.Form["txt_" + dr["FieldName"].ToString()];
                            //    break;
                            case "MapType":
                                //fvalue =;
                                break;

                            case "Charts":
                                fvalue = "0";
                                break;

                            case "SqlType":
                                fvalue = "";
                                break;

                            case "SqlFile":
                                fvalue = "";
                                break;
                            }
                            fdr[2] = fvalue;
                        }
                            #endregion
                            break;
                        } //for end;
                    }     //else end;
                }
                catch (Exception ex)
                {
                    if (!ex.Message.Contains("正在中止线程"))
                    {
                        throw new Exception("[" + dr["FieldAlias"] + "][" + dr["FieldName"] + "(" + dr["FieldType"] + ")],原因:" + ex.Message);
                    }
                }
                fdr[2] = StringHelper.Strip_Script(DataConverter.CStr(fdr[2]));
                table.Rows.Add(fdr);
            }//for end;
            return(table);
        }
        private SearchModel BuildSearchModel()
        {
            var model           = new SearchModel();
            var assetNameFilter = new FieldModel
            {
                DisplayOrder    = 1,
                Name            = "AssetName",
                ResourceKey     = "Asset.Name",
                DbColumn        = "Asset.Name",
                Value           = null,
                ControlType     = FieldControlType.TextBox,
                DataType        = FieldDataType.String,
                DataSource      = FieldDataSource.None,
                IsRequiredField = false
            };

            model.Filters.Add(assetNameFilter);

            var siteFilter = new FieldModel
            {
                DisplayOrder    = 2,
                Name            = "Site",
                ResourceKey     = "Site",
                DbColumn        = "Site.Id",
                Value           = this._workContext.CurrentUser.DefaultSiteId,
                ControlType     = FieldControlType.DropDownList,
                DataType        = FieldDataType.Int64,
                DataSource      = FieldDataSource.MVC,
                MvcController   = "Site",
                MvcAction       = "SiteList",
                IsRequiredField = false
            };

            model.Filters.Add(siteFilter);

            var assetTypeFilter = new FieldModel
            {
                DisplayOrder    = 3,
                Name            = "AssetType",
                ResourceKey     = "Asset.AssetType",
                DbColumn        = "AssetType.Id",
                Value           = null,
                ControlType     = FieldControlType.DropDownList,
                DataType        = FieldDataType.Int64,
                DataSource      = FieldDataSource.MVC,
                MvcController   = "Common",
                MvcAction       = "ValueItems",
                AdditionalField = "category",
                AdditionalValue = "Asset Type",
                IsRequiredField = false
            };

            model.Filters.Add(assetTypeFilter);

            var assetStatusFilter = new FieldModel
            {
                DisplayOrder    = 4,
                Name            = "AssetStatus",
                ResourceKey     = "Asset.AssetStatus",
                DbColumn        = "AssetStatus.Id",
                Value           = null,
                ControlType     = FieldControlType.DropDownList,
                DataType        = FieldDataType.Int64,
                DataSource      = FieldDataSource.MVC,
                MvcController   = "Common",
                MvcAction       = "ValueItems",
                AdditionalField = "category",
                AdditionalValue = "Asset Status",
                IsRequiredField = false
            };

            model.Filters.Add(assetStatusFilter);

            var assetCategoryFilter = new FieldModel
            {
                DisplayOrder    = 5,
                Name            = "AssetCategory",
                ResourceKey     = "AssetCategory",
                DbColumn        = "AssetCategory.Id",
                Value           = null,
                ControlType     = FieldControlType.DropDownList,
                DataType        = FieldDataType.Int64,
                DataSource      = FieldDataSource.MVC,
                MvcController   = "Common",
                MvcAction       = "ValueItems",
                AdditionalField = "category",
                AdditionalValue = "Asset Category",
                IsRequiredField = false
            };

            model.Filters.Add(assetCategoryFilter);

            return(model);
        }
Esempio n. 13
0
 public override IRuntimeField CreateRuntimeField(FieldModel fieldModel)
 {
     return(new UFIXED16RuntimeField(fieldModel));
 }
        private static string GenerateScalarField(FieldModel field, TypeModel type)
        {
            var name = TypeUtilities.PascalCase(field.Name);

            return($"        {TypeUtilities.GetCSharpReturnType(type)} {name} {{ get; }}");
        }
Esempio n. 15
0
        /// <summary>
        /// Create a single field from an item field
        /// </summary>
        /// <param name="field"></param>
        /// <param name="levels"></param>
        /// <returns></returns>
        private FieldModel CreateField(ItemField field, int levels)
        {
            if (levels-- < 0)
            {
                return(null);
            }

            var type = TypeMap[field.GetType()];

            var fieldModel = new FieldModel(field.Name, type);

            switch (type)
            {
            case FieldTypes.Text:
                var textField = (TextField)field;
                fieldModel.StringValues = textField.Values;
                break;

            case FieldTypes.Number:
                var numberField = (NumberField)field;
                fieldModel.NumberValues = numberField.Values;
                break;

            case FieldTypes.Date:
                var dateField = (DateField)field;
                fieldModel.DateTimeValues = dateField.Values;
                break;

            case FieldTypes.Keyword:
                var keywordField = (KeywordField)field;
                fieldModel.KeywordValues = keywordField.Values.Select(x => new KeywordModel
                {
                    TcmUri     = x.Id,
                    Key        = x.Key,
                    Title      = x.Title,
                    SchemaName = x.MetadataSchema != null
                                                                                                    ? x.MetadataSchema.Title
                                                                                                    : null,
                    Metadata =
                        MapItemFields(x.Metadata, x.MetadataSchema, levels)
                });
                break;

            case FieldTypes.Embedded:
                var embeddedField = (EmbeddedSchemaField)field;
                fieldModel.EmbeddedValues = embeddedField.Values.Select(x => MapItemFields(x, levels));
                break;

            case FieldTypes.Link:
                var linkField = (ComponentLinkField)field;
                fieldModel.ComponentLinkValues = linkField.Values.Select(x => new ComponentModel
                {
                    TcmUri     = x.Id,
                    Title      = x.Title,
                    SchemaName = x.Schema.Title,
                    Content    = MapItemFields(x.Content, x.Schema, levels),
                    Metadata   =
                        MapItemFields(x.Metadata, x.MetadataSchema, levels),
                    BinaryUrl = x.BinaryContent != null
                                                                                                      ? x.PublishBinary(_engine, _package)
                                                                                                      : null
                });
                break;

            default:
                return(null);
            }

            return(fieldModel);
        }
Esempio n. 16
0
 public abstract int GetSize(FieldModel fieldModel);
Esempio n. 17
0
 public abstract IRuntimeField CreateRuntimeField(FieldModel fieldModel);
Esempio n. 18
0
        //
        // GET: /Bas/SmsTemplate/

        protected override SqlModel GetSqlModel(RequestData data)
        {
            FieldModel where = null;
            string SMSTEMPTYPE = data.Get("TEMPTYPE").Trim();

            if (SMSTEMPTYPE != "")
            {
                where &= SMSTEMPLATE.SMSTEMPTYPE == SMSTEMPTYPE;
            }

            DateTime dtNow   = DateTime.Now;
            DateTime tmStart = new DateTime(dtNow.Year, dtNow.Month, 1);
            DateTime tmEnd   = dtNow.Date;

            if (!string.IsNullOrEmpty(data.Get("opBegDate")))
            {
                DateTime.TryParse(data.Get("opBegDate"), out tmStart);
            }
            if (!string.IsNullOrEmpty(data.Get("opEndDate")))
            {
                DateTime.TryParse(data.Get("opEndDate"), out tmEnd);
            }

            tmEnd  = tmEnd.AddHours(23).AddMinutes(59).AddSeconds(59);
            where &= SMSLOG.SENDTIME.BetweenAnd(tmStart, tmEnd);

            SqlModel sqlmode = SqlModel.SelectAll(
                BASDIC.TITLE.As("SMSTEMPTYPE_TEXT"),
                "u".Field(BASUSER.TRUENAME).ListAgg("u".Field(BASUSER.TRUENAME).ToChar(), ',').As("USERNAME_TEXT")
                )
                               .From(DB.SMSLOG)
                               .LeftJoin(DB.BASDIC).On(SMSLOG.SMSTEMPTYPE == BASDIC.CODE & BASDIC.TYPECODE == "SMSTEMPTYPE")
                               .LeftJoin(DB.BASUSER.As("u")).On(SMSLOG.RECEIVEUSER.Instr("u".Field(BASUSER.MOBILE).ToChar(), ','))
                               .Where(where).OrderByDesc(SMSLOG.SENDTIME)
                               .GroupBy(
                SMSLOG.ID,
                SMSLOG.CONTENT,
                SMSLOG.STATUS,
                SMSLOG.SENDTIME,
                SMSLOG.RECEIVEUSER,
                SMSLOG.SMSTEMPTYPE,
                SMSLOG.SMSBASTYPE,
                BASDIC.TITLE,
                "u".Field(BASUSER.TRUENAME)
                );

            if (!string.IsNullOrEmpty(data.Get("USERNAME_TEXT")))
            {
                FieldModel field = new FieldModel();
                field.Name      = "SEND_PERSON_TEXT";
                field.TableName = "t";

                sqlmode = SqlModel.Select(new FieldModel[] {
                    new FieldModel()
                    {
                        Name = SMSLOG.ID.Name, TableName = "t"
                    },
                    new FieldModel()
                    {
                        Name = SMSLOG.CONTENT.Name, TableName = "t"
                    },
                    new FieldModel()
                    {
                        Name = SMSLOG.STATUS.Name, TableName = "t"
                    },
                    new FieldModel()
                    {
                        Name = SMSLOG.SENDTIME.Name, TableName = "t"
                    },
                    new FieldModel()
                    {
                        Name = SMSLOG.RECEIVEUSER.Name, TableName = "t"
                    },
                    new FieldModel()
                    {
                        Name = SMSLOG.SMSTEMPTYPE.Name, TableName = "t"
                    },
                    new FieldModel()
                    {
                        Name = "USERNAME_TEXT", TableName = "t"
                    }
                }).From(sqlmode.As("t")).Where(field.Like(data.Get("USERNAME_TEXT")));
            }

            return(sqlmode);
        }
        private SearchModel BuildSearchModel()
        {
            var model        = new SearchModel();
            var numberFilter = new FieldModel
            {
                DisplayOrder    = 1,
                Name            = "Number",
                ResourceKey     = "Common.Number",
                DbColumn        = "PurchaseRequest.Number, PurchaseRequest.Description",
                Value           = null,
                ControlType     = FieldControlType.TextBox,
                DataType        = FieldDataType.String,
                DataSource      = FieldDataSource.None,
                IsRequiredField = false
            };

            model.Filters.Add(numberFilter);

            var siteFilter = new FieldModel
            {
                DisplayOrder    = 2,
                Name            = "Site",
                ResourceKey     = "Site",
                DbColumn        = "Site.Id",
                Value           = this._workContext.CurrentUser.DefaultSiteId,
                ControlType     = FieldControlType.DropDownList,
                DataType        = FieldDataType.Int64,
                DataSource      = FieldDataSource.MVC,
                MvcController   = "Site",
                MvcAction       = "SiteList",
                IsRequiredField = false
            };

            model.Filters.Add(siteFilter);

            var priorityFilter = new FieldModel
            {
                DisplayOrder    = 3,
                Name            = "Priority",
                ResourceKey     = "Priority",
                DbColumn        = "PurchaseRequest.Priority",
                Value           = null,
                ControlType     = FieldControlType.DropDownList,
                DataType        = FieldDataType.Int32,
                DataSource      = FieldDataSource.CSV,
                CsvTextList     = "Urgent,High,Medium,Low",
                CsvValueList    = "0,1,2,3",
                IsRequiredField = false
            };

            model.Filters.Add(priorityFilter);

            var statusFilter = new FieldModel
            {
                DisplayOrder    = 4,
                Name            = "Status",
                ResourceKey     = "Common.Status",
                DbColumn        = "Assignment.Name",
                Value           = null,
                ControlType     = FieldControlType.MultiSelectList,
                DataType        = FieldDataType.String,
                DataSource      = FieldDataSource.CSV,
                CsvTextList     = "Open,WaitingForApproval,Approved,Rejected",
                CsvValueList    = "Open,WaitingForApproval,Approved,Rejected",
                IsRequiredField = false
            };

            model.Filters.Add(statusFilter);

            var dateRequiredFromFilter = new FieldModel
            {
                DisplayOrder    = 5,
                Name            = "DateRequiredFrom",
                ResourceKey     = "PurchaseRequest.DateRequiredFrom",
                DbColumn        = "PurchaseRequest.DateRequired",
                Value           = null,
                ControlType     = FieldControlType.DateTime,
                DataType        = FieldDataType.DateTime,
                DataSource      = FieldDataSource.None,
                IsRequiredField = false
            };

            model.Filters.Add(dateRequiredFromFilter);

            var dateRequiredToFilter = new FieldModel
            {
                DisplayOrder    = 6,
                Name            = "DateRequiredTo",
                ResourceKey     = "PurchaseRequest.DateRequiredTo",
                DbColumn        = "PurchaseRequest.DateRequired",
                Value           = null,
                ControlType     = FieldControlType.DateTime,
                DataType        = FieldDataType.DateTime,
                DataSource      = FieldDataSource.None,
                IsRequiredField = false
            };

            model.Filters.Add(dateRequiredToFilter);

            return(model);
        }
Esempio n. 20
0
        public void SendWarmingEmails()
        {
            try
            {
                LogFile.AddMessage("Start: Warming Blast Service on " + DateTime.Now.ToString());

                #region Get Warming email table fields
                List <FieldModel> lstField = new List <FieldModel>();
                DataTable         dtfield  = new DataTable();
                dtfield = DAL.GetWarmingEmailField();
                if (dtfield != null && dtfield.Rows.Count > 0)
                {
                    foreach (DataRow row in dtfield.Rows)
                    {
                        FieldModel model = new FieldModel();
                        model.Id        = SafeValue <int>(row["ID"]);
                        model.FieldName = SafeValue <string>(row["FieldName"]);
                        model.FieldType = SafeValue <string>(row["FieldType"]);
                        lstField.Add(model);
                    }
                }
                #endregion

                #region Get Account details for sending email in a loop
                List <EmailAccountDetails> lstAcDetails = new List <EmailAccountDetails>();
                DataTable dtlstAcDetails = new DataTable();
                dtlstAcDetails = DAL.GetAccountDetails();
                if (dtlstAcDetails != null && dtlstAcDetails.Rows.Count > 0)
                {
                    lstAcDetails = dtlstAcDetails.ToListof <EmailAccountDetails>();
                }
                #endregion

                if (lstAcDetails.Count > 0)
                {
                    #region Get email template tag list
                    var EmailTagList = GetEmailTemplateTagMaster();
                    #endregion

                    foreach (var account in lstAcDetails)
                    {
                        try
                        {
                            List <TimeSloat> lsttimesloat = new List <TimeSloat>();

                            #region Bind Time Sloat in hours
                            TimeSpan time = account.StartTime;
                            for (int i = 0; i < 24; i++)
                            {
                                if (time < account.EndTime)
                                {
                                    string[] tm = time.ToString().Split(':');
                                    DateTime dt = DateTime.Now.Date.AddMinutes((Convert.ToInt32(tm[0]) * 60) + (Convert.ToInt32(tm[1])));
                                    lsttimesloat.Add(new TimeSloat()
                                    {
                                        StartTime = dt,
                                        EndTime   = dt.AddHours(1)
                                    });
                                    time = time.Add(TimeSpan.FromHours(1));
                                    if (DateTime.Now.Date.AddHours(24) < dt.AddHours(1))
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            #endregion

                            #region Bind Time Sloat in minutes
                            //TimeSpan time = account.StartTime;
                            //for (int i = 0; i < 500; i++)
                            //{
                            //    if (time < account.EndTime)
                            //    {
                            //        string[] tm = time.ToString().Split(':');
                            //        DateTime dt = DateTime.Now.Date.AddMinutes((Convert.ToInt32(tm[0]) * 60) + (Convert.ToInt32(tm[1])));
                            //        lsttimesloat.Add(new TimeSloat()
                            //        {
                            //            StartTime = dt,
                            //            EndTime = dt.AddMinutes(5)
                            //            //EndTime = dt.AddHours(1)
                            //        });
                            //        //time = time.Add(TimeSpan.FromHours(1));
                            //        time = time.Add(TimeSpan.FromMinutes(5));
                            //        //if (DateTime.Now.Date.AddHours(24) < dt.AddHours(1))
                            //        if (DateTime.Now.Date.AddHours(24) < dt.AddMinutes(5))
                            //            break;

                            //    }
                            //    else
                            //    {
                            //        break;
                            //    }
                            //}
                            #endregion

                            #region Get per day send email count

                            List <DateTime> lstTodaySentEmail = new List <DateTime>();
                            DataTable       dtTodaySentEmail  = new DataTable();
                            dtTodaySentEmail = DAL.GetTodaysSendEmail(account.EmailAccountHost);
                            if (dtTodaySentEmail != null && dtTodaySentEmail.Rows.Count > 0)
                            {
                                foreach (DataRow row in dtTodaySentEmail.Rows)
                                {
                                    lstTodaySentEmail.Add(SafeValue <DateTime>(row["LastEmailed"]));
                                }
                            }
                            #endregion

                            #region Validation for email send limit

                            int perDaySendCount = lstTodaySentEmail.Count();

                            TimeSpan currentTime = DateTime.Now.TimeOfDay;
                            if (account.PerDayEmailSent <= perDaySendCount || (currentTime > account.StartTime && account.EndTime < currentTime))
                            {
                                continue;
                            }

                            var FindTimeSloat = lsttimesloat.Where(m => m.StartTime <= DateTime.Now && m.EndTime >= DateTime.Now).FirstOrDefault();
                            if (FindTimeSloat == null)
                            {
                                continue;
                            }

                            int hourlySentCount = lstTodaySentEmail.Where(m => m > FindTimeSloat.StartTime && m <= FindTimeSloat.EndTime).ToList().Count();
                            int topcount        = account.PerHourEmailSent - hourlySentCount;
                            if (topcount <= 0)
                            {
                                continue;
                            }
                            #endregion

                            #region Get dynamic query enter by user
                            List <QueryModel> lstquery = new List <QueryModel>();
                            DataTable         dtquery  = new DataTable();
                            dtquery = DAL.GetDynamicQuery(account.WarmingBulkScheduleEmailsId);
                            if (dtquery != null && dtquery.Rows.Count > 0)
                            {
                                foreach (DataRow row in dtquery.Rows)
                                {
                                    QueryModel model = new QueryModel();
                                    model.Id = SafeValue <int>(row["Id"]);
                                    model.WarmingBulkScheduleEmailsId = SafeValue <int>(row["WarmingBulkScheduleEmailsId"]);
                                    model.FieldName = SafeValue <string>(row["FieldName"]);
                                    model.Condition = SafeValue <string>(row["Condition"]);
                                    model.Value     = SafeValue <string>(row["Value"]);
                                    model.Operator  = SafeValue <string>(row["Operator"]);
                                    lstquery.Add(model);
                                }
                            }
                            else
                            {
                                LogFile.AddMessage("**************** ERROR START **************************");
                                LogFile.AddMessage("**DYNAMIC QUERY DATA NOT FOUND IN 'WarmingBulkScheduleEmailsFilter' TABLE, Reference ID is " + account.WarmingBulkScheduleEmailsId + " (WarmingBulkScheduleEmailsId) for the debuge perpose **");
                                LogFile.AddMessage("**************** ERROR END **************************");
                                continue;
                            }
                            #endregion

                            #region Set Query
                            string Query = string.Empty;
                            foreach (var item in lstquery)
                            {
                                Query += SetQuery(item, lstField);
                            }

                            // add condition of do not repeat sent email after input days
                            if (account.DoNotRepeatSentEmailDays > 0)
                            {
                                Query += " AND datediff(day,lastemailed,getdate()) > " + account.DoNotRepeatSentEmailDays + " order by LastEmailed asc";
                            }
                            else
                            {
                                Query += " order by LastEmailed asc";
                            }
                            #endregion

                            #region Get Query Result
                            List <WarmingEmailModel> lstQueryResult = new List <WarmingEmailModel>();
                            DataTable dtQueryResult = new DataTable();

                            dtQueryResult = DAL.GetDynamicQueryResult(topcount, Query);
                            if (dtQueryResult != null && dtQueryResult.Rows.Count > 0)
                            {
                                lstQueryResult = dtQueryResult.ToListof <WarmingEmailModel>();
                            }
                            else
                            {
                                // if query data not found then continue to next loop record
                                continue;
                            }
                            #endregion

                            #region Send Email
                            EmailSetting emailModel = new EmailSetting();
                            emailModel.EmailTemplateMasterID       = account.EmailTemplateMasterID;
                            emailModel.WarmingBulkScheduleEmailsId = account.WarmingBulkScheduleEmailsId;
                            emailModel.FromEmail  = account.EmailAccountId;
                            emailModel.Password   = account.EmailAccountPassword;
                            emailModel.ServerHost = account.EmailAccountHost;
                            emailModel.Subject    = account.EmailTemplateSubject;
                            emailModel.BodyHTML   = account.EmailTemplateBodyHTML;

                            foreach (var emailBlast in lstQueryResult)
                            {
                                if (account.PerDayEmailSent <= perDaySendCount)
                                {
                                    break;
                                }

                                emailModel.BodyHTML           = ReplaceEmailTag(emailModel.BodyHTML, EmailTagList, emailBlast);
                                emailModel.WarmingEmailListId = emailBlast.ID;
                                emailModel.ToEmail            = emailBlast.Email;
                                string message = objEmail.SendEmailToCustomer(emailModel);
                                perDaySendCount = perDaySendCount + 1;

                                if (message.ToLower().Contains("unable to connect"))
                                {
                                    break;
                                }
                            }
                            #endregion
                        }
                        catch (Exception ex)
                        {
                            LogFile.AddMessage("**************** ERROR START **************************");
                            LogFile.AddMessage("ERROR in Main Loop (Ignoring it and continuing) WarmingBulkScheduleEmailsId: " + account.WarmingBulkScheduleEmailsId + "");
                            LogFile.AddMessage("Error Message:" + ex.Message);
                            LogFile.AddMessage("StackTrace Message:" + ex.StackTrace);
                            LogFile.AddMessage("**************** ERROR END   **************************");

                            continue;
                        }
                    }
                }

                LogFile.AddMessage("END: Warming Blast Service on " + DateTime.Now.ToString());
            }
            catch (Exception ex)
            {
                DAL.InsertErrorLog("WarmingBlastService", ex.Message, ex.StackTrace);
            }
        }
Esempio n. 21
0
 public DrawingControlBase()
 {
     CurrentField = new FieldModel();
 }
Esempio n. 22
0
 public sealed override int GetSize(FieldModel fieldModel)
 {
     return(_numberOfBits / 8);
 }
Esempio n. 23
0
        private PostEditModel Transform(DynamicPost post, bool isDraft)
        {
            var config = new Config(_api);
            var type   = App.PostTypes.GetById(post.TypeId);
            var route  = type.Routes.FirstOrDefault(r => r.Route == post.Route) ?? type.Routes.FirstOrDefault();

            var model = new PostEditModel
            {
                Id                     = post.Id,
                BlogId                 = post.BlogId,
                TypeId                 = post.TypeId,
                Title                  = post.Title,
                Slug                   = post.Slug,
                MetaKeywords           = post.MetaKeywords,
                MetaDescription        = post.MetaDescription,
                Published              = post.Published?.ToString("yyyy-MM-dd HH:mm"),
                RedirectUrl            = post.RedirectUrl,
                RedirectType           = post.RedirectType.ToString(),
                EnableComments         = post.EnableComments,
                CloseCommentsAfterDays = post.CloseCommentsAfterDays,
                CommentCount           = post.CommentCount,
                State                  = post.GetState(isDraft),
                UseBlocks              = type.UseBlocks,
                SelectedRoute          = route == null ? null : new RouteModel
                {
                    Title = route.Title,
                    Route = route.Route
                },
                Permissions = App.Permissions
                              .GetPublicPermissions()
                              .Select(p => new KeyValuePair <string, string>(p.Name, p.Title))
                              .ToList(),
                SelectedPermissions = post.Permissions
            };

            foreach (var r in type.Routes)
            {
                model.Routes.Add(new RouteModel
                {
                    Title = r.Title,
                    Route = r.Route
                });
            }

            foreach (var regionType in type.Regions)
            {
                var region = new RegionModel
                {
                    Meta = new RegionMeta
                    {
                        Id           = regionType.Id,
                        Name         = regionType.Title,
                        Description  = regionType.Description,
                        Placeholder  = regionType.ListTitlePlaceholder,
                        IsCollection = regionType.Collection,
                        Expanded     = regionType.ListExpand,
                        Icon         = regionType.Icon,
                        Display      = regionType.Display.ToString().ToLower()
                    }
                };
                var regionListModel = ((IDictionary <string, object>)post.Regions)[regionType.Id];

                if (!regionType.Collection)
                {
                    var regionModel = (IRegionList)Activator.CreateInstance(typeof(RegionList <>).MakeGenericType(regionListModel.GetType()));
                    regionModel.Add(regionListModel);
                    regionListModel = regionModel;
                }

                foreach (var regionModel in (IEnumerable)regionListModel)
                {
                    var regionItem = new RegionItemModel();

                    foreach (var fieldType in regionType.Fields)
                    {
                        var appFieldType = App.Fields.GetByType(fieldType.Type);

                        var field = new FieldModel
                        {
                            Meta = new FieldMeta
                            {
                                Id          = fieldType.Id,
                                Name        = fieldType.Title,
                                Component   = appFieldType.Component,
                                Placeholder = fieldType.Placeholder,
                                IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth),
                                Description = fieldType.Description
                            }
                        };

                        if (typeof(Extend.Fields.SelectFieldBase).IsAssignableFrom(appFieldType.Type))
                        {
                            foreach (var item in ((Extend.Fields.SelectFieldBase)Activator.CreateInstance(appFieldType.Type)).Items)
                            {
                                field.Meta.Options.Add(Convert.ToInt32(item.Value), item.Title);
                            }
                        }

                        if (regionType.Fields.Count > 1)
                        {
                            field.Model = (Extend.IField)((IDictionary <string, object>)regionModel)[fieldType.Id];

                            if (regionType.ListTitleField == fieldType.Id)
                            {
                                regionItem.Title        = field.Model.GetTitle();
                                field.Meta.NotifyChange = true;
                            }
                        }
                        else
                        {
                            field.Model             = (Extend.IField)regionModel;
                            field.Meta.NotifyChange = true;
                            regionItem.Title        = field.Model.GetTitle();
                        }
                        regionItem.Fields.Add(field);
                    }

                    if (string.IsNullOrWhiteSpace(regionItem.Title))
                    {
                        regionItem.Title = "...";
                    }

                    region.Items.Add(regionItem);
                }
                model.Regions.Add(region);
            }

            foreach (var block in post.Blocks)
            {
                var blockType = App.Blocks.GetByType(block.Type);

                if (block is BlockGroup blockGroup)
                {
                    var group = new BlockGroupModel
                    {
                        Id   = block.Id,
                        Type = block.Type,
                        Meta = new BlockMeta
                        {
                            Name        = blockType.Name,
                            Icon        = blockType.Icon,
                            Component   = "block-group",
                            IsGroup     = true,
                            isCollapsed = config.ManagerDefaultCollapsedBlocks,
                            ShowHeader  = !config.ManagerDefaultCollapsedBlockGroupHeaders
                        }
                    };

                    if (blockType.Display != BlockDisplayMode.MasterDetail)
                    {
                        group.Meta.Component = blockType.Display == BlockDisplayMode.Horizontal ?
                                               "block-group-horizontal" : "block-group-vertical";
                    }

                    group.Fields = ContentUtils.GetBlockFields(block);

                    bool firstChild = true;
                    foreach (var child in blockGroup.Items)
                    {
                        blockType = App.Blocks.GetByType(child.Type);

                        if (!blockType.IsGeneric)
                        {
                            group.Items.Add(new BlockItemModel
                            {
                                IsActive = firstChild,
                                Model    = child,
                                Meta     = new BlockMeta
                                {
                                    Name      = blockType.Name,
                                    Title     = child.GetTitle(),
                                    Icon      = blockType.Icon,
                                    Component = blockType.Component
                                }
                            });
                        }
                        else
                        {
                            // Generic block item model
                            group.Items.Add(new BlockGenericModel
                            {
                                IsActive = firstChild,
                                Model    = ContentUtils.GetBlockFields(child),
                                Type     = child.Type,
                                Meta     = new BlockMeta
                                {
                                    Name      = blockType.Name,
                                    Title     = child.GetTitle(),
                                    Icon      = blockType.Icon,
                                    Component = blockType.Component,
                                }
                            });
                        }
                        firstChild = false;
                    }
                    model.Blocks.Add(group);
                }
                else
                {
                    if (!blockType.IsGeneric)
                    {
                        // Regular block item model
                        model.Blocks.Add(new BlockItemModel
                        {
                            Model = block,
                            Meta  = new BlockMeta
                            {
                                Name        = blockType.Name,
                                Title       = block.GetTitle(),
                                Icon        = blockType.Icon,
                                Component   = blockType.Component,
                                isCollapsed = config.ManagerDefaultCollapsedBlocks
                            }
                        });
                    }
                    else
                    {
                        // Generic block item model
                        model.Blocks.Add(new BlockGenericModel
                        {
                            Model = ContentUtils.GetBlockFields(block),
                            Type  = block.Type,
                            Meta  = new BlockMeta
                            {
                                Name        = blockType.Name,
                                Title       = block.GetTitle(),
                                Icon        = blockType.Icon,
                                Component   = blockType.Component,
                                isCollapsed = config.ManagerDefaultCollapsedBlocks
                            }
                        });
                    }
                }
            }

            // Custom editors
            foreach (var editor in type.CustomEditors)
            {
                model.Editors.Add(new EditorModel
                {
                    Component = editor.Component,
                    Icon      = editor.Icon,
                    Name      = editor.Title
                });
            }
            return(model);
        }
Esempio n. 24
0
    /// <summary>
    /// 仅用于添加修改文章如AddContent等, DataTable dt = this.bfield.GetModelFieldList(this.ModelID).Tables[0];
    /// </summary>
    /// <param name="dt">模型字段列表</param>
    /// <param name="page">this.Page</param>
    /// <param name="viewState">ViewState</param>
    /// <param name="content">用于后台生成静态页</param>
    /// <param name="flag">是否需要检测空值</param>
    /// <param name="fields">如不为空,则非其中的字段不允许修改</param>
    public DataTable GetDTFromPage(DataTable dt, Page page, StateBag viewState, IList <string> content = null, bool flag = true, string fields = "")
    {
        B_ModelField mfieldBll = new B_ModelField();

        dt.DefaultView.RowFilter = "IsCopy <>-1";
        dt = dt.DefaultView.ToTable();
        if (content == null)
        {
            content = new List <string>();
        }
        DataTable table = new DataTable();

        table.Columns.Add(new DataColumn("FieldName", typeof(string)));
        table.Columns.Add(new DataColumn("FieldType", typeof(string)));
        table.Columns.Add(new DataColumn("FieldValue", typeof(string)));
        table.Columns.Add(new DataColumn("FieldAlias", typeof(string)));
        foreach (DataRow dr in dt.Rows)
        {
            DataRow fdr = table.NewRow();
            if (!string.IsNullOrEmpty(fields) && !("," + fields + ",").Contains("," + dr["FieldName"] + ","))
            {
                continue;
            }
            try
            {
                if (dr["FieldType"].ToString() == "DoubleDateType")
                {
                    fdr[0] = dr["FieldName"].ToString();
                    fdr[1] = "DoubleDateType";
                    DateTime ti1 = DataConverter.CDate(page.Request.Form["txt" + dr["FieldName"].ToString()]);
                    DateTime ti2 = DataConverter.CDate(page.Request.Form["txt_" + dr["FieldName"].ToString()]);
                    fdr[2] = ti1.ToShortDateString() + "|" + ti2.ToShortDateString();
                    fdr[3] = dr["FieldAlias"];
                    table.Rows.Add(fdr);
                }
                else
                {
                    if (DataConverter.CBool(dr["IsNotNull"].ToString()) && flag)
                    {
                        if (string.IsNullOrEmpty(page.Request.Form["txt_" + dr["FieldName"].ToString()]))
                        {
                            function.WriteErrMsg(dr["FieldAlias"].ToString() + "不能为空!", "javascript:history.go(-1);");
                        }
                    }
                    string[] Sett = dr["Content"].ToString().Split(new char[] { ',' });
                    switch (dr["FieldType"].ToString())
                    {
                    case "FileType":    //其与MultiPicType一样,都是读页面上的隐藏控件,而非<select>中的值,存在一个隐藏字段中
                        #region
                        //ChkFileSize=0,FileSizeField=,MaxFileSize=1024,UploadFileExt=rar|zip|docx|pdf:::是否保存文件大小,保存在大小的字段名,文件上传限制,上传后缀名限制
                        bool   chksize   = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]);
                        string sizefield = Sett[1].Split(new char[] { '=' })[1];
                        if (chksize && sizefield != "")
                        {
                            DataRow row1 = table.NewRow();
                            row1[0] = sizefield;
                            row1[1] = "FileSize";
                            row1[2] = page.Request.Form["txt_" + sizefield];
                            row1[3] = dr["FieldAlias"];
                            table.Rows.Add(row1);
                        }
                        //信息由JS控制放置入txt_中
                        DataRow rowr1 = table.NewRow();
                        rowr1[0] = dr["FieldName"];
                        rowr1[1] = "FileType";
                        rowr1[2] = page.Request.Form["txt_" + dr["FieldName"]];
                        rowr1[3] = dr["FieldAlias"];
                        table.Rows.Add(rowr1);
                        #endregion
                        break;

                    case "MultiPicType":
                        #region
                        //ChkThumb=0,ThumbField=,Warter=0,MaxPicSize=1024,PicFileExt=jpg|png|gif|bmp|jpeg:::是否保存缩略图地址,缩略点路径,水印,大小,后缀名限制
                        bool   chkthumb   = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]);
                        string ThumbField = Sett[1].Split(new char[] { '=' })[1];
                        if (chkthumb && ThumbField != "")
                        {
                            DataRow row2 = table.NewRow();
                            if (DataConverter.CBool(dr["IsNotNull"].ToString()) && string.IsNullOrEmpty(page.Request.Form["txt_" + ThumbField]))
                            {
                                function.WriteErrMsg(dr["FieldAlias"].ToString() + "的缩略图不能为空!");
                            }
                            row2[0] = ThumbField;
                            row2[1] = "ThumbField";
                            row2[2] = page.Request.Form["txt_" + ThumbField];
                            row2[3] = dr["FieldAlias"];
                            table.Rows.Add(row2);
                        }
                        {
                            DataRow rowr2 = table.NewRow();
                            rowr2[0] = dr["FieldName"];
                            rowr2[1] = "MultiPicType";
                            rowr2[2] = page.Request.Form["txt_" + dr["FieldName"]];
                            rowr2[3] = dr["FieldAlias"];
                            table.Rows.Add(rowr2);
                        }
                        #endregion
                        break;

                    case "TableField":    //库选字段
                        fdr[0] = dr["FieldName"].ToString();
                        fdr[1] = "TableField";
                        string tableval = page.Request.Form["txt_" + dr["FieldName"].ToString()];
                        if (!string.IsNullOrEmpty(tableval))
                        {
                            string[] temparr = tableval.Split(',');
                            tableval = string.Join("$", temparr);
                        }
                        fdr[2] = tableval;
                        fdr[3] = dr["FieldAlias"];
                        table.Rows.Add(fdr);
                        break;

                    case "NumType":
                        #region
                        double value = DataConverter.CDouble(string.IsNullOrEmpty(page.Request.Form["txt_" + dr["FieldName"]]) ? "0" : page.Request.Form["txt_" + dr["FieldName"]]);    //避免空字符串报错
                        //TitleSize=35,NumberType=1,DefaultValue=50,NumSearchType=0,NumRangType=1,NumSearchRang=0-100,NumLenght=0
                        string[] conArr    = dr["Content"].ToString().Split(',');
                        string   NumLenght = "f" + conArr[6].Split('=')[1]; //小数点位数
                        if (conArr[4].Split('=')[1].Equals("1"))            //指定了上限与下限检测,则检测
                        {
                            string range = conArr[5].Split('=')[1];
                            if (!string.IsNullOrEmpty(range) && range.Split('-').Length == 2)    //范围不为空,并正确填了值,才做判断
                            {
                                double minValue = Convert.ToDouble(range.Split('-')[0]);
                                double maxValue = Convert.ToDouble(range.Split('-')[1]);
                                if (value < minValue || value > maxValue)
                                {
                                    function.WriteErrMsg(dr["FieldAlias"] + ":的值不正确,必须大于" + minValue + ",并且小于" + maxValue);
                                }
                            }
                        }
                        fdr[0] = dr["FieldName"].ToString();
                        fdr[1] = "NumType";
                        fdr[2] = value.ToString(NumLenght);
                        fdr[3] = dr["FieldAlias"];
                        table.Rows.Add(fdr);
                        #endregion
                        break;

                    case "Images":    //组图
                        fdr[0] = dr["FieldName"].ToString();
                        fdr[1] = "Images";
                        fdr[2] = (page.Request.Form["txt_" + dr["FieldName"].ToString()] ?? "").Trim(',');
                        table.Rows.Add(fdr);
                        break;

                    case "CameraType":
                        fdr[0] = dr["FieldName"].ToString();
                        fdr[1] = "CameraType";
                        fdr[2] = page.Request.Form[dr["FieldName"] + "_hid"].ToString();
                        table.Rows.Add(fdr);
                        break;

                    case "SqlType":    //文件入库,图片入库,,,图片与文件base64存数据库,一个单独字段标识其
                    {
                        fdr[0] = dr["FieldName"];
                        fdr[1] = dr["FieldType"];
                        fdr[2] = page.Request.Form["FIT_" + dr["FieldName"]];
                        fdr[3] = dr["FieldAlias"];
                        table.Rows.Add(fdr);
                    }
                    break;

                    case "SqlFile":
                    {
                        fdr[0] = dr["FieldName"];
                        fdr[1] = dr["FieldType"];
                        fdr[2] = page.Request.Form["FIT_" + dr["FieldName"]];
                        fdr[3] = dr["FieldAlias"];
                        table.Rows.Add(fdr);
                    }
                    break;

                    case "MapType":
                    {
                        fdr[0] = dr["FieldName"].ToString();
                        fdr[1] = "MapType";
                        fdr[2] = page.Request.Form["txt_" + dr["FieldName"].ToString()];
                        fdr[3] = dr["FieldAlias"];
                        table.Rows.Add(fdr);
                    }
                    break;

                    case "autothumb":
                    {
                        FieldModel fieldMod = new FieldModel(dr["Content"].ToString());
                        string     thumb    = page.Request.Form["txt_" + dr["FieldName"].ToString()];
                        string     topimg   = page.Request.Form["ctl00$Content$ThumImg_Hid"];
                        thumb = ZoomLa.BLL.Helper.ThumbHelper.Thumb_Compress(topimg, thumb, fieldMod.GetValInt("width"), fieldMod.GetValInt("height"));
                        //如thumb为空,但topimg不为空,则生成缩图
                        fdr[0] = dr["FieldName"].ToString();
                        fdr[1] = "auththumb";
                        fdr[2] = thumb;
                        table.Rows.Add(fdr);
                    }
                    break;

                    case "api_qq_mvs":
                    {
                        fdr[0] = dr["FieldName"];
                        fdr[1] = dr["FieldType"];
                        fdr[2] = page.Request.Form["UpMvs_" + dr["FieldName"].ToString()];
                        fdr[3] = dr["FieldAlias"];
                        table.Rows.Add(fdr);
                    }
                    break;

                    default:
                        #region
                        string[] txtftype = "TextType,MultipleTextType,MultipleHtmlType,PullFileType".Split(',');    //文本类型
                        DataRow  row      = table.NewRow();
                        row[0] = dr["FieldName"].ToString();
                        string ftype = dr["FieldType"].ToString();
                        row[1] = ftype;
                        string fvalue = page.Request.Form["txt_" + dr["FieldName"].ToString()];
                        if (!string.IsNullOrEmpty(fvalue) && (txtftype.Where(p => p.Equals(ftype)).ToArray().Length > 0))
                        {
                            if (ftype == "MultipleHtmlType")
                            {
                                content.Add(fvalue);
                            }
                        }
                        switch (ftype)
                        {
                        case "Random":
                            fvalue = page.Request.Form["txt_" + dr["FieldName"].ToString()];
                            break;

                        case "MapType":
                            //fvalue =;
                            break;

                        case "Charts":
                            if (page.Request.Form[dr["FieldName"].ToString()] == null || page.Request.Form[dr["FieldName"].ToString()] == "0")
                            {
                                fvalue = "0";
                            }
                            else
                            {
                                fvalue = page.Request.Form[dr["FieldName"].ToString()];
                            }
                            break;

                        case "SqlType":
                            if (page.Request.Form["txt_" + dr["FieldName"].ToString()] == null || page.Request.Form["txt_" + dr["FieldName"].ToString()] == "")
                            {
                                fvalue = "";
                            }
                            else
                            {
                                fvalue = page.Request.Form["txt_" + dr["FieldName"].ToString()];
                            }
                            break;

                        case "SqlFile":
                            if (page.Request.Form["txt_" + dr["FieldName"].ToString()] == null || page.Request.Form["txt_" + dr["FieldName"].ToString()] == "")
                            {
                                fvalue = "";
                            }
                            else
                            {
                                fvalue = page.Request.Form["txt_" + dr["FieldName"].ToString()];
                            }
                            break;
                        }
                        string strUrl  = HttpContext.Current.Request.Url.Authority.ToString();
                        string serPath = page.Request.PhysicalApplicationPath;
                        if (SiteConfig.SiteOption.IsSaveRemoteImage)
                        {
                            //保存远程图片功能
                            if (dr["FieldName"].ToString() == "content")
                            {
                                //获取img路径列表
                                List <string> remoteImageList = mfieldBll.GetImgUrl(fvalue);
                                fvalue = page.Request.Form["txt_content"];
                                foreach (string str in remoteImageList)
                                {
                                    string imgurl = page.Request.PhysicalApplicationPath + WaterModuleConfig.WaterConfig.imgLogo;
                                    //新图片名称
                                    string newImgname;
                                    string Patha;
                                    mfieldBll.SaveGz(str, out newImgname, out Patha, viewState["NodeDir"].ToString());
                                    string imgInfo = "";
                                    //保存远程图片,并获取图片详细名称
                                    if (str.Substring(0, 7) == "http://" && !str.Contains(strUrl) && !str.Contains(SiteConfig.SiteInfo.SiteUrl))
                                    {
                                        try
                                        {
                                            imgInfo = mfieldBll.downRemoteImg(page.Server.MapPath(Patha), str, newImgname, Patha, imgurl);
                                            fvalue  = fvalue.Replace(str.ToString(), imgInfo);
                                        }
                                        catch (Exception)
                                        {
                                            imgInfo = str;
                                            fvalue  = fvalue.Replace(str.ToString(), imgInfo);
                                        }
                                    }
                                }
                            }
                        }
                        row[2] = fvalue;
                        row[3] = dr["FieldAlias"];
                        table.Rows.Add(row);
                        #endregion
                        break;
                    }
                }
            }
            catch (Exception ex) { function.WriteErrMsg("自定义字段[" + dr["FieldName"] + "(" + dr["FieldType"] + ")]出错,原因:" + ex.Message); }
        }
        return(table);
    }
Esempio n. 25
0
        private bool InitializeStructMembers(StructMapping mapping, StructModel model, RecursionLimiter limiter)
        {
            if (mapping.IsFullyInitialized)
            {
                return(true);
            }
            if (model.TypeDesc.BaseTypeDesc != null)
            {
                StructMapping baseMapping = ImportStructLikeMapping((StructModel)_modelScope.GetTypeModel(model.Type.BaseType, false), limiter);

                // check to see if the import of the baseMapping was deferred
                int baseIndex = limiter.DeferredWorkItems.IndexOf(mapping.BaseMapping);
                if (baseIndex < 0)
                {
                    mapping.BaseMapping = baseMapping;
                }
                else
                {
                    // the import of the baseMapping was deferred, make sure that the derived mappings is deferred as well
                    if (!limiter.DeferredWorkItems.Contains(mapping))
                    {
                        limiter.DeferredWorkItems.Add(new ImportStructWorkItem(model, mapping));
                    }
                    // make sure that baseMapping get processed before the derived
                    int top = limiter.DeferredWorkItems.Count - 1;
                    if (baseIndex < top)
                    {
                        ImportStructWorkItem baseMappingWorkItem = limiter.DeferredWorkItems[baseIndex];
                        limiter.DeferredWorkItems[baseIndex] = limiter.DeferredWorkItems[top];
                        limiter.DeferredWorkItems[top]       = baseMappingWorkItem;
                    }
                    return(false);
                }
            }
            ArrayList members = new ArrayList();

            foreach (MemberInfo memberInfo in model.GetMemberInfos())
            {
                if (!(memberInfo is FieldInfo) && !(memberInfo is PropertyInfo))
                {
                    continue;
                }
                SoapAttributes memberAttrs = GetAttributes(memberInfo);
                if (memberAttrs.SoapIgnore)
                {
                    continue;
                }
                FieldModel fieldModel = model.GetFieldModel(memberInfo);
                if (fieldModel == null)
                {
                    continue;
                }
                MemberMapping member = ImportFieldMapping(fieldModel, memberAttrs, mapping.Namespace, limiter);
                if (member == null)
                {
                    continue;
                }

                if (!member.TypeDesc.IsPrimitive && !member.TypeDesc.IsEnum && !member.TypeDesc.IsOptionalValue)
                {
                    if (model.TypeDesc.IsValueType)
                    {
                        throw new NotSupportedException(SR.Format(SR.XmlRpcRefsInValueType, model.TypeDesc.FullName));
                    }
                    if (member.TypeDesc.IsValueType)
                    {
                        throw new NotSupportedException(SR.Format(SR.XmlRpcNestedValueType, member.TypeDesc.FullName));
                    }
                }
                if (mapping.BaseMapping != null)
                {
                    if (mapping.BaseMapping.Declares(member, mapping.TypeName))
                    {
                        continue;
                    }
                }
                members.Add(member);
            }
            mapping.Members = (MemberMapping[])members.ToArray(typeof(MemberMapping));
            if (mapping.BaseMapping == null)
            {
                mapping.BaseMapping = GetRootMapping();
            }
            IncludeTypes(model.Type, limiter);

            return(true);
        }
Esempio n. 26
0
 public override int GetSize(FieldModel fieldModel)
 {
     return(4);
 }
Esempio n. 27
0
 public FieldTreeItem(FieldModel fieldModel)
     : base(fieldModel.Name)
 {
     FieldModel = fieldModel;
 }
 public SearchFieldModel(FieldModel fieldType, string baseField)
 {
     this.BaseField = baseField;
     this.FieldType = fieldType;
 }
Esempio n. 29
0
        /// <summary>
        /// 表單欄位
        /// </summary>
        /// <param name="field"></param>
        /// <param name="answer"></param>
        /// <returns></returns>
        public ActionResult ShowField(FieldModel field, FieldAnswerModel answer)
        {
            ViewBag.Answer = answer;

            return(View(field));
        }
Esempio n. 30
0
        public ActionResult GetCompanyData(RequestData data)
        {
            string levelId    = data.Get("LevelId");
            string entGuid    = data.Get("entGuid");
            string actionType = data.Get("ActionType");

            FieldModel where = null;
            where           &= T_THEPEAK_LEVEL_CONFIG.PEAK_LEVE_ID == levelId;
            if ("Stop" == actionType)
            {
                where &= T_THEPEAK_LEVEL_CONFIG.IS_STOP == 1;
            }
            if ("Limit" == actionType)
            {
                where &= T_THEPEAK_LEVEL_CONFIG.LIMIT_TYPE == "TheLimit";
            }
            if ("TimePeak" == actionType)
            {
                where &= T_THEPEAK_LEVEL_CONFIG.LIMIT_TYPE == "limitTime";
            }
            where &= T_THEPEAK_ENT_SUB_LIST.GUID == entGuid;

            List <dynamic> filterRuleslist = Newtonsoft.Json.JsonConvert.DeserializeObject <List <dynamic> >(data.Get("filterRules"));

            if (filterRuleslist != null)
            {
                foreach (var item in filterRuleslist)
                {
                    this.SetWhere <T_BASE_COMPANY>(item, new T_BASE_COMPANY(), ref where);
                }
            }

            SqlModel sql = SqlModel.SelectAll(
                T_SYS_AREA.AREA_TEXT.As("AREA_TEXT")
                , "d1".Field("TITLE").As("INDUSTRY_TYPE_TEXT")
                // , "d2".Field("TITLE").As("POLLUTION_TYPE_TEXT")
                // // , "d3".Field(T_BAS_AIR_MONITOR.MONITOR_ITEM_NAME).As("POLLUTION_ITEM_TEXT")
                // , "d4".Field("TITLE").As("COMPANY_STATE_TEXT")
                , T_THEPEAK_ENT_SUB_LIST.ID.As("ENTSUBID")
                , T_THEPEAK_LEVEL_LIST_INFO.ID.As("LEVEL_ID")
                , T_THEPEAK_ENT_SUB_LIST.ENT_PEAK_TYPE
                , T_THEPEAK_ENT_SUB_LIST.THEPEAKID
                , T_THEPEAK_ENT_SUB_LIST.IS_SELECT
                , T_BASE_COMPANY.ID.As("COMPANY_ID")
                , "d6".Field("TITLE").As("PEAK_LEVEL_TEXT")
                // , "d7".Field(BASUSER.TRUENAME).As("TOWN_SUPERVISOR_TEXT")
                // , "d8".Field(BASUSER.TRUENAME).As("INDUSTRY_SUPERVISOR_TEXT")
                , "d9".Field(BASUSER.TRUENAME).As("SUPERVISOR_TEXT")

                // , "d8".Field("TITLE").As("PEAK_LEVEL_TEXT")
                )
                           .From(DB.T_BASE_COMPANY)
                           .LeftJoin(DB.T_SYS_AREA).On(T_BASE_COMPANY.AREA == T_SYS_AREA.AREA_CODE)
                           .LeftJoin(DB.BASDIC.As("d1")).On(T_BASE_COMPANY.BASTYPE == "d1".Field("CODE") & "d1".Field("TYPECODE") == ConstStrings.IndustryType)
                           //.LeftJoin(DB.BASDIC.As("d2")).On(T_BASE_COMPANY.POLLUTION_TYPE == "d2".Field("CODE") & "d2".Field("TYPECODE") == ConstStrings.PollutionType)
                           ///.LeftJoin(DB.T_BAS_AIR_MONITOR.As("d3")).On(T_BASE_COMPANY.POLLUTION_ITEM == "d3".Field(T_BAS_AIR_MONITOR.MONITOR_ITEM_CODE))
                           // .LeftJoin(DB.BASDIC.As("d4")).On(T_BASE_COMPANY.COMPANY_STATE == "d4".Field("CODE") & "d4".Field("TYPECODE") == ConstStrings.Company_State)
                           // .LeftJoin(DB.BASDIC.As("d5")).On(T_BASE_COMPANY.FUEL_TYPE == "d5".Field("CODE") & "d5".Field("TYPECODE") == ConstStrings.FuelType)
                           .LeftJoin(DB.T_THEPEAK_LEVEL_CONFIG).On(T_THEPEAK_LEVEL_CONFIG.COMPANY_ID == T_BASE_COMPANY.ID)
                           .LeftJoin(DB.T_THEPEAK_LEVEL_LIST_INFO).On(T_THEPEAK_LEVEL_LIST_INFO.ID == T_THEPEAK_LEVEL_CONFIG.PEAK_LEVE_ID)
                           .LeftJoin(DB.T_THEPEAK_ENT_SUB_LIST).On(T_THEPEAK_ENT_SUB_LIST.COMPANY_ID == T_BASE_COMPANY.ID & T_THEPEAK_LEVEL_LIST_INFO.ID == T_THEPEAK_ENT_SUB_LIST.LEVEL_ID & T_THEPEAK_ENT_SUB_LIST.GUID == entGuid)//
                           .LeftJoin(DB.T_THEPEAK_LEVEL_LIST_INFO.As("d10")).On("d10".Field("ID") == T_THEPEAK_ENT_SUB_LIST.CONTROL_MEAS)
                           .LeftJoin(DB.BASDIC.As("d6")).On("d10".Field(T_THEPEAK_LEVEL_LIST_INFO.PEAK_LEVEL) == "d6".Field("CODE") & "d6".Field("TYPECODE") == ConstStrings.LevelType)
                           //.LeftJoin(DB.BASUSER.As("d7")).On(T_BASE_COMPANY.TOWN_SUPERVISOR=="d7".Field(BASUSER.USERNAME))
                           //.LeftJoin(DB.BASUSER.As("d8")).On(T_BASE_COMPANY.INDUSTRY_SUPERVISOR == "d8".Field(BASUSER.USERNAME))
                           .LeftJoin(DB.BASUSER.As("d9")).On(T_BASE_COMPANY.SUPERVISOR == "d9".Field(BASUSER.USERNAME))
                           .Where(where);

            return(base.PagedJson(sql, data));
        }
Esempio n. 31
0
        private PageEditModel Transform(DynamicPage page, bool isDraft)
        {
            var type = App.PageTypes.GetById(page.TypeId);

            var model = new PageEditModel
            {
                Id              = page.Id,
                SiteId          = page.SiteId,
                ParentId        = page.ParentId,
                SortOrder       = page.SortOrder,
                TypeId          = page.TypeId,
                Title           = page.Title,
                NavigationTitle = page.NavigationTitle,
                Slug            = page.Slug,
                MetaKeywords    = page.MetaKeywords,
                MetaDescription = page.MetaDescription,
                Published       = page.Published.HasValue ? page.Published.Value.ToString("yyyy-MM-dd HH:mm") : null,
                State           = GetState(page, isDraft),
                UseBlocks       = type.UseBlocks
            };

            foreach (var regionType in type.Regions)
            {
                var region = new RegionModel
                {
                    Meta = new RegionMeta
                    {
                        Id           = regionType.Id,
                        Name         = regionType.Title,
                        Description  = regionType.Description,
                        Placeholder  = regionType.ListTitlePlaceholder,
                        IsCollection = regionType.Collection,
                        Icon         = regionType.Icon,
                        Display      = regionType.Display.ToString().ToLower()
                    }
                };
                var regionListModel = ((IDictionary <string, object>)page.Regions)[regionType.Id];

                if (!regionType.Collection)
                {
                    var regionModel = (IRegionList)Activator.CreateInstance(typeof(RegionList <>).MakeGenericType(regionListModel.GetType()));
                    regionModel.Add(regionListModel);
                    regionListModel = regionModel;
                }

                foreach (var regionModel in (IEnumerable)regionListModel)
                {
                    var regionItem = new RegionItemModel();

                    foreach (var fieldType in regionType.Fields)
                    {
                        var appFieldType = App.Fields.GetByType(fieldType.Type);

                        var field = new FieldModel
                        {
                            Meta = new FieldMeta
                            {
                                Id          = fieldType.Id,
                                Name        = fieldType.Title,
                                Component   = appFieldType.Component,
                                Placeholder = fieldType.Placeholder,
                                IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth),
                                Description = fieldType.Description
                            }
                        };

                        if (regionType.Fields.Count > 1)
                        {
                            field.Model = (Extend.IField)((IDictionary <string, object>)regionModel)[fieldType.Id];

                            if (regionType.ListTitleField == fieldType.Id)
                            {
                                regionItem.Title        = field.Model.GetTitle();
                                field.Meta.NotifyChange = true;
                            }
                        }
                        else
                        {
                            field.Model             = (Extend.IField)regionModel;
                            field.Meta.NotifyChange = true;
                            regionItem.Title        = field.Model.GetTitle();
                        }
                        regionItem.Fields.Add(field);
                    }

                    if (string.IsNullOrWhiteSpace(regionItem.Title))
                    {
                        regionItem.Title = "...";
                    }

                    region.Items.Add(regionItem);
                }
                model.Regions.Add(region);
            }

            foreach (var block in page.Blocks)
            {
                var blockType = App.Blocks.GetByType(block.Type);

                if (block is Extend.BlockGroup)
                {
                    var group = new BlockGroupModel
                    {
                        Id   = block.Id,
                        Type = block.Type,
                        Meta = new BlockMeta
                        {
                            Name      = blockType.Name,
                            Icon      = blockType.Icon,
                            Component = "block-group",
                            IsGroup   = true
                        }
                    };

                    if (blockType.Display != BlockDisplayMode.MasterDetail)
                    {
                        group.Meta.Component = blockType.Display == BlockDisplayMode.Horizontal ?
                                               "block-group-horizontal" : "block-group-vertical";
                    }

                    foreach (var prop in block.GetType().GetProperties(App.PropertyBindings))
                    {
                        if (typeof(Extend.IField).IsAssignableFrom(prop.PropertyType))
                        {
                            var fieldType = App.Fields.GetByType(prop.PropertyType);

                            group.Fields.Add(new FieldModel
                            {
                                Model = (Extend.IField)prop.GetValue(block),
                                Meta  = new FieldMeta
                                {
                                    Id        = prop.Name,
                                    Name      = prop.Name,
                                    Component = fieldType.Component,
                                }
                            });
                        }
                    }

                    bool firstChild = true;
                    foreach (var child in ((Extend.BlockGroup)block).Items)
                    {
                        blockType = App.Blocks.GetByType(child.Type);

                        group.Items.Add(new BlockItemModel
                        {
                            IsActive = firstChild,
                            Model    = child,
                            Meta     = new BlockMeta
                            {
                                Name      = blockType.Name,
                                Title     = child.GetTitle(),
                                Icon      = blockType.Icon,
                                Component = blockType.Component
                            }
                        });
                        firstChild = false;
                    }
                    model.Blocks.Add(group);
                }
                else
                {
                    model.Blocks.Add(new BlockItemModel
                    {
                        Model = block,
                        Meta  = new BlockMeta
                        {
                            Name      = blockType.Name,
                            Title     = block.GetTitle(),
                            Icon      = blockType.Icon,
                            Component = blockType.Component
                        }
                    });
                }
            }

            // Custom editors
            foreach (var editor in type.CustomEditors)
            {
                model.Editors.Add(new EditorModel
                {
                    Component = editor.Component,
                    Icon      = editor.Icon,
                    Name      = editor.Title
                });
            }
            return(model);
        }
        private SearchModel BuildCreateIssueItemsSearchModel()
        {
            var model          = new SearchModel();
            var itemNameFilter = new FieldModel
            {
                DisplayOrder    = 1,
                Name            = "ItemName",
                ResourceKey     = "Item.Name",
                DbColumn        = "Item.Name",
                Value           = null,
                ControlType     = FieldControlType.TextBox,
                DataType        = FieldDataType.String,
                DataSource      = FieldDataSource.None,
                IsRequiredField = false
            };

            model.Filters.Add(itemNameFilter);

            var itemGroupFilter = new FieldModel
            {
                DisplayOrder    = 2,
                Name            = "ItemGroup",
                ResourceKey     = "ItemGroup",
                DbColumn        = "ItemGroup.Id",
                Value           = null,
                ControlType     = FieldControlType.DropDownList,
                DataType        = FieldDataType.Int64,
                DataSource      = FieldDataSource.DB,
                DbTable         = "ItemGroup",
                DbTextColumn    = "Name",
                DbValueColumn   = "Id",
                IsRequiredField = false
            };

            model.Filters.Add(itemGroupFilter);

            var itemCategoryFilter = new FieldModel
            {
                DisplayOrder    = 3,
                Name            = "ItemCategory",
                ResourceKey     = "Item.ItemCategory",
                DbColumn        = "Item.ItemCategory",
                Value           = null,
                ControlType     = FieldControlType.DropDownList,
                DataType        = FieldDataType.Int64,
                DataSource      = FieldDataSource.CSV,
                CsvTextList     = "Part,Tool,Asset,Other",
                CsvValueList    = "0,1,2,3",
                IsRequiredField = false
            };

            model.Filters.Add(itemCategoryFilter);

            var barcodeFilter = new FieldModel
            {
                DisplayOrder    = 4,
                Name            = "Barcode",
                ResourceKey     = "Item.Barcode",
                DbColumn        = "Item.Barcode",
                Value           = null,
                ControlType     = FieldControlType.TextBox,
                DataType        = FieldDataType.String,
                DataSource      = FieldDataSource.None,
                IsRequiredField = false
            };

            model.Filters.Add(barcodeFilter);

            var itemStatusFilter = new FieldModel
            {
                DisplayOrder    = 5,
                Name            = "ItemStatus",
                ResourceKey     = "Item.ItemStatus",
                DbColumn        = "Item.Id",
                Value           = null,
                ControlType     = FieldControlType.DropDownList,
                DataType        = FieldDataType.Int64,
                DataSource      = FieldDataSource.MVC,
                MvcController   = "Common",
                MvcAction       = "ValueItems",
                AdditionalField = "category",
                AdditionalValue = "Item Status",
                IsRequiredField = false
            };

            model.Filters.Add(itemStatusFilter);

            return(model);
        }
Esempio n. 33
0
 public BIT16RuntimeField(FieldModel fieldModel)
     : base(fieldModel, 16)
 {
 }
        private SearchModel BuildSearchModel()
        {
            var model           = new SearchModel();
            var issueNameFilter = new FieldModel
            {
                DisplayOrder    = 1,
                Name            = "Number",
                ResourceKey     = "Issue.Number",
                DbColumn        = "Issue.Number, Issue.Description",
                Value           = null,
                ControlType     = FieldControlType.TextBox,
                DataType        = FieldDataType.String,
                DataSource      = FieldDataSource.None,
                IsRequiredField = false
            };

            model.Filters.Add(issueNameFilter);

            var siteFilter = new FieldModel
            {
                DisplayOrder    = 2,
                Name            = "Site",
                ResourceKey     = "Site",
                DbColumn        = "Site.Id",
                Value           = this._workContext.CurrentUser.DefaultSiteId,
                ControlType     = FieldControlType.DropDownList,
                DataType        = FieldDataType.Int64,
                DataSource      = FieldDataSource.MVC,
                MvcController   = "Site",
                MvcAction       = "SiteList",
                IsRequiredField = false
            };

            model.Filters.Add(siteFilter);

            var storeFilter = new FieldModel
            {
                DisplayOrder    = 4,
                Name            = "Store",
                ResourceKey     = "Store",
                DbColumn        = "Store.Id",
                Value           = null,
                ControlType     = FieldControlType.DropDownList,
                DataType        = FieldDataType.Int64,
                DataSource      = FieldDataSource.MVC,
                MvcController   = "Site",
                MvcAction       = "StoreList",
                IsRequiredField = false,
                ParentFieldName = "Site"
            };

            model.Filters.Add(storeFilter);

            var issueDateFromFilter = new FieldModel
            {
                DisplayOrder    = 3,
                Name            = "IssueDateFrom",
                ResourceKey     = "Issue.IssueDateFrom",
                DbColumn        = "Issue.IssueDate",
                Value           = null,
                ControlType     = FieldControlType.DateTime,
                DataType        = FieldDataType.DateTime,
                DataSource      = FieldDataSource.None,
                IsRequiredField = false
            };

            model.Filters.Add(issueDateFromFilter);

            var issueDateToFilter = new FieldModel
            {
                DisplayOrder    = 5,
                Name            = "IssueDateTo",
                ResourceKey     = "Issue.IssueDateTo",
                DbColumn        = "Issue.IssueDate",
                Value           = null,
                ControlType     = FieldControlType.DateTime,
                DataType        = FieldDataType.DateTime,
                DataSource      = FieldDataSource.None,
                IsRequiredField = false
            };

            model.Filters.Add(issueDateToFilter);

            return(model);
        }
Esempio n. 35
0
        /// <summary>
        /// Html 表單欄位元件
        /// </summary>
        /// <param name="field"></param>
        /// <param name="answer"></param>
        /// <returns></returns>
        public ActionResult HtmlField(FieldModel field, FieldAnswerModel answer)
        {
            ViewBag.Answer = answer;

            switch (field.TypeID)
            {
                #region 地址

            case "address":

                ViewBag.Levels1 = new List <SelectListItem>();
                ViewBag.Levels2 = new List <SelectListItem>();
                ViewBag.Levels3 = new List <SelectListItem>();
                ViewBag.Levels4 = new List <SelectListItem>();

                var regionLevel1 = WorldRegionDAO.GetRegionsByLevel(1);
                var regionLevel2 = WorldRegionDAO.GetRegionsByLevel(2);
                var regionLevel3 = WorldRegionDAO.GetRegionsByLevel(3);
                var regionLevel4 = WorldRegionDAO.GetRegionsByLevel(4);

                AddressAnswerModel ans = null;

                if (answer != null && !string.IsNullOrWhiteSpace(answer.Answer))
                {
                    ans = JsonConvert.DeserializeObject <AddressAnswerModel>(answer.Answer);
                }

                var levels1 = new List <SelectListItem>();
                var levels2 = new List <SelectListItem>();
                var levels3 = new List <SelectListItem>();
                var levels4 = new List <SelectListItem>();

                var parentID = field.RangeLimit;

                if (!field.Range)
                {
                    foreach (var item in regionLevel1)
                    {
                        var isAns = false;
                        if (ans != null)
                        {
                            if (ans.Level1 == item.ID)
                            {
                                isAns    = true;
                                parentID = item.ID;
                            }
                        }
                        levels1.Add(new SelectListItem {
                            Text = item.Name, Value = item.ID.ToString(), Selected = isAns
                        });
                    }
                    ViewBag.Levels1 = levels1;
                }

                if ((field.Range && field.RangeLevel == 1) || (ans != null && ans.Level2 != null))
                {
                    foreach (var item in regionLevel2.Where(x => x.ParentID == parentID))
                    {
                        var isAns = false;
                        if (ans != null)
                        {
                            if (ans.Level2 == item.ID)
                            {
                                isAns    = true;
                                parentID = item.ID;
                            }
                        }
                        levels2.Add(new SelectListItem {
                            Text = item.Name, Value = item.ID.ToString(), Selected = isAns
                        });
                    }
                    ViewBag.Levels2 = levels2;
                }

                if ((field.Range && field.RangeLevel == 2) || levels2.Count == 0 || (ans != null && ans.Level3 != null))
                {
                    foreach (var item in regionLevel3.Where(x => x.ParentID == parentID))
                    {
                        var isAns = false;
                        if (ans != null)
                        {
                            if (ans.Level3 == item.ID)
                            {
                                isAns    = true;
                                parentID = item.ID;
                            }
                        }
                        levels3.Add(new SelectListItem {
                            Text = item.Name, Value = item.ID.ToString(), Selected = isAns
                        });
                    }
                    ViewBag.Levels3 = levels3;
                }

                if ((field.Range && field.RangeLevel == 3) || levels3.Count == 0 || (ans != null && ans.Level4 != null))
                {
                    foreach (var item in regionLevel4.Where(x => x.ParentID == parentID))
                    {
                        var isAns = false;
                        if (ans != null)
                        {
                            if (ans.Level4 == item.ID)
                            {
                                isAns    = true;
                                parentID = item.ID;
                            }
                        }
                        levels4.Add(new SelectListItem {
                            Text = item.Name, Value = item.ID.ToString(), Selected = isAns
                        });
                    }
                    ViewBag.Levels4 = levels4;
                }

                break;

                #endregion
            }

            return(View(field));
        }