private void openConfig(string configFilePath)
        {
            string oa3ConfigXml = "";

            using (FileStream stream = new FileStream(this.currentFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    oa3ConfigXml = reader.ReadToEnd();
                }
            }

            try
            {
                //Type[] types = new Type[] { typeof(OA3ServerBased), typeof(OA3ServerBasedKeyProviderServerLocation), typeof(OA3ServerBasedParameters), typeof(OA3ServerBasedParametersOEMOptionalInfoField), typeof(OA3ServerBasedParametersParameter), typeof(OA3OutputData) };

                DISAdapter.OA3ToolConfiguration oa3ToolConf = Utility.XmlDeserialize(oa3ConfigXml, typeof(OA3ToolConfiguration), null, "UTF-8") as OA3ToolConfiguration;

                if (oa3ToolConf != null)
                {
                    this.OA3ToolConfiguration = oa3ToolConf;
                }
            }
            catch (Exception ex)
            {
                string errorMessage = String.Format("Error(s) occurred: {0}", ex.ToString());
                MessageBox.Show(errorMessage, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            try
            {
                string url                = this.Settings[ModuleConfiguration.AppStateKey_CloudServicePoint].ToString();
                string userName           = this.Settings[ModuleConfiguration.AppStateKey_CloudUserName].ToString();
                string password           = this.Settings[ModuleConfiguration.AppStateKey_CloudPassword].ToString();
                string dbConnectionString = ModuleConfiguration.GetDBConnectionString(url, userName, password, this.OA3ToolConfiguration.ServerBased.Parameters.CloudConfigurationID);

                this.Settings[ModuleConfiguration.AppStateKey_DBConnectionString] = dbConnectionString;
            }
            catch (Exception ex)
            {
                this.Settings[ModuleConfiguration.AppStateKey_DBConnectionString] = null;
            }

            this.setControls();

            this.toolStripStatusLabel1.Text = this.currentFilePath;
        }
Exemple #2
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if ((this.currentCustomers != null) && (this.comboBoxBusiness.SelectedIndex >= 0))
            {
                //this.Settings[ModuleConfiguration.AppStateKey_CloudConfigurationID] = this.currentCustomers.FirstOrDefault((o) => (o.ID == this.comboBoxBusiness.SelectedValue.ToString())).Configurations.FirstOrDefault((c) => (c.ConfigurationType == ConfigurationType.FactoryFloor)).ID;
                //this.Settings[ModuleConfiguration.AppStateKey_DBConnectionString] = this.currentCustomers.FirstOrDefault((o) => (o.ID == this.comboBoxBusiness.SelectedValue.ToString())).Configurations.FirstOrDefault((c) => (c.ConfigurationType == ConfigurationType.FactoryFloor)).DbConnectionString;

                Configuration ffConfig = ModuleConfiguration.GetFactoryFloorConfigurationByBusinessID(this.currentCustomers, this.comboBoxBusiness.SelectedValue.ToString());
                this.Settings[ModuleConfiguration.AppStateKey_CloudConfigurationID] = ffConfig.ID;
                this.Settings[ModuleConfiguration.AppStateKey_DBConnectionString]   = ffConfig.DbConnectionString;

                OA3ToolConfiguration oa3Config = this.Settings[ModuleConfiguration.AppStateKey_OA3ToolConfiguration] as OA3ToolConfiguration;

                if (oa3Config == null)
                {
                    oa3Config = new OA3ToolConfiguration();
                }

                if (oa3Config.ServerBased == null)
                {
                    oa3Config.ServerBased = new OA3ServerBased();
                }

                if (oa3Config.ServerBased.Parameters == null)
                {
                    oa3Config.ServerBased.Parameters = new OA3ServerBasedParameters();
                }

                oa3Config.ServerBased.Parameters.CloudConfigurationID = ffConfig.ID;

                this.Settings[ModuleConfiguration.AppStateKey_OA3ToolConfiguration] = oa3Config;
            }

            this.Settings[ModuleConfiguration.AppStateKey_CloudServicePoint]      = this.textBoxDISConfiguraitonCloudUrl.Text;
            this.Settings[ModuleConfiguration.AppStateKey_CloudUserName]          = this.textBoxUserName.Text;
            this.Settings[ModuleConfiguration.AppStateKey_CloudPassword]          = this.textBoxPassword.Text;
            this.Settings[ModuleConfiguration.AppStateKey_CloudConfigurationSets] = this.currentCustomers;

            DialogResult = System.Windows.Forms.DialogResult.OK;

            this.Close();
        }
        private void buttonMore_Click(object sender, EventArgs e)
        {
            FormCloudConfigDialog formCloudConfig = new FormCloudConfigDialog(this.Settings);

            if (formCloudConfig.ShowDialog(this) == DialogResult.OK)
            {
                //this.textBoxCloudConfigurationID.Text = this.Settings[ModuleConfiguration.AppStateKey_CloudConfigurationID].ToString(); //this.OA3ToolConfiguration.Parameters[0].CloudConfigurationID;

                //this.ucParameterLPN.DBConnectionString = this.Settings[ModuleConfiguration.AppStateKey_DBConnectionString].ToString();
                //this.ucParameterOPN.DBConnectionString = this.Settings[ModuleConfiguration.AppStateKey_DBConnectionString].ToString();
                //this.ucParameterOPON.DBConnectionString = this.Settings[ModuleConfiguration.AppStateKey_DBConnectionString].ToString();
                //this.ucParameterSN.DBConnectionString = this.Settings[ModuleConfiguration.AppStateKey_DBConnectionString].ToString();

                if (this.Settings != null)
                {
                    this.OA3ToolConfiguration = this.Settings[ModuleConfiguration.AppStateKey_OA3ToolConfiguration] as OA3ToolConfiguration;
                }

                this.setControls();
            }
        }
        private void loadAppState()
        {
            string filePath = Application.StartupPath;

            if (!filePath.EndsWith("\\"))
            {
                filePath += "\\";
            }

            filePath += "appstate.dat";

            if (File.Exists(filePath))
            {
                byte[] bytes = File.ReadAllBytes(filePath);

                this.Settings = Utility.BinaryDeserialize(bytes) as Dictionary <string, object>;

                if (this.Settings != null)
                {
                    this.OA3ToolConfiguration = this.Settings[ModuleConfiguration.AppStateKey_OA3ToolConfiguration] as OA3ToolConfiguration;
                }
            }
        }
        private void setOA3ToolConfiguration()
        {
            this.OA3ToolConfiguration = new OA3ToolConfiguration()
            {
                ServerBased = new OA3ServerBased()
                {
                    KeyProviderServerLocation = new OA3ServerBasedKeyProviderServerLocation()
                    {
                        IPAddress        = this.textBoxKPSAddress.Text,
                        EndPoint         = this.textBoxKeyProviderServicePortNumber.Text,
                        ProtocolSequence = ModuleConfiguration.OA3ToolConfigurationValue_ProtocolSequence,
                        Options          = ModuleConfiguration.OA3ToolConfigurationValue_Options
                    },
                    Parameters = new OA3ServerBasedParameters()
                    {
                        CloudConfigurationID = this.Settings[ModuleConfiguration.AppStateKey_CloudConfigurationID] != null ? this.Settings[ModuleConfiguration.AppStateKey_CloudConfigurationID].ToString() : "",
                    }
                },

                OutputData = new OA3OutputData()
                {
                    AssembledBinaryFile = this.textBoxBinFileOutputPath.Text,
                    ReportedXMLFile     = this.textBoxXMLResultFileOutputPath.Text
                }
            };

            List <OA3ServerBasedParametersParameter> parameters = new List <OA3ServerBasedParametersParameter>();

            if (this.ucParameterLPN.IsSelected)
            {
                parameters.Add(new OA3ServerBasedParametersParameter()
                {
                    name = this.ucParameterLPN.ParameterName, value = this.ucParameterLPN.ParameterValue
                });
            }

            if (this.ucParameterOPN.IsSelected)
            {
                parameters.Add(new OA3ServerBasedParametersParameter()
                {
                    name = this.ucParameterOPN.ParameterName, value = this.ucParameterOPN.ParameterValue
                });
            }

            if (this.ucParameterOPON.IsSelected)
            {
                parameters.Add(new OA3ServerBasedParametersParameter()
                {
                    name = this.ucParameterOPON.ParameterName, value = this.ucParameterOPON.ParameterValue
                });
            }

            if (this.ucParameterSN.IsSelected)
            {
                parameters.Add(new OA3ServerBasedParametersParameter()
                {
                    name = this.ucParameterSN.ParameterName, value = this.ucParameterSN.ParameterValue
                });
            }

            this.OA3ToolConfiguration.ServerBased.Parameters.Parameter = parameters.ToArray();

            if (this.checkBoxOHRRequired.Checked)
            {
                Dictionary <string, string> ohrValues = this.ucohrOHRData.GetOHR();

                this.OA3ToolConfiguration.ServerBased.Parameters.OEMOptionalInfo = new OA3ServerBasedParametersOEMOptionalInfoField[ohrValues.Count];

                for (int i = 0; i < ohrValues.Keys.Count; i++)
                {
                    this.OA3ToolConfiguration.ServerBased.Parameters.OEMOptionalInfo[i] = new OA3ServerBasedParametersOEMOptionalInfoField()
                    {
                        Name  = ohrValues.Keys.ToArray()[i],
                        Value = ohrValues.Values.ToArray()[i]
                    };
                }
            }
        }