I need to create a condition that if the barcode does not exist in the sdpj_proc_inter table, I have to move it to a processed folder with a slope, would anyone have any examples of how I could be doing this condition?
- public class ReadingTxt
- {
- static Thread _ThreadVerification;
-
- static string FoldersFile = "C: \ CommonIndex \ ProofPants";
- static string FileFilesImported = @ "C: \ Provisional Import \ ProofImported";
- static string FolderLogLog = @ "C: \ CommonComports \ Log";
-
- public static void Read ()
- {
-
- _ThreadVerification = new Thread;
- _ThreadVerification.Start ();
- }
-
-
-
- private static void CheckTime ()
- {
- while (true)
- {
- if (DateTime.Now.Hour == 10)
- {
- InsertLog ("");
- InsertLog ("\ n HOME ::" + DateTime.Now.ToShortDateString () + "" + DateTime.Now.ToShortTimeString ());
-
- try
- {
- DirectoryInfo dirPending = new DirectoryInfo (PendingPlacesFolder);
-
-
- foreach (FileInfo file in dirPending.GetFiles ())
- {
- if (file.Extension == ".cpv")
- {
- Process File (file.FullName, file.Name);
- }
- }
-
- }
-
- catch (Exception)
- {
- throw;
- }
- finally
- {
- InsertLog ("\ n FIM ::" + DateTime.Now.ToShortDateString () + "" + DateTime.Now.ToShortTimeString ());
- }
- }
-
- Thread.Sleep (3600000);
- }
- }
-
-
- private static void ProcessFile (string FullPathFile, string FileName)
- {
- try
- {
-
- bool Move = true;
- string [] StringLine = System.IO.File.ReadAllLines (FullPathFile);
- string CodBar = "";
-
- for (int line = 0; line <StringLine.Length; line ++)
- {
- string DateScheduling = "";
- string DocumentValue = "";
- string Protocol = "";
- string Record = "";
- string Emission = "";
-
- #region Retrieve the Barcode
-
- if (String [line] .Contains ("Bar Cod:"))
- {
- CodBar + = String [line] .Replace ("Cod. Bars:", "");
- line + = 2;
- }
- if (CodBar! = "")
- {
- CodBar + = String [line];
- CodBar = CodBar.Replace ("", "");
- }
-
- #endregion
-
- if (CodBar == "")
- continues;
-
- line + = 6;
-
- #region Scheduling Date
-
- if (String [line] .Contains ("Delay:"))
- {
- DateScheduling + = String [line] .Replace ("Dt.Scheduling:", "") .Replace ("", "");
- }
-
- #endregion
-
- line + = 2;
-
- #region Document Value
-
- if (String [line] .Contains ("Vlr.Document:"))
- {
- DocumentValue + = String [line] .Replace ("Vlr.Document:", "") .Replace ("", "");
- }
-
- #endregion
-
- line + = 2;
-
- #region Protocol
-
- if (StringLine[line].Contains("Protocol:"))
- {
- Protocol += StringLine[line].Replace("Protocol:", "").Replace(" ", "");
- }
-
- #endregion
-
- line += 12;
-
- #region Register
-
- if (StringLine[line].Contains("Register:"))
- {
- Register += StringLine[line].Replace("Register:", "");
- }
-
- #endregion
-
- line += 2;
-
- #region Emission
-
- if (String [line] .Contains ("Emission:"))
- {
- Emission + = String [line] .Replace ("Emission:", "");
- }
-
- #endregion
-
-
- string CodProcInter = GetCodProcInter (CodBar)
-
-
- if (! string.IsNullOrEmpty (CodProcInter))
- {
- if (! CodBarInserted (CodBar))
- {
-
- bool inserted = BankInfo (CodProcInter, CodBar, DateScheduling , DocumentValue, Protocol, Register, Emission);
- }
- else
- {
-
- Move = false;
- InsertLog ("\ n Already Exists ->" + CodBar);
- }
- }
- else
- {
-
- Move = false;
- InsertLog ("\ nCode Bar Not Available ->" + CodBar);
- }
-
- / Clear Variables
- CodBar = "";
- }
-
- if
- {
- MoveFile (FileName);
- }
-
- }
- catch (Exception ex)
- {
- throw;
- }
- }
Here is my code that I read from the file and validate whether the barcode exists or not in the sdpj_proc_inter table of the database, existing I process the file, insert in the database and generate a service log and move the file to the folder processed. But I would like to know how I could do to this condition if it does not exist I generate the log stating that it does not exist, even in the log part all ok but the problem is how will I implement a condition to move that file to the processed if this barcode does not exist there in the database. How could I do it?