Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么我的oxi文件仍在in文件夹中,并在数据库中集成了2次或更多次?_C#_.net - Fatal编程技术网

C# 为什么我的oxi文件仍在in文件夹中,并在数据库中集成了2次或更多次?

C# 为什么我的oxi文件仍在in文件夹中,并在数据库中集成了2次或更多次?,c#,.net,C#,.net,我有一个自动机将我的文件(.oxi=xml文件)集成到数据库中,但我有一个问题,同一个文件被集成了2次甚至更多 我做了很多预防措施来防止在集成之后使用move函数从IN路径移动到归档路径,但它仍然不起作用 之后,我使用复制到归档路径,并在集成成功后从IN路径中删除该文件,但它仍然不起作用 有谁能向我解释一下到底是什么问题吗 public class Doc { public XmlDocument xDoc { get; set; } public Str

我有一个自动机将我的文件(.oxi=xml文件)集成到数据库中,但我有一个问题,同一个文件被集成了2次甚至更多

我做了很多预防措施来防止在集成之后使用move函数从IN路径移动到归档路径,但它仍然不起作用

之后,我使用复制到归档路径,并在集成成功后从IN路径中删除该文件,但它仍然不起作用

有谁能向我解释一下到底是什么问题吗

public class Doc
    {
        public XmlDocument xDoc { get; set; }
        public String Path { get; set; }
        public String file_name { get; set; } 
    }


public class Job
    {
        public String Name { get; set; }
        public String PathIn { get; set; }
        public String PathArchive { get; set; }
        public String PathError { get; set; }
        public String StatutLotOut { get; set; }
    }





  // start the job called every period by the timer


      public void start()
        {
            //General.addLog("hello, i am started");
            UpdateText();
            List<Job> jobs = get_jobs();
            foreach (Job job in jobs)
            {
                List<Doc> docs = new List<Doc>();
                //read all xml document inside the IN forlder path in   
                docs = gen.read_oxi(job);
                foreach (Doc doc in docs)
                {
                    try
                    {
                        TransferOpex.doc = doc;
                        TransferOpex.job = job;
                        xml_serialisation(doc.xDoc, job);
                        gen.moveDocToArchiverPath();
                        break;
                    }
                    catch (Exception ex)
                    {
                        General.addText("\n error : " + ex.ToString());
                        General.addLog(ex.ToString());
                        gen.moveDocToErrorPath();
                    }
                }
            }
        }
   public void moveDocToArchiverPath()
        {
            if (File.Exists(TransferOpex.doc.Path))
            {
                string Path2 = Path.Combine(TransferOpex.job.PathArchive, TransferOpex.doc.file_name + ".oxi");
                if (File.Exists(Path2))
                    File.Delete(Path2);

                File.Copy(TransferOpex.doc.Path, Path2,true);
                addText("\n file " + TransferOpex.doc.Path + " copied to Archive path at" + DateTime.Now);
                General.addLog("\n file " + TransferOpex.doc.Path + " copied to Archive path at" + DateTime.Now);
                if (File.Exists(TransferOpex.doc.Path))
                {


                    while (!IsFileReady(TransferOpex.doc.Path)) {

                    }

                    File.Delete(TransferOpex.doc.Path);
                    addText("\n file " + TransferOpex.doc.Path + " deleted from in path at" + DateTime.Now);
                    General.addLog("\n file " + TransferOpex.doc.Path + " deleted from in  path at" + DateTime.Now);
                }

            }
        }

        public static bool IsFileReady(string filename)
        {
            // If the file can be opened for exclusive access it means that the file
            // is no longer locked by another process.
            try
            {
                using (FileStream inputStream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.None))
                    return inputStream.Length > 0;
            }
            catch (Exception)
            {
                return false;
            }
        }
这就是在数据库中进行集成的功能

