public String PrintDocment()
        {
            String error_str_t = null;

            this.Wait();
            Debug.WriteLine(">>>>>>>>>进入打印+/n" + file.GetFileName());
            LogHelper.WriteLog(this.GetType(), i++.ToString());
            LogHelper.WriteLog(this.GetType(), ">>>>>>>>>进入打印+/n" + file.GetFileName());
#if true
            bool Success = false;


#if true
            Success = printerOnLocal.PrintDocment();
#endif


            if (Success == false)
            {
                LogHelper.WriteLog(this.GetType(), "本地打印【失败】");
                error_str_t = "机器故障";
#if USE_NET
                /*---本地打印失败-----*/
                try {
                    Success = printerOnNet.PrintDocment();
                }catch (Exception e) {
                    LogHelper.WriteLog(this.GetType(), e);
                }
#endif
            }
            else
            {
                LogHelper.WriteLog(this.GetType(), "本地打印【成功】");
            }

            /* if (false||LibCui.DeleteFileForce(file.mFileFullPath))
             * {
             *   LogHelper.WriteLog(this.GetType(), "文件【已删除】");
             * }
             * else {
             *   LogHelper.WriteLog(this.GetType(), "文件【删除失败】");
             * }*/
            //   LibCui.DeleteFile(file.GetPCLprnfullPath());
#endif

            if (Success == true)
            {
                //打印成功--
                PrintRecord pp = new PrintRecord();
                pp.WriteRecord2Disk(file);
                //
                PcCloudComm.Notify_Thread();
            }

            Debug.WriteLine("<<<<<<<<<<<退出打印");
            LogHelper.WriteLog(this.GetType(), "<<<<<<<<<<<退出打印");
            this.Release();

            return(error_str_t);
        }
示例#2
0
        /**
         *       保存提交信息到本地,
         *写入提交记录
         *
         */
        public void WriteSubmitRecord2Disk_NoPay(FileSendOnNet fson)
        {
            /*
             * 文件拷贝
             */
            {
                String from = fson.FileFullPath;
                String to   = GetFileFullPath_SubmitDocPath() + fson.GetFileName();
                File.Move(from, to);
                fson.FileFullPath = to;
            }

            this.Wait();
            try
            {
                PrintRecordItem PRI = new PrintRecordItem(fson);

                PRI.WriteSubmitRecord2Disk(true);

                PrintSubmitItems.Add(PRI);
            }
            catch (Exception e)
            {
                LogHelper.WriteLog(this.GetType(), e);
            }
            this.Release();
        }
 public bool PrintDocment()
 {
     if (File.Exists(file.mFileFullPath))
     {
         //打印?
         return(this.PrintDoc(file));
     }
     else
     {
         LogHelper.WriteLog(this.GetType(), "文件不存在" + file.GetFileName());
         return(false);
     }
 }
        public String PostFile2Server()
        {
            String filefullPath = file.mFileFullPath;

            StringBuilder FullUrl = new StringBuilder();

            FullUrl.Append(GetAppConfig("URL_POST_FILE"));
            FullUrl.Append("?LoginID=zhangxiaochen");
            FullUrl.Append("&Password=123123");
            FullUrl.Append("&FileName=" + HttpUtility.UrlEncode(file.GetFileName(), Encoding.UTF8));
            FullUrl.Append("&PrinterCopies=" + file.PParamcopies.ToString());
            FullUrl.Append("&PrinterColor=" + ((file.PParamcolor == true) ? 1 : 0).ToString());
            FullUrl.Append("&PrintPaperSize=A4");
            FullUrl.Append("&PrintRange=" + file.PParamRange);
            FullUrl.Append("&PrinterIsDuplex=" + ((file.PParam2Paper == true)?1:0).ToString());
            FullUrl.Append("&WifiMac=" + LibCui.GetWifiMacAddress());
            FullUrl.Append("&PrinterMachineMac=" + LibCui.GetLocalMacAddress());
            FullUrl.Append("&MachineBrand=" + HttpUtility.UrlEncode(file.GetPrinterName(), Encoding.UTF8));
            FullUrl.Append("&MachineType=" + HttpUtility.UrlEncode(file.GetPrinterName(), Encoding.UTF8));
            FullUrl.Append("&Latitude=" + "0");
            FullUrl.Append("&Logitude=" + "0");
            return(this.HttpPostFile(FullUrl.ToString(), filefullPath));
        }
示例#5
0
        public static FileSendOnNet RcvFileRawData(Socket client)
        {
            FileSendOnNet fileRcv        = new FileSendOnNet();
            long          FileLength     = 0;
            long          ReceivedLength = 0;
            FileStream    fs             = null;

            try
            {
                ;
                if (fileRcv.RcvFileHeader(client))
                {
#if true
                    LogHelper.WriteLog(typeof(PhonePcCommunication), "+++++++开始接受文件:" + fileRcv.GetFileName());
#endif
                    fs         = new FileStream(fileRcv.mFileFullPath, FileMode.Create);
                    FileLength = fileRcv.FileSize;
                    int    RcvOneReadFile = 0;
                    byte[] recvBytes      = new byte[1024];
                    //1.2接收文件内容
                    while (ReceivedLength < FileLength)
                    {
                        long UnReadLength = FileLength - ReceivedLength;
                        if (UnReadLength == 0)
                        {
                            break;
                        }
                        //有数据
                        RcvOneReadFile = client.Receive(
                            recvBytes,
                            0,
                            recvBytes.Length,
                            SocketFlags.None);

                        if (RcvOneReadFile == 0)
                        {
                            Thread.Sleep(200);
                            if (client.Available > 0)
                            {
                            }
                            else
                            {
                                Thread.Sleep(200);
                            }
                        }
                        else
                        {
                            ReceivedLength += RcvOneReadFile;
                            fs.Write(recvBytes, 0, RcvOneReadFile);
                        }
                    }
                }
            }
            catch (IOException e)
            {
                Debug.WriteLine("Request error: " + e);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Request error: " + ex);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Flush();
                    fs.Close();
                    fs.Dispose();
                }
                //  int test_t=-1;
                //  byte[] recvBytes = new byte[1024];
                if (ReceivedLength == FileLength)
                {
#if true
                    LogHelper.WriteLog(typeof(PhonePcCommunication), "-------文件【已接受】:" + fileRcv.GetFileName());
#endif
                    //test_t = client.Receive(
                    //           recvBytes,
                    //           0,
                    //           recvBytes.Length ,
                    //           SocketFlags.None);
                }
                else
                {
#if true
                    LogHelper.WriteLog(typeof(PhonePcCommunication), "********文件【接收失败】:" + fileRcv.GetFileName());
#endif
                    fileRcv.mFileFullPath = null;
                    DeleteFile(fileRcv);
                }
            }

            return(fileRcv);
        }