public void OKCommandExecute(IXmlSettingCollection collection)
 {
     if (!XmlTypeStatusFlag)
     {
         MessageBox.Show("Please check your xml type name first!");
         return;
     }
     else if (!XmlSampleStatusFlag)
     {
         MessageBox.Show("Please upload a xml file example to analyze the Nodes and Attribues for this type xml file");
         return;
     }
     else
     {
         //write Nodes and attribute list to the xml setting
         IXmlSetting xmlSetting = xmlFact.InitFromXmlFile(XmlType,
                                                          SamplePath,
                                                          xmlUserControl.GetCurrentUser().Id);
         m_XmlSettingCollection =
             xmlFact.ReadSettingCollection(ToolSetting.GetXmlSettingFilePath().Value);
         m_XmlSettingCollection.AppendSetting(xmlSetting);
         _ea.GetEvent <CollectionEvent>().Publish(m_XmlSettingCollection);
         XmlType           = null;
         SamplePath        = null;
         XmlTypeStatusFlag = false;
         Checkimage        = null;
         _regionManager.RequestNavigate("ContentRegion", "ToolSettingView");
     }
 }
Beispiel #2
0
 public ToolSettingViewModel(IEventAggregator ea, IXmlCompareToolSetting ToolSetting, IXmlSettingCollection CurrentSettingCollection, pnlDictionaryEdtPanelViewModel DictionaryEdtPanel, IXmlCompareUserControl UserControl, IXmlSettingReportDictionary CurrentReportDictionary, IXmlSettingFactorty SettingFact, IRegionManager regionManager, IXmlSettingNode _CurrentNode, IXmlSetting _CurrentSetting)
 {
     AddNewTypeCommand            = new DelegateCommand <IXmlSettingCollection>(AddNewTypeCommandExecute);
     DeleteTypeCommand            = new DelegateCommand(DeleteTypeCommandExecute);
     KeyFlagTrueCommand           = new DelegateCommand(KeyFlagTrueCommandExecute);
     KeyFlagFalseCommand          = new DelegateCommand(KeyFlagFalseCommandExecute);
     SaveCommand                  = new DelegateCommand(SaveCommandExecute);
     chkMoreCommand               = new DelegateCommand(chkMoreCommandExecute);
     BackCommand                  = new DelegateCommand(Back);
     AddAttrCompareFlagCommand    = new DelegateCommand(AddAttrCompareFlag);
     RemoveAttrCompareFlagCommand = new DelegateCommand(RemoveAttrCompareFlag);
     AddNodeCompareFlagCommand    = new DelegateCommand(AddNodeCompareFlag);
     RemoveNodeCompareFlagCommand = new DelegateCommand(RemoveNodeCompareFlag);
     CurrentNode                  = _CurrentNode;
     _CurrentReportDictionary     = CurrentReportDictionary;
     CurrentSetting               = _CurrentSetting;
     _regionManager               = regionManager;
     m_ToolSetting                = ToolSetting;
     m_UserControl                = UserControl;
     m_SettingFact                = SettingFact;
     m_DictionaryEdtPanel         = DictionaryEdtPanel;
     m_DictionaryEdtPanel         = new pnlDictionaryEdtPanelViewModel(ea, m_ToolSetting, m_UserControl, _CurrentReportDictionary, CurrentNode, CurrentSetting);
     ChkMoreSelected              = false;
     m_CurrentSettingCollection   = CurrentSettingCollection;
     m_CurrentSettingCollection   =
         m_SettingFact.ReadSettingCollection(m_ToolSetting.GetXmlSettingFilePath().Value);
     _ea = ea;
     _ea.GetEvent <CollectionEvent>().Subscribe(GetCollection);
     Flag        = m_UserControl.IsUserHasPriviledge(m_UserControl.GetCurrentUser(), "XmlSettingFilePath");
     XmlTypeList = new ObservableCollection <string>(m_CurrentSettingCollection.GetAllSettingTypes());
     SelectType  = null;
     ChkContent  = "Show Report Dictionary Setting";
 }
 public NewXmlTypeViewModel(IEventAggregator ea, IXmlCompareToolSetting _ToolSetting, IXmlSettingCollection xmlSettingCollection, IRegionManager regionManager, IXmlSettingFactorty _xmlFact, IXmlCompareUserControl _xmlUserControl)
 {
     _regionManager         = regionManager;
     xmlFact                = _xmlFact;
     ToolSetting            = _ToolSetting;
     xmlUserControl         = _xmlUserControl;
     SampleEnable           = false;
     m_XmlSettingCollection = xmlSettingCollection;
     UploadSampleCommand    = new DelegateCommand(UploadSampleCommandExecute);
     OKCommand              = new DelegateCommand <IXmlSettingCollection>(OKCommandExecute);
     CancelCommand          = new DelegateCommand(Cancel);
     CheckCommand           = new DelegateCommand(Check);
     _ea = ea;
 }
 public void WriteSettingCollection(IXmlSettingCollection instance, string filePath)
 {
     try
     {
         IFormatter formatter = new BinaryFormatter();
         Stream     fs        = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
         formatter.Serialize(fs, (CXmlSettingCollectionImp)instance);
         fs.Close();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public void Check()
        {
            m_XmlSettingCollection =
                xmlFact.ReadSettingCollection(ToolSetting.GetXmlSettingFilePath().Value);
            IXmlSetting tempSetting = m_XmlSettingCollection.GetSetting(XmlType);

            if (tempSetting == null && XmlType != null)
            {
                m_XmlTypeStatusFlag = true;
                Checkimage          = System.IO.Directory.GetCurrentDirectory() + "\\Images\\xmlTypeOK.ico";
            }
            else
            {
                m_XmlTypeStatusFlag = false;
                Checkimage          = System.IO.Directory.GetCurrentDirectory() + "\\Images\\xmlTypeKO.ico";
            }
        }
Beispiel #6
0
        public bool Initialize(out IXmlSettingCollection xmlSettingCollection)
        {
            bool result = false;

            try
            {
                CUser user = m_UserControl.GetCurrentUser();
                result = m_UserControl.CheckUser(user.Id);
                if (!result)
                {
                    m_UserControl.CreateUser(user.Id, user.Name);
                    result = true;
                }
                xmlSettingCollection = m_SettingFactory.ReadSettingCollection(m_ToolSetting.GetXmlSettingFilePath().Value);
            }
            catch (Exception e)
            {
                result = false;
                xmlSettingCollection = null;
                System.Windows.MessageBox.Show(e.Message);
            }
            return(result);
        }
        public IXmlSettingCollection ReadSettingCollection(string filePath)
        {
            if (!File.Exists(filePath))
            {
                CXmlSettingCollectionImp tmp = new CXmlSettingCollectionImp();
                WriteSettingCollection(tmp, filePath);
            }

            IFormatter formatter = new BinaryFormatter();
            Stream     fs        = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.None);

            try
            {
                IXmlSettingCollection result = (CXmlSettingCollectionImp)formatter.Deserialize(fs);
                fs.Close();
                return(result as IXmlSettingCollection);
            }
            catch (Exception e)
            {
                fs.Close();
                throw e;
            }
        }
Beispiel #8
0
 private void GetCollection(IXmlSettingCollection Collection)
 {
     settingCollection = Collection;
     Filetype          = new ObservableCollection <string>(settingCollection.GetAllSettingTypes());
     Selectedtype      = Filetype[0];
 }
Beispiel #9
0
 private void GetCollection(IXmlSettingCollection Collection)
 {
     m_CurrentSettingCollection = Collection;
     XmlTypeList = new ObservableCollection <string>(m_CurrentSettingCollection.GetAllSettingTypes());
     SelectType  = XmlTypeList.First();
 }
Beispiel #10
0
 public void AddNewTypeCommandExecute(IXmlSettingCollection collection)
 {
     //Navigation to NewXmlTypeView
     _regionManager.RequestNavigate("ContentRegion", "NewXmlTypeView");
 }