Exemplo n.º 1
0
 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");
     }
 }
Exemplo n.º 2
0
        private bool GetKeyForNode(XmlNode currentNode, string name, IXmlSetting currentSetting, out string key)
        {
            bool rc = true;

            key = "";

            try
            {
                IXmlSettingNode settingNode    = currentSetting.GetNode(name);
                List <String>   lstKeyAttrName = settingNode.identifier().Split(',').ToList <string>();
                if (lstKeyAttrName.Count > 0)
                {
                    List <string> tempKeys = new List <string>();
                    foreach (string attrNameNode in lstKeyAttrName)
                    {
                        string attrValue = currentNode.Attributes[attrNameNode].Value;
                        tempKeys.Add(attrValue);
                    }
                    key = String.Join("|", tempKeys.ToArray());
                }
            }
            catch (Exception e)
            {
                key = "";
                rc  = false;
            }
            return(rc);
        }
Exemplo n.º 3
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";
 }
Exemplo n.º 4
0
 private void BindgingSettingNodeToNodeTlv(IXmlSetting currentXmlSetting, string strSelectedItemText)
 {
     if (SelectType != "")
     {
         NodesList.Clear();
         foreach (IXmlSettingNode tempNode in currentXmlSetting.GetNodes)
         {
             tempNode.IdtAttributes = tempNode.identifier();
             if (tempNode.compare_flag)
             {
                 tempNode.Compare_flag = "1";
                 tempNode.CompareImage = System.IO.Directory.GetCurrentDirectory() + "\\Images\\compare_flag_true.png";
             }
             else
             {
                 tempNode.Compare_flag = "0";
                 tempNode.CompareImage = System.IO.Directory.GetCurrentDirectory() + "\\Images\\compare_flag_false.png";
             }
             tempNode.NameImage = System.IO.Directory.GetCurrentDirectory() + "\\Images\\node.png";
             NodesList.Add(tempNode);
             if (tempNode.name == strSelectedItemText)
             {
                 // neoItem.Selected = true;
             }
         }
     }
 }
Exemplo n.º 5
0
        public void AppendSetting(IXmlSetting setting)
        {
            CXmlSettingImp value = (CXmlSettingImp)setting;

            if (m_NodeSettingCollection.Exists(m => m.file_type == value.file_type))
            {
                //throw new Exception("diplicate file type[" + value.file_type + "] exist in setting collcetion.append failed");
                MessageBox.Show("Type already exists!");
            }
            else
            {
                m_NodeSettingCollection.Add(value);
            }
        }
Exemplo n.º 6
0
        private bool GetEffectiveAttributeNames(XmlNode currentNode, string name, IXmlSetting currentSetting, out List <string> AttrNameList)
        {
            bool rc = true;

            AttrNameList = new List <string>();
            try
            {
                IXmlSettingNode settingNode          = currentSetting.GetNode(name);
                List <String>   lstEffectiveAttrName = settingNode.attributesToCompare().Split(',').ToList <string>();
                AttrNameList.AddRange(lstEffectiveAttrName);
            }
            catch (Exception e)
            {
                rc = false;
            }
            return(rc);
        }
Exemplo n.º 7
0
        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";
            }
        }
Exemplo n.º 8
0
        public void DeleteTypeCommandExecute()
        {
            DialogResult flag = MessageBox.Show("Do you want to delete this xml setting from Setting File?",
                                                "Setting File Change Confirm",
                                                MessageBoxButtons.YesNo,
                                                MessageBoxIcon.Exclamation);

            if (flag == DialogResult.Yes)
            {
                IXmlSetting currentXmlSetting = m_CurrentSettingCollection.GetSetting(SelectType);
                m_CurrentSettingCollection.RemoveSetting(currentXmlSetting);
                _ea.GetEvent <CollectionEvent>().Publish(m_CurrentSettingCollection);
                XmlTypeList = null;
                XmlTypeList = new ObservableCollection <string>(m_CurrentSettingCollection.GetAllSettingTypes());
                SelectType  = null;
                AttributeList.Clear();
            }
        }
