private IEnumerable <vProcessDB> ConvertToTankReadings(DataTable dataTable) { Constant.Init(); foreach (DataRow row in dataTable.Rows) { DateTime? dtDATETIME = string.IsNullOrEmpty(row["DATETIME"].ToString()) ? (DateTime?)null : DateTime.Parse(row["DATETIME"].ToString()); string strStep = row["STEP"].ToString(); string strStatus = row["STATUS"].ToString(); LOOKUP_DB vpdb = Constant.LookupMTProcessStep.Where(x => x.CODE == strStep).FirstOrDefault(); string strProcessStep = vpdb.DESCRIPTION; string strProcessStepRemark = vpdb.REMARK; LOOKUP_DB vmtps = Constant.LookupMTPROCStatus.Where(x => x.CODE == strStatus).FirstOrDefault(); string strProcessStatus = vmtps.DESCRIPTION; string strProcessStatusRemark = vmtps.REMARK; yield return(new vProcessDB { NO = Convert.ToDecimal(row["NO"].ToString()), MSGID = Convert.ToString(row["MSGID"]), DATETIME = dtDATETIME, STEP = Convert.ToDecimal(strStep), STATUS = Convert.ToDecimal(strStatus), ProcessStep = strProcessStep, ProcessStepRemark = strProcessStepRemark, ProcessStatus = strProcessStatus, ProcessStatusRemark = strProcessStatusRemark }); } }
public IEnumerable <LOOKUP_DB> Get(LOOKUP_DB db) { string sqlString = GetSqlQuery(db); System.Data.DataTable dt = DAO.oracleCmdDataSetSP(this.config, sqlString).Tables[0]; LOOKUPDBList = ConvertToTankReadings(dt); return(LOOKUPDBList); }
private IEnumerable <VMTDB> ConvertToTankReadings(DataTable dataTable) { Constant.Init(); foreach (DataRow row in dataTable.Rows) { DateTime?dtCREATEDATE = string.IsNullOrEmpty(row["CREATEDATE"].ToString()) ? (DateTime?)null : DateTime.Parse(row["CREATEDATE"].ToString()); DateTime?dtUPDATETIME = string.IsNullOrEmpty(row["UPDATETIME"].ToString()) ? (DateTime?)null : DateTime.Parse(row["UPDATETIME"].ToString()); DateTime?dtEDIDATE = string.IsNullOrEmpty(row["EDIDATE"].ToString()) ? (DateTime?)null : DateTime.Parse(row["EDIDATE"].ToString()); string strStatus = row["STATUS"].ToString(); string strDirection = row["DIRECTION"].ToString(); LOOKUP_DB vmts = Constant.LookupMTStatus.Where(x => x.CODE == strStatus).FirstOrDefault(); string strMTStatus = vmts.DESCRIPTION; string strMTStatusRemark = vmts.REMARK; LOOKUP_DB vmtd = Constant.LookupMTMsgDirection.Where(x => x.CODE == strDirection).FirstOrDefault(); string strMTDirection = vmtd.DESCRIPTION; string strMTDirectionRemark = vmtd.REMARK; yield return(new VMTDB { MSGID = Convert.ToString(row["MSGID"]), PARENT = Convert.ToString(row["PARENT"]), AS2PARTNER = Convert.ToString(row["AS2PARTNER"]), DIRECTION = Convert.ToDecimal(row["DIRECTION"]), MTDirection = strMTDirection, MTDirectionRemark = strMTDirectionRemark, CHLMSGID = Convert.ToString(row["CHLMSGID"]), CREATEDATE = dtCREATEDATE, STATUS = Convert.ToDecimal(row["STATUS"]), MTStatus = strMTStatus, MTStatusRemark = strMTStatusRemark, UPDATETIME = dtUPDATETIME, GSSENDERID = Convert.ToString(row["GSSENDERID"]), GSRECEIVERID = Convert.ToString(row["GSRECEIVERID"]), DOCNUM = Convert.ToString(row["DOCNUM"]), ISASENDERID = Convert.ToString(row["ISASENDERID"]), ISARECEIVERID = Convert.ToString(row["ISARECEIVERID"]), CONTROLNUM = Convert.ToString(row["CONTROLNUM"]), EDIDATE = dtEDIDATE, EDIMSGTYPE = Convert.ToString(row["EDIMSGTYPE"]), FILEURI = Convert.ToString(row["FILEURI"]), KEYWORD_SEARCH = Convert.ToString(row["KEYWORD_SEARCH"]), IDOC = Convert.ToString(row["IDOC"]), AUDIT_CHECK_STATUS = Convert.ToInt16(row["AUDIT_CHECK_STATUS"]), PI_STATUS = Convert.ToString(row["PI_STATUS"]), PI_ERROR_CODE = Convert.ToString(row["PI_ERROR_CODE"]), PI_ERROR_CATEGORY = Convert.ToString(row["PI_ERROR_CATEGORY"]), IDOC_CALLBACK_MSG = Convert.ToString(row["IDOC_CALLBACK_MSG"]) }); } }
public static void Init() { ILOOKUPDBCollection LookupdbCollection; LOOKUP_DB db = new LOOKUP_DB(); LookupdbCollection = DataAccess.CreateLOOKUPDBCollection(Constant.PIPServer); IEnumerable <LOOKUP_DB> LookupdbList = LookupdbCollection.Get(db); LookupMTProcessStep = LookupdbList.Where(x => x.TYPE == "MT_PROCESS_STEP").ToList(); LookupMTStatus = LookupdbList.Where(x => x.TYPE == "MT_STATUS").ToList(); LookupMTPROCStatus = LookupdbList.Where(x => x.TYPE == "MT_PROC_STATUS").ToList(); LookupMTMsgDirection = LookupdbList.Where(x => x.TYPE == "MT_MSG_DIRECTION").ToList(); LookupMTAuditCheck = LookupdbList.Where(x => x.TYPE == "MT_AUDIT_CHECK").ToList(); }
private int CheckIsNullOrEmpty(LOOKUP_DB db) { int rslt = 0; foreach (PropertyInfo prop in db.GetType().GetProperties()) { var varprop = db.GetType().GetProperty(prop.Name); if (varprop.PropertyType.Name == "String") { rslt = string.IsNullOrEmpty(varprop.GetValue(db, null) as string) ? rslt : ++rslt; } } //rslt = (mtdb.CREATEDATE.HasValue) ? rslt : rslt++; return(rslt); }
public IEnumerable <LOOKUP_DB> Get(LOOKUP_DB db) { lookupdbcollection = new LOOKUPDBCollection(config); lookupdbcollection.Get(db); return(lookupdbcollection.LOOKUPDBList); }
private string GetSqlQuery(LOOKUP_DB db) { StringBuilder sql = new StringBuilder(); StringBuilder sbwhere = new StringBuilder(); string space = " "; string select = string.Empty; string where = string.Empty; string orderby = string.Empty; select = "SELECT * FROM LOOKUP_DB"; if (CheckIsNullOrEmpty(db) == 0) { sql.Append(select); sql.Append(space); sql.Append(" ORDER BY CODE"); } else { sbwhere.Append("WHERE"); sbwhere.Append(space); int icond = 0; foreach (PropertyInfo prop in db.GetType().GetProperties()) { var varprop = db.GetType().GetProperty(prop.Name); if (varprop.PropertyType.Name == "String") { string value = varprop.GetValue(db, null) as string; if (!string.IsNullOrEmpty(value)) { where = varprop.Name + " = '@'"; where = where.Replace("@", value); if (icond > 0) { sbwhere.Append(space); sbwhere.Append("AND"); sbwhere.Append(space); } sbwhere.Append(where); icond++; } } } // end foreach where = "ROWNUM <= @"; where = where.Replace("@", 100.ToString()); if (icond > 0) { sbwhere.Append(space); sbwhere.Append("AND"); sbwhere.Append(space); } sbwhere.Append(where); orderby = "ORDER BY CODE"; sql.Append(select); sql.Append(space); sql.Append(sbwhere.ToString()); sql.Append(space); sql.Append(orderby); } // end if return(sql.ToString()); }