示例#1
0
        public ActionResult Home()
        {
            //if (!Utits.IsLogin)
            //{
            //    return RedirectPermanent("/Login/Index");
            //}
            //var currentUser = Utits.CurrentUser;
            //ViewBag.LogPerson = currentUser.user_TrueName;
            ViewBag.LogPerson = "管理员";// currentUser.user_TrueName;

            var cNetBll  = new BLL_Network();
            var cRoomBll = new BLL_ComputerRoom();
            var cTerBll  = new BLL_Terminal();
            var cSecuBll = new BLL_Security();
            var cCproBll = new BLL_ConstructionProject();
            var cResBll  = new BLL_ResourceCatalog();
            var cGSoft   = new BLL_GenuineSoftware();


            var Netlist   = cNetBll.GetObjectAll();
            var Roomlist  = cNetBll.GetObjectAll();
            var Terlist   = cTerBll.GetObjectAll();
            var Seculist  = cSecuBll.GetObjectAll();
            var Cprolist  = cCproBll.GetObjectAll();
            var Reslist   = cResBll.GetObjectAll();
            var GSoftlist = cGSoft.GetObjectAll();

            ViewBag.jhj   = Netlist.Sum(c => c.scjhj);
            ViewBag.gx    = Netlist.Sum(c => c.gx);
            ViewBag.wxjrd = Netlist.Sum(c => c.wxjrd);

            ViewBag.jfsl = Roomlist.Count();

            ViewBag.zd    = Terlist.Sum(c => c.zdsl);
            ViewBag.jrww  = Terlist.Sum(c => c.jrzwwwsl);
            ViewBag.az360 = Terlist.Sum(c => c.az360tysl);

            ViewBag.fwq = Seculist.Sum(c => c.fhq);
            ViewBag.VPN = Seculist.Sum(c => c.VPNsb);

            ViewBag.xxm = Cprolist.Count();

            ViewBag.zyml = Reslist.Sum(c => c.zymlsl);
            ViewBag.ysj  = Reslist.Sum(c => c.ysjzyl);
            ViewBag.gxzy = Reslist.Sum(c => c.gxcs);
            ViewBag.fwzy = Reslist.Sum(c => c.fwl);

            ViewBag.czxt = GSoftlist.Count();

            return(View());
        }
        /// <summary>
        /// 1
        /// </summary>
        /// <returns></returns>
        public JsonResult ListPhyDel1()
        {
            var sReturnModel = new ReturnMessageModel();

            #region 登录验证
            if (!Utits.IsLogin)
            {
                sReturnModel.ErrorType      = 3;
                sReturnModel.MessageContent = "登录状态已失效.";
                return(Json(sReturnModel));
            }
            #endregion
            var ids = RequestParameters.Pstring("ids");
            if (ids.Length < 1)
            {
                sReturnModel.ErrorType      = 0;
                sReturnModel.MessageContent = "参数错误.";
                return(Json(sReturnModel));
            }
            var        tempArry = ids.Split(',');
            List <int> delIds   = new List <int>();
            foreach (var s in tempArry)
            {
                if (RegexValidate.IsInt(s))
                {
                    delIds.Add(int.Parse(s));
                }
            }
            if (!delIds.Any())
            {
                sReturnModel.ErrorType      = 0;
                sReturnModel.MessageContent = "参数格式错误.";
                return(Json(sReturnModel));
            }
            var cBll = new BLL_ComputerRoom();

            if (cBll.PhysicalDelete1(delIds.ToArray()))
            {
                sReturnModel.ErrorType      = 1;
                sReturnModel.MessageContent = "操作成功.";
            }
            else
            {
                sReturnModel.ErrorType      = 0;
                sReturnModel.MessageContent = "操作失败.";
            }
            return(Json(sReturnModel));
        }
