Exemple #1
0
        public AppsResult ArchiveTemplateProperty(int propertyId)
        {
            var result = new AppsResult();

            try
            {
                var templateProperties = _db.GetCollection <ContentTemplateProperty>("TemplateProperties");

                //var props = templateProperties.Query().Where(p => p.ID == propertyId).ToList();
                //if(props.Count() == 1)
                // {
                templateProperties.Delete(propertyId);
                ///}
                //templateProperty.Updated = DateTime.Now;
                //templateProperties.Upsert(templateProperty);

                //result.Data = templateProperty;
                result.Success = true;
            }
            catch (System.Exception ex)
            {
                new AppFlows.Plan.Apps.Exception(ex, ref result);
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Makes sure all config components are created on disk
        /// </summary>
        /// <returns></returns>
        public void RefreshComponents(ref AppsResult result)
        {
            try
            {
                M("Getting current config...", ref result);
                var config = Config.CurrentConfig;

                M("Loading components from config...", ref result);
                var components = Config.LoadComponentsConfig().Components;

                M("Loading base component folder...", ref result);
                var componentFolder = new DirectoryInfo(config.BaseComponentsFolder);

                M("Got base component folder " + componentFolder.FullName + ". Getting templates folder...", ref result);
                //var templateFolder = new DirectoryInfo(config.BaseTemplatesFolder);

                // M("Got base template folder " + templateFolder.FullName + ". Creating components as needed...", ref result);
                //CreateComponents(components, componentFolder, templateFolder, ref result);

                //result.Success = true;
            }
            catch (System.Exception ex)
            {
                M("Exception creating component: " + ex.Message + ". Stack: " + ex.StackTrace, ref result);
                //result.Data = ex;
            }
        }
        public AppsResult GetSteps(int testId)
        {
            var result = new AppsResult();

            try
            {
                if (testId > 0)
                {
                    var testRunController = new TestRunController(_env, _data, _driver, _ctx);
                    var steps             = _db.GetCollection <TestStep>("Steps");

                    var appSteps = steps.Query().Where(s => s.TestID == testId && s.Archived == false).ToList();
                    var test     = (List <Test>)GetTest(testId).Data; //TODO: Refactor safer

                    foreach (var step in appSteps)
                    {
                        //TODO: Decide how to choose between result from test plan or individual step test runs
                        var testResults = testRunController.GetLatestResults(TestRunInstanceType.TestPlan, test.Single().TestPlanID).Data;
                        step.Results = Newtonsoft.Json.JsonConvert.SerializeObject(testResults);
                    }

                    result.Data    = appSteps;
                    result.Success = true;
                }
                else
                {
                    result.FailMessages.Add("Test ID is zero.");
                }
            }
            catch (System.Exception ex)
            {
                new AppFlows.Test.Exception(ex, ref result);
            }
            return(result);
        }
Exemple #4
0
        public AppsResult GetFiles(int appId)
        {
            var result = new AppsResult();

            try
            {
                using (var client = new Client(appId, _db, ref result))
                {
                    var files = client.DB.GetCollection <SoftwareFile>("SoftwareFiles");
                    var codes = client.DB.GetCollection <SoftwareFileCode>("SoftwareFileCodes");

                    var fileList = files.Query().Where(f => f.AppID == appId).ToList();

                    foreach (var file in fileList)
                    {
                        var fileCodes = codes.Query().Where(c => c.SoftwareFileID == file.SoftwareFileID);
                        if (fileCodes.Count() > 0)
                        {
                            file.SoftwareFileCodes.AddRange(fileCodes.ToList());
                        }
                    }
                    result.Data    = fileList;
                    result.Success = true;
                }
            }
            catch (System.Exception ex)
            {
                new AppFlows.Develop.Exception(ex, ref result);
            }
            return(result);
        }
Exemple #5
0
        public AppsResult GetDocTypeByDocID(int docId)
        {
            var result = new AppsResult();

            try
            {
                using (var dblocal = new LiteDatabase(dbPath))
                {
                    var docList = dblocal.GetCollection <Doc>("Docs");
                    var docs    = docList.FindAll().ToList().Where(d => d.DocID == docId);

                    if (docs.Count() == 1)
                    {
                        var docTypeList = dblocal.GetCollection <DocType>("DocTypes");

                        result.Data    = docTypeList.FindAll().ToList().Where(dt => dt.DocTypeID == docs.Single().DocTypeID);
                        result.Success = true;
                    }
                }
            }
            catch (System.Exception ex)
            {
                result.Data = ex;
            }

            return(result);
        }
        public AppsResult GetSoftwareTypes()
        {
            var result           = new AppsResult();
            var softwareTypeList = new List <SoftwareTypeModel>();

            try
            {
                foreach (int stid in Enum.GetValues <SoftwareTypes>())
                {
                    var sft = new SoftwareTypeModel()
                    {
                        SoftwareTypeID   = stid,
                        SoftwareTypeName = Enum.GetName <SoftwareTypes>((SoftwareTypes)stid)
                    };
                    softwareTypeList.Add(sft);
                }
                result.Data    = softwareTypeList;
                result.Success = true;
            }
            catch (System.Exception ex)
            {
                new AppFlows.Helpers.AppsSystem.Exception(ex, ref result);
            }

            return(result);
        }
Exemple #7
0
        public AppsResult GetDocs()
        {
            var result = new AppsResult();

            try
            {
                using (var dblocal = new LiteDatabase(dbPath))
                {
                    var docsTable = dblocal.GetCollection <Doc>("Docs").FindAll().ToList();

                    foreach (var doc in docsTable)
                    {
                        doc.ChildCount = docsTable.Where(dl => dl.ParentDocID == doc.DocID).Count();
                    }

                    result.Data    = docsTable; //.Where(d => d.DocTypeID == docTypeId);
                    result.Success = true;
                }
            }
            catch (System.Exception ex)
            {
                result.Data = ex;
            }

            return(result);
        }
        public AppsResult GetTestPlan(int testPlanId)
        {
            var result            = new AppsResult();
            var testRunController = new TestRunController(_env, _data, _driver, _ctx);

            try
            {
                var testplans = _db.GetCollection <TestPlan>("TestPlans").Query().Where(tp => tp.ID == testPlanId);
                if (testplans.Count() == 1)
                {
                    var testPlan    = testplans.Single();
                    var testResults = testRunController.GetLatestResults(TestRunInstanceType.TestPlan, testPlan.ID).Data;
                    testPlan.Results = Newtonsoft.Json.JsonConvert.SerializeObject(testResults);

                    result.Data    = testPlan;
                    result.Success = true;
                }
                else
                {
                    new AppFlows.Test.Fail("Returned either zero or more than one test plans.", ref result);
                }
            }
            catch (System.Exception ex)
            {
                new AppFlows.Test.Exception(ex, ref result);
            }
            return(result);
        }
        public AppsResult AppsServer([FromBody] AppsParameters parameters)
        {
            var result = new AppsResult();


            return(result);
        }
        public static AppsResult Main()
        {
            var result  = new AppsResult();
            var factory = new ConnectionFactory()
            {
                HostName = "https://localhost:5002"
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(queue: "hello",
                                         durable: false,
                                         exclusive: false,
                                         autoDelete: false,
                                         arguments: null);

                    string message = "Hello World!";
                    var    body    = Encoding.UTF8.GetBytes(message);

                    channel.BasicPublish(exchange: "",
                                         routingKey: "hello",
                                         basicProperties: null,
                                         body: body);
                    result.SuccessMessages.Add("Sent message: " + message);
                }

            //Console.WriteLine(" Press [enter] to exit.");
            //Console.ReadLine();
            return(result);
        }
Exemple #11
0
        public AppsResult GetResourceReport()
        {
            var result = new AppsResult();

            try
            {
                if (Config.IsValid)
                {
                    using (StreamReader r = new StreamReader(Config.CurrentConfig.BaseResourcesFilePath))
                    {
                        var json = r.ReadToEnd();
                        result.Data    = JsonConvert.DeserializeObject <ResourceReport>(json);
                        result.Success = true;
                    }
                }
                else
                {
                    result.Messages.Add("Config was not valid getting resource report.");
                }
            }
            catch (System.Exception ex)
            {
                result.Data = ex;
            }
            return(result);
        }
Exemple #12
0
        public AppsResult GetComponentReport()
        {
            var result = new AppsResult();

            try
            {
                if (Config.IsValid)
                {
                    using (StreamReader r = new StreamReader(Config.CurrentConfig.BaseComponentsFilePath))
                    {
                        var json       = r.ReadToEnd();
                        var components = JsonConvert.DeserializeObject <ComponentReport>(json);
                        components.DiskTest(Config.CurrentConfig.BaseComponentsFolder); //Checks each component whether actually on disk

                        result.Data    = components;
                        result.Success = true;
                    }
                }
                else
                {
                    result.Messages.Add("Config was not valid.");
                }
            }
            catch (System.Exception ex)
            {
                result.Data = ex;
            }
            return(result);
        }
Exemple #13
0
        public AppsResult GetToken(string client_id)
        {
            // discover endpoints from metadata
            var result = new AppsResult();
            var client = new HttpClient();
            var disco  = client.GetDiscoveryDocumentAsync("https://localhost:5002").Result;

            //Send.Main();
            //Receive.Main();


            //if(disco..IsCompleted)
            //{

            //}


            return(result);

            //var tokenResponse = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
            //{
            //    Address = disco.TokenEndpoint,

            //    ClientId = "client",
            //    ClientSecret = "secret",
            //    Scope = "api1"
            //});

            //if (tokenResponse.IsError)
            //{
            //    //Console.WriteLine(tokenResponse.Error);
            //    //return;
            //}
            //return new JsonResult(from c in User.Claims select new { c.Type, c.Value });
        }
        public AppsResult GetPublishProfile(int publishProfileId)
        {
            var result = new AppsResult();

            try
            {
                var objs = _db.GetCollection <PublishProfile>("PublishProfiles"); // db.Softwares.Add(software);

                var ppList = objs.Query().Where(pp => pp.PublishProfileID == publishProfileId).ToList();
                if (ppList.Count() == 1)
                {
                    result.Data    = ppList.Single();
                    result.Success = true;
                }
                //else if(ppList.Count() == 0)
                //{
                //    //create one
                //    objs.Upsert(new PublishProfile())
                //}
                else
                {
                    new AppFlows.Publish.Fail("None or too many returned from get profile.", ref result);
                }
            }
            catch (System.Exception ex)
            {
                new AppFlows.Publish.Exception(ex, ref result);
            }

            return(result);
        }
Exemple #15
0
        public AppsResult GetTemplates()
        {
            var result = new AppsResult();

            try
            {
                var templates          = _db.GetCollection <ContentTemplate>("Templates");
                var templateProperties = _db.GetCollection <ContentTemplateProperty>("TemplateProperties");
                var templateList       = templates.Query().Where(t => t.ID > 0).ToList();

                foreach (var t in templateList)
                {
                    t.TemplateProperties.Clear();

                    t.TemplateProperties = templateProperties.Query().Where(p => p.TemplateID == t.ID).ToList();
                }

                result.Data    = templateList;
                result.Success = true;
            }
            catch (System.Exception ex)
            {
                new AppFlows.Develop.Exception(ex, ref result);
            }
            return(result);
        }
        public AppsResult UnitTests()
        {
            var result = new AppsResult();

            try
            {
                using (var db = new LiteDatabase(dbPath))
                {
                    //get model
                    result = GetEmployeeModel();

                    //bind model
                    //get employees
                    //get single employee
                    //create employee
                }
            }
            catch (Exception ex)
            {
                result.FailMessages.Add("Exception getting employee by ID.");
                AppsLog.LogStep <Business.Flows.Employee.Exception>(ex.ToString());
            }

            return(result);
        }
        public AppsResult GetLatestResults(TestRunInstanceType type, int uniqueId)
        {
            var result = new AppsResult();

            try
            {
                var triList = _db.GetCollection <TestRunInstance>("TestRunInstances"); //plan, test or step
                var trList  = _db.GetCollection <TestRun>("TestRuns");                 //each step

                var tri = triList.Query()
                          .Where(tri => tri.Type == type && tri.UniqueID == uniqueId)
                          .OrderByDescending(tri => tri.DateCreated);

                if (tri.Count() > 0)
                {
                    var triSingle = tri.First();

                    var runResult = new TestResult();
                    runResult.Instance = triSingle;
                    runResult.Runs     = trList.Query().Where(tr => tr.TestRunInstanceID == triSingle.ID).ToList();

                    result.Data    = runResult;
                    result.Success = true;
                }
            }
            catch (System.Exception ex)
            {
                new AppFlows.Test.TestRun.Exception(ex, ref result);
            }

            return(result);
        }
        public static AppsResult Main()
        {
            var result  = new AppsResult();
            var factory = new ConnectionFactory()
            {
                HostName = "localhost"
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(queue: "hello",
                                         durable: false,
                                         exclusive: false,
                                         autoDelete: false,
                                         arguments: null);

                    var consumer = new EventingBasicConsumer(channel);
                    consumer.Received += (model, ea) =>
                    {
                        var body    = ea.Body.ToArray();
                        var message = Encoding.UTF8.GetString(body);
                        result.SuccessMessages.Add(message);
                    };
                    channel.BasicConsume(queue: "hello",
                                         autoAck: true,
                                         consumer: consumer);


                    //Console.WriteLine(" Press [enter] to exit.");
                    //Console.ReadLine();
                }
            return(result);
        }
        public AppsResult UpsertEmployee([FromBody] Employee employee)
        {
            var result = new AppsResult();

            try
            {
                //using (var dblocal = new LiteDatabase(dbPath))
                //{

                //    var objs = dblocal.GetCollection<Employee>("Employees");
                //    objs.Upsert(employee);

                //    result.Data = objs.FindAll().ToList();
                //    result.Success = true;
                //}

                using (var db = new Data())
                {
                    db.Employees.Add(employee);
                    db.SaveChanges();
                    result.Success = true;
                }
            }
            catch (Exception ex)
            {
                result.FailMessages.Add("Exception saving employee.");
                AppsLog.LogStep <Business.Flows.Employee.Exception>(ex.ToString());
            }

            return(result);
        }
        public AppsResult GetEmployeeById(int id)
        {
            var result = new AppsResult();

            try
            {
                //using (var db = new LiteDatabase(dbPath))
                //{
                //    var objs = db.GetCollection<Employee>("Employees");

                //    result.Data = objs.FindAll().Where(e => e.ID == id).ToList();
                //    result.Success = true;
                //}

                using (var db = new Data())
                {
                    result.Data    = db.Employees.Where(e => e.ID == id).ToList();
                    result.Success = true;
                }
            }
            catch (Exception ex)
            {
                result.FailMessages.Add("Exception getting employee by ID.");
                AppsLog.LogStep <Business.Flows.Employee.Exception>(ex.ToString());
            }

            return(result);
        }
        public AppsResult GetTestPlanModel()
        {
            var result = new AppsResult();

            result.Data    = new TestPlan();
            result.Success = true;
            return(result);
        }
        public AppsResult GetStepModel()
        {
            var result = new AppsResult();

            result.Data    = new TestStep();
            result.Success = true;
            return(result);
        }
Exemple #23
0
        public AppsResult GetFileCodeModel()
        {
            var result = new AppsResult();

            result.Data    = new SoftwareFileCode();
            result.Success = true;
            return(result);
        }
        public AppsResult AddAppsJS(int appId)
        {
            var result = new AppsResult();

            try
            {
                var appResult = GetApp(appId);

                if (appResult.Success)
                {
                    var apps = (List <App>)appResult.Data;
                    var app  = apps.Single();

                    if (System.IO.Directory.Exists(app.WorkingFolder))
                    {
                        if (!System.IO.Directory.Exists(app.WorkingFolder + "\\wwwroot"))
                        {
                            System.IO.Directory.CreateDirectory(app.WorkingFolder + "\\wwwroot");
                        }

                        if (!System.IO.Directory.Exists(app.WorkingFolder + "\\wwwroot\\Scripts"))
                        {
                            System.IO.Directory.CreateDirectory(app.WorkingFolder + "\\wwwroot\\Scripts");
                        }

                        if (!System.IO.Directory.Exists(app.WorkingFolder + "\\wwwroot\\Scripts\\Apps"))
                        {
                            string copyFromFolder = System.Environment.CurrentDirectory + "\\Business\\Create\\Source\\AppsJS";
                            string copyToFolder   = app.WorkingFolder + "\\wwwroot\\Scripts";
                            DirectoryCopy(copyFromFolder, copyToFolder, true, ref result);
                        }
                        else
                        {
                            new AppFlows.Create.Fail("Apps folder already there.", ref result);
                        }


                        result.Success = true;
                    }
                    else
                    {
                        new AppFlows.Create.Fail("App #" + appId.ToString() + " working folder not found.", ref result);
                    }
                }
                else
                {
                    new AppFlows.Create.Fail("Failed getting the app for #" + appId.ToString(), ref result);
                }
            }
            catch (System.Exception ex)
            {
                new AppFlows.Plan.Apps.Exception(ex, ref result);
            }

            return(result);
        }
Exemple #25
0
        public AppsResult GetTemplateModel()
        {
            var result      = new AppsResult();
            var newTemplate = new ContentTemplate();
            var newprop     = new ContentTemplateProperty();

            newTemplate.TemplateProperties.Add(newprop);
            result.Data    = newTemplate;
            result.Success = true;
            return(result);
        }
Exemple #26
0
        public AppsResult GetFoundDirectories()
        {
            var result = new AppsResult();

            try
            {
                Config.LoadFoundDirectoriesConfig(ref result);
                result.Success = true;
            }
            catch (System.Exception ex)
            {
                result.Data = ex;
            }
            return(result);
        }
        public AppsResult GetSearchParams()
        {
            var result = new AppsResult();

            try
            {
                result.Data    = new SearchParams();
                result.Success = true;
            }
            catch (System.Exception ex)
            {
                result.FailMessages.Add("Components map exception: " + ex.Message);
            }
            return(result);
        }
Exemple #28
0
        public AppsResult DeleteComponent(Component component)
        {
            var result = new AppsResult();

            try
            {
                if (Config.IsValid)
                {
                    M("Config is valid, loading components from config...", ref result);
                    var components = Config.LoadComponentsConfig();

                    M("Got components (" + components.Components.Count().ToString() + "). Removing component from config:" + component.Name, ref result);
                    components.Components.RemoveAll(c => c.Name == component.Name);

                    M("Removed components. New component count is " + components.Components.Count().ToString() + ". Saving components...", ref result);
                    Config.SaveComponentsConfig(components);

                    M("Component removed from config. Removing from disk...", ref result);
                    string componentFolderPath = Config.CurrentConfig.BaseComponentsFolder + "\\" + component.Name;

                    M("Got full component path: " + componentFolderPath + ". Checking if folder exists...", ref result);
                    bool folderExists = Directory.Exists(componentFolderPath);
                    if (folderExists)
                    {
                        M("Folder exists. Deleting...", ref result);
                        Directory.Delete(componentFolderPath, true);

                        M("Component folder deleted.", ref result);
                    }
                    else
                    {
                        M("Component folder was not on disk.", ref result);
                    }

                    result.Success = true;
                }
                else
                {
                    M("Config was not valid (DeleteComponent).", ref result);
                }
            }
            catch (System.Exception ex)
            {
                M("Exception in DeleteComponent: " + ex.Message + ". Stack: " + ex.StackTrace, ref result);
                //result.Data = ex;
            }
            return(result);
        }
        public AppsResult ArchiveEvents(string eventName)
        {
            var result = new AppsResult();

            try
            {
                //result.Data = FlowsData.FlowTable.DeleteMany(e => e.FlowProps["Name"] == eventName.Replace(" ", "+"));
                result.Success = true;
            }
            catch (System.Exception ex)
            {
                new AppFlows.Plan.Apps.Exception(ex, ref result);
            }

            return(result);
        }
Exemple #30
0
        public AppsClient.AppsResult GetComputerName()
        {
            var result = new AppsResult();

            try
            {
                result.Messages.Add(Environment.MachineName);
                result.Success = true;
            }
            catch (System.Exception ex)
            {
                result.Data = ex;
            }

            return(result);
        }