I have the following doubt, I have a windows service, and in it after reading the file I move that file to another folder, however if any barcode that exists inside that file is not registered in my database, I will not insert in another particular table, I am explaining only the process.
Now my doubt: In the log generated, I inform this barcode that was not inserted for this reason, but I would like to know how I could do to inform the responsible person, that the bar code was not inserted in the given table of the bank because it is not registered , is there a way to send an email informing this bar code and asking for it to register the same? how could I do the coding for the email?
-
- private static void InsertLog (string row)
- {
-
- if (! Directory.Exists (LogFileLog))
- {
- Directory.CreateDirectory (LogFileLog);
- }
-
-
- string FullPath = LogFileLog + "\\ Proofing Processing Log.txt";
- if (! File.Exists (FullPath))
- {
- using (File.Create (FullPath));
- }
-
-
- using (StreamWriter file = new StreamWriter (FullPath, true))
- {
- file.WriteLine (line);
- file.Dispose ();
- }
- }
-
-
- GetCodProcInter (string CodBar)
- {
- using (DB db = new DB ())
- {
- string SQL = string.Format (@ "SELECT T0.cod_proc_inter FROM sdpj_proc_inter T0 WHERE T0.cod_bars_banestes = '{0}'", CodBar);
- var data = db.ExecuteCommandCommission (SQL);
-
- if (data.Read ())
- {
- return data ["cod_proc_inter"]. ToString ();
- }
- }
-
- return "";
- }
-
- private static void MoveFile (string FileName)
- {
- try
- {
- FileFilesImported + = "\\" + FileName;
- FileFilesPpendents + = "\\" + FileName;
- File.Move (FolderFiles, FileFilesImported);
- }
- catch (Exception)
- {
- throw;
- }
-
- }
-
-
-
- private static void ProcessesFile (string FullPathFile, string FileName)
- {
- try
- {
-
- bool Move r = true;
-
- string [] StringLine = System.IO.File.ReadAllLines (FullPathFile);
- string CodBars = "";
-
- for (int line = 0; line
- {
- string DateScheduling = "";
- string DocumentValue = "";
- string Protocol = "";
- string Register = "";
- string Emission = "";
-
- #regi on Retrieve Bar Code
-
- if (String [line] .Contains ("Bar Cod:"))
- {
- CodBars + = String [line] .Replace ("BarCode:", "");
- ln + = 2;
- }
-
-
-
- if (CodBar! = "")
- {
- CodBar + = String [line];
- CodBar = CodBar.Replace ("", "");
- }
-
- #endregion
-
- if (CodBar == "")
- continue;
-
- line + = 6;
-
- #region Scheduling Date
-
- if (String [line] .Contains ("Delay:"))
- {
- DateScheduling + = String [line] .Replace ("Date.Scheduling:", "").Replace ("", "");
- }
-
- #endregion
-
- line + = 2;
-
- #region Document Value
-
- if (StringLine [line] .Contains ("Document.Value:"))
- {
- DocumentValue + = String [line] .Replace ("Vlr.Documento:", "") .Replace ("", "");
- }
-
-
- #endr?egion
-
- line += 2;
-
- #region Protocol
-
- if (StringLine[line].Contains("Protocol:"))
- {
- Protocolo += StringLine[line].Replace("Protocol:", "").Replace(" ", "");
- }
- ?
- #endr?egion
- ?
- line ?+= 12;
-
- #region Register
-
- if (StringLine[line].Contains("Register:"))
- {
- Register += StringLine[line].Replace("Register:", "");
- }?
-
- #?endregion
-
- l?ine ??+= 2;
-
- #?region Emission
-
- i?f (StringLine[line].Contains("Emission.:"))
- {
- ? E?mission += StringLine[line].Replace("Emission.:", "");
- }??
- ??
- #?endr?egion
- ?
-
-
- string CodProcInter = GetCodProcInter (CodeBarra);
-
- if (! string.IsNullOrEmpty (CodProcInter))
- {
- if (! CodeBarAlreadyInserted (CodeBar))
- {
-
- bool inserted = BankInfo (CodProcInter, CodeBar, DateScheduling, DocumentValue, Protocol, Register, Emission);
- }
-
- {
-
- InsertLog ("\ n Already Exists ->" + CodBar);
- }
- }
- else
- {
-
-
- Move = false;
- InsertLog ("\ nCode Bar Not Available ->" + CodeBar);
- }
-
-
- CodeBar = "";
- }
-
- if
- {
- MoveFile (FileName);
- }
-
- }
- catch (Except ion)
- {
- throw;
- }
- }
In that part of the code my doubt lives.
- if (! string.IsNullOrEmpty (CodProcInter))
- {
- if (!CodeBarAlreadyinserted(CodeBar))
- {
-
- bool inserted = BankInfo (CodProcInter, CodBar, DateScheduling, DocumentValue, Protocol, Register, Emission);
- }
-
- {
-
- InsertLog ("\ n Already Exists ->" + CodeBar);
- }
- }
- else
- {
-
-
- Move = false;
- InsertLog ("\ nCode Bar Not Available ->" + CodeBar);
- }