public bool InsertReconDataReceived(Recon_DataReceived input) { try { using (SimplyPaymentCardDataContext db = new SimplyPaymentCardDataContext(ConnectionStringIntranet)) { //Check if the FileName already exists var fileNameQuery = db.Recon_DataReceiveds.Where(f => f.DR_FileName.Equals(input.DR_FileName)); if (fileNameQuery.Count() >= 1) { logger.Info(MethodBase.GetCurrentMethod().Name + "DR_FileName already exists"); return(false); } db.Recon_DataReceiveds.InsertOnSubmit(input); db.SubmitChanges(); return(true); } } catch (Exception ex) { logger.Info(MethodBase.GetCurrentMethod().Name + ex.Message); return(false); } }
public bool InsertDRData(VarClass.JobType jobType) { try { using (SimplyPaymentCardDataContext db = new SimplyPaymentCardDataContext(ConnectionStringIntranet)) { int DocType = db.Recon_DocTypes.SingleOrDefault(t => t.DT_DocType.Equals(VarClass.doctypeDescription)).DT_UID; var files = jobType.Equals(VarClass.JobType.PAYMENT_CARDS) ? Directory.GetFiles(VarClass.downloadPath1, "*.CSV") : Directory.GetFiles(VarClass.downloadPath1, "*.txt"); foreach (string file in files) { Recon_DataReceived data = new Recon_DataReceived { DR_ClientID = 1, DR_JobID = jobType.Equals(VarClass.JobType.PAYMENT_CARDS) ? Int32.Parse(getInputString(0, file)) : Int32.Parse(DateTime.Now.ToString("yyyyMMdd")), DR_Datetime = DateTime.Now, DR_TotalReceived = jobType.Equals(VarClass.JobType.PAYMENT_CARDS) ? Int32.Parse(getInputString(3, file)) : GetEntPackInfo().Item1, DR_DocType = DocType, DR_FileName = jobType.Equals(VarClass.JobType.PAYMENT_CARDS) ? getInputString(2, file) : GetEntPackInfo().Item2, }; db.Recon_DataReceiveds.InsertOnSubmit(data); db.SubmitChanges(); } return(true); } } catch (Exception ex) { logger.Info(string.Format("InsertDRData Failed. {0}", ex.Message.ToString())); return(false); } }
public int GetDRUIDByFileName(string fileName) { bool isSuccess = false; Recon_DataReceived query = new Recon_DataReceived(); try { using (SimplyPaymentCardDataContext db = new SimplyPaymentCardDataContext(ConnectionStringIntranet)) { query = db.Recon_DataReceiveds.Where(vrr => vrr.DR_FileName.Equals(fileName)).SingleOrDefault(); if (query != null) { isSuccess = true; } } } catch (Exception ex) { logger.Info(MethodBase.GetCurrentMethod().Name + ex.Message); } if (isSuccess) { return(query.DR_UID); } else { return(-1); } }