Ejemplo n.º 1
0
 internal void AddDiscrepancy(string id, Discrepancy discrepancy)
 {
     if (discrepancy._description != string.Empty)
     {
         _discrepancies.Add(id, discrepancy);
     }
 }
Ejemplo n.º 2
0
 static internal void HandleGroup(ref Discrepancy discrepancy, string inValue, string outValue)
 {
     inValue  = HandleNullValue(inValue);
     outValue = HandleNullValue(outValue);
     if (inValue != outValue)
     {
         discrepancy._description += "group: " + ((outValue == string.Empty || outValue == null) ? "not set" : outValue) + Environment.NewLine;
         discrepancy._significant  = true;
     }
 }
Ejemplo n.º 3
0
 static internal void HandleComment(ref Discrepancy discrepancy, string inValue, string outValue, bool privateComment)
 {
     inValue  = HandleNullValue(inValue);
     outValue = HandleNullValue(outValue);
     if (inValue != outValue)
     {
         discrepancy._description += (privateComment ? "private " : "") + "comment: " +
                                     ((outValue == string.Empty) ? "not set" : outValue) + Environment.NewLine;
     }
 }
Ejemplo n.º 4
0
 static internal void HandleName(ref Discrepancy discrepancy, string inValue, string outValue)
 {
     inValue  = HandleNullValue(inValue);
     outValue = HandleNullValue(outValue);
     if (inValue != outValue)
     {
         discrepancy._description += "name: " + outValue + Environment.NewLine;
         discrepancy._significant  = true;
     }
 }
Ejemplo n.º 5
0
 static internal void HandlePrivate(ref Discrepancy discrepancy, string inValue, string outValue)
 {
     inValue  = HandleNullValue(inValue);
     outValue = HandleNullValue(outValue);
     if (inValue == string.Empty)
     {
         inValue = DefPar.Value.NO;
     }
     if (outValue == string.Empty)
     {
         outValue = DefPar.Value.NO;
     }
     if (inValue != outValue)
     {
         discrepancy._description += "private: " + (outValue != DefPar.Value.YES ? "not " : "") + "set" + Environment.NewLine;
         discrepancy._significant  = true;
     }
 }
Ejemplo n.º 6
0
        internal bool LoadFromFile()
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Title           = "Load discrepancy marker info from file ...";
                openFileDialog.Filter          = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
                openFileDialog.CheckPathExists = true;
                openFileDialog.CheckFileExists = true;
                openFileDialog.AddExtension    = true;
                openFileDialog.Multiselect     = false;

                if (openFileDialog.ShowDialog() == DialogResult.Cancel)
                {
                    return(false);
                }

                System.IO.StreamReader txtReader = new System.IO.StreamReader(openFileDialog.FileName);

                //read creation-date of info
                string strCreationDate = txtReader.ReadLine();
                _creationDate = Convert.ToDateTime(strCreationDate);

                //read concerned systems
                _concernedSystems.Clear();
                string strConcernedSystems = txtReader.ReadLine();
                foreach (string strConcernedSystem in strConcernedSystems.Split(new string[] { _entrySeparator }, StringSplitOptions.None))
                {
                    List <string> idAndName = strConcernedSystem.Split(new string[] { _idSeparator }, StringSplitOptions.None).ToList <string>();
                    if (idAndName.Count == 2)
                    {
                        _concernedSystems.Add(idAndName.ElementAt(0), idAndName.ElementAt(1));
                    }
                }

                //read discrepancies
                _discrepancies.Clear();
                string strDiscrepancies = txtReader.ReadToEnd();
                foreach (string strDiscrepancy in strDiscrepancies.Split(new string[] { _entrySeparator }, StringSplitOptions.None))
                {
                    List <string> idAndDiscrepancy = strDiscrepancy.Split(new string[] { _idSeparator }, StringSplitOptions.None).ToList <string>();
                    if (idAndDiscrepancy.Count == 2)
                    {
                        Discrepancy discrepancy = new Discrepancy();
                        discrepancy.FromStoreFormat(idAndDiscrepancy.ElementAt(1));
                        _discrepancies.Add(idAndDiscrepancy.ElementAt(0), discrepancy);
                    }
                }

                if (_creationDate == null || _concernedSystems.Count == 0 || _discrepancies.Count == 0)
                {
                    throw new System.ArgumentException("The selected file does not seem to contain the relevant information."); //to hand the error to the error handler
                }
                UserInfoHandler.ShowSuccess("Information successfully loaded.");
                return(true);
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowError("Failed to read info for markers from file because of the following error:"
                                          + Environment.NewLine + Environment.NewLine + exception.Message);
                return(false);
            }
        }