• txt内容导入数据库


    public bool ImportPurviewManIds(string fileName, string CurrentUserDomainId, string Pduid, string uploadtype) 
            { 
                try 
                { 
                    if (File.Exists(fileName)) 
                    { 
                        //读取文件 一行一行读取 
                        StreamReader objReader = new StreamReader(fileName, Encoding.Default); 
                        string sLine = ""; 
                        List<string> arrText = new List<string>(); 

                        while (sLine != null) 
                        { 
                            sLine = objReader.ReadLine(); 
                            if (!string.IsNullOrEmpty(sLine)) 
                            { 
                                arrText.Add(sLine); 
                            } 
                        } 
                        objReader.Close(); 


                        List<iPAL.Models.Pub.INFO_USER_CONFIG> objlist = new List<INFO_USER_CONFIG>(); 
                        IUserVisit uv = new UserVisit(); 
                        foreach (string strline in arrText.Distinct()) 
                        { 
                            if (string.IsNullOrEmpty(strline.Trim())) 
                                continue; 
                            UserInfo info = uv.GetHRInfo(strline.ToLower().Trim()); 
                            INFO_USER_CONFIG obj = new INFO_USER_CONFIG(); 
                            obj.SvrId = int.Parse(Pduid); 
                            obj.RoleName = "普通用户"; 
                            obj.UserId = strline.ToLower().Trim(); 
                            obj.UserCnName = info.UserName; 
                            objlist.Add(obj); 

                        } 
                        db.INFO_USER_CONFIG.InsertAllOnSubmit(objlist); 
                        db.SubmitChanges(); 
                    } 
                    return true; 
                } 
                catch (Exception ex) 
                { 
                    throw ex; 
                    return false; 
                } 
            }

  • 相关阅读:
    bug排查
    做接口测试没反应
    wcf配置文件
    mvc学习-编辑提交需要注意-mvc重点
    大批量导出思路
    进程基础知识
    (转)JMS事务
    (转)JMS简明学习教程
    (转)Linux下使用system()函数一定要谨慎
    LInux文件基础知识和文件目录操作(二)文件I/O操作
  • 原文地址:https://www.cnblogs.com/cw_volcano/p/2173526.html
Copyright © 2020-2023  润新知