Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. GC.Collect();
  2. using (var con = new SQLiteConnection("Data Source=" + finalDbFileName + ";Version=3;"))
  3. {
  4. con.Open();
  5. using (var command = new SQLiteCommand(con))
  6. {
  7. using (var transaction = con.BeginTransaction())
  8. {
  9. string columns = ConfigurationManager.AppSettings["columnNames"].ToString();
  10. foreach (NumberDetails numDetails in numberDetails.Where(s => s.DBName == DBName))
  11. {
  12. errorNUM = numDetails.Number.ToString();
  13. string date = numDetails.Date.ToString();
  14. if (!date.Contains("DATE") && !date.Equals("") && !date.Contains("date") && date.Length == 11)
  15. {
  16. date = Convert.ToDateTime(numDetails.Date.ToString()).ToString("dd-MM-yyyy");
  17. }
  18. sim = numDetails.SimType;
  19. string fnam = numDetails.Full_Name.Replace("'", "");
  20. fnam = fnam.Replace("", "");
  21. fnam = Regex.Replace(fnam, @"[^u0000-u007F]+", string.Empty);
  22. if (simType == "" && sim != "")
  23. {
  24. command.CommandText = "insert into `" + numDetails.Number.ToString().Substring(0, 5) + "` (" + columns + ") " +
  25. "select '" + numDetails.Number + "','" + numDetails.Full_Name.Replace("'", "") + "','" + numDetails.Address.Replace("'", "") + "','" + date.ToString() + "','" + circle + "','" + mobileOperator + "','" + numDetails.Alterno.Replace("'", "") + "','" + numDetails.IDProof.Replace("'", "") + "','" + numDetails.SimType + "' where not exists " +
  26. "(select number,full_name,address,circle,operator,SimType from `" + numDetails.Number.ToString().Substring(0, 5) + "`" +
  27. "where (number='" + numDetails.Number + "' AND full_name='" + numDetails.Full_Name.Replace("'", "") + "' AND address='" + numDetails.Address.Replace("'", "") + "' AND circle='" + circle + "' AND operator='" + mobileOperator + "' AND Alterno='" + numDetails.Alterno.Replace("'", "") + "' AND IDProof='" + numDetails.IDProof.Replace("'", "") + "' AND SimType='" + numDetails.SimType + "' )); ";
  28. command.ExecuteNonQuery();
  29. }
  30. else
  31. {
  32. command.CommandText = "insert into `" + numDetails.Number.ToString().Substring(0, 5) + "` (" + columns + ") " +
  33. "select '" + numDetails.Number + "','" + fnam + "','" + numDetails.Address.Replace("'", "") + "','" + date.ToString() + "','" + circle + "','" + mobileOperator + "','" + numDetails.Alterno.Replace("'", "") + "','" + numDetails.IDProof.Replace("'", "") + "','" + simType + "' where not exists " +
  34. "(select number,full_name,address,circle,operator,SimType from `" + numDetails.Number.ToString().Substring(0, 5) + "`" +
  35. "where (number='" + numDetails.Number + "' AND full_name='" + fnam + "' AND address='" + numDetails.Address.Replace("'", "") + "' AND circle='" + circle + "' AND operator='" + mobileOperator + "' AND Alterno='" + numDetails.Alterno.Replace("'", "") + "' AND IDProof='" + numDetails.IDProof.Replace("'", "") + "' AND SimType='" + simType + "' )); ";
  36. command.ExecuteNonQuery();
  37. }
  38. }
  39. transaction.Commit();
  40. }
  41. command.CommandText = string.Empty;
  42. }
  43. }
  44.  
  45. GC.Collect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement