Esempio n. 1
0
 private void createTableToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if ((username != null) && (pass != null))
         {
             TableCreation tablecreation = new TableCreation();
             tablecreation.Show();
         }
         else
         {
             Login login = new Login();
             login.Show();
         }
     }
     catch (Exception ex)
     {
         System.Net.WebException webex = new System.Net.WebException();
         if (ex.GetType() != webex.GetType())
         {
             Program.errorreport(ex);
         }
         else
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Esempio n. 2
0
 private void decryptToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if ((username != null) && (pass != null))
         {
             /*string dbname;
              * dbname = Microsoft.VisualBasic.Interaction.InputBox("Type the Name of the Database", Application.ProductName, "", 0, 0);
              * if (dbname != null)
              * {
              *  Program.client.CreateDataBase(username, pass, dbname);
              * }*/
         }
         else
         {
             Login login = new Login();
             login.Show();
         }
     }
     catch (Exception ex)
     {
         System.Net.WebException webex = new System.Net.WebException();
         if (ex.GetType() != webex.GetType())
         {
             Program.errorreport(ex);
         }
         else
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Esempio n. 3
0
 private void loadTableToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if ((MainWindow.username != null) && (MainWindow.pass != null))
         {
             TableList dblis = new TableList();
             dblis.Show();
         }
         else
         {
             Login login = new Login();
             login.Show();
             TableList dblis = new TableList();
             dblis.Show();
         }
     }
     catch (Exception ex)
     {
         System.Net.WebException webex = new System.Net.WebException();
         if (ex.GetType() != webex.GetType())
         {
             Program.errorreport(ex);
         }
         else
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Esempio n. 4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                MainWindow.username = txtUsername.Text;
                MainWindow.pass     = txtPassword.Text;
                NetworkCredential cred = new NetworkCredential(MainWindow.username, MainWindow.pass, Environment.UserDomainName);
                //frmMain.Program.client.Program.clientCredentials.Windows.Program.clientCredential.UserName = frmMain.username;
                //frmMain.Program.client.Program.clientCredentials.Windows.Program.clientCredential.Password = frmMain.pass;
                //frmMain.Program.client.Program.clientCredentials.Windows.Program.clientCredential = cred;

                Program.client.Login(MainWindow.username, MainWindow.pass);
                this.Close();
            }
            catch (Exception ex)
            {
                System.Net.WebException webex = new System.Net.WebException();
                // MessageBox.Show(ex.ToString());
                if (ex.GetType() != webex.GetType())
                {
                    Program.errorreport(ex);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 5
0
        private void updateTableToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if ((MainWindow.username != null) && (MainWindow.pass != null))
                {
                    List <object[]> vals = new List <object[]>();
                    foreach (DataRow row in set.Tables[0].Rows)
                    {
                        //   List<object> vals2 =new  List<object>();
                        //   vals2.AddRange(row.ItemArray);
                        vals.Add(row.ItemArray);
                    }
                    Program.client.AddRows(Hydrobase.BaseClass.tabletag, Hydrobase.BaseClass.recordtag, MainWindow.username, MainWindow.pass, dbname, set.Tables[0].TableName, vals.ToArray(), true);
                    Program.client.UpdateTable(Hydrobase.BaseClass.tabletag, Hydrobase.BaseClass.recordtag, MainWindow.username, MainWindow.pass, dbname, set.Tables[0].TableName, vals.ToArray());
                }
                else
                {
                    Login log = new Login();
                    log.Show();
                    List <object[]> vals = new List <object[]>();
                    foreach (DataRow row in set.Tables[0].Rows)
                    {
                        // List<object> vals2 = new List<object>();
                        // vals2.AddRange(row.ItemArray);
                        vals.Add(row.ItemArray);
                    }
                    Program.client.AddRows(Hydrobase.BaseClass.tabletag, Hydrobase.BaseClass.recordtag, MainWindow.username, MainWindow.pass, dbname, set.Tables[0].TableName, vals.ToArray(), true);
                    grid = new DataGridView();
                    set.ReadXml(util.StringToStream(Program.client.LoadTable(BaseClass.recordtag, MainWindow.username, MainWindow.pass, dbname, tablename)));
                    //MessageBox.Show(util.StringToStream(frmMain.Program.client.LoadTable(BaseClass.recordtag, frmMain.username, frmMain.pass, lstDbs.Text, lsttables.Text)).ToString());

                    grid.DataSource = set;
                    grid.DataMember = set.Tables[set.Tables.Count - 1].TableName;
                }
            }
            catch (Exception ex)
            {
                System.Net.WebException webex = new System.Net.WebException();
                if (ex.GetType() != webex.GetType())
                {
                    Program.errorreport(ex);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 6
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     try
     {
         this.Close();
     }
     catch (Exception ex)
     {
         System.Net.WebException webex = new System.Net.WebException();
         if (ex.GetType() != webex.GetType())
         {
             Program.errorreport(ex);
         }
         else
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Esempio n. 7
0
 private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         AboutBox about = new AboutBox();
         about.Show();
     }
     catch (Exception ex)
     {
         System.Net.WebException webex = new System.Net.WebException();
         if (ex.GetType() != webex.GetType())
         {
             Program.errorreport(ex);
         }
         else
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Esempio n. 8
0
 private void LoginMenu(object sender, EventArgs e)
 {
     try
     {
         Login login = new Login();
         login.Show();
     }
     catch (Exception ex)
     {
         System.Net.WebException webex = new System.Net.WebException();
         if (ex.GetType() != webex.GetType())
         {
             Program.errorreport(ex);
         }
         else
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Esempio n. 9
0
 private void addColumnsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         AddCols addcol = new AddCols();
         addcol.Show();
     }
     catch (Exception ex)
     {
         System.Net.WebException webex = new System.Net.WebException();
         if (ex.GetType() != webex.GetType())
         {
             Program.errorreport(ex);
         }
         else
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Esempio n. 10
0
 public frmEdit()
 {
     try
     {
         InitializeComponent();
         grid = this.dataGridView1;
         Program.ActiveEditForm = this;
     }
     catch (Exception ex)
     {
         System.Net.WebException webex = new System.Net.WebException();
         MessageBox.Show(ex.ToString());
         if (ex.GetType() != webex.GetType())
         {
             Program.errorreport(ex);
         }
         else
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Esempio n. 11
0
            public void HandleTwitterWebException(WebException e, String prefix)
            {
                HttpWebResponse response = (HttpWebResponse)e.Response;
                String protcol = (response == null) ? "" : "HTTP/" + response.ProtocolVersion;

                String error = String.Empty;
                //try reading JSON response
                if (response != null && response.ContentType != null && response.ContentType.ToLower().Contains("json"))
                {
                    try
                    {
                        StreamReader sin = new StreamReader(response.GetResponseStream());
                        String data = sin.ReadToEnd();
                        sin.Close();

                        Hashtable jdata = (Hashtable)JSON.JsonDecode(data);
                        if (jdata == null || !jdata.ContainsKey("error") ||
                            jdata["error"] == null || !jdata["error"].GetType().Equals(typeof(String)))
                            throw new Exception();

                        error = "Twitter Error: " + (String)jdata["error"] + ", ";
                    }
                    catch (Exception ex)
                    {
                    }
                }

                /* Handle Time-Out Gracefully */
                if (e.Status.Equals(WebExceptionStatus.Timeout))
                {
                    plugin.ConsoleException("Twitter " + prefix + " Request(" + protcol + ") timed-out");
                    return;
                }
                else if (e.Status.Equals(WebExceptionStatus.ProtocolError))
                {
                    plugin.ConsoleException("Twitter " + prefix + " Request(" + protcol + ") failed, " + error + " " + e.GetType() + ": " + e.Message);
                    return;
                }
                else
                    throw e;
            }
Esempio n. 12
0
        private void CheckWebException(WebException exception)
        {
            Trace.Call(exception == null ? null : exception.GetType());

            switch (exception.Status) {
                case WebExceptionStatus.ConnectFailure:
                case WebExceptionStatus.ConnectionClosed:
                case WebExceptionStatus.Timeout:
                case WebExceptionStatus.ReceiveFailure:
                case WebExceptionStatus.NameResolutionFailure:
                case WebExceptionStatus.ProxyNameResolutionFailure:
                    // ignore temporarly issues
            #if LOG4NET
                    f_Logger.Warn("CheckWebException(): ignored exception", exception);
            #endif
                    return;
            }

            /*
            http://apiwiki.twitter.com/HTTP-Response-Codes-and-Errors
            * 200 OK: Success!
            * 304 Not Modified: There was no new data to return.
            * 400 Bad Request: The request was invalid.  An accompanying error
            *     message will explain why. This is the status code will be
            *     returned during rate limiting.
            * 401 Unauthorized: Authentication credentials were missing or
            *     incorrect.
            * 403 Forbidden: The request is understood, but it has been
            *     refused.  An accompanying error message will explain why.
            *     This code is used when requests are being denied due to
            *     update limits.
            * 404 Not Found: The URI requested is invalid or the resource
            *     requested, such as a user, does not exists.
            * 406 Not Acceptable: Returned by the Search API when an invalid
            *     format is specified in the request.
            * 500 Internal Server Error: Something is broken.  Please post to
            *     the group so the Twitter team can investigate.
            * 502 Bad Gateway: Twitter is down or being upgraded.
            * 503 Service Unavailable: The Twitter servers are up, but
            *     overloaded with requests. Try again later. The search and
            *     trend methods use this to indicate when you are being rate
            *     limited.
            */
            HttpWebResponse httpRes = exception.Response as HttpWebResponse;
            if (httpRes == null) {
                throw exception;
            }
            switch (httpRes.StatusCode) {
                case HttpStatusCode.BadGateway:
                case HttpStatusCode.BadRequest:
                case HttpStatusCode.Forbidden:
                case HttpStatusCode.ServiceUnavailable:
                case HttpStatusCode.GatewayTimeout:
                    // ignore temporarly issues
            #if LOG4NET
                    f_Logger.Warn("CheckWebException(): ignored exception", exception);
            #endif
                    return;
                default:
                    throw exception;
            }
        }
Esempio n. 13
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();
                Program.CreateTempPath();
                multyuser.initialiseMultyUserInterface(false);

                MultyUser.CreateHydrobaseFileSystem(Environment.UserName);
                HydrobaseSDK.SDKBase.UserMainPath = MultyUser.GetUsersMainFolder(Environment.UserName);
                Maintenance_Backup mnt = new Maintenance_Backup();
                mnt.CreateFolder(Path.Combine(MultyUser.GetUsersMainFolder(Environment.UserName), BaseClass.tmpFolder));

                discoveryclient = new DiscoveryClient(new UdpDiscoveryEndpoint());
                FindResponse    discoveryResponse = discoveryclient.Find(new FindCriteria(typeof(White_Tiger.IWhiteTigerService)));
                EndpointAddress address;
                if (discoveryResponse.Endpoints.Count > 0)
                {
                    address        = discoveryResponse.Endpoints[0].Address;
                    Program.client = new White_TigerServiceReference.WhiteTigerServiceClient(new BasicHttpBinding(), address);
                }
                else
                {
                    Program.client = new White_TigerServiceReference.WhiteTigerServiceClient();
                }

                ;

                // MessageBox.Show(address.Uri.ToString() );


                BasicHttpBinding httpBinding = new BasicHttpBinding();
                httpBinding.MaxReceivedMessageSize = 2147483647;
                httpBinding.MaxBufferSize          = 2147483647;
                BindingParameterCollection par = new BindingParameterCollection();
                par.Add(httpBinding);

                Program.client.Endpoint.Behaviors[0].AddBindingParameters(Program.client.Endpoint, par);



                Program.client.Open();
                // this.Text += "";

                //Program.client.Open();
                lblStatus.Text               = Program.client.State.ToString();
                lblServerAddress.Text        = Program.client.Endpoint.Address.ToString();
                lblServerVer.Text            = Program.client.GetVersion();
                this.Text                    = Application.ProductName;
                aboutToolStripMenuItem.Text += "  " + Application.ProductName;
            }
            catch (Exception ex)
            {
                System.Net.WebException webex = new System.Net.WebException();
                if (ex.GetType() != webex.GetType())
                {
                    Program.errorreport(ex);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 14
0
        protected ExtApiCallResult HandleWebException(WebException ex)
        {
            var httpResponse = (HttpWebResponse)ex.Response;

            if (httpResponse != null)
            {
                return new ExtApiCallResult
                {
                    StatusCode = httpResponse.StatusCode,
                    ResponseStream = httpResponse.GetResponseStream(),
                    FinalUrl = httpResponse.ResponseUri.AbsoluteUri
                };
            }

            // else
            var stream = new MemoryStream();
            var msg = System.Text.Encoding.ASCII.GetBytes(string.Format("{0}: {1}", ex.GetType().ToString(), ex.Message));
            stream.Write(msg, 0, msg.Length);

            return new ExtApiCallResult
            {
                StatusCode = HttpStatusCode.NoContent,
                ResponseStream = stream,
                FinalUrl = httpResponse.ResponseUri.AbsoluteUri
            };
        }