コード例 #1
0
        private void GetDocFile(DirectoryInfo userPath, string userName)
        {
            WTPMsg wTPMsg;

            foreach (var v in userPath.GetFiles())
            {
                string[] ext = v.Name.Split('.');
                if (ext[ext.Length - 1].ToUpper() != "DOC" && ext[ext.Length - 1].ToUpper() != "DOCX")
                {
                    continue;
                }
                if ((v.Attributes & FileAttributes.Hidden) > 0)
                {
                    continue;
                }
                if (v.Name.IndexOf("~$") == 0)
                {
                    continue;
                }
                wTPMsg = new WTPMsg()
                {
                    FileName     = v.Name,
                    FullFileName = v.FullName,
                    UserName     = userName,
                    pority       = false
                };
                WordToPdf.AddMsg(wTPMsg);
            }
            foreach (var v in userPath.GetDirectories())
            {
                GetDocFile(v, userName);
            }
        }
コード例 #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 { }
     }
 }
コード例 #3
0
        private void AddNoConvertDocFile(DirectoryInfo userPath, string userName)
        {
            WTPMsg wTPMsg;

            foreach (var v in userPath.GetFiles())
            {
                if (UserHelper.isRefresh)
                {
                    return;
                }
                string[] ext = v.Name.Split('.');
                if (ext[ext.Length - 1].ToUpper() != "DOC" && ext[ext.Length - 1].ToUpper() != "DOCX")
                {
                    continue;
                }
                if ((v.Attributes & FileAttributes.Hidden) > 0)
                {
                    continue;
                }
                if (v.Name.IndexOf("~$") == 0)
                {
                    continue;
                }
                string newFileName = WordToPdf.GetPdfPath(v.FullName);
                if (File.Exists(newFileName))
                {
                    continue;
                }
                wTPMsg = new WTPMsg()
                {
                    FileName     = v.Name,
                    FullFileName = v.FullName,
                    UserName     = userName,
                    pority       = false
                };
                WordToPdf.AddMsg(wTPMsg);
            }
            foreach (var v in userPath.GetDirectories())
            {
                AddNoConvertDocFile(v, userName);
            }
        }
コード例 #4
0
        private void fileWatcher_Created(object sender, FileSystemEventArgs e)
        {
            if (!e.FullPath.Replace(fileWatcher.Path, "").Contains('\\'))
            {
                return;
            }
            string [] ext = e.Name.Split('.');
            if (ext[ext.Length - 1].ToUpper() != "DOC" && ext[ext.Length - 1].ToUpper() != "DOCX")
            {
                return;
            }
            string[] tmpStr = e.Name.Split('\\');
            WTPMsg   wTPMsg = new WTPMsg()
            {
                FileName     = tmpStr[tmpStr.Length - 1],
                FullFileName = e.FullPath,
                UserName     = tmpStr[0],
                pority       = false
            };

            WordToPdf.AddMsg(wTPMsg);
        }