示例#3
0
        /// <summary>
        /// 机房情况(部门/间)
        /// </summary>
        /// <returns></returns>
        public JsonResult JFApi()
        {
            var sReturnModel = new ReturnDetailModel();

            var cBll = new BLL_ComputerRoom();
            var list = cBll.GetObjectAll();

            list = list.OrderByDescending(o => o.ID).Distinct().ToList();

            sReturnModel.ErrorType = 1;
            if (list != null)
            {
                sReturnModel.Entity = from a in list
                                      select new
                {
                    name  = a.Dept_Name,
                    value = a.fwq
                };
            }
            return(Json(sReturnModel));
        }
        public JsonResult InitSingle()
        {
            var sReturnModel = new ReturnDetailModel();

            #region 登录验证
            if (!Utits.IsLogin)
            {
                sReturnModel.ErrorType      = 3;
                sReturnModel.MessageContent = "登录状态已失效.";
                return(Json(sReturnModel));
            }
            #endregion
            int id = RequestParameters.Pint("ID");
            if (id < 1)
            {
                sReturnModel.ErrorType      = 0;
                sReturnModel.MessageContent = "参数错误.";
                return(Json(sReturnModel));
            }
            var cBll = new BLL_ComputerRoom();
            sReturnModel.ErrorType = 1;
            sReturnModel.Entity    = cBll.GetObjectDeptById(id);
            return(Json(sReturnModel));
        }
        public JsonResult AddOrUpdate()
        {
            var sReturnModel = new ReturnMessageModel();

            #region 登录验证
            if (!Utits.IsLogin)
            {
                sReturnModel.ErrorType      = 3;
                sReturnModel.MessageContent = "登录状态已失效.";
                return(Json(sReturnModel));
            }
            #endregion

            int    id     = RequestParameters.Pint("ID");
            string DeptId = RequestParameters.Pstring("Dept_Id");
            int    jg     = RequestParameters.Pint("jg");
            int    kt     = RequestParameters.Pint("kt");
            int    sxt    = RequestParameters.Pint("sxt");
            int    mhq    = RequestParameters.Pint("mhq");
            int    UPS    = RequestParameters.Pint("UPS");
            int    fhm    = RequestParameters.Pint("fhm");
            int    fhdb   = RequestParameters.Pint("fhdb");
            int    qtmhzz = RequestParameters.Pint("qtmhzz");
            int    fljsb  = RequestParameters.Pint("fljsb");
            int    fjdsb  = RequestParameters.Pint("fjdsb");
            int    fdcgr  = RequestParameters.Pint("fdcgr");
            int    fcsb   = RequestParameters.Pint("fcsb");
            int    fwq    = RequestParameters.Pint("fwq");

            if (fwq < 1)
            {
                sReturnModel.ErrorType      = 0;
                sReturnModel.MessageContent = "操作失败:服务器数量不能小于1台.";
                return(Json(sReturnModel));
            }

            var currentUser = Utits.CurrentUser;

            #region 检查参数(暂不做处理)
            //if (ECode.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:员工号不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (WCode.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:考勤号不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (Name.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:姓名不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (Dept.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:部门不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (Login.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:登录名不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (Role == Guid.Empty)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:角色不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (id < 1 && Password.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:密码不能为空.";
            //    return Json(sReturnModel);
            //}
            #endregion

            var             cBll = new BLL_ComputerRoom();
            td_ComputerRoom model;
            if (id > 0)
            {
                model = cBll.GetObjectById(id);
                if (model == null)
                {
                    sReturnModel.ErrorType      = 0;
                    sReturnModel.MessageContent = "操作失败.";
                    return(Json(sReturnModel));
                }
            }

            model            = new td_ComputerRoom();
            model.ID         = id;
            model.OperatPid  = currentUser.user_Id;
            model.OperatTime = DateTime.Now;

            model.Dept_Id = DeptId;

            model.jg     = jg;
            model.kt     = kt;
            model.sxt    = sxt;
            model.mhq    = mhq;
            model.UPS    = UPS;
            model.fhm    = fhm;
            model.fhdb   = fhdb;
            model.qtmhzz = qtmhzz;
            model.fljsb  = fljsb;
            model.fjdsb  = fjdsb;
            model.fdcgr  = fdcgr;
            model.fcsb   = fcsb;
            model.fwq    = fwq;

            if (cBll.AddOrUpdate(model))
            {
                sReturnModel.ErrorType      = 1;
                sReturnModel.MessageContent = "操作成功.";
            }
            else
            {
                sReturnModel.ErrorType      = 0;
                sReturnModel.MessageContent = "操作失败.";
            }
            return(Json(sReturnModel));
        }
        /// <summary>
        /// 1
        /// </summary>
        /// <returns></returns>
        public JsonResult LoadPageList1()
        {
            var sReturnModel = new ReturnListModel();

            #region 登录验证
            var currentUser = Utits.CurrentUser;
            if (currentUser == null)
            {
                sReturnModel.ErrorType      = 3;
                sReturnModel.MessageContent = "登录状态已失效.";
                return(Json(sReturnModel));
            }
            #endregion
            #region 参数处理
            #region 分页参数
            int page = RequestParameters.Pint("page");
            int size = RequestParameters.Pint("size");
            if (page < 1 || size < 1)
            {
                sReturnModel.ErrorType      = 0;
                sReturnModel.MessageContent = "参数错误.";
                return(Json(sReturnModel));
            }
            #endregion
            var condition = new ConditionModel();
            #region 查询参数
            var whereList = new List <WhereCondition>();
            //部门名称
            string Search = RequestParameters.Pstring("SearchDept");
            if (Search.Length > 0)
            {
                var where1Condition = new WhereCondition();
                where1Condition.FieldName     = "Dept_Name";
                where1Condition.FieldOperator = EnumOper.Contains;
                where1Condition.FieldValue    = Search;
                whereList.Add(where1Condition);
            }
            condition.WhereList = whereList;
            #endregion
            #region 排序参数
            var orderList      = new List <OrderCondition>();
            var orderCondition = new OrderCondition();
            orderCondition.Ascending  = true;
            orderCondition.FiledOrder = "OperatTime";
            orderList.Add(orderCondition);
            condition.OrderList = orderList;
            #endregion
            #endregion
            int iTotalRecord = 0, iPageIndex = page - 1, iPageSize = size;
            var cBll = new BLL_ComputerRoom();
            var list = cBll.GetPageListByCondition1(iPageIndex, iPageSize, ref iTotalRecord, condition);
            iPageSize = iPageSize == 0 ? iTotalRecord : iPageSize;
            int pageCount = iTotalRecord % iPageSize == 0 ? iTotalRecord / iPageSize : iTotalRecord / iPageSize + 1;

            sReturnModel.ErrorType   = 1;
            sReturnModel.CurrentPage = page;
            sReturnModel.PageSize    = iPageSize;
            sReturnModel.TotalRecord = iTotalRecord;
            sReturnModel.PageCount   = pageCount;
            if (list != null)
            {
                sReturnModel.Data = from a in list
                                    select new
                {
                    a.ID,
                    a.Dept_Name,
                    a.jfwlwz,
                    a.mj,
                    a.jflx,
                    a.lsgx,
                    a.sfjrczww,
                }
            }
            ;
            return(Json(sReturnModel));
        }
