コード例 #1
0
        public void PrintDocment()
        {
            String error_str;

            this.Wait();
#if true
            bool Success = false;


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


            if (Success == false)
            {
        #if true
                /*---本地打印失败-----*/
                try {
                    Success = printerOnNet.PrintDocment();
                }catch (Exception e) {
                    LogHelper.WriteLog(this.GetType(), e);
                }
        #endif
            }
            LibCui.DeleteFile(file.mFileFullPath);
            LibCui.DeleteFile(file.GetPCLprnfullPath());
#endif
            this.Release();
            if (Success == true)
            {
                PrintRecord pp = new PrintRecord();
                pp.WriteRecord2Disk(file);
            }
        }
コード例 #2
0
        public String GetPrice2Pay()
        {
            String price_t = this.GetProperty("price2pay", PrintRecordItem.PriceNone);

            if (LibCui.IsStringNeg(price_t))
            {
                return(PrintRecordItem.PriceNone);
            }
            else
            {
                return(price_t);
            }
        }
コード例 #3
0
        public static IPAddress[] GetNetFindBroadcastaddr()
        {
            ArrayList mAddr = new ArrayList();

            ManagementClass            mc   = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection nics = mc.GetInstances();

            foreach (ManagementObject nic in nics)
            {
                if (Convert.ToBoolean(nic["ipEnabled"]) == true)
                {
                    try {
                        String ip         = (nic["IPAddress"] as String[])[0];
                        String mask       = (nic["IPSubnet"] as String[])[0];
                        String gate_way   = (nic["DefaultIPGateway"] as String[])[0];
                        String broad_cast = LibCui.GetBroadcast(ip, mask);
#if false
                        if (LibCui.IpIs_C_Type(ip) && false)
                        {
                            // C 类 IP 地址--所有地址
                            IPAddress addr     = IPAddress.Parse(ip);
                            byte[]    addrbyte = addr.GetAddressBytes();
                            for (int i = 1; i <= 254; i++)
                            {
                                addrbyte[addrbyte.Length - 1] = (byte)i;
                                IPAddress IPOne = new IPAddress(addrbyte);
                                mAddr.Add(IPOne);
                            }
                        }
                        else
                        {
                            //A,B 类 IP地址 --广播地址
                            mAddr.Add(IPAddress.Parse(broad_cast));
                        }
#else
                        mAddr.Add(IPAddress.Parse(broad_cast));
#endif
                    }catch (Exception e) {
                    }
                }
            }
            IPAddress[] ip_return = (IPAddress[])mAddr.ToArray(typeof(IPAddress));
            return(ip_return);
        }
コード例 #4
0
 private void MainForm_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F11)
     {
         this.timerUpdataBG.Stop();
         this.TransparencyKey = Color.Blue;
     }
     if (e.KeyCode == Keys.F12)
     {
         this.timerUpdataBG.Start();
     }
     if (e.KeyData == (Keys.L | Keys.Control))
     {
         String          a   = LibCui.ReadTxt("txt.txt");
         TextFilePrinter tfp = new TextFilePrinter(a);
         tfp.View();
         tfp.Print();
     }
 }
コード例 #5
0
        /**
         * 根据打印方式,计算价格
         */
        public String GetPrice()
        {
            lock (this) {
                if (string.IsNullOrEmpty(this._FileFullPath))
                {
                    //没有文件
                    return(PriceNone);
                }

                if (LibCui.IsStringNeg(this._Price))
                {
                    //价格没有设置

                    // public int    _PParamcopies =0;//份数
                    //public bool _PParamcolor = false;//彩打
                    //public String _PParamRange = "null";//打印范围
                    //public bool _PParam2Paper = false;//双面

                    //  double price_t=_PParamcopies* (_PParamcolor==true?0.1:0.1)*

                    int Pages = FilePages.GetFilePages(this._FileFullPath);
                    //页数*价格*份数

                    double Duplex = (_PParam2Paper == true) ? 1.1 : 1.0;
                    double Color  = (_PParamcolor == true) ? 1.1 : 1.0;

                    double Total_money = Pages * 0.1 * _PParamcopies * Duplex * Color;



                    return(this._Price = Total_money.ToString("0.00"));
                }
                else
                {
                    return(this._Price);
                }
                // return PriceNone;
            }
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        public static IPAddress[] GetUdpBroadcastaddr()
        {
            ArrayList mAddr = new ArrayList();

            ManagementClass            mc   = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection nics = mc.GetInstances();

            foreach (ManagementObject nic in nics)
            {
                if (Convert.ToBoolean(nic["ipEnabled"]) == true)
                {
                    try {
                        String ip         = (nic["IPAddress"] as String[])[0];
                        String mask       = (nic["IPSubnet"] as String[])[0];
                        String gate_way   = (nic["DefaultIPGateway"] as String[])[0];
                        String broad_cast = LibCui.GetBroadcast(ip, mask);
                        mAddr.Add(IPAddress.Parse(broad_cast));
                    }catch (Exception e) {
                    }
                }
            }
            IPAddress[] ip_return = (IPAddress[])mAddr.ToArray(typeof(IPAddress));
            return(ip_return);
        }
コード例 #8
0
        private byte[] GetNotifyMessageXml(bool IsMulity)
        {
            byte[] buf = null;

            XmlDocument    doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", null);

            doc.AppendChild(dec);

            XmlElement root = doc.CreateElement("CloudPrint");

            XmlNode node = doc.CreateElement("Notify");

            XmlElement elementPort = doc.CreateElement("Port");

            if (this.mTCPServer == null)
            {
                elementPort.InnerText = "10001";
            }
            else
            {
                elementPort.InnerText = ((IPEndPoint)(this.mTCPServer.LocalEndPoint)).Port.ToString();
            }

            node.AppendChild(elementPort);

            XmlElement elementHostType = doc.CreateElement("HostType");

            elementHostType.InnerText = "1";
            node.AppendChild(elementHostType);

            XmlElement elementHostName = doc.CreateElement("HostName");

            elementHostName.InnerText = "pc";
            node.AppendChild(elementHostName);

            XmlElement elementPhoneType = doc.CreateElement("PhoneType");

            elementPhoneType.InnerText = "n";
            node.AppendChild(elementPhoneType);

            XmlElement elementPcName = doc.CreateElement("PcName");

            elementPcName.InnerText = Dns.GetHostName();
            node.AppendChild(elementPcName);

            XmlElement elementPhoneNameAlias = doc.CreateElement("PhoneNameAlias");

            elementPhoneNameAlias.InnerText = "n";
            node.AppendChild(elementPhoneNameAlias);

            {
                XmlElement element = doc.CreateElement("MachineMac");
                element.InnerText = LibCui.GetLocalMacAddress();
                node.AppendChild(element);
            }

            XmlElement elementMultiply = doc.CreateElement("Multiply");

            if (IsMulity)
            {
                elementMultiply.InnerText = "true";
            }
            else
            {
                elementMultiply.InnerText = "false";
            }

            node.AppendChild(elementMultiply);



            root.AppendChild(node);

            doc.AppendChild(root);
            buf = Encoding.UTF8.GetBytes(doc.InnerXml);
            // doc.Save("Notify.xml");
            return(buf);
        }
コード例 #9
0
/**
 *
 *
 */
        public static void DeleteFile(FileSendOnNet fileRcv)
        {
            LibCui.DeleteFile(fileRcv.mFileFullPath);
        }