示例#1
0
        public static SasServer FromXml(string xml)
        {
            SasServer s = new SasServer();

            try
            {
                XElement settings = XElement.Parse(xml);
                if (settings.Attribute("name") != null)
                {
                    s.Name = settings.Attribute("name").Value;
                }
                if (settings.Attribute("host") != null)
                {
                    s.Host = settings.Attribute("host").Value;
                }
                if (settings.Attribute("port") != null)
                {
                    s.Port = settings.Attribute("port").Value;
                }
                if (settings.Attribute("userid") != null)
                {
                    s.UserId = settings.Attribute("userid").Value;
                }
                if (settings.Attribute("useLocal") != null)
                {
                    s.UseLocal = XmlConvert.ToBoolean(settings.Attribute("useLocal").Value);
                }
            }
            catch (System.Exception)
            {
                // no need to bomb if this goes poorly because of bad XML
            }

            return(s);
        }
 public SasServerLoginDlg(SasServer s) : this()
 {
     SasServer        = s;
     txtHost.Text     = s.Host;
     txtName.Text     = s.Name;
     txtUser.Text     = s.UserId;
     txtPort.Text     = s.Port;
     chkLocal.Checked = SasServer.UseLocal;
 }
        public DataViewerForm(SasServer session)
        {
            InitializeComponent();

            // init the OleDbConnection based on the Workspace ID
            // Note that this requires that the Workspace handle has
            // been added to the ObjectKeeper in SASObjectManager
            string wsId = session.Workspace.UniqueIdentifier;
            connection = new System.Data.OleDb.OleDbConnection("Provider=sas.iomprovider.1; SAS Workspace ID=" + wsId);
        }
 public SasServerLoginDlg(SasServer s)
     : this()
 {
     SasServer = s;
     txtHost.Text = s.Host;
     txtName.Text = s.Name;
     txtUser.Text = s.UserId;
     txtPort.Text = s.Port;
     chkLocal.Checked = SasServer.UseLocal;
 }
        public DataViewerForm(SasServer session)
        {
            InitializeComponent();

            // init the OleDbConnection based on the Workspace ID
            // Note that this requires that the Workspace handle has
            // been added to the ObjectKeeper in SASObjectManager
            string wsId = session.Workspace.UniqueIdentifier;

            connection = new System.Data.OleDb.OleDbConnection("Provider=sas.iomprovider.1; SAS Workspace ID=" + wsId);
        }
 protected override void OnClosing(CancelEventArgs e)
 {
     if (DialogResult == System.Windows.Forms.DialogResult.OK)
     {
         SasServer = new SasServer();
         SasServer.UseLocal = chkLocal.Checked;
         SasServer.Host = txtHost.Text;
         SasServer.Port = txtPort.Text;
         SasServer.UserId = txtUser.Text;
         SasServer.Password = txtPassword.Text;
         SasServer.Name = txtName.Text;
     }
     base.OnClosing(e);
 }
 protected override void OnClosing(CancelEventArgs e)
 {
     if (DialogResult == System.Windows.Forms.DialogResult.OK)
     {
         SasServer          = new SasServer();
         SasServer.UseLocal = chkLocal.Checked;
         SasServer.Host     = txtHost.Text;
         SasServer.Port     = txtPort.Text;
         SasServer.UserId   = txtUser.Text;
         SasServer.Password = txtPassword.Text;
         SasServer.Name     = txtName.Text;
     }
     base.OnClosing(e);
 }
        private void ConnectToServer()
        {
            activeSession = new SasServer();

            string settingsFile = Path.Combine(Application.LocalUserAppDataPath, appSettings);

            if (File.Exists(settingsFile))
            {
                string xml = File.ReadAllText(settingsFile);
                activeSession = SasServer.FromXml(xml);
            }
            SasServerLoginDlg login = new SasServerLoginDlg(activeSession);

            if (login.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                activeSession = login.SasServer;

                try
                {
                    activeSession.Connect();
                    File.WriteAllText(settingsFile, activeSession.ToXml());
                    if (activeSession.UseLocal)
                    {
                        statusMsg.Text = string.Format("Connected to Local SAS session as {0}",
                                                       System.Environment.UserName);
                    }
                    else
                    {
                        statusMsg.Text = string.Format("Connected to {0} ({1}) as {2}",
                                                       activeSession.Name,
                                                       activeSession.Host,
                                                       string.IsNullOrEmpty(activeSession.UserId) ? Environment.UserName : activeSession.UserId);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Could not connect: {0}", ex.Message));
                    statusMsg.Text = "";
                }
            }
        }
示例#9
0
        private void ConnectToServer()
        {
            activeSession = new SasServer();

            string settingsFile = Path.Combine(Application.LocalUserAppDataPath, appSettings);
            if (File.Exists(settingsFile))
            {
                string xml = File.ReadAllText(settingsFile);
                activeSession = SasServer.FromXml(xml);
            }
            SasServerLoginDlg login = new SasServerLoginDlg(activeSession);

            if (login.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                activeSession = login.SasServer;

                try
                {
                    activeSession.Connect();
                    File.WriteAllText(settingsFile, activeSession.ToXml());
                    if (activeSession.UseLocal)
                        statusMsg.Text = string.Format("Connected to Local SAS session as {0}",
                            System.Environment.UserName);
                    else
                        statusMsg.Text = string.Format("Connected to {0} ({1}) as {2}",
                            activeSession.Name,
                            activeSession.Host,
                            string.IsNullOrEmpty(activeSession.UserId) ? Environment.UserName : activeSession.UserId);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Could not connect: {0}", ex.Message));
                    statusMsg.Text = "";
                }
            }
        }
示例#10
0
        public static SasServer FromXml(string xml)
        {
            SasServer s = new SasServer();
            try
            {
                XElement settings = XElement.Parse(xml);
                if (settings.Attribute("name") != null)
                    s.Name = settings.Attribute("name").Value;
                if (settings.Attribute("host") != null)
                    s.Host = settings.Attribute("host").Value;
                if (settings.Attribute("port") != null)
                    s.Port = settings.Attribute("port").Value;
                if (settings.Attribute("userid") != null)
                    s.UserId = settings.Attribute("userid").Value;
                if (settings.Attribute("useLocal") != null)
                    s.UseLocal = XmlConvert.ToBoolean(settings.Attribute("useLocal").Value);
            }
            catch (System.Exception)
            {
                // no need to bomb if this goes poorly because of bad XML
            }

            return s;
        }