public ApplicationConfiguration(IMSApiSessionContextStruct sessionContext, MainView view)
        {
            try
            {
                dicConfig = new Dictionary <string, string>();
                ConfigManage configHandler = new ConfigManage(sessionContext, view);
                CommonModel  commonModel   = ReadIhasFileData.getInstance();
                if (commonModel.UpdateConfig == "L")
                {
                    XDocument config = XDocument.Load("ApplicationConfig.xml");
                    StationNumber    = commonModel.Station;
                    Client           = commonModel.Client;
                    RegistrationType = commonModel.RegisterType;
                    SerialPort       = GetParameterValues(config, "SerialPort");
                    BaudRate         = GetParameterValues(config, "BaudRate");
                    Parity           = GetParameterValues(config, "Parity");
                    StopBits         = GetParameterValues(config, "StopBits");
                    DataBits         = GetParameterValues(config, "DataBits");
                    NewLineSymbol    = GetParameterValues(config, "NewLineSymbol");
                    High             = GetParameterValues(config, "High");
                    Low                         = GetParameterValues(config, "Low");
                    EndCommand                  = GetParameterValues(config, "EndCommand");
                    DLExtractPattern            = GetParameterValues(config, "DLExtractPattern");
                    MBNExtractPattern           = GetParameterValues(config, "MBNExtractPattern");
                    EquipmentExtractPattern     = GetParameterValues(config, "EquipmentExtractPattern");
                    OpacityValue                = GetParameterValues(config, "OpacityValue");
                    LocationXY                  = GetParameterValues(config, "LocationXY");
                    NoRead                      = GetParameterValues(config, "NoRead");
                    LogFileFolder               = GetParameterValues(config, "LogFileFolder");
                    LogTransOK                  = GetParameterValues(config, "LogTransOK");
                    LogTransError               = GetParameterValues(config, "LogTransError");
                    ChangeFileName              = GetParameterValues(config, "ChangeFileName");
                    CheckListFolder             = GetParameterValues(config, "CheckListFolder");
                    LoadExtractPattern          = GetParameterValues(config, "LoadExtractPattern");
                    LogInType                   = GetParameterValues(config, "LogInType");
                    Language                    = GetParameterValues(config, "Language");
                    MDAPath                     = GetParameterValues(config, "MDAPath");
                    IPAddress                   = GetParameterValues(config, "IPAddress");
                    Port                        = GetParameterValues(config, "Port");
                    FileNamePattern             = GetParameterValues(config, "FileNamePattern");
                    FilterByFileName            = GetParameterValues(config, "FilterByFileName");
                    RefreshWO                   = GetParameterValues(config, "RefreshWO");
                    IPI_STATUS_CHECK            = GetParameterValues(config, "IPI_STATUS_CHECK");
                    Production_Inspection_CHECK = GetParameterValues(config, "Production_Inspection_CHECK");
                    FILE_CLEANUP                = GetParameterValues(config, "FILE_CLEANUP");
                    FILE_CLEANUP_TREAD_TIMER    = GetParameterValues(config, "FILE_CLEANUP_TREAD_TIMER");
                    FILE_CLEANUP_FOLDER_TYPE    = GetParameterValues(config, "FILE_CLEANUP_FOLDER_TYPE");
                    LIGHT_CHANNEL_ON            = GetParameterValues(config, "LIGHT_CHANNEL_ON");
                    LIGHT_CHANNEL_OFF           = GetParameterValues(config, "LIGHT_CHANNEL_OFF");
                    IO_BOX_CONNECT              = GetParameterValues(config, "IO_BOX_CONNECT");
                    ReduceEquType               = GetParameterValues(config, "ReduceEquType"); // config.Descendants("ReduceEquType").First().Value;
                    StencilPrefix               = GetParameterValues(config, "StencilPrefix"); //config.Descendants("StencilPrefix").First().Value;
                    if (IO_BOX_CONNECT != null && IO_BOX_CONNECT.Split(';').Length >= 6)
                    {
                        string[] infos = IO_BOX_CONNECT.Split(';');
                        IOSerialPort = "COM" + infos[0];
                        IOBaudRate   = infos[1];
                        IOStopBits   = infos[4];
                        IODataBits   = infos[2];
                        IOParity     = infos[3];
                    }
                    OutputEnter         = GetParameterValues(config, "OutputEnter");
                    DataOutputInterface = GetParameterValues(config, "DataOutputInterface");
                    LAYER_DISPLAY       = GetParameterValues(config, "LAYER_DISPLAY");
                    CHECKCONECTTIME     = GetParameterValues(config, "CHECKCONECTTIME");
                    CEHCKTXTFILE        = GetParameterValues(config, "CEHCKTXTFILE");

                    #region checklist
                    CHECKLIST_IPAddress     = GetParameterValues(config, "CHECKLIST_IPAddress");
                    CHECKLIST_Port          = GetParameterValues(config, "CHECKLIST_Port");
                    CHECKLIST_SOURCE        = GetParameterValues(config, "CHECKLIST_SOURCE");
                    AUTH_CHECKLIST_APP_TEAM = GetParameterValues(config, "AUTH_CHECKLIST_APP_TEAM");
                    CHECKLIST_FREQ          = GetParameterValues(config, "CHECKLIST_FREQ");
                    SHIFT_CHANGE_TIME       = GetParameterValues(config, "SHIFT_CHANGE_TIME");
                    RESTORE_TIME            = GetParameterValues(config, "RESTORE_TIME");
                    RESTORE_TREAD_TIMER     = GetParameterValues(config, "RESTORE_TREAD_TIMER");
                    AUTH_TEAM = GetParameterValues(config, "AUTH_TEAM");
                    #endregion
                }
                else
                {
                    if (commonModel.UpdateConfig == "Y")
                    {
                        //int error = configHandler.DeleteConfigParameters(commonModel.APPTYPE);
                        //if (error == 0 || error == -3303 || error == -3302)
                        //{
                        //    WriteParameterToiTac(configHandler);
                        //}
                        string[] parametersValue = configHandler.GetParametersForScope(commonModel.APPTYPE);
                        if (parametersValue != null && parametersValue.Length > 0)
                        {
                            foreach (var parameterID in parametersValue)
                            {
                                configHandler.DeleteConfigParametersExt(parameterID);
                            }
                        }
                        WriteParameterToiTac(configHandler);
                    }
                    List <ConfigEntity> getvalues = configHandler.GetConfigData(commonModel.APPID, commonModel.APPTYPE, commonModel.Cluster, commonModel.Station);
                    if (getvalues != null)
                    {
                        foreach (var item in getvalues)
                        {
                            if (item != null)
                            {
                                string[] strs = item.PARAMETER_NAME.Split(new char[] { '.' });
                                dicConfig.Add(strs[strs.Length - 1], item.CONFIG_VALUE);
                            }
                        }
                    }

                    StationNumber    = commonModel.Station;
                    Client           = commonModel.Client;
                    RegistrationType = commonModel.RegisterType;
                    SerialPort       = GetParameterValue("SerialPort");
                    BaudRate         = GetParameterValue("BaudRate");
                    Parity           = GetParameterValue("Parity");
                    StopBits         = GetParameterValue("StopBits");
                    DataBits         = GetParameterValue("DataBits");
                    NewLineSymbol    = GetParameterValue("NewLineSymbol");
                    High             = GetParameterValue("High");
                    Low                     = GetParameterValue("Low");
                    EndCommand              = GetParameterValue("EndCommand");
                    DLExtractPattern        = GetParameterValue("DLExtractPattern");
                    MBNExtractPattern       = GetParameterValue("MBNExtractPattern");
                    EquipmentExtractPattern = GetParameterValue("EquipmentExtractPattern");
                    OpacityValue            = GetParameterValue("OpacityValue");
                    LocationXY              = GetParameterValue("LocationXY");
                    ThawingDuration         = GetParameterValue("ThawingDuration");
                    ThawingCheck            = GetParameterValue("ThawingCheck");
                    LockTime                = GetParameterValue("LockOutTime");
                    UsageTime               = GetParameterValue("UsageDurationSetting");
                    GateKeeperTimer         = GetParameterValue("GateKeeperTimer");
                    SolderPasteValidity     = GetParameterValue("SolderPasteValidity");
                    OpenControlBox          = GetParameterValue("OpenControlBox");
                    StencilPrefix           = GetParameterValue("StencilPrefix");
                    TimerSpan               = GetParameterValue("TimerSpan");
                    StartTrigerStr          = GetParameterValue("StartTrigerStr");
                    EndTrigerStr            = GetParameterValue("EndTrigerStr");
                    NoRead                  = GetParameterValue("NoRead");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message, ex);
            }
        }
        public ApplicationConfiguration(IMSApiSessionContextStruct sessionContext, MainView view)
        {
            try
            {
                CommonModel commonModel = ReadIhasFileData.getInstance();
                StationNumber    = commonModel.Station;
                Client           = commonModel.Client;
                RegistrationType = commonModel.RegisterType;
                if (commonModel.UpdateConfig == "L")
                {
                    XDocument config = XDocument.Load("ApplicationConfig.xml");
                    SerialPort              = GetDescendants("SerialPort", config);              //config.Descendants("SerialPort").First().Value;
                    BaudRate                = GetDescendants("BaudRate", config);                //config.Descendants("BaudRate").First().Value;
                    Parity                  = GetDescendants("Parity", config);                  //config.Descendants("Parity").First().Value;
                    StopBits                = GetDescendants("StopBits", config);                //config.Descendants("StopBits").First().Value;
                    DataBits                = GetDescendants("DataBits", config);                //config.Descendants("DataBits").First().Value;
                    NewLineSymbol           = GetDescendants("NewLineSymbol", config);           //config.Descendants("NewLineSymbol").First().Value;
                    DLExtractPattern        = GetDescendants("DLExtractPattern", config);        //config.Descendants("DLExtractPattern").First().Value;
                    MBNExtractPattern       = GetDescendants("MBNExtractPattern", config);       //config.Descendants("MBNExtractPattern").First().Value;
                    EquipmentExtractPattern = GetDescendants("EquipmentExtractPattern", config); //config.Descendants("EquipmentExtractPattern").First().Value;
                    OpacityValue            = GetDescendants("OpacityValue", config);            //config.Descendants("OpacityValue").First().Value;
                    LocationXY              = GetDescendants("LocationXY", config);              //config.Descendants("LocationXY").First().Value;
                    MDAPath                 = GetDescendants("MDAPath", config);                 //config.Descendants("MDAPath").First().Value;
                    OutputEnter             = GetDescendants("OutputEnter", config);             //config.Descendants("OutputEnter").First().Value;

                    #region add by qy
                    Language            = GetDescendants("Language", config);            //config.Descendants("Language").First().Value;
                    OutSerialPort       = GetDescendants("OutSerialPort", config);       //config.Descendants("OutSerialPort").First().Value;
                    OutBaudRate         = GetDescendants("OutBaudRate", config);         //config.Descendants("OutBaudRate").First().Value;
                    OutParity           = GetDescendants("OutParity", config);           //config.Descendants("OutParity").First().Value;
                    OutStopBits         = GetDescendants("OutStopBits", config);         //config.Descendants("OutStopBits").First().Value;
                    OutDataBits         = GetDescendants("OutDataBits", config);         //config.Descendants("OutDataBits").First().Value;
                    DataOutputInterface = GetDescendants("DataOutputInterface", config); //config.Descendants("DataOutputInterface").First().Value;
                    TrayExtractPattern  = GetDescendants("TrayExtractPattern", config);  //config.Descendants("TrayExtractPattern").First().Value;
                    LogInRegular        = GetDescendants("LogInRegular", config);        //config.Descendants("LogInRegular").First().Value;
                    LogInType           = GetDescendants("LogInType", config);           //config.Descendants("LogInType").First().Value;
                    CheckListFolder     = GetDescendants("CheckListFolder", config);     //config.Descendants("CheckListFolder").First().Value;
                    IsSelectWO          = GetDescendants("IsSelectWO", config);          //config.Descendants("IsSelectWO").First().Value;
                    IsCheckList         = GetDescendants("IsCheckList", config);         //config.Descendants("IsCheckList").First().Value;
                    IsMaterialSetup     = GetDescendants("IsMaterialSetup", config);     //config.Descendants("IsMaterialSetup").First().Value;
                    IsEquipSetup        = GetDescendants("IsEquipSetup", config);        //config.Descendants("IsEquipSetup").First().Value;
                    YSLine                = GetDescendants("YSLine", config);            //config.Descendants("YSLine").First().Value;
                    YSPos                 = GetDescendants("YSPos", config);             //config.Descendants("YSPos").First().Value;
                    ASCLine               = GetDescendants("ASCLine", config);           //config.Descendants("ASCLine").First().Value;
                    ASCPos                = GetDescendants("ASCPos", config);            //config.Descendants("ASCPos").First().Value;
                    IQTYPattern           = GetDescendants("IQTYPattern", config);       //config.Descendants("IQTYPattern").First().Value;
                    SelectMode            = GetDescendants("SelectMode", config);        //config.Descendants("SelectMode").First().Value;
                    DataSleepTime         = GetDescendants("DataSleepTime", config);     //config.Descendants("DataSleepTime").First().Value;
                    FilterByFileName      = GetDescendants("FilterByFileName", config);  //config.Descendants("FilterByFileName").First().Value;
                    FileNamePattern       = GetDescendants("FileNamePattern", config);   //config.Descendants("FileNamePattern").First().Value;
                    UserTeam              = GetDescendants("AUTH_TEAM", config);         //config.Descendants("UserTeam").First().Value;
                    PORTAL_SERVER_CONNECT = GetDescendants("PORTAL_SERVER_CONNECT", config);
                    #endregion
                }
                else
                {
                    dicConfig = new Dictionary <string, string>();
                    ConfigManage configHandler = new ConfigManage(sessionContext, view);
                    if (commonModel.UpdateConfig == "Y")
                    {
                        //int error = configHandler.DeleteConfigParameters(commonModel.APPTYPE);
                        //if (error == 0 || error == -3303 || error == -3302)
                        //{
                        //    WriteParameterToiTac(configHandler);
                        //}
                        string[] parametersValue = configHandler.GetParametersForScope(commonModel.APPTYPE);
                        if (parametersValue != null && parametersValue.Length > 0)
                        {
                            foreach (var parameterID in parametersValue)
                            {
                                configHandler.DeleteConfigParametersExt(parameterID);
                            }
                        }
                        WriteParameterToiTac(configHandler);
                    }
                    List <ConfigEntity> getvalues = configHandler.GetConfigData(commonModel.APPID, commonModel.APPTYPE, commonModel.Cluster, commonModel.Station);
                    if (getvalues != null)
                    {
                        foreach (var item in getvalues)
                        {
                            if (item != null)
                            {
                                string[] strs = item.PARAMETER_NAME.Split(new char[] { '.' });
                                dicConfig.Add(strs[strs.Length - 1], item.CONFIG_VALUE);
                            }
                        }
                    }
                    SerialPort              = GetParameterValue("SerialPort");
                    BaudRate                = GetParameterValue("BaudRate");
                    Parity                  = GetParameterValue("Parity");
                    StopBits                = GetParameterValue("StopBits");
                    DataBits                = GetParameterValue("DataBits");
                    NewLineSymbol           = GetParameterValue("NewLineSymbol");
                    DLExtractPattern        = GetParameterValue("DLExtractPattern");
                    MBNExtractPattern       = GetParameterValue("MBNExtractPattern");
                    EquipmentExtractPattern = GetParameterValue("EquipmentExtractPattern");
                    OpacityValue            = GetParameterValue("OpacityValue");
                    LocationXY              = GetParameterValue("LocationXY");
                    MDAPath                 = GetParameterValue("MDAPath");
                    OutputEnter             = GetParameterValue("OutputEnter");

                    #region add by qy
                    Language            = GetParameterValue("Language");
                    OutSerialPort       = GetParameterValue("OutSerialPort");
                    OutBaudRate         = GetParameterValue("OutBaudRate");
                    OutParity           = GetParameterValue("OutParity");
                    OutStopBits         = GetParameterValue("OutStopBits");
                    OutDataBits         = GetParameterValue("OutDataBits");
                    DataOutputInterface = GetParameterValue("DataOutputInterface");
                    TrayExtractPattern  = GetParameterValue("TrayExtractPattern");
                    LogInRegular        = GetParameterValue("LogInRegular");
                    LogInType           = GetParameterValue("LogInType");
                    CheckListFolder     = GetParameterValue("CheckListFolder");
                    IsSelectWO          = GetParameterValue("IsSelectWO");
                    IsCheckList         = GetParameterValue("IsCheckList");
                    IsMaterialSetup     = GetParameterValue("IsMaterialSetup");
                    IsEquipSetup        = GetParameterValue("IsEquipSetup");
                    YSLine           = GetParameterValue("YSLine");
                    YSPos            = GetParameterValue("YSPos");
                    ASCLine          = GetParameterValue("ASCLine");
                    ASCPos           = GetParameterValue("ASCPos");
                    IQTYPattern      = GetParameterValue("IQTYPattern");
                    SelectMode       = GetParameterValue("SelectMode");
                    DataSleepTime    = GetParameterValue("DataSleepTime");
                    FilterByFileName = GetParameterValue("FilterByFileName");
                    FileNamePattern  = GetParameterValue("FileNamePattern");
                    #endregion
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message, ex);
            }
        }
        public ApplicationConfiguration(IMSApiSessionContextStruct sessionContext, MainView view)
        {
            try
            {
                CommonModel commonModel = ReadIhasFileData.getInstance();
                StationNumber    = commonModel.Station;
                Client           = commonModel.Client;
                RegistrationType = commonModel.RegisterType;
                if (commonModel.UpdateConfig == "L")
                {
                    XDocument config = XDocument.Load("ApplicationConfig.xml");
                    SerialPort              = GetDescendants("SerialPort", config);              //config.Descendants("SerialPort").First().Value;
                    BaudRate                = GetDescendants("BaudRate", config);                //config.Descendants("BaudRate").First().Value;
                    Parity                  = GetDescendants("Parity", config);                  //config.Descendants("Parity").First().Value;
                    StopBits                = GetDescendants("StopBits", config);                // config.Descendants("StopBits").First().Value;
                    DataBits                = GetDescendants("DataBits", config);                //config.Descendants("DataBits").First().Value;
                    NewLineSymbol           = GetDescendants("NewLineSymbol", config);           // config.Descendants("NewLineSymbol").First().Value;
                    DLExtractPattern        = GetDescendants("DLExtractPattern", config);        //config.Descendants("DLExtractPattern").First().Value;
                    MBNExtractPattern       = GetDescendants("MBNExtractPattern", config);       // config.Descendants("MBNExtractPattern").First().Value;
                    EquipmentExtractPattern = GetDescendants("EquipmentExtractPattern", config); //config.Descendants("EquipmentExtractPattern").First().Value;
                    OpacityValue            = GetDescendants("OpacityValue", config);            //config.Descendants("OpacityValue").First().Value;
                    LocationXY              = GetDescendants("LocationXY", config);              //config.Descendants("LocationXY").First().Value;
                    MDAPath                 = GetDescendants("MDAPath", config);                 // config.Descendants("MDAPath").First().Value;
                    OutputEnter             = GetDescendants("OutputEnter", config);             //config.Descendants("OutputEnter").First().Value;

                    #region add by qy
                    Language            = GetDescendants("Language", config);                 //config.Descendants("Language").First().Value;
                    OutSerialPort       = GetDescendants("OutSerialPort", config);            //config.Descendants("OutSerialPort").First().Value;
                    OutBaudRate         = GetDescendants("OutBaudRate", config);              //config.Descendants("OutBaudRate").First().Value;
                    OutParity           = GetDescendants("OutParity", config);                // config.Descendants("OutParity").First().Value;
                    OutStopBits         = GetDescendants("OutStopBits", config);              //config.Descendants("OutStopBits").First().Value;
                    OutDataBits         = GetDescendants("OutDataBits", config);              //config.Descendants("OutDataBits").First().Value;
                    DataOutputInterface = GetDescendants("DataOutputInterface", config);      //config.Descendants("DataOutputInterface").First().Value;
                    TrayExtractPattern  = GetDescendants("TrayExtractPattern", config);       //config.Descendants("TrayExtractPattern").First().Value;
                    LogInRegular        = GetDescendants("LogInRegular", config);             //config.Descendants("LogInRegular").First().Value;
                    LogInType           = GetDescendants("LogInType", config);                //config.Descendants("LogInType").First().Value;
                    CheckListFolder     = GetDescendants("CheckListFolder", config);          //config.Descendants("CheckListFolder").First().Value;
                    IsSelectWO          = GetDescendants("IsSelectWO", config);               // config.Descendants("IsSelectWO").First().Value;
                    IsCheckList         = GetDescendants("IsCheckList", config);              //config.Descendants("IsCheckList").First().Value;
                    IsMaterialSetup     = GetDescendants("IsMaterialSetup", config);          // config.Descendants("IsMaterialSetup").First().Value;
                    IsEquipSetup        = GetDescendants("IsEquipSetup", config);             // config.Descendants("IsEquipSetup").First().Value;
                    SDLExtractPattern   = GetDescendants("SDLExtractPattern", config);        //config.Descendants("SDLExtractPattern").First().Value;
                    IPAddress           = GetDescendants("IPAddress", config);                // config.Descendants("IPAddress").First().Value;
                    Port              = GetDescendants("Port", config);                       // config.Descendants("Port").First().Value;
                    ScanSNType        = GetDescendants("ScanSNType", config);                 // config.Descendants("ScanSNType").First().Value;
                    GetCompStation    = GetDescendants("GetCompStation", config);             //config.Descendants("GetCompStation").First().Value;
                    IsCheckLayer      = GetDescendants("IsCheckLayer", config);               //config.Descendants("IsCheckLayer").First().Value;
                    IsNeedCompColumn  = GetDescendants("IsNeedCompColumn", config);           //config.Descendants("IsNeedCompColumn").First().Value;
                    IsGetAllCompByBom = GetDescendants("IsGetAllCompByBom", config);          //config.Descendants("IsGetAllCompByBom").First().Value;
                    IsNeedInfoField   = GetDescendants("IsNeedInfoField", config);            //config.Descendants("IsNeedInfoField").First().Value;

                    FilterByFileName            = GetDescendants("FilterByFileName", config); //config.Descendants("FilterByFileName").First().Value;
                    FileNamePattern             = GetDescendants("FileNamePattern", config);  //config.Descendants("FileNamePattern").First().Value;
                    OK_CHANNEL_Open             = GetDescendants("OK_CHANNEL_Open", config);
                    OK_CHANNEL_CLOSE            = GetDescendants("OK_CHANNEL_CLOSE", config);
                    NG_CHANNEL_OPEN             = GetDescendants("NG_CHANNEL_OPEN", config);
                    NG_CHANGE_CLOSE             = GetDescendants("NG_CHANGE_CLOSE", config);
                    CommandSleepTime            = GetDescendants("PRESS_TIMER", config);
                    UserTeam                    = GetDescendants("AUTH_TEAM", config);//config.Descendants("UserTeam").First().Value;
                    Upload_BARCODE              = GetDescendants("Upload_BARCODE", config);
                    RefreshWO                   = GetDescendants("RefreshWO", config);
                    PrintType                   = GetDescendants("PrintType", config);
                    IsPrint                     = GetDescendants("Traveler_Slip", config);
                    MaxiumCount                 = GetDescendants("PCB_Magazine_Rack_Qty", config);
                    PrintSerialPort             = GetDescendants("PrintSerialPort", config);
                    TemplateFolder              = GetDescendants("TemplateFolder", config);
                    PrinterTypeName             = GetDescendants("PrinterTypeName", config);
                    Temp_PartNo                 = GetDescendants("Temp_PartNo", config);
                    IPI_STATUS_CHECK            = GetDescendants("IPI_STATUS_CHECK", config);
                    Production_Inspection_CHECK = GetDescendants("Production_Inspection_CHECK", config);

                    ACTIVE_WORKORDER_LINE = GetDescendants("ACTIVE_WORKORDER_LINE", config);
                    LAYER_DISPLAY         = GetDescendants("LAYER_DISPLAY", config);
                    #endregion

                    #region checklist
                    CHECKLIST_IPAddress     = GetDescendants("CHECKLIST_IPAddress", config);
                    CHECKLIST_Port          = GetDescendants("CHECKLIST_Port", config);
                    CHECKLIST_SOURCE        = GetDescendants("CHECKLIST_SOURCE", config);
                    AUTH_CHECKLIST_APP_TEAM = GetDescendants("AUTH_CHECKLIST_APP_TEAM", config);
                    CHECKLIST_FREQ          = GetDescendants("CHECKLIST_FREQ", config);
                    SHIFT_CHANGE_TIME       = GetDescendants("SHIFT_CHANGE_TIME", config);
                    RESTORE_TIME            = GetDescendants("RESTORE_TIME", config);
                    RESTORE_TREAD_TIMER     = GetDescendants("RESTORE_TREAD_TIMER", config);
                    #endregion
                }
                else
                {
                    dicConfig = new Dictionary <string, string>();
                    ConfigManage configHandler = new ConfigManage(sessionContext, view);
                    if (commonModel.UpdateConfig == "Y")
                    {
                        //int error = configHandler.DeleteConfigParameters(commonModel.APPTYPE);
                        //if (error == 0 || error == -3303 || error == -3302)
                        //{
                        //    WriteParameterToiTac(configHandler);
                        //}
                        string[] parametersValue = configHandler.GetParametersForScope(commonModel.APPTYPE);
                        if (parametersValue != null && parametersValue.Length > 0)
                        {
                            foreach (var parameterID in parametersValue)
                            {
                                configHandler.DeleteConfigParametersExt(parameterID);
                            }
                        }
                        WriteParameterToiTac(configHandler);
                    }
                    List <ConfigEntity> getvalues = configHandler.GetConfigData(commonModel.APPID, commonModel.APPTYPE, commonModel.Cluster, commonModel.Station);
                    if (getvalues != null)
                    {
                        foreach (var item in getvalues)
                        {
                            if (item != null)
                            {
                                string[] strs = item.PARAMETER_NAME.Split(new char[] { '.' });
                                dicConfig.Add(strs[strs.Length - 1], item.CONFIG_VALUE);
                            }
                        }
                    }
                    SerialPort              = GetParameterValue("SerialPort");
                    BaudRate                = GetParameterValue("BaudRate");
                    Parity                  = GetParameterValue("Parity");
                    StopBits                = GetParameterValue("StopBits");
                    DataBits                = GetParameterValue("DataBits");
                    NewLineSymbol           = GetParameterValue("NewLineSymbol");
                    DLExtractPattern        = GetParameterValue("DLExtractPattern");
                    MBNExtractPattern       = GetParameterValue("MBNExtractPattern");
                    EquipmentExtractPattern = GetParameterValue("EquipmentExtractPattern");
                    OpacityValue            = GetParameterValue("OpacityValue");
                    LocationXY              = GetParameterValue("LocationXY");
                    MDAPath                 = GetParameterValue("MDAPath");
                    OutputEnter             = GetParameterValue("OutputEnter");

                    #region add by qy
                    Language            = GetParameterValue("Language");
                    OutSerialPort       = GetParameterValue("OutSerialPort");
                    OutBaudRate         = GetParameterValue("OutBaudRate");
                    OutParity           = GetParameterValue("OutParity");
                    OutStopBits         = GetParameterValue("OutStopBits");
                    OutDataBits         = GetParameterValue("OutDataBits");
                    DataOutputInterface = GetParameterValue("DataOutputInterface");
                    TrayExtractPattern  = GetParameterValue("TrayExtractPattern");
                    LogInRegular        = GetParameterValue("LogInRegular");
                    LogInType           = GetParameterValue("LogInType");
                    CheckListFolder     = GetParameterValue("CheckListFolder");
                    IsSelectWO          = GetParameterValue("IsSelectWO");
                    IsCheckList         = GetParameterValue("IsCheckList");
                    IsMaterialSetup     = GetParameterValue("IsMaterialSetup");
                    IsEquipSetup        = GetParameterValue("IsEquipSetup");
                    SDLExtractPattern   = GetParameterValue("SDLExtractPattern");
                    IPAddress           = GetParameterValue("IPAddress");
                    Port              = GetParameterValue("Port");
                    ScanSNType        = GetParameterValue("ScanSNType");
                    GetCompStation    = GetParameterValue("GetCompStation");
                    IsCheckLayer      = GetParameterValue("IsCheckLayer");
                    IsNeedCompColumn  = GetParameterValue("IsNeedCompColumn");
                    IsGetAllCompByBom = GetParameterValue("IsGetAllCompByBom");
                    IsNeedInfoField   = GetParameterValue("IsNeedInfoField");
                    OK_CHANNEL_Open   = GetParameterValue("OK_CHANNEL_Open");
                    OK_CHANNEL_CLOSE  = GetParameterValue("OK_CHANNEL_CLOSE");
                    NG_CHANNEL_OPEN   = GetParameterValue("NG_CHANNEL_OPEN");
                    NG_CHANGE_CLOSE   = GetParameterValue("NG_CHANGE_CLOSE");
                    #endregion
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message, ex);
            }
        }
        public ApplicationConfiguration(IMSApiSessionContextStruct sessionContext, MainView view)
        {
            try
            {
                dicConfig = new Dictionary <string, string>();
                ConfigManage configHandler = new ConfigManage(sessionContext, view);
                CommonModel  commonModel   = ReadIhasFileData.getInstance();
                if (commonModel.UpdateConfig == "L")
                {
                    XDocument config = XDocument.Load("ApplicationConfig.xml");
                    StationNumber           = commonModel.Station;
                    Client                  = commonModel.Client;
                    RegistrationType        = commonModel.RegisterType;
                    SerialPort              = GetDescendants("SerialPort", config);              //config.Descendants("SerialPort").First().Value;
                    BaudRate                = GetDescendants("BaudRate", config);                //config.Descendants("BaudRate").First().Value;
                    Parity                  = GetDescendants("Parity", config);                  //config.Descendants("Parity").First().Value;
                    StopBits                = GetDescendants("StopBits", config);                //config.Descendants("StopBits").First().Value;
                    DataBits                = GetDescendants("DataBits", config);                //config.Descendants("DataBits").First().Value;
                    NewLineSymbol           = GetDescendants("NewLineSymbol", config);           //config.Descendants("NewLineSymbol").First().Value;
                    MBNExtractPattern       = GetDescendants("MBNExtractPattern", config);       //config.Descendants("MBNExtractPattern").First().Value;
                    OpacityValue            = GetDescendants("OpacityValue", config);            // config.Descendants("OpacityValue").First().Value;
                    LocationXY              = GetDescendants("LocationXY", config);              // config.Descendants("LocationXY").First().Value;
                    MaterialWarningQty      = GetDescendants("MaterialWarningQty", config);      //config.Descendants("MaterialWarningQty").First().Value;
                    EquipmentExtractPattern = GetDescendants("EquipmentExtractPattern", config); // config.Descendants("EquipmentExtractPattern").First().Value;
                    IPAdress                = GetDescendants("IPAdress", config);                //config.Descendants("IPAdress").First().Value;
                    Port = GetDescendants("Port", config);                                       // config.Descendants("Port").First().Value;
                    LoadExtractPattern = GetDescendants("LoadExtractPattern", config);           //config.Descendants("LoadExtractPattern").First().Value;
                    LogInType          = GetDescendants("LogInType", config);                    //config.Descendants("LogInType").First().Value;
                    Language           = GetDescendants("Language", config);                     //config.Descendants("Language").First().Value;
                    CheckListFolder    = GetDescendants("CheckListFolder", config);              //config.Descendants("CheckListFolder").First().Value;
                    MDAPath            = GetDescendants("MDAPath", config);                      //config.Descendants("MDAPath").First().Value;
                    BJIPath            = GetDescendants("BJIPath", config);                      // config.Descendants("BJIPath").First().Value;
                    BCIPath            = GetDescendants("BCIPath", config);                      //config.Descendants("BCIPath").First().Value;
                    LogFileFolder      = GetDescendants("LogFileFolder", config);                //config.Descendants("LogFileFolder").First().Value;
                    LogTransOK         = GetDescendants("LogTransOK", config);                   //config.Descendants("LogTransOK").First().Value;
                    LogTransError      = GetDescendants("LogTransError", config);                //config.Descendants("LogTransError").First().Value;
                    ChangeFileName     = GetDescendants("ChangeFileName", config);               //config.Descendants("ChangeFileName").First().Value;
                    WaitTime           = GetDescendants("WaitTime", config);                     //config.Descendants("WaitTime").First().Value;
                    UserTeam           = GetDescendants("AUTH_TEAM", config);                    //config.Descendants("UserTeam").First().Value;
                    FilterByFileName   = GetDescendants("FilterByFileName", config);             //config.Descendants("FilterByFileName").First().Value;
                    FileNamePattern    = GetDescendants("FileNamePattern", config);              //config.Descendants("FileNamePattern").First().Value;
                    BackupsOKFile      = GetDescendants("BackupsOKFile", config);                //config.Descendants("FileNamePattern").First().Value;

                    PRINTER_MODE        = GetDescendants("OUTPUT_MODE", config);
                    LABEL_TEMPLATE_PATH = GetDescendants("LABEL_TEMPLATE_PATH", config);
                    LABEL_TEMPLATE_FILE = GetDescendants("LABEL_TEMPLATE_FILE", config);
                    DEFAULT_LABLE       = GetDescendants("DEFAULT_LABLE", config);
                    PrintSerialPort     = GetDescendants("PrintSerialPort", config);
                    PrintBaudRate       = GetDescendants("PrintBaudRate", config);
                    PrintParity         = GetDescendants("PrintParity", config);
                    PrintStopBits       = GetDescendants("PrintStopBits", config);
                    PrintDataBits       = GetDescendants("PrintDataBits", config);
                    PrintNewLineSymbol  = GetDescendants("PrintNewLineSymbol", config);
                    LABEL_QTY           = GetDescendants("LABEL_QTY", config);
                    AutoNextMaterial    = GetDescendants("MATERIAL_SPLICING", config);
                    LAYER_DISPLAY       = GetDescendants("LAYER_DISPLAY", config);

                    CHECKLIST_IPAddress     = GetDescendants("CHECKLIST_IPAddress", config);
                    CHECKLIST_Port          = GetDescendants("CHECKLIST_Port", config);
                    CHECKLIST_SOURCE        = GetDescendants("CHECKLIST_SOURCE", config);
                    AUTH_CHECKLIST_APP_TEAM = GetDescendants("AUTH_CHECKLIST_APP_TEAM", config);
                    CHECKLIST_FREQ          = GetDescendants("CHECKLIST_FREQ", config);
                    SHIFT_CHANGE_TIME       = GetDescendants("SHIFT_CHANGE_TIME", config);
                    RESTORE_TIME            = GetDescendants("RESTORE_TIME", config);
                    RESTORE_TREAD_TIMER     = GetDescendants("RESTORE_TREAD_TIMER", config);
                    BAD_BOARD_AUTO_RESET    = GetDescendants("BAD_BOARD_AUTO_RESET", config);
                    UPLOAD_NG_MODE          = GetDescendants("UPLOAD_NG_MODE", config);
                }
                else
                {
                    if (commonModel.UpdateConfig == "Y")
                    {
                        //int error = configHandler.DeleteConfigParameters(commonModel.APPTYPE);
                        //if (error == 0 || error == -3303 || error == -3302)
                        //{
                        //    WriteParameterToiTac(configHandler);
                        //}
                        string[] parametersValue = configHandler.GetParametersForScope(commonModel.APPTYPE);
                        if (parametersValue != null && parametersValue.Length > 0)
                        {
                            foreach (var parameterID in parametersValue)
                            {
                                configHandler.DeleteConfigParametersExt(parameterID);
                            }
                        }
                        WriteParameterToiTac(configHandler);
                    }
                    List <ConfigEntity> getvalues = configHandler.GetConfigData(commonModel.APPID, commonModel.APPTYPE, commonModel.Cluster, commonModel.Station);
                    if (getvalues != null)
                    {
                        foreach (var item in getvalues)
                        {
                            if (item != null)
                            {
                                string[] strs = item.PARAMETER_NAME.Split(new char[] { '.' });
                                dicConfig.Add(strs[strs.Length - 1], item.CONFIG_VALUE);
                                LogHelper.Info(strs[strs.Length - 1] + ": " + item.CONFIG_VALUE);
                            }
                        }
                    }

                    StationNumber      = commonModel.Station;
                    Client             = commonModel.Client;
                    RegistrationType   = commonModel.RegisterType;
                    SerialPort         = GetParameterValue("SerialPort");
                    BaudRate           = GetParameterValue("BaudRate");
                    Parity             = GetParameterValue("Parity");
                    StopBits           = GetParameterValue("StopBits");
                    DataBits           = GetParameterValue("DataBits");
                    NewLineSymbol      = GetParameterValue("NewLineSymbol");
                    MBNExtractPattern  = GetParameterValue("MBNExtractPattern");
                    OpacityValue       = GetParameterValue("OpacityValue");
                    LocationXY         = GetParameterValue("LocationXY");
                    MaterialWarningQty = GetParameterValue("MaterialWarningQty");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message, ex);
            }
        }