Exemplo n.º 9
0
        private bool CompareXml(string fn1, string fn2, string xmlType)
        {
            XmlDocument xmlDoc1, xmlDoc2;

            try
            {
                xmlDoc1 = new XmlDocument();
                xmlDoc2 = new XmlDocument();
                xmlDoc1.Load(fn1);
                xmlDoc2.Load(fn2);;
                CXmlFileNodeImp nd1, nd2;
                nd1 = new CXmlFileNodeImp(xmlType, fn1);
                nd2 = new CXmlFileNodeImp(xmlType, fn2);

                m_DuplicateKeyMemo.Clear();
                IXmlSetting currentSetting =
                    m_SettingFactory.ReadSettingCollection(m_ToolSetting.GetXmlSettingFilePath().Value)
                    .GetSetting(xmlType);

                DomToNode(currentSetting, xmlDoc1.DocumentElement, ref nd1);
                m_DuplicateKeyMemo.Clear();
                DomToNode(currentSetting, xmlDoc2.DocumentElement, ref nd2);

                if (nd1 == nd2)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 10
0
        private void DomToNode(IXmlSetting currentSetting, XmlNode currentNode, ref CXmlFileNodeImp parent)
        {
            bool NodeCompareFlag = false;

            try
            {
                IXmlSettingNode settingNode = currentSetting.GetNode(currentNode.Name);
                if (settingNode != null)
                {
                    NodeCompareFlag = settingNode.compare_flag;
                }
            }
            catch (Exception e)
            {
                // do nothing
            }

            if (NodeCompareFlag)
            {
                CXmlFileNodeImp neoNode = new CXmlFileNodeImp(currentNode.Name, GetXPath(currentNode));

                string key = "";
                if (GetKeyForNode(currentNode, neoNode.name, currentSetting, out key))
                {
                    neoNode.key = key;
                }
                key = neoNode.name + "|" + neoNode.key;

                if (currentNode.NodeType == XmlNodeType.Text)
                {
                    neoNode.text = currentNode.Value;
                    parent.m_childNodes.Add(neoNode.key, neoNode);
                    neoNode.m_parentNodes.Add(parent.key, parent);
                    return;
                }
                foreach (XmlAttribute xmlAttr in currentNode.Attributes)
                {
                    List <string> listOfAttrName = new List <string>();
                    GetEffectiveAttributeNames(currentNode, neoNode.name, currentSetting, out listOfAttrName);
                    if (listOfAttrName.IndexOf(xmlAttr.Name) >= 0)
                    {
                        neoNode.m_attributes.Add(xmlAttr.Name, xmlAttr.Value);
                    }
                }
                foreach (XmlNode childNode in currentNode.ChildNodes)
                {
                    DomToNode(currentSetting, childNode, ref neoNode);
                }
                if (parent.m_childNodes.ContainsKey(key))
                {
                    // dealing with duplicate key, add numeric suffix to the key
                    if (m_DuplicateKeyMemo.ContainsKey(key))
                    {
                        m_DuplicateKeyMemo[key] = m_DuplicateKeyMemo[key] + 1;
                    }
                    else
                    {
                        m_DuplicateKeyMemo.Add(key, 1);
                    }
                    key = key + "." + m_DuplicateKeyMemo[key].ToString();
                }
                parent.m_childNodes.Add(key, neoNode);
                neoNode.m_parentNodes.Add(key, parent);
            }
        }
Exemplo n.º 11
0
        private void GenerateReport(string fn1, string fn2, string xmlType, string outputDir, bool showAlert)
        {
            CLog               log           = CLog.CreateInstance();
            List <CLogRec>     logList       = log.GetLogs();
            List <CSummaryRec> logSummary    = log.GetSummary();
            string             strReportName = "CmpReport_ " +
                                               System.IO.Path.GetFileName(fn2).Split('.').First() + "_" +
                                               DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") +
                                               ".xlsx";
            string strLogName = "CmpLog_" +
                                DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") +
                                ".txt";

            if (logList.Count > 0)
            {
                List <IXmlSettingReportDictionary> dicList = new List <IXmlSettingReportDictionary>();
                IXmlSetting currentSetting =
                    m_SettingFactory.ReadSettingCollection(m_ToolSetting.GetXmlSettingFilePath().Value)
                    .GetSetting(xmlType);
                foreach (List <IXmlSettingReportDictionary> tmpList
                         in from IXmlSettingNode tmp
                         in currentSetting.GetNodes
                         select tmp.GetDictionarys)
                {
                    dicList.AddRange(tmpList);
                }

                Microsoft.Office.Interop.Excel.Application objExcel     = null;
                Microsoft.Office.Interop.Excel.Workbook    objWorkbook  = null;
                Microsoft.Office.Interop.Excel.Worksheet   objWorksheet = null;
                try
                {
                    objExcel = new Microsoft.Office.Interop.Excel.Application();

                    objExcel.Visible             = false;
                    objExcel.SheetsInNewWorkbook = 3;
                    objWorkbook = objExcel.Workbooks.Add();

                    //write report issue dictionary
                    objWorksheet      = objWorkbook.Worksheets[1];
                    objWorksheet.Name = "Report Dictionary";

                    string[] aTitle = new[] { "Issue Source",
                                              "Issue Category",
                                              "Issue Instruction" };
                    int intLineNo = 1;
                    List <CXmlSettingRptDicRep> listOfRptDic =
                        (from tmp in dicList
                         select new CXmlSettingRptDicRep
                    {
                        source = tmp.issue_source,
                        category = tmp.issue_category,
                        instruction = tmp.issue_instruction
                    }
                        ).ToList();
                    SaifeiAsm.ExcelHelper.WriteData(objWorksheet,
                                                    ref intLineNo,
                                                    SaifeiAsm.ExcelHelper.ObjectParseMethord.UsingFields,
                                                    listOfRptDic,
                                                    aTitle);
                    intLineNo = intLineNo + 2;
                    objWorksheet.Cells[intLineNo, 2] = "General Notes:";
                    foreach (string strGeneralNote in currentSetting.GeneralNotes)
                    {
                        objWorksheet.Cells[intLineNo, 3] = strGeneralNote;
                        intLineNo = intLineNo + 1;
                    }
                    //write report summary
                    objWorksheet      = objWorkbook.Worksheets[2];
                    objWorksheet.Name = "Report Summary";
                    aTitle            = new[] { "Section",
                                                "Attribute Name",
                                                "Count" };
                    intLineNo = 1;
                    SaifeiAsm.ExcelHelper.WriteData <CSummaryRec>(objWorksheet,
                                                                  ref intLineNo,
                                                                  SaifeiAsm.ExcelHelper.ObjectParseMethord.UsingFields,
                                                                  logSummary,
                                                                  aTitle);
                    //write report content
                    objWorksheet      = objWorkbook.Worksheets[3];
                    objWorksheet.Name = "Compare Report";
                    aTitle            = new[] { "TimeStamp",
                                                "Category",
                                                "Source",
                                                "Indentifier",
                                                "Path",
                                                "Attribute Name",
                                                "Old Attribute Name",
                                                "New Attribute Name" };
                    intLineNo = 1;
                    SaifeiAsm.ExcelHelper.WriteData <CLogRec>(objWorksheet,
                                                              ref intLineNo,
                                                              SaifeiAsm.ExcelHelper.ObjectParseMethord.UsingFields,
                                                              logList,
                                                              aTitle);
                    objWorkbook.SaveAs(outputDir + "\\" + strReportName);
                    objWorkbook.Close();
                    objExcel.Visible = true;
                    objExcel.Quit();
                    objWorksheet = null;
                    objWorkbook  = null;
                    objExcel     = null;
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show("Error happened: '"
                                                   + e.Message
                                                   + "' Report could not be generated.");
                }
                finally
                {
                    if (objWorksheet != null)
                    {
                        objWorksheet = null;
                    }
                    if (objWorkbook != null)
                    {
                        objWorkbook.Close();
                        objWorkbook = null;
                    }
                    if (objExcel != null)
                    {
                        objExcel.Quit();
                        objExcel = null;
                    }
                }
            }

            if (showAlert && logList.Count > 0)
            {
                System.Windows.MessageBox.Show("Compare Report is Generated.\n" +
                                               "Please Check Folder '" + outputDir + "'.");
            }
            else if (logList.Count > 0)
            {
                RecordTextLog(outputDir + "\\" + strLogName,
                              "Differents is found between '" + fn1 + "' and '" + fn2
                              + "'. Please check compare report " + outputDir + "\\" + strReportName);
            }
            else
            {
                RecordTextLog(outputDir + "\\" + strLogName,
                              "Files '" + fn1 + "' and '" + fn2
                              + "' are identical per compare setting.");
            }
        }
        public pnlDictionaryEdtPanelViewModel(IEventAggregator ea, IXmlCompareToolSetting ToolSetting, IXmlCompareUserControl UserControl, IXmlSettingReportDictionary CurrentReportDictionary, IXmlSettingNode _CurrentNode, IXmlSetting CurrentSetting)
        {
            _ea = ea;
            _ea.GetEvent <NodeEvent>().Subscribe(GetNode);
            _ea.GetEvent <SourceListEvent>().Subscribe(GetSource);
            _ea.GetEvent <SettingEvent>().Subscribe(GetSetting);
            _ea.GetEvent <SourceEvent>().Subscribe(GetNodetype);

            _ToolSetting             = ToolSetting;
            _UserControl             = UserControl;
            CurrentNode              = _CurrentNode;
            _CurrentReportDictionary = CurrentReportDictionary;

            UpdateCommand        = new DelegateCommand(UpdateCommandExecute);
            DeleteCommand        = new DelegateCommand(DeleteCommandExecute);
            AddCommand           = new DelegateCommand(AddCommandExecute);
            UpdateGeneralCommand = new DelegateCommand(UpdateGeneralCommandExecute);

            Editable = _UserControl.IsUserHasPriviledge(_UserControl.GetCurrentUser(), "XmlSettingFilePath");

            _IssueCategoryList_1.Add(XmlSettingRptDicCategory.ChangedAttribute.ToString());
            _IssueCategoryList_1.Add(XmlSettingRptDicCategory.DeletedAttribute.ToString());
            _IssueCategoryList_1.Add(XmlSettingRptDicCategory.AddedAttribute.ToString());

            _IssueCategoryList_2.Add(XmlSettingRptDicCategory.DeletedChildNode.ToString());
            _IssueCategoryList_2.Add(XmlSettingRptDicCategory.AddedChildNode.ToString());
        }
 public void GetSetting(IXmlSetting setting)
 {
     _CurrentSetting = setting;
 }
 public void BindDictionary(ref IXmlSettingNode iNode, ref IXmlSetting iSetting)
 {
     CurrentNode     = iNode;
     _CurrentSetting = iSetting;
 }
Exemplo n.º 15
0
        public void RemoveSetting(IXmlSetting setting)
        {
            CXmlSettingImp value = (CXmlSettingImp)setting;

            m_NodeSettingCollection.Remove(value);
        }