Пример #1
0
        public ActionResult GetTypeTreeJson()
        {
            Operator user = OperatorProvider.Provider.Current();

            var treeList = new List <TreeEntity>();

            var where = string.Format(" and CreateUserOrgCode='{0}'", user.OrganizeCode);
            var data = nosatratypebll.GetList(where).OrderBy(t => t.CREATEDATE).ToList();

            foreach (var item in data)
            {
                bool       hasChild = data.Where(x => x.ParentId == item.ID).Count() > 0 ? true : false;
                TreeEntity tree     = new TreeEntity();
                tree.id             = item.ID;
                tree.text           = item.Name;
                tree.value          = item.ID;
                tree.parentId       = item.ParentId;
                tree.isexpand       = true;
                tree.complete       = true;
                tree.hasChildren    = hasChild;
                tree.Attribute      = "Code";
                tree.AttributeValue = item.Code;
                treeList.Add(tree);
            }
            return(Content(treeList.TreeToJson("-1")));
        }
Пример #2
0
        private KeyValuePair <NosatrafilesEntity, FileInfoEntity> GenEntity(object[] vals, UserBLL userbll, NosatratypeBLL nosatratypebll, string filePath)
        {
            var user = ERCHTMS.Code.OperatorProvider.Provider.Current();
            NosatrafilesEntity entity = new NosatrafilesEntity()
            {
                ID = Guid.NewGuid().ToString()
            };

            entity.FileName = vals[1].ToString().Trim();
            object obj  = vals[2].ToString().Trim();
            var    list = nosatratypebll.GetList(String.Format(" and createuserorgcode='{0}' and name='{1}'", user.OrganizeCode, obj.ToString())).ToList();

            entity.RefId         = list[0].ID;
            entity.RefName       = list[0].Name;
            entity.PubDepartName = vals[3].ToString().Trim();
            entity.PubUserName   = vals[4].ToString().Trim();
            var uEntity = userbll.GetUserInfoByName(entity.PubDepartName, entity.PubUserName);

            entity.PubUserId   = uEntity.UserId;
            entity.PubDepartId = uEntity.DepartmentId;
            entity.PubDate     = DateTime.Parse(vals[5].ToString());
            obj = vals[6];

            string         fn             = System.IO.Path.Combine(filePath, obj.ToString().Trim());
            var            fileinfo       = new FileInfo(fn);
            FileInfoEntity fileInfoEntity = new FileInfoEntity();

            fileInfoEntity.RecId          = entity.ID; //关联ID
            fileInfoEntity.FolderId       = "NosaTraFiles";
            fileInfoEntity.FileName       = obj.ToString().Trim();
            fileInfoEntity.FilePath       = string.Format("~/Resource/NosaTraFiles/{0}/{1}", DateTime.Now.ToString("yyyyMMdd"), obj.ToString().Trim());
            fileInfoEntity.FileSize       = (Math.Round(decimal.Parse(fileinfo.Length.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb)
            fileInfoEntity.FileExtensions = fileinfo.Extension;
            fileInfoEntity.FileType       = fileinfo.Extension.Replace(".", "");

            return(new KeyValuePair <NosatrafilesEntity, FileInfoEntity>(entity, fileInfoEntity));
        }
Пример #3
0
        private bool Validate(int index, object[] vals, UserBLL userbll, NosatratypeBLL nosatratypebll, string filePath, out string msg)
        {
            var r = true;
            var i = index + 1;

            msg = "";
            if (vals.Length < 7)
            {
                msg += ",格式不正确";
                r    = false;
            }
            var obj = vals[1];

            if (IsNull(obj))
            {
                msg += ",文件名不能为空";
                r    = false;
            }
            obj = vals[2];
            if (IsNull(obj))
            {
                msg += ",类别不能为空";
                r    = false;
            }
            else
            {
                var user = ERCHTMS.Code.OperatorProvider.Provider.Current();
                var list = nosatratypebll.GetList(String.Format(" and createuserorgcode='{0}' and name='{1}'", user.OrganizeCode, obj.ToString().Trim())).ToList();
                if (list.Count() == 0)
                {
                    msg += ",类别不存在";
                    r    = false;
                }
            }
            obj = vals[3];
            if (IsNull(obj))
            {
                msg += ",发布单位(部门)不能为空";
                r    = false;
            }

            obj = vals[4];
            if (IsNull(obj))
            {
                msg += ",发布人不能为空";
                r    = false;
            }
            else if (!IsNull(vals[3]))
            {
                var entity = userbll.GetUserInfoByName(vals[3].ToString().Trim(), obj.ToString().Trim());
                if (entity == null)
                {
                    msg += ",发布单位(部门)中不存在相应的发布用户";
                    r    = false;
                }
            }

            obj = vals[5];
            if (IsNull(obj))
            {
                msg += ",发布日期不能为空";
                r    = false;
            }
            else
            {
                DateTime pubDate = new DateTime();
                if (!DateTime.TryParse(obj.ToString(), out pubDate))
                {
                    msg += ",发布日期格式正确";
                    r    = false;
                }
            }

            obj = vals[6];
            if (IsNull(obj))
            {
                msg += ",附件名称不能为空";
                r    = false;
            }
            else
            {
                string fn = System.IO.Path.Combine(filePath, obj.ToString().Trim());
                if (!System.IO.File.Exists(fn))
                {
                    msg += ",附件名称不存在";
                    r    = false;
                }
            }

            if (!string.IsNullOrWhiteSpace(msg))
            {
                msg += "。";
                r    = false;
            }

            return(r);
        }