예제 #1
0
 public static void PullMainFileData(string mainFileName, string mainFilePath)
 {
     Main = new MainFile()
     {
         FileName = mainFileName,
         FullPath = mainFilePath
     };
 }
예제 #2
0
 private static XDocument WriteMainDoc(MainFile main)
 {
     if (main.Budget != null && main.Category != null && main.Paystub != null)
     {
         return new XDocument(
                 CreateDeclaration(),
                 new XElement(Element.Root, new XAttribute(Element.FileName, main.FileName),
                     new XElement(Element.BudgetFile, main.Budget.FullPath),
                     new XElement(Element.CategoryFile, main.Category.FullPath),
                     new XElement(Element.PaystubFile, main.Paystub.FullPath)
                     )
                 );
     }
     else
 }
예제 #3
0
        public static void BeginSave(Message message, MainFile mainFile)
        {
            // Testing
            Main = mainFile;
            // Testing

            XDocument mainDoc = WriteMainDoc(mainFile);
            XDocument budgetDoc = WriteBudgetDoc(mainFile.Budget);
            XDocument categoryDoc = WriteCategoryDoc(mainFile.Category);
            XDocument paystubDoc = WritePaystubDoc(mainFile.Paystub);

            message($"{mainDoc.ToString()} \n\n {budgetDoc.ToString()} \n\n {categoryDoc.ToString()} \n\n {paystubDoc.ToString()}");

            mainDoc.Save(mainFile.FullPath);
            budgetDoc.Save(mainFile.Budget.FullPath);
            categoryDoc.Save(mainFile.Category.FullPath);
            paystubDoc.Save(mainFile.Paystub.FullPath);
        }
예제 #4
0
        public static MainFile BeginOpen(Message message, string path)
        {
            MainFile output = new MainFile();

            if (File.Exists(path))
            {
                output.FullPath = path;
                XDocument doc = XDocument.Load(path);

                XElement main         = doc.Element(Element.Root);
                string   fileName     = main.Attribute(Element.FileName).Value;
                string   budgetPath   = main.Element(Element.BudgetFile).Value;
                string   categoryPath = main.Element(Element.CategoryFile).Value;
                string   paystubPath  = main.Element(Element.PaystubFile).Value;

                output.FileName = fileName;

                if (budgetPath != Element.Null)
                {
                    if (File.Exists(budgetPath))
                    {
                        output.Budget = OpenBudget(message, budgetPath);
                    }
                    else
                    {
                        message("Budget File could not be found.");
                    }
                }
                else
                {
                    message("budget file is null");
                }

                if (categoryPath != Element.Null)
                {
                    if (File.Exists(categoryPath))
                    {
                        output.Category = OpenCategory(message, categoryPath);
                    }
                    else
                    {
                        message("Category File could not be found.");
                    }
                }
                else
                {
                    message("Category File is Null");
                }

                if (paystubPath != Element.Null)
                {
                    if (File.Exists(paystubPath))
                    {
                        output.Paystub = OpenPaystub(message, paystubPath);
                    }
                    else
                    {
                        message("Paystub File could not be found.");
                    }
                }
                else
                {
                    message("Paystub File is null");
                }
            }

            return(output);
        }