コード例 #1
0
        private void callBack(IAsyncResult ar)
        {
            bool     b      = func.EndInvoke(ar);
            GroupMsg tmpmsg = ar.AsyncState as GroupMsg;

            if (b)
            {
                UserDB udb = new UserDB()
                {
                    userName = tmpmsg.GroupName, lastAddr = tmpmsg.Area, lastTime = DateTime.Parse(tmpmsg.LoadTime), phone = tmpmsg.Phone
                };
                if (tmpmsg.FileMsgList.Count(t => int.Parse(t.state) < 3) == 0)
                {
                    OutUser(tmpmsg, udb);
                    //ExcelHelper.AddMs(tmpmsg);
                }
                SqlModlus.SaveGroupMsg(tmpmsg);
                if (str.Length > 0)
                {
                    MessageBox.Show("打印异常:" + str);
                    str = "";
                }
                foreach (var v in tmpmsg.FileMsgList)
                {
                    if (usingPrinter.ContainsKey(v.Printer))
                    {
                        usingPrinter[v.Printer] = false;
                    }
                }
                tmpmsg.isPrint = false;
            }
            else
            {
                if (tmpmsg.isAbort)
                {
                    tmpmsg.FileMsgList.ForEach(t => t.state = "0");
                }
                foreach (var v in tmpmsg.FileMsgList)
                {
                    if (usingPrinter.ContainsKey(v.Printer))
                    {
                        usingPrinter[v.Printer] = false;
                    }
                }
            }
            tmpmsg.isPrint     = false;
            tmpmsg.isAbort     = false;
            tmpmsg.isCanceling = false;
        }
コード例 #2
0
 private void frm_Main_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!unInit)
     {
         if (main.groupList.FindIndex(t => t.isPrint == true) != -1)
         {
             MessageBox.Show("请打印文件完成后再退出!");
             e.Cancel = true;
         }
         if (this.Text.IndexOf(preString) != -1)
         {
             this.Text.Replace(preString, "-正在关闭...");
         }
         else
         {
             this.Text += "-正在关闭...";
         }
         foreach (var v in main.groupList)
         {
             if (!v.isRemove)
             {
                 SqlModlus.SaveGroupMsg(v);
             }
         }
         try
         {
             bExit               = true;
             WordToPdf.RunFlag   = false;
             ExcelHelper.RunFlag = false;
             WordToPdf.Stop();
             ExcelHelper.Stop();
             foreach (var v in FileHelper.lockFileList)
             {
                 v.fs.Close();
                 File.Delete(v.FullName);
             }
             LogOperate.Add("软件关闭!");
             LogOperate.Stop();
         }
         catch { }
     }
 }