public void xml_serialisation(XmlDocument doc, Job job)
        {
            Lot lot = new Lot();
            classes.Image image = new classes.Image();
            XmlNodeList batchs = doc.GetElementsByTagName("Batch");
            XmlNode batch = batchs[0];
            String BatchIdentifier = batch.Attributes["BatchIdentifier"] != null ? batch.Attributes["BatchIdentifier"].Value : "Unknow value";
            String NUM_LOT = BatchIdentifier;
            String TransportId = batch.Attributes["TransportId"] != null ? batch.Attributes["TransportId"].Value : "Unknow value";
            String NUM_SCANNER = TransportId;
            String StartTime = doc.GetElementsByTagName("Batch")[0].Attributes["StartTime"] != null ? doc.GetElementsByTagName("Batch")[0].Attributes["StartTime"].Value : "Unknow value";
            //String ID_lot = DateTime.Parse(StartTime).ToString("yyyyMMdd") + "" + NUM_LOT + "" + NUM_SCANNER;
            String ID_lot = TransferOpex.doc.file_name;
            String NUM_NB_IMAGE = doc.GetElementsByTagName("EndInfo")[0].Attributes["NumPages"] != null ? doc.GetElementsByTagName("EndInfo")[0].Attributes["NumPages"].Value : "Unknow value";
            String EndTime = doc.GetElementsByTagName("EndInfo")[0].Attributes["EndTime"] != null ? doc.GetElementsByTagName("EndInfo")[0].Attributes["EndTime"].Value : "Unknow value";
            String JobName = doc.GetElementsByTagName("Batch")[0].Attributes["JobName"] != null ? doc.GetElementsByTagName("Batch")[0].Attributes["JobName"].Value : "Unknow value";
            String ImageFilePath = doc.GetElementsByTagName("Batch")[0].Attributes["ImageFilePath"] != null ? doc.GetElementsByTagName("Batch")[0].Attributes["ImageFilePath"].Value : "Unknow value";

            //String OperatorName = doc.GetElementsByTagName("Batch")[0].Attributes["OperatorName"] != null ? doc.GetElementsByTagName("Batch")[0].Attributes["OperatorName"].Value : "Unknow value";
            String OperatorName = gen.ReadSetting("OperatorName");

            //instatiate Class lot 
            lot.TXT_TYPE_LOT = JobName;
            lot.ID_LOT = long.Parse(ID_lot);
            lot.NUM_NB_IMAGE = int.Parse(NUM_NB_IMAGE);
            lot.DAT_DEBUT_NUM = DateTime.Parse(StartTime);
            lot.DAT_FIN_NUM = DateTime.Parse(EndTime);
            lot.ID_STATUT = int.Parse(job.StatutLotOut);// attention!!!!!!!!!!!, faut le recuperer de la configuration
            lot.NUM_SCANNER = int.Parse(NUM_SCANNER);
            lot.TXT_OPERATEUR = OperatorName;
            XmlNodeList pages = doc.GetElementsByTagName("Page");
            List<classes.Image> images = new List<classes.Image>();
            List<Icr> icrs = new List<Icr>();

            foreach (XmlNode page in pages)
            {
                String BatchSequence = page.Attributes["BatchSequence"] != null ? page.Attributes["BatchSequence"].Value : "Unknow value";
                XmlNodeList imgs = null;
                if (page.SelectNodes("Image") != null && page.SelectNodes("Image").Count > 0)
                {
                    imgs = page.SelectNodes("Image");
                }

                String AuditTrail = "";
                if (page.SelectNodes("AuditTrail") != null && page.SelectNodes("AuditTrail").Count >0)
                {
                    AuditTrail = page.SelectNodes("AuditTrail")[0].Attributes["Text"] != null ? page.SelectNodes("AuditTrail")[0].Attributes["Text"].Value : "Unknow value";
                }

                String PageName = page.Attributes["PageName"] != null ? page.Attributes["PageName"].Value : "Unknow value";
                // get node list from the config.xml file
                XmlNodeList Recos = gen.getNodelList("Reco");
                foreach (XmlNode Reco in Recos)
                {
                    String Balise = Reco.Attributes["Balise"] != null ? Reco.Attributes["Balise"].Value : "";
                    String TagValue = Reco.Attributes["TagValue"] != null ? Reco.Attributes["TagValue"].Value : "";
                    String TypeIcr = Reco.Attributes["TypeIcr"] != null ? Reco.Attributes["TypeIcr"].Value : "";
                    XmlNodeList Balises = page.SelectNodes(Balise) != null ? page.SelectNodes(Balise) : null;

                    if (Balises != null)
                    {
                        foreach (XmlNode balise in Balises)
                        {
                            //instatiate Class Icr 
                            String Index = balise.Attributes["Index"] != null ? balise.Attributes["Index"].Value : "";
                            Icr icr = new Icr();
                            // this instance will be saved
                            icr.save_it = true;
                            icr.ID_LOT = lot.ID_LOT;
                            icr.NUM_SEQUENCE = int.Parse(BatchSequence);
                            icr.NUM_INDEX = Index;
                            if (Balise == "Barcode")
                            {
                                icr.TXT_ICR = balise.Attributes["Value"].Value;
                                if (balise.Attributes["Type"] != null)
                                {
                                    if (balise.Attributes["Type"].Value == TagValue)
                                    {
                                        icr.TXT_TYPE = TypeIcr;
                                    }
                                    else
                                    {
                                        icr.TXT_TYPE = "unknow value";
                                        // prevent the instance to be saved in the DB
                                        icr.save_it = false;
                                    }
                                }
                            }
                            else if (Balise == "markDetect")
                            {
                                icr.TXT_ICR = balise.Attributes["Result"].Value;
                                icr.TXT_TYPE = Reco.Attributes["TypeIcr"].Value;
                            }
                            else if (Balise == "Micr")
                            {
                                icr.TXT_ICR = balise.Attributes["Value"].Value;
                                icr.TXT_TYPE = Reco.Attributes["TypeIcr"].Value;
                            }
                            else if (Balise == "OCR")
                            {
                                icr.TXT_ICR = balise.Attributes["Value"].Value;
                                icr.TXT_TYPE = Reco.Attributes["TypeIcr"].Value;
                            }
                            else
                            {
                                icr.save_it = false;
                            }
                            if (icr.TXT_ICR == "")
                            {
                                icr.save_it = false;
                            }

                            if (icr.save_it) icrs.Add(icr);
                        }
                    }
                }
                if(imgs !=null)
                foreach (XmlNode img in imgs)
                {
                    String Filename = img.Attributes["Filename"] != null ? img.Attributes["Filename"].Value : "Unknow value";
                    if (Filename == "" && gen.ReadSetting("acceptBlankImage") == "0")
                    {
                        General.addLog("can't add blank image( image without path ), in order to do that please change the value of acceptBlankImage to 1 ");
                        //create exceprion intentionally outside of the catch
                        int i = 0;
                        int j = 1 / i;
                    }

                    try
                    {
                        String Length = img.Attributes["Length"] != null ? img.Attributes["Length"].Value : "Unknow value";
                        String Height = img.Attributes["Height"] != null ? img.Attributes["Height"].Value : "Unknow value";
                        image = new classes.Image();
                        image.ID_LOT = lot.ID_LOT;
                        image.TXT_CHEMIN_IMAGE = ImageFilePath + "\\" + Filename;
                        String machine = gen.ReadSetting("machine");
                        //String index = "";

                        //if (machine == "IBML")
                        //{
                        //    index = Filename[0] + "" + Filename[1];
                        //}
                        //else if (machine == "OPEX")
                        //{
                        //    String file_name_without_extension = Path.GetFileNameWithoutExtension(Filename);
                        //    int Lenght = file_name_without_extension.Length;
                        //    int firstrightcharindex = Lenght - 1;
                        //    index = file_name_without_extension[firstrightcharindex] + "";
                        //}


                        String expression = gen.ReadSetting("EXPRESSION_NUM_TYPE_PAGE");
                        String index = "";
                        if (expression[0] == 'g' || expression[0] == 'G')
                        {
                            int gauche = (int)char.GetNumericValue(expression[1]);//donne le number de caratère faut le recuperer à droite
                            for (int i = 0; i < gauche; i++)
                            {
                                index += Filename[i] + "";
                            }
                        }

                        else if (expression[0] == 'd' || expression[0] == 'D')
                        {
                            int droite = (int)char.GetNumericValue(expression[1]);//donne le number de caratère faut le recuperer à droite
                            String file_name_without_extension = Path.GetFileNameWithoutExtension(Filename);
                            int Lenght = file_name_without_extension.Length;
                            int firstrightcharindex = Lenght - 1;

                            for (int i = firstrightcharindex; i > firstrightcharindex - droite; i--)
                            {
                                index += file_name_without_extension[i] + "";
                            }
                            index = General.Reverse(index);
                        }

                        image.TXT_ENDOS = AuditTrail;
                        image.NUM_SEQUENCE = int.Parse(BatchSequence);
                        image.NUM_PAGE = int.Parse(BatchSequence);
                        image.NUM_TYPE_PAGE = int.Parse(getTypeImage(PageName, index)); //attention !!!!!!, faut le recuperer de la configuration 
                        image.ID_STATUT = int.Parse(gen.ReadSetting("ID_STATUT")); //attention!!!!!!!, faut le recuperer de la configuration 
                        image.Length = Length;
                        image.Height = Height;
                        images.Add(image);
                    }
                    catch (Exception ex)
                    {

                    }
                }
            }
            DB.Database db = new DB.Database();
            // save into data base
            db.save_to_db(lot, images, icrs);
        }

        //get the job list  from config.xml and serialize into object
        public List<classes.Job> get_jobs()
        {
            XmlNodeList jobsNodelist = gen.getNodelList("Job");
            List<Job> jobs = new List<Job>();
            foreach (XmlNode j in jobsNodelist)
            {
                Job job = new Job();
                job.Name = j.Attributes["Name"] != null ? j.Attributes["Name"].Value : "unknow value";
                job.PathArchive = j.Attributes["PathArchive"] != null ? j.Attributes["PathArchive"].Value : "unknow value";
                job.PathIn = j.Attributes["PathIn"] != null ? j.Attributes["PathIn"].Value : "unknow job";
                job.StatutLotOut = j.Attributes["StatutLotOut"] != null ? j.Attributes["StatutLotOut"].Value : "unknow job";
                job.PathError = j.Attributes["PathError"] != null ? j.Attributes["PathError"].Value : "unknow job";
                jobs.Add(job);
            }
            return jobs;
        }
