zoukankan      html  css  js  c++  java
  • 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; 
                } 
            }

  • 相关阅读:
    python入门6 字符串拼接、格式化输出
    python入门5 运算符
    python入门3 python变量,id(),is运算符
    python入门2 python字符串换行显示、字符串太长连接多行
    python入门1 python手动编译py_compile,compileall
    测试笔记:jsonp跨域接口测试
    Jmeter入门16 数据构造之随机数Random Variable & __Random函数
    Jmeter入门15 JSON Assertion 适用于json格式的响应断言
    openshift 配置ldap认证
    openshift node资源限制
  • 原文地址:https://www.cnblogs.com/cw_volcano/p/2173526.html
Copyright © 2011-2022 走看看