TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Robson Amaral
NA
132
17.3k
Doubts about using IF and else
Aug 29 2018 10:20 PM
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 ()
{
// creation of the verification thread and its execution
_ThreadVerification =
new
Thread;
_ThreadVerification.Start ();
}
// will check whether or not to execute the method every 1 hour
private
static
void
CheckTime ()
{
while
(
true
)
{
if
(DateTime.Now.Hour == 10)
// If it is 07:00 AM in the morning
{
InsertLog (
""
);
InsertLog (
"\ n HOME ::"
+ DateTime.Now.ToShortDateString () +
""
+ DateTime.Now.ToShortTimeString ());
try
{
DirectoryInfo dirPending =
new
DirectoryInfo (PendingPlacesFolder);
// list files in the current directory
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);
// 3,600,000 milliseconds equals 1 hour (Standby)
}
}
//And here is the method used to read the data I need in each line of the file:
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
// Search Bar Code, here I access another method that I use the barcode of the files to check if it is in the table of the procInter database, from here down everything works ok.
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
Move =
false
;
InsertLog (
"\ n Already Exists ->"
+ CodBar);
}
}
else
{
// Barcode not available in table -> sdpj_proc_inter
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?
Reply
Answers (
1
)
Regarding binding Cascaded DropdownList
MVC Edit problem