public void xml_序列化(XmlDocument doc,Job Job)
{
批次=新批次();
classes.Image Image=新类.Image();
XmlNodeList batchs=doc.GetElementsByTagName(“批”);
XmlNode批处理=批处理[0];
字符串BatchIdentifier=batch.Attributes[“BatchIdentifier”]!=null?batch.Attributes[“BatchIdentifier”]。值:“未知值”;
字符串NUM_LOT=BatchIdentifier;
字符串TransportId=batch.Attributes[“TransportId”]!=null?batch.Attributes[“TransportId”]。值:“未知值”;
String NUM_SCANNER=TransportId;
字符串StartTime=doc.GetElementsByTagName(“批次”)[0]。属性[“StartTime”]!=null?doc.GetElementsByTagName(“批次”)[0]。属性[“StartTime”]。值:“未知值”;
//String ID_lot=DateTime.Parse(StartTime).ToString(“yyyyMMdd”)+“”+NUM_lot+“”+NUM_SCANNER;
字符串ID\u lot=TransferOpex.doc.file\u name;
字符串NUM_NB_IMAGE=doc.GetElementsByTagName(“EndInfo”)[0]。属性[“NumPages”]!=null?doc.GetElementsByTagName(“EndInfo”)[0]。属性[“NumPages”]。值:“未知值”;
字符串EndTime=doc.GetElementsByTagName(“EndInfo”)[0]。属性[“EndTime”]!=null?doc.GetElementsByTagName(“EndInfo”)[0]。属性[“EndTime”]。值:“未知值”;
字符串JobName=doc.GetElementsByTagName(“批次”)[0]。属性[“JobName”]!=null?doc.GetElementsByTagName(“批次”)[0]。属性[“JobName”]。值:“未知值”;
字符串ImageFilePath=doc.GetElementsByTagName(“批次”)[0]。属性[“ImageFilePath”]!=null?doc.GetElementsByTagName(“批次”)[0]。属性[“ImageFilePath”]。值:“未知值”;
//字符串OperatorName=doc.GetElementsByTagName(“批次”)[0]。属性[“OperatorName”]!=null?doc.GetElementsByTagName(“批次”)[0]。属性[“OperatorName”]。值:“未知值”;
字符串OperatorName=gen.ReadSetting(“OperatorName”);
//固定类地段
lot.TXT\u TYPE\u lot=JobName;
lot.ID\u lot=long.Parse(ID\u lot);
lot.NUM\u NB\u IMAGE=int.Parse(NUM\u NB\u IMAGE);
lot.DAT_首秀_NUM=DateTime.Parse(StartTime);
lot.DAT_FIN_NUM=DateTime.Parse(EndTime);
lot.ID_statutt=int.Parse(job.StatutLotOut);//注意!!!!!!!!!!!!!请注意
lot.NUM\u SCANNER=int.Parse(NUM\u SCANNER);
lot.TXT_OPERATEUR=OperatorName;
XmlNodeList pages=doc.GetElementsByTagName(“页面”);
列表图像=新列表();
列表icrs=新列表();
foreach(页中的XmlNode页)
{
字符串BatchSequence=page.Attributes[“BatchSequence”]!=null?page.Attributes[“BatchSequence”]。值:“未知值”;
XmlNodeList imgs=null;
如果(page.SelectNodes(“Image”)!=null&&page.SelectNodes(“Image”).Count>0)
{
imgs=页面。选择节点(“图像”);
}
字符串AuditTrail=“”;
如果(page.SelectNodes(“AuditTrail”)!=null和&page.SelectNodes(“AuditTrail”)。计数>0)
{
AuditTrail=page.SelectNodes(“AuditTrail”)[0]。属性[“文本”]!=null?page.SelectNodes(“AuditTrail”)[0]。属性[“文本”]。值:“未知值”;
}
字符串PageName=page.Attributes[“PageName”]!=null?page.Attributes[“PageName”]。值:“未知值”;
//从config.xml文件获取节点列表
XmlNodeList Recos=gen.getNodelList(“Reco”);
foreach(记录中的XmlNode记录)
{
字符串应答器=记录属性[“应答器”]!=null?记录属性[“应答器”]。值:“”;
字符串TagValue=Reco.Attributes[“TagValue”]!=null?Reco.Attributes[“TagValue”]。值:“”;
字符串TypeIcr=Reco.Attributes[“TypeIcr”]!=null?Reco.Attributes[“TypeIcr”]。值:“”;
XmlNodeList应答器=第页。SelectNodes(应答器)!=null?第页。SelectNodes(应答器):null;
if(应答器!=null)
{
foreach(应答器中的XmlNode应答器)
{
//稳定级Icr
字符串索引=应答器。属性[“索引”]!=null?应答器。属性[“索引”]。值:“”;
Icr Icr=新的Icr();
//将保存此实例
icr.save_it=true;
icr.ID_标段=标段.ID_标段;
icr.NUM_SEQUENCE=int.Parse(BatchSequence);
icr.NUM_INDEX=索引;
如果(应答器=“条形码”)
{
icr.TXT_icr=balise.Attributes[“Value”].Value;
if(应答器属性[“类型”!=null)
{
if(应答器属性[“类型”].Value==TagValue)
{
icr.TXT_TYPE=TypeIcr;
public void xml_serialisation(XmlDocument doc, Job job)
        {
            Lot lot = new Lot();
            classes.Image image = new classes.Image();
            XmlNodeList batchs = doc.GetElementsByTagName("Batch");
            XmlNode batch = batchs[0];
            String BatchIdentifier = batch.Attributes["BatchIdentifier"] != null ? batch.Attributes["BatchIdentifier"].Value : "Unknow value";
            String NUM_LOT = BatchIdentifier;
            String TransportId = batch.Attributes["TransportId"] != null ? batch.Attributes["TransportId"].Value : "Unknow value";
            String NUM_SCANNER = TransportId;
            String StartTime = doc.GetElementsByTagName("Batch")[0].Attributes["StartTime"] != null ? doc.GetElementsByTagName("Batch")[0].Attributes["StartTime"].Value : "Unknow value";
            //String ID_lot = DateTime.Parse(StartTime).ToString("yyyyMMdd") + "" + NUM_LOT + "" + NUM_SCANNER;
            String ID_lot = TransferOpex.doc.file_name;
            String NUM_NB_IMAGE = doc.GetElementsByTagName("EndInfo")[0].Attributes["NumPages"] != null ? doc.GetElementsByTagName("EndInfo")[0].Attributes["NumPages"].Value : "Unknow value";
            String EndTime = doc.GetElementsByTagName("EndInfo")[0].Attributes["EndTime"] != null ? doc.GetElementsByTagName("EndInfo")[0].Attributes["EndTime"].Value : "Unknow value";
            String JobName = doc.GetElementsByTagName("Batch")[0].Attributes["JobName"] != null ? doc.GetElementsByTagName("Batch")[0].Attributes["JobName"].Value : "Unknow value";
            String ImageFilePath = doc.GetElementsByTagName("Batch")[0].Attributes["ImageFilePath"] != null ? doc.GetElementsByTagName("Batch")[0].Attributes["ImageFilePath"].Value : "Unknow value";

            //String OperatorName = doc.GetElementsByTagName("Batch")[0].Attributes["OperatorName"] != null ? doc.GetElementsByTagName("Batch")[0].Attributes["OperatorName"].Value : "Unknow value";
            String OperatorName = gen.ReadSetting("OperatorName");

            //instatiate Class lot 
            lot.TXT_TYPE_LOT = JobName;
            lot.ID_LOT = long.Parse(ID_lot);
            lot.NUM_NB_IMAGE = int.Parse(NUM_NB_IMAGE);
            lot.DAT_DEBUT_NUM = DateTime.Parse(StartTime);
            lot.DAT_FIN_NUM = DateTime.Parse(EndTime);
            lot.ID_STATUT = int.Parse(job.StatutLotOut);// attention!!!!!!!!!!!, faut le recuperer de la configuration
            lot.NUM_SCANNER = int.Parse(NUM_SCANNER);
            lot.TXT_OPERATEUR = OperatorName;
            XmlNodeList pages = doc.GetElementsByTagName("Page");
            List<classes.Image> images = new List<classes.Image>();
            List<Icr> icrs = new List<Icr>();

            foreach (XmlNode page in pages)
            {
                String BatchSequence = page.Attributes["BatchSequence"] != null ? page.Attributes["BatchSequence"].Value : "Unknow value";
                XmlNodeList imgs = null;
                if (page.SelectNodes("Image") != null && page.SelectNodes("Image").Count > 0)
                {
                    imgs = page.SelectNodes("Image");
                }

                String AuditTrail = "";
                if (page.SelectNodes("AuditTrail") != null && page.SelectNodes("AuditTrail").Count >0)
                {
                    AuditTrail = page.SelectNodes("AuditTrail")[0].Attributes["Text"] != null ? page.SelectNodes("AuditTrail")[0].Attributes["Text"].Value : "Unknow value";
                }

                String PageName = page.Attributes["PageName"] != null ? page.Attributes["PageName"].Value : "Unknow value";
                // get node list from the config.xml file
                XmlNodeList Recos = gen.getNodelList("Reco");
                foreach (XmlNode Reco in Recos)
                {
                    String Balise = Reco.Attributes["Balise"] != null ? Reco.Attributes["Balise"].Value : "";
                    String TagValue = Reco.Attributes["TagValue"] != null ? Reco.Attributes["TagValue"].Value : "";
                    String TypeIcr = Reco.Attributes["TypeIcr"] != null ? Reco.Attributes["TypeIcr"].Value : "";
                    XmlNodeList Balises = page.SelectNodes(Balise) != null ? page.SelectNodes(Balise) : null;

                    if (Balises != null)
                    {
                        foreach (XmlNode balise in Balises)
                        {
                            //instatiate Class Icr 
                            String Index = balise.Attributes["Index"] != null ? balise.Attributes["Index"].Value : "";
                            Icr icr = new Icr();
                            // this instance will be saved
                            icr.save_it = true;
                            icr.ID_LOT = lot.ID_LOT;
                            icr.NUM_SEQUENCE = int.Parse(BatchSequence);
                            icr.NUM_INDEX = Index;
                            if (Balise == "Barcode")
                            {
                                icr.TXT_ICR = balise.Attributes["Value"].Value;
                                if (balise.Attributes["Type"] != null)
                                {
                                    if (balise.Attributes["Type"].Value == TagValue)
                                    {
                                        icr.TXT_TYPE = TypeIcr;
                                    }
                                    else
                                    {
                                        icr.TXT_TYPE = "unknow value";
                                        // prevent the instance to be saved in the DB
                                        icr.save_it = false;
                                    }
                                }
                            }
                            else if (Balise == "markDetect")
                            {
                                icr.TXT_ICR = balise.Attributes["Result"].Value;
                                icr.TXT_TYPE = Reco.Attributes["TypeIcr"].Value;
                            }
                            else if (Balise == "Micr")
                            {
                                icr.TXT_ICR = balise.Attributes["Value"].Value;
                                icr.TXT_TYPE = Reco.Attributes["TypeIcr"].Value;
                            }
                            else if (Balise == "OCR")
                            {
                                icr.TXT_ICR = balise.Attributes["Value"].Value;
                                icr.TXT_TYPE = Reco.Attributes["TypeIcr"].Value;
                            }
                            else
                            {
                                icr.save_it = false;
                            }
                            if (icr.TXT_ICR == "")
                            {
                                icr.save_it = false;
                            }

                            if (icr.save_it) icrs.Add(icr);
                        }
                    }
                }
                if(imgs !=null)
                foreach (XmlNode img in imgs)
                {
                    String Filename = img.Attributes["Filename"] != null ? img.Attributes["Filename"].Value : "Unknow value";
                    if (Filename == "" && gen.ReadSetting("acceptBlankImage") == "0")
                    {
                        General.addLog("can't add blank image( image without path ), in order to do that please change the value of acceptBlankImage to 1 ");
                        //create exceprion intentionally outside of the catch
                        int i = 0;
                        int j = 1 / i;
                    }

                    try
                    {
                        String Length = img.Attributes["Length"] != null ? img.Attributes["Length"].Value : "Unknow value";
                        String Height = img.Attributes["Height"] != null ? img.Attributes["Height"].Value : "Unknow value";
                        image = new classes.Image();
                        image.ID_LOT = lot.ID_LOT;
                        image.TXT_CHEMIN_IMAGE = ImageFilePath + "\\" + Filename;
                        String machine = gen.ReadSetting("machine");
                        //String index = "";

                        //if (machine == "IBML")
                        //{
                        //    index = Filename[0] + "" + Filename[1];
                        //}
                        //else if (machine == "OPEX")
                        //{
                        //    String file_name_without_extension = Path.GetFileNameWithoutExtension(Filename);
                        //    int Lenght = file_name_without_extension.Length;
                        //    int firstrightcharindex = Lenght - 1;
                        //    index = file_name_without_extension[firstrightcharindex] + "";
                        //}


                        String expression = gen.ReadSetting("EXPRESSION_NUM_TYPE_PAGE");
                        String index = "";
                        if (expression[0] == 'g' || expression[0] == 'G')
                        {
                            int gauche = (int)char.GetNumericValue(expression[1]);//donne le number de caratère faut le recuperer à droite
                            for (int i = 0; i < gauche; i++)
                            {
                                index += Filename[i] + "";
                            }
                        }

                        else if (expression[0] == 'd' || expression[0] == 'D')
                        {
                            int droite = (int)char.GetNumericValue(expression[1]);//donne le number de caratère faut le recuperer à droite
                            String file_name_without_extension = Path.GetFileNameWithoutExtension(Filename);
                            int Lenght = file_name_without_extension.Length;
                            int firstrightcharindex = Lenght - 1;

                            for (int i = firstrightcharindex; i > firstrightcharindex - droite; i--)
                            {
                                index += file_name_without_extension[i] + "";
                            }
                            index = General.Reverse(index);
                        }

                        image.TXT_ENDOS = AuditTrail;
                        image.NUM_SEQUENCE = int.Parse(BatchSequence);
                        image.NUM_PAGE = int.Parse(BatchSequence);
                        image.NUM_TYPE_PAGE = int.Parse(getTypeImage(PageName, index)); //attention !!!!!!, faut le recuperer de la configuration 
                        image.ID_STATUT = int.Parse(gen.ReadSetting("ID_STATUT")); //attention!!!!!!!, faut le recuperer de la configuration 
                        image.Length = Length;
                        image.Height = Height;
                        images.Add(image);
                    }
                    catch (Exception ex)
                    {

                    }
                }
            }
            DB.Database db = new DB.Database();
            // save into data base
            db.save_to_db(lot, images, icrs);
        }

        //get the job list  from config.xml and serialize into object
        public List<classes.Job> get_jobs()
        {
            XmlNodeList jobsNodelist = gen.getNodelList("Job");
            List<Job> jobs = new List<Job>();
            foreach (XmlNode j in jobsNodelist)
            {
                Job job = new Job();
                job.Name = j.Attributes["Name"] != null ? j.Attributes["Name"].Value : "unknow value";
                job.PathArchive = j.Attributes["PathArchive"] != null ? j.Attributes["PathArchive"].Value : "unknow value";
                job.PathIn = j.Attributes["PathIn"] != null ? j.Attributes["PathIn"].Value : "unknow job";
                job.StatutLotOut = j.Attributes["StatutLotOut"] != null ? j.Attributes["StatutLotOut"].Value : "unknow job";
                job.PathError = j.Attributes["PathError"] != null ? j.Attributes["PathError"].Value : "unknow job";
                jobs.Add(job);
            }
            return jobs;
        }