Example #1
0
        private void Save()
        {
            #region  Socket parameter
            clientSocketParams.LocalIP      = "";
            clientSocketParams.LocalPort    = -1;
            clientSocketParams.CallbackIP   = this.txtCallbackIP.Text;
            clientSocketParams.CallbackPort = (int)this.txtCallbackPort.Value;
            clientSocketParams.ServerIP     = this.txtServerIP.Text;
            clientSocketParams.ServerPort   = (int)this.txtServerPort.Value;
            SocketOutboundAdapterConfigMgt.SocketOutAdapterConfig.OutGeneralParams.TimerInterval = Int32.Parse(this.txtInterval.Text);
            clientSocketParams.ConnectTimeout  = Int32.Parse(this.txtConnectTimeout.Text);
            clientSocketParams.ConnectTryCount = Int32.Parse(this.txtTryCount.Text);
            clientSocketParams.RecTimeout      = Int32.Parse(this.txtReceiveTimeout.Text);
            clientSocketParams.SendTimeout     = Int32.Parse(this.txtSendTimeout.Text);
            clientSocketParams.CodePageName    = EncodingPage.GetAllCodePages()[cbCodePage.SelectedIndex].Name;
            #endregion

            string FileName = Application.StartupPath + "\\" + SocketOutboundAdapterConfigMgt.FileName;
            if (!SocketOutboundAdapterConfigMgt.Save(FileName))
            {
                if (SocketOutboundAdapterConfigMgt.LastException != null)
                {
                    Program.log.Write(LogType.Error, "Cannot save information to configuration file: " + FileName);
                }
                MessageBox.Show(SocketOutboundAdapterConfigMgt.LastException.Message);
            }
        }
Example #2
0
        public static void Preloading()
        {
            Log.WriteAppStart("SocketOutboundAdapter");

            string FileName = Application.StartupPath + "\\" + SocketOutboundAdapterConfigMgt.FileName;

            //SocketOutboundAdapterConfigMgt.SocketOutAdapterConfig = SocketOutboundAdapterConfigMgt.BuildSampleConfig();
            //SocketOutboundAdapterConfigMgt.Save(FileName);

            if (!SocketOutboundAdapterConfigMgt.Load(FileName))
            {
                Log.Write(LogType.Error, "Load configuration failed. \r\n" + FileName + "\r\n" + SocketOutboundAdapterConfigMgt.LastException.Message);
            }
        }
Example #3
0
        public static void PreLoading()
        {
            //LoadConfigXMLFile();
            string FileName = Application.StartupPath + "\\" + SocketOutboundAdapterConfigMgt.FileName;

            if (!SocketOutboundAdapterConfigMgt.Load(FileName))
            {
                log.Write(LogType.Error, "Cannot Load Configuration file: " + FileName);
                if (MessageBox.Show("Cannot load configuration file. Do you want to create an empty configuration file?",
                                    "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    SocketOutboundAdapterConfigMgt.Save(FileName);
                }
            }
            else
            {
                //log.LogLevel = SocketOutboundAdapterConfigMgt.SocketOutAdapterConfig.OutGeneralParams.LogLevel;
            }
        }
Example #4
0
        private void btBuildEmptyConfiguration_Click(object sender, EventArgs e)
        {
            string sConfigFile  = Application.StartupPath + "\\" + SocketOutboundAdapterConfigMgt.FileName;
            string sBakFileName = StarFile.BackupFile(sConfigFile);

            if (sBakFileName == "")
            {
                Program.Log.Write(LogType.Error, "Cannot backup configuration file:" + sConfigFile);
            }
            else
            {
                Program.Log.Write(LogType.Debug, "Configuration file:" + sConfigFile + " has been backup to " + sBakFileName);
            }

            SocketOutboundAdapterConfigMgt.SocketOutAdapterConfig = new SocketOutboundAdapterConfig();
            SocketOutboundAdapterConfigMgt.Save(sConfigFile);

            MessageBox.Show("New Configuration have been built!");
        }