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; 
                } 
            }

  • 相关阅读:
    二、java基本语法
    LINQ入门教程之各种标准查询操作符(一)
    LINQ入门教程之各种标准查询操作符(二)
    读《穷爸爸 富爸爸》有想
    考考你的逻辑推理能力
    读《自控力》有感
    读大数据有感
    django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.的解决办法
    RabbitMQ入门
    ubuntu安装mysql可视化工具MySQL-workbench及简单操作
  • 原文地址:https://www.cnblogs.com/cw_volcano/p/2173526.html
Copyright © 2011-2022 走看看