예제 #1
0
        public static List <string> MakeHostHtml(DataInfo info,
                                                 Options options)
        {
            List <string> stringResult = new List <string>();
            string        htmlFile     = GetHostFile(options, info);

            if (CommonIO.Exists(htmlFile, options) == true)
            {
                if (options.IsTraceOn(Trace_Options.TraceInfo))
                {
                    Trace.TraceInformation("Host file = [" + htmlFile + "]");
                }

                stringResult = LoadStrings(htmlFile, options);
            }
            else
            {
                if (options.IsTraceOn(Trace_Options.TraceWarning))
                {
                    Trace.TraceWarning("No Host file, likely webassembly or Razor");
                }
            }

            return(stringResult);
        }
예제 #2
0
        public void SaveOrderToList(Order newOrder)
        {
            OrdrLkpResponses AllOrders = new OrdrLkpResponses();

            AllOrders = _manager.LoadOrders(newOrder.OrderDate);
            String userConfirm = ConsoleIO.RequireYorN("Would you like to save this order? (y=yes, n=no)");

            _orders = AllOrders.Orders;

            if (userConfirm == "Y")
            {
                int   orderNumToReplace = newOrder.OrderNumber;
                Order OldOrder          = _orders.FirstOrDefault(o => o.OrderNumber == newOrder.OrderNumber);

                int indexToReplace = (_orders.IndexOf(OldOrder));

                _orders[indexToReplace] = newOrder;
                _manager.SaveOrders(newOrder.OrderDate, _orders);

                userConfirm = userConfirm.ToUpper();
                CommonIO.MessageToUserInBlue($"New order ID {newOrder.OrderNumber} has been saved.");
                CommonIO.Continue();
            }
            else if (userConfirm == "N")
            {
                CommonIO.MessageToUserInBlue($"New order ID {newOrder.OrderNumber} was NOT saved.");
                CommonIO.Continue();
            }
        }
예제 #3
0
        //private List<Order> myVar = Orders;
        public void Execute()
        {
            CommonIO.ShowHeader("Lookup an order");

            List <Order> _allOrders = new List <Order>();
            DateTime     OrderDate  = ConsoleIO.AskForOrderDate();

            OrdrLkpResponses AllOrders = new OrdrLkpResponses();

            AllOrders = _manager.LoadOrders(OrderDate);

            _allOrders = AllOrders.Orders;

            Console.Clear();

            if (AllOrders.Success)
            {
                foreach (Order OneOrder in _allOrders)
                {
                    ConsoleIO.DisplayOrderDetails(OneOrder);
                }
                CommonIO.Continue();
            }
            else
            {
                CommonIO.MessageToUserInBlue(AllOrders.Message);
            }
        }
예제 #4
0
        private static void ApplyChoice(int menuChoice)
        {
            switch (menuChoice)
            {
            case 1:
                OrderLookupWorkflow LookupWorkflow = new OrderLookupWorkflow();
                LookupWorkflow.Execute();
                break;

            case 2:
                AddOrderWorkflow AddOrder = new AddOrderWorkflow();
                AddOrder.Execute();
                break;

            case 3:
                EditOrderWorkflow EditOrder = new EditOrderWorkflow();
                EditOrder.Execute();
                break;

            case 4:
                DeleteOrderWorkflow DeleteOrder = new DeleteOrderWorkflow();
                DeleteOrder.Execute();
                break;

            case 5:
                Console.Write("To exit, ");
                CommonIO.Continue();
                break;
            }
        }
예제 #5
0
        public static void OutputRazorCodeBehindFile(Options options,
                                                     DataInfo info)
        {
            string blazerFile = GetRazorFile(options, info) + ".cs";

            Console.WriteLine("Razor Code Behind File = [" + blazerFile + "]");

            CommonIO.OutputFile(blazerFile, info.RazorCodeBehindStrings, options);
        }
예제 #6
0
        public static void Start()
        {
            int menuChoice = 0;

            do
            {
                ShowMenu();
                menuChoice = CommonIO.GetIntFromUser(1, 5);
                ApplyChoice(menuChoice);
            } while (menuChoice != 5);
        }
예제 #7
0
        public static void OutputCustomRazorLayout(Options options,
                                                   DataInfo info)
        {
            string strFile = GetRazorCustomLayoutFile(options, info);

            if (options.IsTraceOn(Trace_Options.TraceInfo))
            {
                Trace.TraceError("Razor Custom Layout File = [" + strFile + "]");
            }

            CommonIO.OutputFile(strFile, info.RazorCustomLayoutStrings, options);
        }