示例#7
0
        /// <summary>
        /// 机房
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public JsonResult ImportRoomExcelFile(HttpPostedFileBase file)
        {
            // string filePath = RequestParameters.Pstring("filePath");
            if (!Utits.IsLogin)
            {
                return(Json(new { jsonrpc = 2.0, error = new { code = 102, message = "登录状态已失效." } }));
            }
            string filePathName = string.Empty;
            string localPath    = Server.MapPath(string.Format("/{0}/RoomData/", Utits.UploadExcelPath));

            if (Request.Files.Count == 0)
            {
                return(Json(new { jsonrpc = 2.0, error = new { code = 100, message = "文件上传失败." } }));
            }

            //  string ex = Path.GetExtension(file.FileName);
            filePathName = DateTime.Now.ToString("yyyyMMddHHssmm") + "_" + file.FileName;
            if (!System.IO.Directory.Exists(localPath))
            {
                System.IO.Directory.CreateDirectory(localPath);
            }
            file.SaveAs(localPath + filePathName);

            #region 信息
            try
            {
                var currentUser = Utits.CurrentUser;
                var OpUserId    = currentUser.user_Id;
                var Opdate      = System.DateTime.Now;

                var cBll = new BLL_ComputerRoom();
                List <td_ComputerRoom_1>      list      = new List <td_ComputerRoom_1>();
                List <td_ComputerRoom_sbsl_1> list_sbsl = new List <td_ComputerRoom_sbsl_1>();

                using (FileStream fsfile = new FileStream(localPath + filePathName, FileMode.Open, FileAccess.Read))
                {
                    XSSFWorkbook             workbook = new XSSFWorkbook(fsfile);
                    NPOI.SS.UserModel.ISheet sheet    = workbook.GetSheetAt(0); //第一个工作表
                    ISheet sheet_sbsl = workbook.GetSheetAt(1);
                    ///Excel 第一行是标题,不需要导入数据库的
                    for (int i = 1; i <= sheet.LastRowNum; i++)
                    {
                        IRow row = sheet.GetRow(i);
                        td_ComputerRoom_1 Room = new td_ComputerRoom_1();

                        if (row.GetCell(0) == null)
                        {
                            Room.Dept_Name = "";
                        }
                        else
                        {
                            Room.Dept_Name = row.GetCell(0).StringCellValue;
                        }

                        if (row.GetCell(1) == null)
                        {
                            Room.jfwlwz = "";
                        }
                        else
                        {
                            Room.jfwlwz = row.GetCell(1).StringCellValue;
                        }

                        if (row.GetCell(2) == null)
                        {
                            Room.mj = 0;
                        }
                        else
                        {
                            Room.mj = Convert.ToInt32(row.GetCell(2).NumericCellValue);
                        }

                        if (row.GetCell(3) == null)
                        {
                            Room.jflx = "";
                        }
                        else
                        {
                            Room.jflx = row.GetCell(3).StringCellValue;
                        }

                        if (row.GetCell(4) == null)
                        {
                            Room.lsgx = "";
                        }
                        else
                        {
                            Room.lsgx = row.GetCell(4).StringCellValue;
                        }

                        if (row.GetCell(5) == null)
                        {
                            Room.sfjrczww = "";
                        }
                        else
                        {
                            Room.sfjrczww = row.GetCell(5).StringCellValue;
                        }

                        if (row.GetCell(6) == null)
                        {
                            Room.jfglyxm = "";
                        }
                        else
                        {
                            Room.jfglyxm = row.GetCell(6).StringCellValue;
                        }

                        if (row.GetCell(7) == null)
                        {
                            Room.lxfs = "";
                        }
                        else
                        {
                            Room.lxfs = row.GetCell(7).NumericCellValue.ToString();
                        }

                        Room.OperatTime = Opdate;
                        Room.OperatPid  = OpUserId;

                        list.Add(Room);
                    }

                    for (int i = 1; i <= sheet_sbsl.LastRowNum; i++)
                    {
                        IRow row = sheet_sbsl.GetRow(i);
                        td_ComputerRoom_sbsl_1 Room_sl = new td_ComputerRoom_sbsl_1();

                        if (row.GetCell(0) == null)
                        {
                            Room_sl.Dept_Name = "";
                        }
                        else
                        {
                            Room_sl.Dept_Name = row.GetCell(0).StringCellValue;
                        }


                        if (row.GetCell(1) == null)
                        {
                            Room_sl.sbmc = "";
                        }
                        else
                        {
                            Room_sl.sbmc = row.GetCell(1).StringCellValue;
                        }

                        if (row.GetCell(2) == null)
                        {
                            Room_sl.pp = "";
                        }
                        else
                        {
                            Room_sl.pp = row.GetCell(2).StringCellValue;
                        }

                        if (row.GetCell(2) == null)
                        {
                            Room_sl.pp = "";
                        }
                        else
                        {
                            Room_sl.pp = row.GetCell(2).StringCellValue;
                        }

                        if (row.GetCell(3) == null)
                        {
                            Room_sl.xh = "";
                        }
                        else
                        {
                            Room_sl.xh = row.GetCell(3).StringCellValue;
                        }

                        if (row.GetCell(4) == null)
                        {
                            Room_sl.sl = 0;
                        }
                        else
                        {
                            Room_sl.sl = Convert.ToInt32(row.GetCell(4).NumericCellValue);
                        }

                        //Room_sl.OperatTime = Opdate;
                        //Room_sl.OperatPid = OpUserId;

                        list_sbsl.Add(Room_sl);
                    }

                    if (cBll.AddImport(list) && cBll.AddImport_sl(list_sbsl))
                    {
                        return(Json(new { jsonrpc = 2.0, message = "导入成功." }));
                    }
                    else
                    {
                        return(Json(new { jsonrpc = 2.0, error = new { code = 100, message = "导入失败." } }));
                    }
                }
            }
            catch (Exception e)
            {
                MessageLog.AddLog(string.Format("UpDataProcess(数据导入)异常:{0}", e.Message));
            }
            return(Json(new { jsonrpc = 2.0, error = new { code = 100, message = "系统错误.(请确保数据完整)" } }));

            #endregion
        }