public CommonReturnValue AddProject(string name)/*: { success: boolean, userError ?: string }*/
        {
            if (this.ProjectList == null)
            {
                this.ProjectList = new List <Project>();
            }

            // TODO: Add more validation rules - mostly around having valid URL-friendly chars only - or make sure Project/App/Endpoint names are valid to be used as sub dirs

            if (string.IsNullOrWhiteSpace(name))
            {
                return(CommonReturnValue.UserError("Please provide a valid project name."));
            }

            if (this.Exists(name))
            {
                return(CommonReturnValue.UserError($"A project with the name \"{name}\" already exists."));
            }

            var proj = new Project();

            proj.Name = name;
            this.ProjectList.Add(proj);

            return(CommonReturnValue.Success());
        }
        public CommonReturnValue UpdateProject(string currentName, string newName)/*: { success: boolean, userError ?: string }*/
        {
            if (this.ProjectList == null)
            {
                this.ProjectList = new List <Project>();
            }

            if (newName == null || string.IsNullOrWhiteSpace(newName))
            {
                return(CommonReturnValue.UserError("Please provide a valid project name."));
            }

            if (this.Exists(newName))
            {
                return(CommonReturnValue.UserError($"A project with the name \"{newName}\" already exists."));
            }
            if (!this.Exists(currentName))
            {
                return(CommonReturnValue.UserError($"The project \"{newName}\" does not exist so the update operation cannot continue"));
            }

            var existing = this.ProjectList.FirstOrDefault(p => p.Name.Equals(currentName, StringComparison.OrdinalIgnoreCase));

            existing.Name = newName;

            return(CommonReturnValue.Success());
        }
Example #3
0
        public CommonReturnValue GetInlinePluginModuleSource(string inlineEntryId, out InlineModuleManifestEntry existingInlineEntry, out string source)
        {
            source = null;
            existingInlineEntry = null;

            var pluginAssembly = this.PluginAssemblies.FirstOrDefault(p => p.InlineEntryId != null && p.InlineEntryId.Equals(inlineEntryId, StringComparison.Ordinal) && p.IsInline);

            if (pluginAssembly == null)
            {
                return(CommonReturnValue.UserError($"An inline module with the Id '{inlineEntryId}' does not exist"));
            }

            try
            {
                existingInlineEntry = InlineModuleManifest.Instance.GetEntryById(pluginAssembly.InlineEntryId);
                var sourcePath = System.IO.Path.Combine(InlinePluginSourcePath, existingInlineEntry.Id);

                if (System.IO.File.Exists(sourcePath))
                {
                    source = System.IO.File.ReadAllText(sourcePath);
                    return(CommonReturnValue.Success());
                }
                else
                {
                    return(CommonReturnValue.UserError($"Failed to find source at: {sourcePath}"));
                }
            }
            catch (Exception e)
            {
                SessionLog.Warning("Failed to fetch file of plugin module with InstanceId = {0}; {1}", pluginAssembly.InstanceId, pluginAssembly.Assembly.FullName);
                SessionLog.Exception(e);
            }

            return(CommonReturnValue.Success());
        }
        public CommonReturnValue DeleteProject(string name)
        {
            if (this.ProjectList == null)
            {
                this.ProjectList = new List <Project>();
            }

            if (!this.Exists(name))
            {
                return(CommonReturnValue.UserError($"The project \"{name}\" does not exist."));
            }

            var existing = this.ProjectList.FirstOrDefault(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            this.ProjectList.Remove(existing);

            return(CommonReturnValue.Success());
        }
 public ExecuteRoutineAsyncResult(object apiResponse, RoutineExecution execMetric, CommonReturnValue mayAccess, Dictionary <string, string> responseHeaders)
 {
     this.ApiResponse            = apiResponse;
     this.RoutineExecutionMetric = execMetric;
     this.MayAccess       = mayAccess;
     this.ResponseHeaders = responseHeaders;
 }