示例#1
0
        public ActionResult AddSubStrucToCurrentStruc(int parentID, string parentStrucName)
        {
            StructureAddSubModel model = new StructureAddSubModel();

            model.InspectType1    = true;
            model.ExNoticeType1   = true;
            model.MapType1        = true;
            model.MapType2        = true;
            model.MapType3        = true;
            model.ParentID        = parentID;
            model.ParentStrucName = parentStrucName;

            return(PartialView("_AddSubStructureInfo", model));
        }
示例#2
0
        public ActionResult AddSubStrucToCurrentStruc(StructureAddSubModel model)
        {
            //暂时没有做相应的验证特性,进行手动验证
            //一个地图类型都没有选
            if (!(model.MapType1 || model.MapType2 || model.MapType3))
            {
                ModelState.AddModelError("MapType1", DataAnnotations.StructureMustSelectMapType);
            }
            //上传了LOGO文件则验证logo格式与大小 只能是png或jpg 最大1M
            if (model.LogoFile != null)
            {
                Regex reg = new Regex(@"\.(png|PNG|jpg|JPG|jpeg|jpeg)$");

                if (!reg.IsMatch(model.LogoFile.FileName))
                {
                    ModelState.AddModelError("LogoFile", DataAnnotations.LogoTypeError);
                }
                else if (model.LogoFile.ContentLength > 1024 * 1024)
                {
                    ModelState.AddModelError("LogoFile", DataAnnotations.LogoSizeError);
                }
            }


            if (ModelState.IsValid)
            {
                if (model.LogoFile != null)
                {
                    //将图片转换为字节数组
                    int    logoLength = model.LogoFile.ContentLength;
                    byte[] logoBytes  = new byte[logoLength];
                    model.LogoFile.InputStream.Read(logoBytes, 0, logoLength);
                    model.Logo = logoBytes;
                }


                var result = StructureBLL.AddStructure(model);
                base.DoLog(OperationTypeEnum.Add, result, "StrucName:" + model.StrucName);
                return(Json(result));
            }
            else
            {
                return(PartialView("_AddSubStructureInfo", model));
            }
        }