public string ConcateStringHSS02003(CUSTOM_S02003_TEMP HS) { StringBuilder strHS = new StringBuilder(1000); strHS.Append("HS|"); strHS.Append(HS.PONumber); strHS.Append("|"); strHS.Append(HS.VersionPOSera); strHS.Append("|"); strHS.Append(HS.DataVersion); strHS.Append("|"); strHS.Append(HS.KodeCabangAI); strHS.Append("|"); strHS.Append(HS.ReasonRejection); return(strHS.ToString()); }
public int DeleteTempHSS02003(CUSTOM_S02003_TEMP tempHS) { int result = 1; try { EntityCommand cmd = new EntityCommand("EProcEntities.sp_DeleteTempHSS02003", entityConnection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("PONUMBER", DbType.String).Value = tempHS.PONumber; OpenConnection(); cmd.ExecuteNonQuery(); } catch (Exception ex) { result = 0; throw ex; } finally { CloseConnection(); } return(result); }
public List <CUSTOM_S02003_TEMP> CheckingHistoryHS(List <CUSTOM_S02003_TEMP> tempHS) { LogEvent logEvent = new LogEvent(); List <CUSTOM_S02003_TEMP> listDataHS = new List <CUSTOM_S02003_TEMP>(); try { if (tempHS.Count > 0) { listDataHS = tempHS; var existingRow = (from o in tempHS where entities.CUSTOM_S02003.Any(e => o.PONumber == e.PONumber) select new S02003HSViewModel { PONumber = o.PONumber, VersionPOSera = o.VersionPOSera, DataVersion = o.DataVersion, KodeCabangAI = o.KodeCabangAI, ReasonRejection = o.ReasonRejection, CompanyCodeAI = o.CompanyCodeAI }).ToList(); for (int i = 0; i < existingRow.Count; i++) { string existPoNumber = existingRow[i].PONumber; var q = (from o in entities.CUSTOM_S02003 where o.PONumber == existPoNumber select new S02003HSViewModel { PONumber = o.PONumber, VersionPOSera = o.VersionPOSera, DataVersion = o.DataVersion, KodeCabangAI = o.KodeCabangAI, ReasonRejection = o.ReasonRejection }).SingleOrDefault(); var compare = EqualS02003HS(existingRow[i], q); //jika ada yg beda di salah satu field atau lebih, maka update list if (!compare) { //removeat(index) var rowDel = (from o in listDataHS where o.PONumber == existingRow[i].PONumber select o).SingleOrDefault(); listDataHS.Remove(rowDel); CUSTOM_S02003_TEMP row = new CUSTOM_S02003_TEMP(); row.PONumber = existingRow[i].PONumber; row.VersionPOSera = q.VersionPOSera != null ? q.VersionPOSera + 1 : existingRow[i].VersionPOSera != null ? existingRow[i].VersionPOSera : 1; row.DataVersion = q.DataVersion != null ? q.DataVersion + 1 : existingRow[i].DataVersion != null ? existingRow[i].DataVersion : 1; row.KodeCabangAI = existingRow[i].KodeCabangAI; row.ReasonRejection = existingRow[i].ReasonRejection; row.CompanyCodeAI = existingRow[i].CompanyCodeAI; listDataHS.Add(row); } else { //removeat(index) var rowDel = (from o in listDataHS where o.PONumber == existingRow[i].PONumber select o).SingleOrDefault(); listDataHS.Remove(rowDel); } } } //add task kill when tempHS.Count <= 0 : by fhi 04.06.2014 else { logEvent.WriteDBLog("", "UploadS02003_Load", false, "", "tempHS.Count <= 0", "S02003", "SERA"); Process.Start("taskkill.exe", "/f /im B2BAISERA_S02003.exe"); } //end } catch (Exception ex) { //add task kill when error : by fhi 04.06.2014 logEvent.WriteDBLog("", "UploadS02003_Load", false, "", ex.Message, "S02003", "SERA"); Process.Start("taskkill.exe", "/f /im B2BAISERA_S02003.exe"); //end throw ex; } return(listDataHS); }