コード例 #1
0
        public ApAddApplicationResponse AddApplication(ApAddApplicationRequest request)
        {
            Log.Debug(this, "AddApplication()");

            try
            {
                Authenticate(request);
                Log.Info(this, "Application " + request.Application.Name + " received");

                if (!ControllerUtil.ApplicationExists(request.Application))
                {
                    string filePath = Settings.ApplicationStorePath + Path.DirectorySeparatorChar + request.Application.FileName;
                    if (!MonoscapeUtil.WebConfigExistsInRoot(filePath))
                    {
                        if (File.Exists(filePath))
                            File.Delete(filePath);
                        throw new MonoscapeException("Application package is not valid. Re-package the application excluding any project folders and try again.");
                    }

                    try
                    {
                        Database.GetInstance().Applications.Add(request.Application);
                        Database.GetInstance().Commit();
                        Log.Debug(this, "Application added to the database");
                    }
                    catch (Exception)
                    {
                        Log.Debug(this, "Application package not found");
                    }
                }
                else
                {
                    Log.Debug(this, "Application already exists in the database");
                }
                return new ApAddApplicationResponse();
            }
            catch (Exception e)
            {
                Log.Error(this, e);
                throw e;
            }
        }
コード例 #2
0
        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);
        }