private void tmx_Tick(object sender, EventArgs e)
        {
            // Check if there PDF file in source folder
            POProcess FolderPO = new POProcess();

            var files = FolderPO.GetAllFile(FolderPO.srcFolder, "txt");

            // Check if it has
            if (!files.Length.Equals(0))
            {
                // Check if there is Internet Connection
                if (new Ping().Send("www.danubeco.com").Status != IPStatus.Success)
                {
                    RichTxt(rtBox, "unavailable..", Color.Red);

                    return;
                }

                // Disable timer so that it won't process any pdf
                tmx.Enabled = false;

                // Show uploader Form
                App.Upload frm = new App.Upload();

                // Inform System Log -> Uploader
                RichTxt(rtBox, "Processing..", Color.Green);

                // System log
                frm.SysLog += new App.Upload.SystemLog(sysLOG);

                if (frm.ShowDialog(this) == DialogResult.Cancel)
                {
                    // if done uploading files enable timer
                    tmx.Enabled = true;

                    RichTxt(rtBox, "Finished..", Color.Green);

                    FolderPO.CreateFolder(FolderPO.bckFolder);

                    rtBox.SaveFile(Path.Combine(FolderPO.bckFolder, DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("hmmss") + DateTime.Now.ToString("tt") + ".log"), RichTextBoxStreamType.PlainText);
                }
            }
        }
        public bool ConvertToPDFPO(string input, string output, string compny)
        {
            POProcess rProcess = new POProcess();

            Document doc = new Document();

            PdfWriter.GetInstance(doc, new FileStream(output, FileMode.Create));

            doc.Open();

            StringBuilder sb = new StringBuilder();

            var uhh = Path.GetFileNameWithoutExtension(input);

            int pageNum = 1;

            using (StreamReader rdr = new StreamReader(input))
            {
                while (rdr.Peek() >= 0)
                {
                    var strLine = rdr.ReadLine();

                    sb.AppendLine(strLine);

                    if (strLine.Contains("Continue to Next Page"))
                    {
                        StreamWriter sw = new StreamWriter(Path.Combine(rProcess.tmpXFolder, uhh + pageNum + ".txt"), true);

                        sw.Write(sb.ToString());

                        sw.Close();

                        sb.Clear();

                        pageNum++;
                    }
                    else
                    {
                        if (strLine.Contains("General Manager"))
                        {
                            StreamWriter sw = new StreamWriter(Path.Combine(rProcess.tmpXFolder, uhh + pageNum + ".txt"), true);

                            sw.Write(sb.ToString());

                            sw.Close();

                            sb.Clear();
                        }
                    }
                }

                for (int i = 1; i <= pageNum; i++)
                {
                    using (StreamReader rdr1 = new StreamReader(Path.Combine(rProcess.tmpXFolder, uhh + i + ".txt")))
                    {
                        doc.NewPage();

                        iTextSharp.text.Image addlogo = default(iTextSharp.text.Image);

                        addlogo = iTextSharp.text.Image.GetInstance(Path.Combine(rProcess.tmpXFolder, compny));

                        addlogo.SetAbsolutePosition(36, 790);
                        //addlogo.Alignment = Image.ALIGN_LEFT | Image.TEXTWRAP;
                        //addlogo.Alignment = Image.TEXTWRAP;

                        doc.Add(addlogo);

                        Paragraph para = new Paragraph(rdr1.ReadToEnd(), new Font(Font.COURIER, 6.5f));

                        para.SetLeading(12f, 2f);

                        doc.Add(para);

                        rdr1.Close();
                    }
                }

                for (int i = 1; i <= pageNum; i++)
                {
                    File.Delete(Path.Combine(rProcess.tmpXFolder, uhh + i + ".txt"));
                }

                try
                {
                    rdr.Close();

                    doc.Close();

                    return(true);
                }
                catch
                {
                    if (doc.PageNumber == 0)
                    {
                        return(false);
                    }
                }

                return(true);
            }
        }
Exemple #3
0
        public void PayPayItem(PayItemInfo entity)
        {
            if (entity.SysNo == null)
            {
                throw new ArgumentNullException("entity.SysNo");
            }
            if (entity.PayUserSysNo == null)
            {
                throw new ArgumentNullException("entity.PayUserSysNo");
            }
            var payItems = m_FinaceDA.QueryPayItems(new PayableItemCriteriaInfo
            {
                SysNo = entity.SysNo
            });

            if (payItems == null || payItems.Count == 0)
            {
                //throw new BizException(string.Format("编号为[{0}]的付款单不存在", entity.SysNo));
                ThrowBizException("Payable_PayBillNotFound");
            }
            var item = payItems[0];

            if (item.Status != PayItemStatus.Origin)
            {
                //throw new BizException("只有未支付的付款单才能支付.");
                ThrowBizException("Payable_JustUnPayBillCanPay");
            }

            item.PayUserSysNo = entity.PayUserSysNo;

            var payList = m_FinaceDA.PayableQuery(new PayableCriteriaInfo {
                SysNo = item.PaySysNo
            });

            if (payList == null || payList.Count == 0)
            {
                //throw new BizException("未找到该付款单对应的应付款信息");
                ThrowBizException("Payable_PayBillNotFoundPayInfo");
            }
            var pay = payList[0];

            if (!string.Equals(pay.AuditStatus.ToString(), PayableAuditStatus.Audited.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                //throw new BizException("只有财务审核通过的付款单才能支付.");
                ThrowBizException("Payable_JustAuditPassCanPay");
            }

            item.OrderSysNo  = pay.OrderSysNo;
            item.BatchNumber = pay.BatchNumber;

            //现金支付的必须有银行科目号
            //if (pay.OrderType == PayableOrderType.ReturnPointCashAdjust)
            //{
            //    if (string.IsNullOrEmpty(entity.BankGLAccount))
            //    {
            //        throw new BizException("现金支付必须有银行科目账号");
            //    }
            //    item.BankGLAccount = entity.BankGLAccount;
            //}

            if (pay.OrderType == PayableOrderType.PO ||
                pay.OrderType == PayableOrderType.POAdjust)
            {
                item = new POProcess().Pay(item, true);
            }
            //else if (pay.OrderType == PayableOrderType.ReturnPointCashAdjust
            //    || pay.OrderType == PayableOrderType.SubAccount
            //    || pay.OrderType == PayableOrderType.SubInvoice)
            //{
            //    item = new EIMSReturnPointCashProcess().Pay(item, true);
            //}
            else
            {
                item = new OtherOrderTypeProcess().Pay(item, true);
            }
        }