/// <summary>
        /// creates a graph workflows class.
        /// </summary>
        /// <param name="account"> cosmos db account, prefereably with GRAPH API (graph database) set as the default expirience. </param>
        /// <param name="name"> name of the account. </param>
        /// <returns> an instance of GraphWorkflows</returns>
        public GraphWorkflows GenerateGraphWF(ICosmosDBAccount account, string name)
        {
            GraphWorkflows wf = new GraphWorkflows(account);

            graphWorkflows.Add(name, wf);
            return(wf);
        }
Пример #2
0
        /// <summary>
        /// run a resource level operation.
        /// </summary>
        /// <param name="manager"> an instance of resource manager. </param>
        /// <param name="op"> the menu choice which denotes the operation to be completed. </param>
        public void InteractResource(ResourceManager manager, int op)
        {
            try
            {
                string accountName = GeneralUtils.PromptInput("Please enter the name of the database account that contains the resources you want to interact with");
                char   lookUp      = manager.CheckForExistingWorkFlow(accountName);
                if (lookUp != 'n')
                {
                    switch (lookUp)
                    {
                    case 'd': manager.RunDoc(manager.docdbWorkflows[accountName], op); break;

                    case 'm': manager.RunMongo(manager.mongodbWorkflows[accountName], op); break;

                    case 'g': manager.RunGraph(manager.graphWorkflows[accountName], op); break;

                    case 't': manager.RunTable(manager.tableWorkflows[accountName], op); break;
                    }
                }
                else
                {
                    string model = manager.accountWorkflow.acctUtil.databaseAccountInformation[accountName][4];
                    Task <ICosmosDBAccount> accountTask = manager.accountWorkflow.acctUtil.SelectAccountByName(accountName);
                    ICosmosDBAccount        account     = accountTask.Result;
                    switch (model)
                    {
                    case "DocumentDB":
                        DocumentDBWorkflows doc = manager.GenerateDocDBWF(account, accountName);
                        manager.RunDoc(doc, op);
                        break;

                    case "MongoDB":
                        MongoDBWorkflows mongo = manager.GenerateMongoDBWF(account, accountName);
                        manager.RunMongo(mongo, op);
                        break;

                    case "Graph":
                        GraphWorkflows graph = manager.GenerateGraphWF(account, accountName);
                        manager.RunGraph(graph, op);
                        break;

                    case "Table":
                        TableWorkflows table = manager.GenerateTableWF(account, accountName);
                        manager.RunTable(table, op);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Something went wrong while trying to process the request...");
                Console.WriteLine(e.Message);
            }
        }
        /// <summary>
        /// runs database level operations.
        /// </summary>
        /// <param name="wf"> instance of workflows. </param>
        /// <param name="op"> the operation to complete. </param>
        public void RunGraph(GraphWorkflows wf, int op)
        {
            switch (op)
            {
            case 0: wf.CreateDatabaseWF(); break;

            case 1: wf.DeleteDatabaseWF(); break;

            case 2: wf.ListDatabasesWF(); break;

            case 3: wf.CreateCollectionWF(); break;

            case 4: wf.DeleteCollectionWF(); break;

            case 5: wf.ListCollectionsWF(); break;

            case 6: wf.InsertOneOrManyWF(); break;
            }
        }