R
rta_vix
Guest
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?
// InsertLog Method
private static void InsertLog (string row)
{
// Create Log Folder, if it does not exist
if (! Directory.Exists (LogFileLog))
{
Directory.CreateDirectory (LogFileLog);
}
// Create Log File, if it does not exist
string FullPath = LogFileLog + "\\ Proofing Processing Log.txt";
if (! File.Exists (FullPath))
{
using (File.Create (FullPath));
}
// Write to LOG file
using (StreamWriter file = new StreamWriter (FullPath, true))
{
file.WriteLine (line);
file.Dispose ();
}
}
// Here I look for all proc_inter from the sdpj_proc_interest table
// that has the bar code read in the file, only for you to understand where I want to go.
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 "";
}
// This method, I use to move the read files.
private static void MoveFile (string FileName)
{
try
{
FileFilesImported + = "\\" + FileName;
FileFilesPpendents + = "\\" + FileName;
File.Move (FolderFiles, FileFilesImported);
}
catch (Exception)
{
throw;
}
}
// In this method I go through all the lines, until I find the information that
// I need to read and write.
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 <StringLine.Length; 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 ("", "");
}
#endregion
line += 2;
#region Protocol
if (StringLine[line].Contains("Protocol:"))
{
Protocolo += 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 (StringLine[line].Contains("Emission.:"))
{
Emission += StringLine[line].Replace("Emission.:", "");
}
#endregion
// Search BarCode
string CodProcInter = GetCodProcInter (CodeBarra);
if (! string.IsNullOrEmpty (CodProcInter))
{
if (! CodeBarAlreadyInserted (CodeBar))
{
// Insert Bar Code
bool inserted = BankInfo (CodProcInter, CodeBar, DateScheduling, DocumentValue, Protocol, Register, Emission);
}
{
// Bar Code Already Inserted
InsertLog ("\ n Already Exists ->" + CodBar);
}
}
else
{
// Barcode not available in table -> sdpj_proc_inter
// if it is not available, should I inform the responsible person, sending the barcode number to that person, how to do it?
Move = false;
InsertLog ("\ nCode Bar Not Available ->" + CodeBar);
}
// Clear Variables
CodeBar = "";
}
if
{
MoveFile (FileName);
}
}
catch (Except ion)
{
throw;
}
}
In that part of the code my doubt lives.
if (! string.IsNullOrEmpty (CodProcInter))
{
if (!CodeBarAlreadyinserted(CodeBar))
{
// Insert Bar Code
bool inserted = BankInfo (CodProcInter, CodBar, DateScheduling, DocumentValue, Protocol, Register, Emission);
}
{
// Bar Code Already Inserted
InsertLog ("\ n Already Exists ->" + CodeBar);
}
}
else
{
// Barcode not available in table -> sdpj_proc_inter
// if it is not available, should I inform the responsible person, sending the barcode number to that person, how to do it?
Move = false;
InsertLog ("\ nCode Bar Not Available ->" + CodeBar);
}
Continue reading...
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?
// InsertLog Method
private static void InsertLog (string row)
{
// Create Log Folder, if it does not exist
if (! Directory.Exists (LogFileLog))
{
Directory.CreateDirectory (LogFileLog);
}
// Create Log File, if it does not exist
string FullPath = LogFileLog + "\\ Proofing Processing Log.txt";
if (! File.Exists (FullPath))
{
using (File.Create (FullPath));
}
// Write to LOG file
using (StreamWriter file = new StreamWriter (FullPath, true))
{
file.WriteLine (line);
file.Dispose ();
}
}
// Here I look for all proc_inter from the sdpj_proc_interest table
// that has the bar code read in the file, only for you to understand where I want to go.
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 "";
}
// This method, I use to move the read files.
private static void MoveFile (string FileName)
{
try
{
FileFilesImported + = "\\" + FileName;
FileFilesPpendents + = "\\" + FileName;
File.Move (FolderFiles, FileFilesImported);
}
catch (Exception)
{
throw;
}
}
// In this method I go through all the lines, until I find the information that
// I need to read and write.
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 <StringLine.Length; 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 ("", "");
}
#endregion
line += 2;
#region Protocol
if (StringLine[line].Contains("Protocol:"))
{
Protocolo += 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 (StringLine[line].Contains("Emission.:"))
{
Emission += StringLine[line].Replace("Emission.:", "");
}
#endregion
// Search BarCode
string CodProcInter = GetCodProcInter (CodeBarra);
if (! string.IsNullOrEmpty (CodProcInter))
{
if (! CodeBarAlreadyInserted (CodeBar))
{
// Insert Bar Code
bool inserted = BankInfo (CodProcInter, CodeBar, DateScheduling, DocumentValue, Protocol, Register, Emission);
}
{
// Bar Code Already Inserted
InsertLog ("\ n Already Exists ->" + CodBar);
}
}
else
{
// Barcode not available in table -> sdpj_proc_inter
// if it is not available, should I inform the responsible person, sending the barcode number to that person, how to do it?
Move = false;
InsertLog ("\ nCode Bar Not Available ->" + CodeBar);
}
// Clear Variables
CodeBar = "";
}
if
{
MoveFile (FileName);
}
}
catch (Except ion)
{
throw;
}
}
In that part of the code my doubt lives.
if (! string.IsNullOrEmpty (CodProcInter))
{
if (!CodeBarAlreadyinserted(CodeBar))
{
// Insert Bar Code
bool inserted = BankInfo (CodProcInter, CodBar, DateScheduling, DocumentValue, Protocol, Register, Emission);
}
{
// Bar Code Already Inserted
InsertLog ("\ n Already Exists ->" + CodeBar);
}
}
else
{
// Barcode not available in table -> sdpj_proc_inter
// if it is not available, should I inform the responsible person, sending the barcode number to that person, how to do it?
Move = false;
InsertLog ("\ nCode Bar Not Available ->" + CodeBar);
}
Continue reading...