Пример #1
0
        private Incident AddIncidentToDataGrid(string incidentName, string incidentText, string incidentSolution, string incidentNotes)
        {
            Incident incidentObj = new Incident();
            incidentObj.Name = incidentName;
            incidentObj.IncidentText = incidentText;
            incidentObj.Solution = incidentSolution;
            incidentObj.Notes = incidentNotes;

            dgvIncidents.Rows.Add();
            dgvIncidents.Rows[dgvIncidents.Rows.Count - 1].Cells["dgvcName"].Value = incidentObj.Name;
            dgvIncidents.Rows[dgvIncidents.Rows.Count - 1].Cells["dgvcIncident"].Value = incidentObj.IncidentText;
            dgvIncidents.Rows[dgvIncidents.Rows.Count - 1].Cells["dgvcSolution"].Value = incidentObj.Solution;
            dgvIncidents.Rows[dgvIncidents.Rows.Count - 1].Cells["dgvcNotes"].Value = incidentObj.Notes;

            return incidentObj;
        }
Пример #2
0
 private void SaveIncident(string incidentName, string incidentText, string incidentSolution, string incidentNotes)
 {
     try {
         if (IsValidToAddIncident(txtIncidentName.Text, txtIncident.Text, txtIncidentSolution.Text, false)) {
             Incident incident = new Incident();
             incident.Name = txtIncidentName.Text;
             incident.IncidentText = txtIncident.Text;
             incident.Solution = txtIncidentSolution.Text;
             incident.Notes = txtIncidentNotes.Text;
             CreateIncidentFile(incident);
         }
     } catch (Exception ex) {
         ShowCustomError(ex.Message, false);
     }
 }
Пример #3
0
 private void CreateIncidentFile(Incident incident)
 {
     if (!Directory.Exists(rulesDirectory + @"\Incidents\")) {
         DialogResult dialog = ShowCustomError("Incidents directory not found, do you want to create one ?", true);
         if (dialog == DialogResult.Yes) {
             Directory.CreateDirectory(rulesDirectory + @"\Incidents\");
         }
     }
     StreamWriter writer = new StreamWriter(rulesDirectory + @"\Incidents\" + incident.Name + ".inc");
     try {
         writer.Write(incident.Name + "\n#END#\n");
         writer.Write(incident.IncidentText + "\n#END#\n");
         writer.Write(incident.Solution + "\n#END#\n");
         writer.Write(incident.Notes);
     } finally {
         if (writer != null) {
             writer.Close();
         }
     }
 }
Пример #4
0
 private Incident ReadIncidentFiles(string fileName)
 {
     Incident incidentObj = new Incident();
     StreamReader reader = new StreamReader(fileName);
     try {
         string fileText = reader.ReadToEnd();
         string[] delimiter = new string[] { "\n#END#\n" };
         string[] incidentAttributes = fileText.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
         if (incidentAttributes.Length < 4) {
             return null;
         }
         incidentObj.Name = incidentAttributes[0];
         incidentObj.IncidentText = incidentAttributes[1];
         incidentObj.Solution = incidentAttributes[2];
         incidentObj.Notes = incidentAttributes[3];
         return incidentObj;
     } finally {
         if (reader != null) {
             reader.Close();
         }
     }
 }