예제 #8
0
        public static void CopyAssetsDirectory(Options options)
        {
            string sourceDirectory      = GetSourceDirectory(options);
            string destinationDirectory = GetDestinationDirectory(options);

            if (options.IsTraceOn(Trace_Options.TraceInfo))
            {
                Trace.TraceInformation("Copying Assets Source=" + sourceDirectory);
                Trace.TraceInformation("               Dest  =" + destinationDirectory);
            }
            CommonIO.CopyDirectory(sourceDirectory, destinationDirectory, options);
        }
예제 #9
0
        public static void OutputBlazorFile(Options options,
                                            DataInfo info)
        {
            string blazerFile = GetRazorFile(options, info);

            if (options.IsTraceOn(Trace_Options.TraceInfo))
            {
                Trace.TraceInformation("Blazor File = [" + blazerFile + "]");
            }

            CommonIO.OutputFile(blazerFile, info.BlazorStrings, options);
        }
예제 #10
0
        public void Execute()
        // The construct doesn't get executed when a method is static.
        // But, without having this static makes it difficult to count orders
        // AND diffiuclt to get the next order number.
        {
            Order orderFromUsr = new Order();

            CommonIO.ShowHeader("Add an order");

            orderFromUsr = ConsoleIO.GetNewOrder();

            OrdrLkpResponses AllOrders = new OrdrLkpResponses();

            AllOrders = _manager.LoadOrders(orderFromUsr.OrderDate);

            if (AllOrders.Success)
            {
                _orders = AllOrders.Orders;
            }
            else
            {
                Console.WriteLine("An error occurred: ");
                Console.WriteLine(AllOrders.Message);
            }

            orderFromUsr = CalcRestofOrder(orderFromUsr);
            //DateTime OrderDate = orderFromUsr.OrderDate;
            CommonIO.MessageToUserInBlue("Order entry is complete.");
            CommonIO.Continue();

            ConsoleIO.DisplayOrderDetails(orderFromUsr);

            String userConfirm = ConsoleIO.RequireYorN("Would you like to save this information? (y=Yes, n=No.)");

            if (userConfirm.ToUpper() == "Y")
            {
                //List<Order> AllOrders = _manager.LoadOrders(DateTime.Now);

                _manager.SaveOrder(orderFromUsr);
                //manager.SaveOrders(AllOrders);
                CommonIO.MessageToUserInBlue($"New order ID {orderFromUsr.OrderNumber} has been saved.");
                CommonIO.Continue();
            }
            else
            {
                CommonIO.MessageToUserInBlue($"New order ID {orderFromUsr.OrderNumber} was NOT saved.");
                CommonIO.Continue();
            }
        }
예제 #11
0
        public static void OutputNavMenuFile(Options options,
                                             DataInfo info)
        {
            if (info.NewNavMenuStrings.Count > 0)
            {
                string strFile = GetNavMenuFile(options, info);

                if (options.IsTraceOn(Trace_Options.TraceInfo))
                {
                    Trace.TraceInformation("NavMenu File = [" + strFile + "]");
                }

                CommonIO.OutputFile(strFile, info.NewNavMenuStrings, options);
            }
        }
예제 #12
0
        public static void OutputHostFile(Options options,
                                          DataInfo info)
        {
            if (info.NewHostStrings.Count > 0)
            {
                string htmlFile = GetHostFile(options, info);

                if (options.IsTraceOn(Trace_Options.TraceInfo))
                {
                    Trace.TraceInformation("Host File = [" + htmlFile + "]");
                }

                CommonIO.OutputFile(htmlFile, info.NewHostStrings, options);
            }
        }
예제 #13
0
        public static void OutputPreview(Options options,
                                         DataInfo info)
        {
            if (options.HasPreview() == true)
            {
                string previewFile = options.PreviewFile;

                if (options.IsTraceOn(Trace_Options.TraceInfo))
                {
                    Trace.TraceInformation("Preview  File = [" + previewFile + "]");
                }

                CommonIO.OutputFile(previewFile, info.PreviewStrings, options);
            }
        }
예제 #14
0
        // support methods


        public static List <string> LoadStrings(string fileName,
                                                Options options)
        {
            List <string> strings = new List <string>();

            if (CommonIO.Exists(fileName, options) == true)
            {
                string[] strs = CommonIO.ReadAllLines(fileName, options);
                foreach (string s in strs)
                {
                    strings.Add(s);
                }
            }

            return(strings);
        }
