D"
iv> the result of the above query is stored as string in the property M
oduleInformation
of the class clsImportExportDetails.
v> the connection is disconnected and the command object is disposed.
<3> get the current software version.
*****************How It Works***************
i> frmWSImportExport_Load(object sender, System.EventArgs e) of class
frmWSImportExport
calls getSoftwareVer() of same class.
ii> getSoftwareVer() creates a clsConnection object and a oleDbCommand
retrieve information about the software version.
object to
of the
previously created object.ImportData() carries out the whole task o
f importing.
iv> ImportData() calls getListOfTobeImportedFiles() of class clsImport.
getListOfTobeImportedFiles() gets the list of files to be imported
into an arraylist
getListOfTobeImportedFiles() puts the list of files to be impoted i
nto the
arraylist in the following manner :
(a) It calls setRequiredCount() of class clsImport which sets
a long integer
"RequiredCount".
(b) setRequiredCount() creates a clsConnection object and an O
leDbCommand
object.
(c) setRequiredCount() executes the following sql command :
"SELECT SYSINF_EXP_IMP_COUNT FROM SYSTEM_INFORMATION WHERE
SYSINF_CODE =
'IMPORT'" and then converts the result t
o integer and then sends it back to
"RequiredCount".
(d) Then getListOfTobeImportedFiles() creates an arraylist of
the size of the
number of files present in the "director
y"(initialized previously) having
name "HO*.exp"
(e) Then getListOfTobeImportedFiles() creates an empty arrayli
st of and a
string array of the size of the previous
ly created filled arraylist.
(f) Each file present in the arraylist is first brought into t
he string array.
Since the filled array list contains file name with full p
ath,the string
array also contains file name with full path.
(g) Next,for each file in the string array , only the file nam
e is
extracted leaving the path information.
(h) Now if in this file name all characters starting from 8-th
(0-based
indexing)position upto 8-th from the other other end are d
igits then
the file name along with the path information is added to
the empty
arraylist,on condition that the digit value is less than "
RequiredCount" .
(i) otherwise if not all of them are digits, then that file na
me is diretly
added to the empty array list along with the path informat
ion.
(j) So the empty arraylist may not contain all the files the f
illed arraylist.
But all the file names included in the empty array list ar
e removed from
filled array list.
(k) Now the filled array list and RequiredCount is passed
to SortAccordingToCount() of class clsIm
port to be sorted and put into
another array list which is returned.
v> Next ImportData() calls importIntoDatabase() of class clsImport for
name(along with path) present in the list returne
each file
d by getListOfTobeImportedFiles().
vi> importIntoDatabase() calls importXMLFile() of the class clsImport.
vii> importXMLFile() actually imports the files on the array list passed
to
importIntoDatabase().It does it in the following manner :
(a) It creates necessary objects like it first creates a clsCo
nnection object
next it assigns this object to an OleDbConnection Object,t
hen it creates
one OleDbDataAdapter object and one OleDbTransaction objec
t.
(b) Then it reads the file to be imported into a dataset with
the help of
readXML() of class clsImport.To read an XML file readXML()
first calls
getXMLFileFromEXPFile() of the same class.getXMLFileFromEX
PFile() then
sheds the file extension and attaches ".zip" at the end(ac
tually all the
file names on the array list have extension ".exp").Then i
t checks if the
already exists in "directory".If it already exists then it
deletes the file
from the "directory".Then it moves the ".exp" file to the
"directory" with
".zip" extension.it then unzips this file to a folder and
returns the full
path of the unzipped file.Since this was originally a an X
ML file,after
unzipping the XML file is retrieved.Hence the returned pat
h is the path of
an XML file.After that the XML file is read into a file st
ream.Then an
XmlTextReader of the size of the file stream is created.Fi
nally this
XmlTextReader is read into a data set with the help of Rea
dXml() and the
data set is returned.
(c) After that importXMLFile() calls isFileinRequiredFormat()
of class
clsImport which picks up the table named "CHECKFILEINFO" i
nto a data table
from the returned dataset.Now the cellvalue of the first r
ow and
"ExportCount" column is loaded into property ImportCount o
f class
clsResource.Now it throws up error message if the cellvalu
e corresponding
to the first row and "FileName" column does not match with
required ".exp"
file name or if the cellvalue corresponding to first row a
nd "SoftwareVer"
does not match with the property value of SoftwareVersion
of class
clsImportExportDetails.But if they matched then it is assu
med that the file
is in required format.