示例#1
0
        public async Task <ActionResult> ImportUser()       //导入用户
        {
            string    file_user = Server.MapPath("~") + "Files\\per.xlsx";
            DataTable dt;

            dt = OpenXmlExcelHelper.Import(file_user);


            List <Organization> orglist = db.Organizations.ToList();


            foreach (DataRow dr in dt.Rows)
            {
                var l    = orglist.Where(i => i.temp_id == dr[3].ToString().Trim()).FirstOrDefault();
                var user = new ApplicationUser()
                {
                    UserName = dr[0].ToString().Trim()
                };
                user.TrueName       = dr[1].ToString().Trim() + dr[2].ToString().Trim();
                user.OrganizationID = l.ID;
                var result = await UserManager.CreateAsync(user, "000000");
            }

            var json = new
            {
                okMsg = "ok"
            };

            return(Json(json, "text/html", JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public ActionResult test()
        {
            List <ItServiceItem> dd = bdb.ItServiceItems.ToList();
            DataTable            dt = ListToDataTable(dd);

            OpenXmlExcelHelper.ExportByWeb(dt, "ccc.xls", "aaa");
            var json = new
            {
                okMsg = "ok"
            };

            return(Json(json, "text/html", JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public string ImportOrg()           //导入组织机构
        {
            string    file_org = Server.MapPath("~") + "Files\\org.xlsx";
            DataTable dt;

            dt = OpenXmlExcelHelper.Import(file_org);


            string    file_orgrel = Server.MapPath("~") + "Files\\orgrel.xlsx";
            DataTable dtrel;

            dtrel = OpenXmlExcelHelper.Import(file_orgrel);



            foreach (DataRow dr in dt.Rows)
            {
                // sss+=dr[0].ToString()+""+dr[1].ToString()+dr[2].ToString()+"<br>";
                Organization org1 = new Organization();
                org1.orgName      = dr[2].ToString();
                org1.orgShortName = dr[1].ToString();
                org1.temp_id      = dr[0].ToString();

                foreach (DataRow drrel in dtrel.Rows)
                {
                    if (dr[0].ToString().Trim() == drrel[1].ToString().Trim())
                    {
                        org1.temp_pid = drrel[0].ToString().Trim();
                        continue;
                    }
                }


                db.Organizations.Add(org1);
                db.SaveChanges();
            }

            return("ok");
        }
示例#4
0
        public ActionResult IsiExportXls(string DealwithpeopleName, string isitype, string sub_isitype, string end_isitype, DateTime?logTimeB, DateTime?logTimeE)
        {
            int totalCount;
            var query = bdb.ItServiceItems.AsQueryable();
            List <ItServiceItem> list;



            totalCount = bdb.ItServiceItems.ToList().Count();

            if (!string.IsNullOrWhiteSpace(DealwithpeopleName))
            {
                query      = query.Where(i => i.DealwithpeopleName.Contains(DealwithpeopleName.Trim()));
                totalCount = query.ToList().Count();
            }

            if (!string.IsNullOrWhiteSpace(isitype))
            {
                query      = query.Where(i => i.isitype.Contains(isitype));
                totalCount = query.ToList().Count();
            }

            if (!string.IsNullOrWhiteSpace(sub_isitype))
            {
                query      = query.Where(i => i.sub_isitype.Contains(sub_isitype));
                totalCount = query.ToList().Count();
            }

            if (!string.IsNullOrWhiteSpace(end_isitype))
            {
                query      = query.Where(i => i.end_isitype.Contains(end_isitype));
                totalCount = query.ToList().Count();
            }

            if (!string.IsNullOrWhiteSpace(logTimeB.ToString()) && !string.IsNullOrWhiteSpace(logTimeE.ToString()))
            {
                logTimeE = logTimeE.Value.AddDays(1);
                query    = query.Where(i => i.isiCreateDate >= logTimeB && i.isiCreateDate <= logTimeE);
                //query = query.Where(w => w.logTime.ToString().Contains(logTime));
                totalCount = query.ToList().Count();
            }

            list = query.OrderByDescending(c => c.isiCreateDate).ToList();

            DataTable dt = new DataTable();

            dt.Columns.Add("标题", typeof(string));
            dt.Columns.Add("类别", typeof(string));
            dt.Columns.Add("申请人", typeof(string));
            dt.Columns.Add("申请时间", typeof(string));
            dt.Columns.Add("处理人", typeof(string));
            dt.Columns.Add("问题描述", typeof(string));
            dt.Columns.Add("解决方法", typeof(string));

            int k = 0;

            foreach (var item in list)
            {
                DataRow dr = dt.NewRow();
                dr["标题"]   = item.Title.ToString();
                dr["类别"]   = GetAllIsiType(item.isitype, item.sub_isitype, item.end_isitype);
                dr["申请人"]  = item.applicant;
                dr["申请时间"] = item.isiCreateDate.ToString("yyyy/MM/dd hh:mm:ss");
                dr["处理人"]  = item.DealwithpeopleName;
                dr["问题描述"] = item.description;
                dr["解决方法"] = item.solution;
                dt.Rows.Add(dr);
            }
            OpenXmlExcelHelper.ExportByWeb(dt, "result.xls", "result");

            var json = new
            {
                okMsg = "导出成功"
            };

            return(Json(json, "text/html", JsonRequestBehavior.AllowGet));
        }