public SDataClient(TechDashboardDatabase database)
 {
     if (database.HasValidSetup())
     {
         App_Settings appSettings = database.GetApplicatioinSettings();
         if (appSettings != null)
         {
             _isUsingHttps = appSettings.IsUsingHttps;
             _sDataUrl     = appSettings.SDataUrl;
             _userId       = appSettings.SDataUserId;
             _password     = appSettings.SDataPassword;
         }
     }
 }
 public TestPageViewModel()
 {
     // dch rkl 12/07/2016 catch exception
     try
     {
         _sDataClient = new SDataClient(App.Database);
         _database    = new TechDashboardDatabase();
     }
     catch (Exception ex)
     {
         // dch rkl 12/07/2016 Log Error
         ErrorReporting errorReporting = new ErrorReporting();
         errorReporting.sendException(ex, "TechDashboard.TestPageViewModel");
     }
 }
Exemplo n.º 3
0
        public static void sendException(Exception exception, string thread)
        {
            // dch rkl 12/07/2016 only log error if there is a connection
            // TODO - may want to log errors locally, and send over in Sync when connected
            TechDashboardDatabase oDB = new TechDashboardDatabase();
            bool bHasConnection       = oDB.HasDataConnection();

            if (bHasConnection)
            {
                ApplicationLog appLog = new ApplicationLog();
                appLog.log_date         = DateTime.Now.ToLongTimeString();
                appLog.log_level        = "Error";
                appLog.log_logger       = "REST SERVICE";
                appLog.log_message      = exception.Message;
                appLog.log_machine_name = System.Environment.MachineName;
                appLog.log_user_name    = "WPF TechDashboard";
                appLog.log_call_site    = App.Database.GetApplicationSettings().SDataUrl;  // we're going to use their SDATA root

                // dch rkl 12/07/2016 add the call/sub/proc to log
                //appLog.log_thread = "";
                appLog.log_thread = thread;

                appLog.log_stacktrace = exception.StackTrace;

                // dch rkl 12/07/2016 change to new API
                //var client = new RestSharp.RestClient("http://50.200.65.158/tdwsnew/tdwsnew.svc/i/ApplicationLog"); //hard coded to get it back to us
                var client = new RestSharp.RestClient("http://50.200.65.158/techdashboardapi/v1-6/i/ApplicationLog"); //hard coded to get it back to us

                var request = new RestSharp.RestRequest(RestSharp.Method.POST);
                request.RequestFormat = RestSharp.DataFormat.Json;
                request.AddBody(appLog);

                try
                {
                    var response = client.Execute(request) as RestSharp.RestResponse;
                }
                catch (Exception restException)
                {
                    // can't do much
                }
            }
        }
 public TestPageViewModel()
 {
     _sDataClient = new SDataClient(App.Database);
     _database    = new TechDashboardDatabase();
 }
 public App_BaseObject(TechDashboardDatabase database)
 {
     _database = database;
     // puke... at some point, we should create an abstrated data access layer object/interface
 }