コード例 #5
0
        public static List <FileMsg> GetAllFile(DirectoryInfo root, string userName, string userID, string newPath, string oldPath)
        {
            List <FileMsg> tmpList = new List <FileMsg>();

            FileInfo[]      files = root.GetFiles();
            DirectoryInfo[] info  = root.GetDirectories();
            foreach (var v in files)
            {
                if ((v.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                {
                    continue;
                }
                if (v.Extension.ToUpper() == "")
                {
                    continue;
                }
                if (v.Extension.ToUpper() == ".RAR")
                {
                    continue;
                }
                if (v.Extension.ToUpper() == ".ZIP")
                {
                    continue;
                }
                double filesize = System.Math.Ceiling(v.Length / 1024.0);
                //string strSize = "";
                //if (filesize > 1024)
                //    strSize = Math.Round((filesize / 1024.0), 2).ToString() + "M";
                //else
                //    strSize = filesize.ToString() + "K";
                if (v.Extension.ToUpper() == ".PDF")
                {
                    if (v.Name.IndexOf("W2P_tmp~W2P_tmp~") == 0)
                    {
                        continue;
                    }
                    string tmpPageCount = FileHelper.GetPDFofPageCount(v.FullName).ToString();
                    if (tmpPageCount == "-1")
                    {
                        tmpList.Add(new FileMsg()
                        {
                            FileSize     = filesize,
                            UserID       = userID,
                            FullName     = newPath + "\\" + v.FullName.Replace(oldPath, "").Trim('\\'),
                            FileName     = v.Name,
                            PageCount    = "----",
                            Count        = "1",
                            PrintColor   = "黑白",
                            VerForm      = "正反",
                            LoadTime     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            state        = "0",
                            isNew        = true,
                            isInit       = true,
                            isNormalFile = true
                        });
                    }
                    else
                    {
                        tmpList.Add(new FileMsg()
                        {
                            FileSize   = filesize,
                            UserID     = userID,
                            FullName   = newPath + "\\" + v.FullName.Replace(oldPath, "").Trim('\\'),
                            FileName   = v.Name,
                            PageCount  = tmpPageCount,
                            Count      = "1",
                            PrintColor = "黑白",
                            VerForm    = (tmpPageCount == "1" ? "单面" : "正反"),
                            LoadTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            state      = "0",
                            isNew      = true,
                            isInit     = true
                        });
                    }
                }
                else if (v.Extension.ToUpper() == ".DOC" || v.Extension.ToUpper() == ".DOCX")
                {
                    string newFileName1 = WordToPdf.GetPdfName(v.FullName);
                    string newFileName  = WordToPdf.GetPdfPath(v.FullName);

                    if (File.Exists(newFileName))
                    {
                        string tmpPageCount = FileHelper.GetPDFofPageCount(newFileName).ToString();
                        tmpList.Add(new FileMsg()
                        {
                            FileSize   = filesize,
                            UserID     = userID,
                            FullName   = newPath + "\\" + newFileName.Replace(oldPath, "").Trim('\\'),
                            FileName   = v.Name,
                            PageCount  = tmpPageCount,
                            Count      = "1",
                            PrintColor = "黑白",
                            VerForm    = tmpPageCount == "1"?"单面": "正反",
                            LoadTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            state      = "0",
                            isNew      = true,
                            isInit     = true
                        });
                    }
                    else
                    {
                        WTPMsg   wTPMsg = new WTPMsg();
                        string[] tmpStr = v.FullName.Split('\\');
                        wTPMsg.FileName     = tmpStr[tmpStr.Count() - 1];
                        wTPMsg.FullFileName = v.FullName;
                        wTPMsg.UserName     = userName;
                        LogOperate.Add("刷新检测Word没有转化,当前路径:" + newFileName + "," + userName);
                        WordToPdf.AddMsg(wTPMsg);
                        return(null);
                    }
                }
                else
                {
                    tmpList.Add(new FileMsg()
                    {
                        FileSize     = filesize,
                        UserID       = userID,
                        FullName     = newPath + "\\" + v.FullName.Replace(oldPath, "").Trim('\\'),
                        FileName     = v.Name,
                        PageCount    = "----",
                        Count        = "1",
                        PrintColor   = "黑白",
                        VerForm      = "正反",
                        LoadTime     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        state        = "0",
                        isNew        = true,
                        isInit       = true,
                        isNormalFile = true
                    });
                }
            }
            foreach (DirectoryInfo dir in info)
            {
                tmpList.AddRange(GetAllFile(dir, userName, userID, newPath, oldPath));
            }
            return(tmpList);
        }
コード例 #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //File.AppendAllLines(@"E:\代码\C#\Winform\私单\打印管理20190916\20190820\打印管理\打印管理\bin\Debug\log\logtext 20190926 171728.txt",new string[] { "123456"});

            bool b = SQLiteHelper.SQLiteInit(string.Format(@"Data Source={0}\PrintDB.db", Application.StartupPath), "jtmes");

            if (b)
            {
                KeyPreview = true;
                try
                {
                    foreach (var v in toolStrip1.Items)
                    {
                        if (v is ToolStripButton)
                        {
                            ToolStripButton Tbtn = v as ToolStripButton;
                            if (Convert.ToString(Tbtn.Tag) == "1")
                            {
                                Tbtn.Paint     += toolStrip1_Paint;
                                Tbtn.MouseMove += toolStrip1_MouseMove;
                            }
                        }
                    }
                    logFlag = Convert.ToBoolean(ConfigClass.GetConfigString("sys", "log", "true"));
                    LogOperate.Init();
                    LogOperate.Start();
                    LogOperate.Add("软件运行");
                    CurrentPath = ConfigClass.GetConfigString("File", "path", "");
                    if (!Directory.Exists(CurrentPath))
                    {
                        FolderBrowserDialog f = new FolderBrowserDialog();
                        if (f.ShowDialog() == DialogResult.OK)
                        {
                            CurrentPath = f.SelectedPath;
                            ConfigClass.SetConfigString("File", "path", CurrentPath);
                        }
                        else
                        {
                            unInit = true;
                            Application.Exit();
                        }
                    }
                    string strFastPrint = ConfigClass.GetConfigString("Printer", "speed", "false");
                    CK_fastPrint.Checked = strFastPrint.ToUpper() == "TRUE" ? true : false;
                    nFastPrint           = CK_fastPrint.Checked;
                    bool bConvert = Convert.ToBoolean(ConfigClass.GetConfigString("sys", "Convert", "false"));
                    if (bConvert)
                    {
                        timer2.Interval = 1000;
                        timer2.Enabled  = true;
                    }
                    else
                    {
                        fileWatcher.Path = CurrentPath;
                        fileWatcher.EnableRaisingEvents = true;
                    }
                    sysConfigData.printerName = ConfigClass.GetConfigString("sys", "小票打印机", "");
                    sysConfigData.ShopName    = ConfigClass.GetConfigString("sys", "店铺名称", "");
                    sysConfigData.BarcodePath = ConfigClass.GetConfigString("sys", "二维码路径", "");
                    sound = new System.Media.SoundPlayer("Audio.wav");
                    sound.Load();
                    //main.groupList = ConfigClass.LoadCookie<GroupMsg>("cookie.dat");
                    main.groupList = SqlModlus.selectTmpUserMsg();
                    if (main.groupList == null)
                    {
                        main.groupList = new List <GroupMsg>();
                    }
                    foreach (var v in main.groupList)
                    {
                        if (!v.isManual)
                        {
                            List <FileMsg> fmsg = SqlModlus.selectTmpFileMsg(v.UserID);
                            v.FileMsgList = fmsg;
                        }
                    }
                    main.groupList.ForEach(t => t.isPrint = false);
                    main.groupList.RemoveAll(t => t.isRemove == true);
                    txt_Date.Text = DateTime.Now.Date.ToLongDateString();
                    CurrentDate   = txt_Date.Text;

                    FileHelper.timelist = GetPeopleMsg.GetTimeList();
                    FileHelper.addrList = GetPeopleMsg.GetAddrList();
                    FileHelper.rowMsg   = GetDefaultAddMsg.getMsg();
                    GetPaperType.UpdatePaperList();
                    GetPrinterType.UpdatePrinterList();
                    GetPaperPrice.getPrice();

                    GetUserMsg(CurrentPath);
                    WordToPdf.Start();
                    DealControl(new int[] { 0, 0, 0 });
                    CheckForIllegalCrossThreadCalls = false;
                    treeView1.ExpandAll();
                    treeView1.MouseDoubleClick += new MouseEventHandler(treeView1_DoubleClick);
                    txt_path.Text = CurrentPath;
                    //FileHelper.act.BeginInvoke(frm_Main.CurrentPath, callback, null);
                    frm_MainMenu = New_Form(frm_MainMenu);
                    tooldoWork   = frm_MainMenu.doWork;
                    if (frm_MainMenu != null)
                    {
                        frm_MainMenu.setdgvPos(panel_Parent.Width, panel_Parent.Height);
                    }
                    ExcelHelper.Start();
                    frm_MainMenu.refresh("");
                    toolStrip2.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.toolStrip2_ItemClicked);
                    unInit = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("数据库连接异常!");
            }
        }