private void UploadFile(Stream fileStream, Application application)
        {
            ApGetConfigurationSettingsRequest request1 = new ApGetConfigurationSettingsRequest(Credentials);
            ApGetConfigurationSettingsResponse response1 = EndPoints.ApDashboardService.GetConfigurationSettings(request1);

            IPAddress appGridIpAddress = response1.ConfigurationSettings.IpAddress;
            ApFileTransferSocket socket = new ApFileTransferSocket(appGridIpAddress, Settings.ApFileTransferSocketPort);
            socket.SendFile(fileStream, application.FileName);

            ApAddApplicationRequest request = new ApAddApplicationRequest(Credentials);
            request.Application = application;
            EndPoints.ApDashboardService.AddApplication(request);
        }
        public ApGetConfigurationSettingsResponse GetConfigurationSettings(ApGetConfigurationSettingsRequest request)
        {
            Log.Debug(this, "GetConfigurationSettings()");

            try
            {
                Authenticate(request);
                ApGetConfigurationSettingsResponse response = new ApGetConfigurationSettingsResponse();
                ApConfigurationSettings settings = new ApConfigurationSettings();
                settings.IpAddress = MonoscapeUtil.FindHostIpAddress();
                settings.RunningOnMono = MonoscapeUtil.IsRunningOnMono();
                settings.MonoRuntime = MonoscapeUtil.GetMonoRuntime();
                settings.DotNetRuntime = MonoscapeUtil.GetDotNetRuntime();
                settings.OperatingSystem = MonoscapeUtil.GetOperatingSystem();

                settings.IaasName = Settings.IaasName;
                settings.IaasAccessKey = Settings.IaasAccessKey;
                settings.IaasSecretKey = Settings.IaasSecretKey;
                settings.IaasServiceURL = Settings.IaasServiceURL;
                settings.IaasKeyName = Settings.IaasKeyName;

                response.ConfigurationSettings = settings;
                return response;
            }
            catch(Exception e)
            {
                Log.Error(this, e);
                throw e;
            }
        }
        //
        // GET: /applicationgrid/
        public ActionResult Index()
        {
            try
            {
                ViewData["MonoscapeAccessKey"] = Credentials.AccessKey;
                ViewData["MonoscapeSecretKey"] = Credentials.SecretKey;
                ViewData["ApplicationGridEndPointURL"] = Settings.ApplicationGridEndPointURL;
                ViewData["ApplicationGridStatus"] = "Offline";

                try
                {
                    ApGetConfigurationSettingsRequest request = new ApGetConfigurationSettingsRequest(Credentials);
                    ApGetConfigurationSettingsResponse response = EndPoints.ApDashboardService.GetConfigurationSettings(request);
                    if (response != null)
                    {
                        ViewData["IaasName"] = response.ConfigurationSettings.IaasName;
                        ViewData["IaasAccessKey"] = response.ConfigurationSettings.IaasAccessKey;
                        ViewData["IaasSecretKey"] = response.ConfigurationSettings.IaasSecretKey;
                        ViewData["IaasServiceURL"] = response.ConfigurationSettings.IaasServiceURL;
                        ViewData["IaasKeyName"] = response.ConfigurationSettings.IaasKeyName;
                        ViewData["RunningOnMono"] = response.ConfigurationSettings.RunningOnMono.ToString().ToUpper();
                        ViewData["MonoRuntime"] = response.ConfigurationSettings.MonoRuntime;
                        ViewData["DotNetRuntime"] = response.ConfigurationSettings.DotNetRuntime;
                        ViewData["OperatingSystem"] = response.ConfigurationSettings.OperatingSystem;
                        ViewData["ApplicationGridStatus"] = "Authorized";

                        try
                        {
                            ApAuthorizeRequest authRequest = new ApAuthorizeRequest(Credentials);
                            ApAuthorizeResponse authResponse = EndPoints.ApDashboardService.Authorize(authRequest);
                            if (authResponse.Authorized)
                                ViewData["IaasStatus"] = "Authorized";
                            else
                                ViewData["IaasStatus"] = "Authentication failed";
                        }
                        catch (Exception e)
                        {
                            ViewData["IaasStatus"] = "Authentication failed";
                            ViewData["IaasError"] = e.Message;
                        }
                    }
                }
                catch (Exception e)
                {
                    ViewData["ApplicationGridError"] = e.Message;
                }
                return View();
            }
            catch (Exception e)
            {
                return ShowError(e);
            }
        }