예제 #15
0
        public static Type_Options GetProjectType(Options options)
        {
            Type_Options result = Type_Options.Unknown;

            try
            {
                string strFile = options.BlazorProjectPath + options.HostHtml;
                if (CommonIO.Exists(strFile, options) == true)
                {
                    result = Type_Options.BlazorServer;
                }
                else
                {
                    strFile = options.BlazorProjectPath + options.WasmHostHtml;
                    if (CommonIO.Exists(strFile, options) == true)
                    {
                        strFile = options.BlazorProjectPath + options.PWAFile;
                        if (CommonIO.Exists(strFile, options) == true)
                        {
                            result = Type_Options.BlazorWebassemblyPWA;
                        }
                        else
                        {
                            result = Type_Options.BlazorWebassembly;
                        }
                    }
                    else
                    {
                        strFile = options.BlazorProjectPath + options.RazorHostHtml;
                        if (CommonIO.Exists(strFile, options) == true)
                        {
                            result = Type_Options.ASPNetRazor;
                        }
                    }
                }
            }
            catch (IOException e)
            {
                if (options.IsTraceOn(Trace_Options.TraceExceptions))
                {
                    Trace.TraceError("Exception get Project Type", e);
                }
            }

            return(result);
        }
예제 #16
0
        public void Execute()
        {
            //OrderManager manager = OrderManagerFactory.Create();

            CommonIO.ShowHeader("Edit an order");
            OrderLookupResponse response = ConsoleIO.AskForExistingOrder();

            if (response.Success)
            {
                EditOrderIO.ShowEditInstructions();
                GetEdits(response.Order);
                SaveOrderToList(response.Order);
            }
            else
            {
                Console.WriteLine("An error occurred: ");
                CommonIO.errMsg(response.Message);
            }
        }
예제 #17
0
        public void Execute()
        {
            CommonIO.ShowHeader("Delete Order");
            DateTime OrderDateToDelete = ConsoleIO.AskForOrderDate();

            OrdrLkpResponses AllOrders = new OrdrLkpResponses();

            AllOrders = _manager.LoadOrders(OrderDateToDelete);

            if (AllOrders.Success)
            {
                _orders = AllOrders.Orders;
                int orderNumtoDelete = CommonIO.GetIntFromUser(1, 999, 0, "What order number would you like to delete?");
                DeleteOrder(OrderDateToDelete, orderNumtoDelete);
            }
            else
            {
                CommonIO.MessageToUserInBlue(AllOrders.Message);
            }
        }
예제 #18
0
        private void DeleteOrder(DateTime OrderDateToDelete, int orderNumtoDelete)
        {
            OrderLookupResponse response = _manager.LookupOrder(OrderDateToDelete, orderNumtoDelete);

            if (response.Success)
            {
                ConsoleIO.DisplayOrderDetails(response.Order);
                string confirmYN = ConsoleIO.RequireYorN("Are you sure you want to remove this order? (y=yes, n=no)");

                do
                {
                    if (confirmYN == "Y")
                    {
                        _orders.RemoveAll(o => o.OrderNumber == response.Order.OrderNumber);
                        //_orders.Remove(_orders[indexToDelete]);
                        //TODO: Learn why .remove did not work and .removeall did work.

                        _manager.SaveOrders(OrderDateToDelete, _orders);
                        CommonIO.MessageToUserInBlue($"Order {orderNumtoDelete} was deleted.");
                    }
                    else if (confirmYN == "N")
                    {
                        CommonIO.MessageToUserInBlue($"Order {orderNumtoDelete} was NOT deleted.");
                        //CommonIO.Continue();
                    }
                    else
                    {
                        CommonIO.MessageToUserInBlue("Please enter y or n.");
                    }
                } while ((confirmYN == "Y") && (confirmYN == "N"));
            }
            else
            {
                Console.WriteLine("An error occurred: ");
                Console.WriteLine(response.Message);
            }

            CommonIO.Continue();
        }
예제 #19
0
        private string GetInputPathArgument(StreamState state)
        {
            var protocol = state.InputProtocol;
            var mediaPath = state.MediaPath ?? string.Empty;

            var inputPath = new[] { mediaPath };

            if (state.IsInputVideo)
            {
                if (!(state.VideoType == VideoType.Iso && state.IsoMount == null))
                {
                    inputPath = MediaEncoderHelpers.GetInputArgument(FileSystem, mediaPath, state.InputProtocol, state.IsoMount, state.PlayableStreamFileNames);
                }
            }

            return MediaEncoder.GetInputArgument(inputPath, protocol);
        }
