• Asp.Net 实现线程传递多个参数。。。。。。。。。。。。。(并利用线程动态替代Word内的书签等)


    using System.IO;
    using System.Threading;


                ThreadOutput to1 
    = new ThreadOutput();
                to1.picName 
    = pic;
                to1.companyName 
    = company;
                to1.chuName 
    = chu;
                to1.traID 
    = traid;
                Thread tThread 
    = new Thread(new ThreadStart(to1.WordSaveAs));
                
    // 设置为后台线程,主要是为不影响主线程的结束
                 tThread.IsBackground = true;
                tThread.Start();



     
    //*******************
        public class ThreadOutput
        {
            
    string pic = "";        //抬头图片
            string company = "";    //名称 
            int travelid = -1;      //ID
            string chu = "";  //名称

            
    /// <summary>
            
    /// 抬头图片
            
    /// </summary>
            public string picName
            {
                
    set { pic = value; }
            }
            
    /// <summary>
            
    /// 名称
            
    /// </summary>
            public string companyName
            {
                
    set { company = value; }
            }
            
    /// <summary>
            
    /// ID
            
    /// </summary>
            public int tralID
            {
                
    set { travelid = value; }
            }
            
    /// <summary>
            
    /// 办事处名称
            
    /// </summary>
            public string chuName
            {
                
    set { banshichu = value; }
            }

            
    /// <summary>
            
    /// 要分割的字符
            
    /// </summary>
            
    /// <param name="txt">分割的字符</param>
            
    /// <param name="lex">所取的值</param>
            
    /// <returns></returns>
            public string splitText(object txt, int lex)
            {
                
    string label = txt.ToString();
                
    if (label != "")
                {
                    
    string[] strArr = label.Split('&');

                    
    if (strArr.Length >= lex)
                        
    return strArr[lex].ToString();
                    
    else
                        
    return "";
                }
                
    else
                {
                    
    return "";
                }
            }
      
            
    //另存抬头
            public void WordSaveAs()
            {
          
                
    //获取文件列表 
                string sd = AppDomain.CurrentDomain.BaseDirectory + "travel_new\\doc\\";
                
    string[] files = Directory.GetFiles(sd); 

                
    foreach (string f in files)
                {
                    
    if (f.LastIndexOf("\\"!= -1)
                    {
                        
    string strFile = f.Substring(f.LastIndexOf("\\"+ 1);
                        
    string strLast = strFile.Substring(strFile.Length - 33);
                        
    if (strLast.ToLower() == "doc")
                        {
                            
    string strName = strFile.Substring(0, strFile.Length - 4);
                            
    string fileName = strName + ".doc";//客户端保存的文件名 
                            string filePath = AppDomain.CurrentDomain.BaseDirectory + "travel_new\\doc\\" + fileName;//路径
                            if (company != "")
                            {
                                
    //判断行程路线文档说明是否存在,不存在则创建替代文档,否则调用已存在的logo文档。
                                if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "travel_new\\doc\\logo\\" + strName + "_" + company + "_logo.doc"== false)
                                {
                                    
    if (pic != "")
                                    {
                                        
    if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\" + pic))
                                        {
                                            
    //进行logo标志替代,并另存为新文档。
                                            OutputWod.CreatWordDocument(strName, filePath, fileName, pic, company);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
  • 相关阅读:
    centos7安装webmin
    webmin账户重置密码
    gitlab访问用户安装的postgresql数据库
    更改配置:远程访问gitlab的postgresql数据库
    将gitlab中的postgresql数据库开通远程访问
    python的前后端分离(一):django+原生js实现get请求
    强制禁用gitlab的双因子认证:Two-Factor Authentication
    gitlab小结
    mysql DML语句
    基于memcache的缓存机制的6个指令
  • 原文地址:https://www.cnblogs.com/Fooo/p/1513700.html
Copyright © 2020-2023  润新知