Esempio n. 1
0
        public static bool CheckForEdits(object dirty, bool flag)
        {
            bool      UpdateOriginalViewModel = false;
            bool      IsModified = false;
            utilities util       = utilities.GetInstance();

            IsModified = CompareObjects(dirty);

            if (IsModified == true)
            {
                string           msg        = string.Format("{0}{1}{2}", "This page contains unsaved changes.", Environment.NewLine, "Click 'Yes' to save changes, 'No' to discard unsaved changes, or 'Cancel' to return to previous document.");
                MessageBoxResult userResult = ShowMessageDialog(msg, "Unsaved Changes");
                if (userResult == MessageBoxResult.Yes)
                {
                    Dictionary <string, string> dlgResults = ShowSaveDialog(util.userPath);
                    if (dlgResults["result"] == "True")
                    {
                        SaveFile(dirty, dlgResults["path"], fileType.xml);
                        UpdateOriginalViewModel = true;
                    }
                }
                if (userResult == MessageBoxResult.Cancel)
                {
                    return(UpdateOriginalViewModel);
                }
                else
                {
                    IsModified = false;
                }
            }
            return(UpdateOriginalViewModel);
        }
Esempio n. 2
0
        public static bool CompareObjects(object dirty)
        {
            utilities util      = utilities.GetInstance();
            string    jsonDirty = JsonConvert.SerializeObject(dirty, Newtonsoft.Json.Formatting.Indented);

            bool isModified = !jsonDirty.Equals(util.cleanJson);

            return(isModified);
        }
Esempio n. 3
0
        public static void SaveFileAs(object dirty)
        {
            utilities util = utilities.GetInstance();
            Dictionary <string, string> dlgResults = ShowSaveDialog(util.userPath);

            if (dlgResults["result"] == "True")
            {
                SaveFile(dirty, dlgResults["path"], fileType.xml);
                CreateCleanJson(dirty);
            }
            util.activeFilePath = dlgResults["path"];
        }
Esempio n. 4
0
        public static MessageBoxResult ShowMessageDialog(string message, string title)
        {
            utilities util = utilities.GetInstance();

            util.canceled = false;
            MessageBoxButton button = MessageBoxButton.YesNoCancel;
            MessageBoxResult result = MessageBox.Show(message, title, button);

            if (result == MessageBoxResult.Cancel)
            {
                util.canceled = true;
            }
            return(result);
        }
Esempio n. 5
0
        public static bool SaveFile(object current, string path, utilities.fileType fileType)
        {
            bool result = false;

            if (fileType == fileType.xml)
            {
                string s = ConvertToXml(current);
                File.WriteAllText(path, s);
            }
            utilities util = utilities.GetInstance();

            util.activeFilePath = path;
            CreateCleanJson(current);
            return(result);
        }
Esempio n. 6
0
        public static vmTaxonomy OpenSoa(vmTaxonomy viewModel)
        {
            utilities util      = utilities.GetInstance();
            mSoa      soaToOpen = new mSoa();

            util.dictDlgResults = OpenFileDialogBox(util.userPath, util.dictDlgResults);

            if (util.dictDlgResults["result"] != "False")
            {
                string s = File.ReadAllText(util.dictDlgResults["path"]);
                util.activeFilePath = util.dictDlgResults["path"];
                vmTaxonomy tempVm = DeserializeXml(s, viewModel);
                viewModel.vmSoa.Clear();
                viewModel.vmSoa.Add(tempVm.vmSoa[2]);
                viewModel.vmSoa.Add(tempVm.vmSoa[3]);
                viewModel.vmClient = tempVm.vmClient;
            }
            return(viewModel);
        }
Esempio n. 7
0
        public static vmCmc GetTaxonomyMasterFromXml()
        {
            utilities   util = utilities.GetInstance();
            vmCmc       vm   = new vmCmc();
            XmlDocument doc  = new XmlDocument();

            doc.Load(util.taxonomiesPath);
            List <XmlNodeList> nl = new List <XmlNodeList>();

            nl.Add(doc.SelectNodes("/cmc_taxonomies/Measure/Measure"));
            nl.Add(doc.SelectNodes("/cmc_taxonomies/Source/Source"));
            foreach (XmlNodeList nlChild in nl)
            {
                foreach (XmlNode node in nlChild)
                {
                    mTaxonomy t = new mTaxonomy();
                    t.action   = node["Action"].InnerText;
                    t.taxonomy = node["Taxonomy"].InnerText;
                    t.quantity = node["Quantity"].InnerText;
                    XmlNodeList nlReq = node.SelectNodes("Required_Parameter");
                    foreach (XmlNode reqNode in nlReq)
                    {
                        mRequiredParams param = new mRequiredParams();
                        param.parameter = reqNode.InnerText;
                        t.requiredParams.Add(param);
                    }

                    XmlNodeList nlOpt = node.SelectNodes("Optional_Parameter");
                    foreach (XmlNode optNode in nlOpt)
                    {
                        mOptionalParams param = new mOptionalParams();
                        param.parameter = optNode.InnerText;
                        t.optionalParams.Add(param);
                    }
                    vm.masterTaxonomy.Add(t);
                }
            }
            return(vm);
        }
Esempio n. 8
0
 static utilities()
 {
     instance = new utilities();
 }
Esempio n. 9
0
        public static void CreateCleanJson(object vm)
        {
            utilities util = utilities.GetInstance();

            util.cleanJson = JsonConvert.SerializeObject(vm, Newtonsoft.Json.Formatting.Indented);
        }