예제 #20
0
        public Order GetEdits(Order OrderToEdit)
        {
            //Order EditedOrder = new Order();

            // Edit Customer Name
            Console.Write($"Customer Name ({OrderToEdit.CustomerName}), ");
            CommonIO.MessageToUserInBlue("press Enter for no change.");
            String newCustomerName = ConsoleIO.AskForNewCustomerName();

            if (newCustomerName == "")
            {
                Console.WriteLine("Name Unchanged\n");
            }
            else
            {
                OrderToEdit.CustomerName = newCustomerName;
            }

            // Edit State
            Console.WriteLine($"Order State ({OrderToEdit.State}):");
            CommonIO.MessageToUserInBlue("  0. No change");
            String newState = ConsoleIO.AskForNewStateAbbr();

            if (newState != null)
            {
                Console.WriteLine("State Unchanged");
            }
            else
            {
                OrderToEdit.State = newState;
            }

            // Edit Product
            Console.WriteLine($"Product ({OrderToEdit.ProductType}):");
            CommonIO.MessageToUserInBlue("  0. No change");
            Product EditedProduct = ConsoleIO.AskForNewProduct();

            if (newState == null)
            {
                Console.WriteLine("Product Unchanged");
            }
            else
            {
                OrderToEdit.State = newState;
            }

            // Edit Area
            Console.WriteLine($"Area ({OrderToEdit.Area}), ");
            CommonIO.MessageToUserInBlue("Enter 0 for no change.");

            //Decimal editedArea = ConsoleIO.AskForArea();

            decimal editedArea = 0;

            int  min = 100, max = 100000;
            bool intCk = false;

            do
            {
                intCk = decimal.TryParse(Console.ReadLine(), out editedArea);

                if (!intCk)
                {
                    editedArea = 1;
                }
                if (editedArea == 0)
                {
                    CommonIO.MessageToUserInBlue("Area unchanged.");
                    break;
                }
                else if (editedArea < min)
                {
                    CommonIO.MessageToUserInBlue($"Please enter a number between {min} and {max}");
                    //CommonIO.Continue();
                }
            } while (editedArea < min || editedArea > max);

            if (editedArea != 0)
            {
                OrderToEdit.Area = editedArea;
            }

            CommonIO.MessageToUserInBlue("Editing order is complete. Next, you'll view the edited order and decide if you want to save it.");
            CommonIO.Continue();
            Console.Clear();
            ConsoleIO.DisplayOrderDetails(OrderToEdit);

            //•	CustomerName, State, ProductType, Area
            return(OrderToEdit);
        }
예제 #21
0
        public static void MoveAssetsDirectory(Options options,
                                               DataInfo info)
        {
            string sourceDirectory      = GetSourceDirectory(options);
            string destinationDirectory = GetDestinationDirectory(options);

            try
            {
                if (options.IsTraceOn(Trace_Options.TraceInfo))
                {
                    Trace.TraceInformation("Moving Assets Source=" + sourceDirectory);
                    Trace.TraceInformation("              Dest  =" + destinationDirectory);
                }

                CommonIO.CreateDirectory(destinationDirectory, options);

                foreach (Asset TheAsset in info.Assets)
                {
                    if (TheAsset.AssetType == AssetType_Options.ImageAsset)
                    {
                        string sourceFile = options.BootstrapProjectPath + TheAsset.HtmlAsset;
                        string destFile   = destinationDirectory + TheAsset.RawAsset;
                        string sourcePath = Path.GetDirectoryName(sourceFile);
                        string destPath   = Path.GetDirectoryName(destFile) + @"\assets\img";

                        if (options.IsTraceOn(Trace_Options.TraceInfo))
                        {
                            Trace.TraceInformation("Copying Assets Source=" + sourcePath);
                            Trace.TraceInformation("               Dest  =" + destPath);
                        }

                        CommonIO.CopyDirectory(sourcePath, destPath, options);
                    }
                    else if (TheAsset.AssetType == AssetType_Options.HostAsset)
                    {
                        string sourcePath = options.BootstrapProjectPath + TheAsset.RawAsset;
                        string destPath   = options.BlazorProjectPath + "wwwroot\\" + options.PageName + "\\" + TheAsset.RawAsset;

                        if (options.IsTraceOn(Trace_Options.TraceInfo))
                        {
                            Trace.TraceInformation("Copying Assets Source=" + sourcePath);
                            Trace.TraceInformation("               Dest  =" + destPath);
                        }

                        CommonIO.CopyDirectory(sourcePath, destPath, options);
                    }
                    else if (TheAsset.AssetType == AssetType_Options.ScriptAsset)
                    {
                        string sourcePath = options.BootstrapProjectPath + TheAsset.RawAsset;
                        string destPath   = options.BlazorProjectPath + "wwwroot\\" + options.PageName + "\\" + TheAsset.RawAsset;

                        if (options.IsTraceOn(Trace_Options.TraceInfo))
                        {
                            Trace.TraceInformation("Copying Assets Source=" + sourcePath);
                            Trace.TraceInformation("               Dest  =" + destPath);
                        }

                        CommonIO.CopyDirectory(sourcePath, destPath, options);
                    }
                }
            }
            catch (IOException e)
            {
                if (options.IsTraceOn(Trace_Options.TraceExceptions))
                {
                    Trace.TraceError("IO Exception copying assets" + e.ToString());
                }
            }
        }