R
rta_vix
Guest
I have a validation in my application, which checks if the barcode I have in my voucher exists in a certain table of the bank, if it does not exist I will insert a log warning that it does not exist, however this file that has the extension .CPV it can not be moved, however, in my Move method, it ends up forcing and moving all the files in the directory, is there a way to validate a condition inside my move method? Or call the method or something that performs this validation?
This is my method of reading the voucher:
private static void ProcessFile (string FullPathFile)
{
try
{
bool Move = true;
string [] StringLine = System.IO.File.ReadAllLines (FullPathFile);
string CodBar = "";
for (int line = 0; line <StringLine.Length; line ++)
{
#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;
}
#endregion
// Search Bar Code
string CodProcInter = GetCodProcInter (CodBar);
if (! string.IsNullOrEmpty (CodProcInter))
{
if (! CodBarInserted (CodBar))
{
// Insert Bar Code
bool inserted = BankInfo (CodProcInter, CodBar, DateScheduling, DocumentValue, Protocol, Register, Emission);
}
else
{
// Bar Code Already Inserted
InsertLog ("\ n Already Exists ->" + CodBar);
}
}
else
{
// Barcode not available in table -> sdpj_proc_inter
Move = false;
InsertLog ("\ n The file was not imported because the Bar Code ->" + CodBar + "is not available in the interested process table");
}
CodBarra = "";
}
if (Move)
{
MoveFile(FullPathFile);
}
}
catch (Exception)
{
throw;
}
}
Here I check if my barcode file exists in the sdpj_proc_inter table, if it does not exist, log the log that does not exist and the voucher can not be moved.
private static string 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_bar_banestes = '{0}'", CodBar);
var data = db.ExecuteCommandCommission (SQL);
if (data.Read ())
{
return data ["cod_proc_inter"]. ToString ();
}
}
return "";
}
And here is my method of moving, where it forces the transfer of all the files, it seems that the same is not undergoing validation.
private static void MoveFile (string FileName)
{
string server = @ "C: \ test";
string client = @ "C: \ test1";
string [] files = Directory.GetFiles (server, "* .CPV");
foreach (string item in files)
{
string filename = Path.GetFileName (item);
string destination = Path.Combine (client, filename);
File.Move (item, destination);
}
}
Continue reading...
This is my method of reading the voucher:
private static void ProcessFile (string FullPathFile)
{
try
{
bool Move = true;
string [] StringLine = System.IO.File.ReadAllLines (FullPathFile);
string CodBar = "";
for (int line = 0; line <StringLine.Length; line ++)
{
#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;
}
#endregion
// Search Bar Code
string CodProcInter = GetCodProcInter (CodBar);
if (! string.IsNullOrEmpty (CodProcInter))
{
if (! CodBarInserted (CodBar))
{
// Insert Bar Code
bool inserted = BankInfo (CodProcInter, CodBar, DateScheduling, DocumentValue, Protocol, Register, Emission);
}
else
{
// Bar Code Already Inserted
InsertLog ("\ n Already Exists ->" + CodBar);
}
}
else
{
// Barcode not available in table -> sdpj_proc_inter
Move = false;
InsertLog ("\ n The file was not imported because the Bar Code ->" + CodBar + "is not available in the interested process table");
}
CodBarra = "";
}
if (Move)
{
MoveFile(FullPathFile);
}
}
catch (Exception)
{
throw;
}
}
Here I check if my barcode file exists in the sdpj_proc_inter table, if it does not exist, log the log that does not exist and the voucher can not be moved.
private static string 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_bar_banestes = '{0}'", CodBar);
var data = db.ExecuteCommandCommission (SQL);
if (data.Read ())
{
return data ["cod_proc_inter"]. ToString ();
}
}
return "";
}
And here is my method of moving, where it forces the transfer of all the files, it seems that the same is not undergoing validation.
private static void MoveFile (string FileName)
{
string server = @ "C: \ test";
string client = @ "C: \ test1";
string [] files = Directory.GetFiles (server, "* .CPV");
foreach (string item in files)
{
string filename = Path.GetFileName (item);
string destination = Path.Combine (client, filename);
File.Move (item, destination);
}
}
Continue reading...