示例#1
0
        private string GetNewPONumber(string company)
        {
            try
            {
                var       sql = "exec CS_GetPONumber('" + company + "', 'PO');";
                DataTable dt  = _pervasiveClient.QueryPervasiveADO(sql);

                if (dt is null || dt.Rows.Count == 0)
                {
                    return(null);
                }
                if (!int.TryParse(dt.Rows[0]["poNumber"].ToString(), out int result))
                {
                    _serviceLog.AppendLog(String.Format("Unable to GetNewPONumber using company {0}.", company.ToString()));
                    return(null);
                }

                return(dt.Rows[0]["poNumber"].ToString());
            }
            catch (Exception ex)
            {
                _serviceLog.AppendLog(ex.Message, "", ex);
                return(null);
            }
        }
        public DataTable GetPervasiveJobCstActs(string jobNumber, string company = "")
        {
            try
            {
                string sql = GetJobCstActsByJobSql(jobNumber, company);

                //_serviceLog.AppendLog($" Getting pervasive JobCstActs for job {jobNumber}", "", null);
                DataTable pervasiveJobCstActs = _pervasiveClient.QueryPervasiveADO(sql);

                // if no records returned from po_header
                if (pervasiveJobCstActs is null || !(pervasiveJobCstActs.AsEnumerable().Any()))
                {
                    // this should not happen, and usually will only happen if querying an invalid job number or sapphire query connection and pervasive connection environments do not match

                    // in rare cases, this is a correct result, meaning no po_header records exist in pervasive - usually caused by an error record in PO DI preventing processing
                    //  if this scenario is encountered, a notification should be generated immediately so the PO DI queue can be checked and error records can be resolved
                    //_serviceLog.AppendLog($" Failure getting pervasive JobCstActs for job {jobNumber} company {company}", "", null);
                    throw new Exception($"Workflow failure: Failure getting pervasive job cost records for job {jobNumber}");
                }

                //_serviceLog.AppendLog($" {pervasiveJobCstActs.Rows.Count} Pervasive JobCstActs records found");

                return(pervasiveJobCstActs);
            }
            catch (PsqlException pSqlException)
            {
                _serviceLog.AppendLog($" Failure getting pervasive JobCstActs for job {jobNumber} company {company}", "", pSqlException);
                return(null);
            }
        }
        public void SavePO(POHeader poHeader)
        {
            var connString  = ConfigurationManager.ConnectionStrings["ADONET35"].ToString();
            var queryString = CreateSelectStatement(poHeader);

            var fromDb = _pervasiveClient.QueryPervasiveADO(queryString, connString);

            if (fromDb == null || fromDb.Rows.Count == 0)
            {
                InsertPo(poHeader);
            }
            else
            {
                UpdatePo(poHeader);
            }
        }