예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="p_certapp"></param>
        /// <param name="p_certifier"></param>
        /// <param name="p_invoicerId"></param>
        /// <param name="p_issueIds"></param>
        /// <returns></returns>
        public int SignatureWithIDs(Guid p_certapp, string[] p_certifier, string p_invoicerId, string[] p_issueIds)
        {
            int _result = 0;

            try
            {
                if (ISigner.CheckValidApplication(p_certapp) == true)
                {
                    if (p_issueIds.Length > 100)
                    {
                        throw new SignerException(String.Format("Issue-ids can not exceed 100-records. invoiceId->'{0}', length->{1})", p_invoicerId, p_issueIds.Length));
                    }

                    X509CertMgr _invoicerCert = UCertHelper.GetCustomerCertMgr(p_invoicerId, p_certifier[0], p_certifier[1], p_certifier[2]);
                    _result = ESigner.DoSignInvoice(_invoicerCert, p_invoicerId, p_issueIds);
                }
            }
            catch (SignerException ex)
            {
                ELogger.SNG.WriteLog(ex);
            }
            catch (Exception ex)
            {
                ELogger.SNG.WriteLog(ex);
            }

            return(_result);
        }
예제 #2
0
        //-------------------------------------------------------------------------------------------------------------------------
        //
        //-------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        ///
        /// </summary>
        /// <param name="p_certapp"></param>
        /// <param name="p_certifier"></param>
        /// <param name="p_invoicerId"></param>
        /// <param name="p_fromDay"></param>
        /// <param name="p_tillDay"></param>
        /// <returns></returns>
        public int SignatureWithDateRange(Guid p_certapp, string[] p_certifier, string p_invoicerId, DateTime p_fromDay, DateTime p_tillDay)
        {
            int _result = 0;

            try
            {
                if (ISigner.CheckValidApplication(p_certapp) == true)
                {
                    UTextHelper.SNG.GetSigningRange(ref p_fromDay, ref p_tillDay);

                    var _sqlstr
                        = "SELECT invoicerId, COUNT(invoicerId) as norec "
                          + "  FROM TB_eTAX_INVOICE "
                          + " WHERE isSuccess != @isSuccess "         // for resignning, do check 'isSuccess' here
                          + "   AND ( "
                          + "         (RIGHT(typeCode, 2) IN ('01', '02', '04') AND invoicerId=@invoicerId) "
                          + "         OR "
                          + "         (RIGHT(typeCode, 2) IN ('03', '05') AND brokerId=@invoicerId) "
                          + "       ) "
                          + "   AND issueDate>=@fromDate AND issueDate<=@tillDate "
                          + " GROUP BY invoicerId";

                    var _dbps = new PgDatParameters();
                    {
                        _dbps.Add("@isSuccess", NpgsqlDbType.Varchar, "T");
                        _dbps.Add("@invoicerId", NpgsqlDbType.Varchar, p_invoicerId);
                        _dbps.Add("@fromDate", NpgsqlDbType.TimestampTz, p_fromDay);
                        _dbps.Add("@tillDate", NpgsqlDbType.TimestampTz, p_tillDay);
                    }

                    var _ds = LSQLHelper.SelectDataSet(UAppHelper.ConnectionString, _sqlstr, _dbps);
                    if (LSQLHelper.IsNullOrEmpty(_ds) == false)
                    {
                        X509CertMgr _invoicerCert = UCertHelper.GetCustomerCertMgr(p_invoicerId, p_certifier[0], p_certifier[1], p_certifier[2]);

                        var _rows = _ds.Tables[0].Rows;
                        for (int i = 0; i < _rows.Count; i++)
                        {
                            string _invoicerId = Convert.ToString(_rows[i]["invoicerId"]);
                            int    _noInvoice  = Convert.ToInt32(_rows[i]["norec"]);

                            _result += ESigner.DoSignInvoice(_invoicerCert, _invoicerId, _noInvoice, p_fromDay, p_tillDay);
                        }
                    }
                }
            }
            catch (SignerException ex)
            {
                ELogger.SNG.WriteLog(ex);
            }
            catch (Exception ex)
            {
                ELogger.SNG.WriteLog(ex);
            }

            return(_result);
        }
예제 #3
0
        private X509Certificate2 GetProviderKey(string p_invoiceeId)
        {
            if (m_providerKey == null || m_invoiceeId != p_invoiceeId)
            {
                m_providerKey = UCertHelper.GetProviderCertByCustomer(p_invoiceeId);
                m_invoiceeId  = p_invoiceeId;
            }

            return(m_providerKey);
        }
예제 #4
0
        private void SignerCallback(Object p_invoicer)
        {
            var _signingDay = DateTime.Now;

            try
            {
                DataRow _invoicerRow = (DataRow)p_invoicer;

                string _invoicerId = Convert.ToString(_invoicerRow["invoicerId"]);
                int    _noInvoicee = Convert.ToInt32(_invoicerRow["norec"]);

                DateTime _fromDay = Convert.ToDateTime(_invoicerRow["fromDay"]);
                DateTime _tillDay = Convert.ToDateTime(_invoicerRow["tillDay"]);

                DataSet _customer_set = ESigner.GetCustomerSet(_invoicerId);
                DataRow _customerRow  = _customer_set.Tables[0].Rows[0];

                decimal _fromSigningDay = Convert.ToDecimal(_customerRow["signFromDay"]);
                decimal _tillSigningDay = Convert.ToDecimal(_customerRow["signTillDay"]);

                string _signingType = Convert.ToString(_customerRow["signingType"]);
                if (_signingType == "01" || _signingType == "03")
                {
                    if (_signingType == "01")
                    {
                        decimal _today = _signingDay.Day;
                        if (_today < _fromSigningDay || _today > _tillSigningDay)
                        {
                            throw new SignerException(
                                      String.Format(
                                          "out of range sign-period: invoicerId->'{0}', fromDay->{1}, tillDay->{2}, toDay->{3}",
                                          _invoicerId, _fromSigningDay, _tillSigningDay, _today
                                          )
                                      );
                        }
                    }

                    X509CertMgr _invoicerCert = UCertHelper.GetCustomerCertMgr(_invoicerId);
                    ESigner.DoSignInvoice(_invoicerCert, _invoicerId, _noInvoicee, _fromDay, _tillDay);
                }
                else
                {
                    ISigner.WriteDebug(String.Format("invoicer '{0}' is skipped {1} record(s) because sign-type is {2}.", _invoicerId, _noInvoicee, _signingType));
                }
            }
            catch (SignerException ex)
            {
                ELogger.SNG.WriteLog(ex);
            }
            catch (Exception ex)
            {
                ELogger.SNG.WriteLog(ex);
            }
        }