Beispiel #1
0
        public static void CreateNewCourtCase(string SuspectName, DateTime SuspectDOB, string Crime, DateTime CrimeDate, int GuiltyChance, string CourtVerdict, DateTime ResultsPublishTime, bool Published, bool ResultsPublishedNotificationShown)
        {
            CourtCase courtcase = new CourtCase(SuspectName, SuspectDOB, Crime, CrimeDate, GuiltyChance, CourtVerdict, ResultsPublishTime, Published, ResultsPublishedNotificationShown);

            AddCourtCaseToXMLFile(CourtCaseFilePath, courtcase);
            courtcase.AddToCourtsMenuAndLists();
        }
Beispiel #2
0
        private static void AddCourtCaseToXMLFile(string File, CourtCase ccase)
        {
            try
            {
                XDocument xdoc = XDocument.Load(File);
                char[]    trim = new char[] { '\'', '\"', ' ' };


                XElement LSPDFRPlusElement = xdoc.Element("LSPDFRPlus");
                XElement CcaseElement      = new XElement("CourtCase",
                                                          new XAttribute("ID", ccase.XMLIdentifier),
                                                          new XElement("SuspectName", ccase.SuspectName),
                                                          new XElement("SuspectDOB", ccase.SuspectDOB.ToBinary()),
                                                          new XElement("Crime", ccase.Crime),
                                                          new XElement("CrimeDate", ccase.CrimeDate.ToBinary()),
                                                          new XElement("GuiltyChance", ccase.GuiltyChance.ToString()),
                                                          new XElement("CourtVerdict", ccase.CourtVerdict),
                                                          new XElement("ResultsPublishTime", ccase.ResultsPublishTime.ToBinary()),
                                                          new XElement("Published", ccase.ResultsPublished.ToString()),
                                                          new XElement("ResultsPublishedNotificationShown", ccase.ResultsPublishedNotificationShown.ToString()));
                LSPDFRPlusElement.Add(CcaseElement);
                xdoc.Save(File);
            }
            catch (Exception e)
            {
                Game.LogTrivial("LSPDFR+ encountered an exception writing a court case to \'" + File + "\'. It was: " + e.ToString());
                Game.DisplayNotification("~r~LSPDFR+: Error while working with CourtCases.xml.");
            }
        }
Beispiel #3
0
 public static void DeleteCourtCase(CourtCase CourtCase)
 {
     DeleteCourtCaseFromXMLFile(CourtCaseFilePath, CourtCase);
     if (CourtSystem.PublishedCourtCases.Contains(CourtCase))
     {
         if (Menus.PublishedResultsList.Items.Count == 1)
         {
             Menus.PublishedResultsList.Items.Add(new TabItem(" ")); CourtCase.ResultsMenuCleared = false;
         }
         Menus.PublishedResultsList.Items.RemoveAt(CourtSystem.PublishedCourtCases.IndexOf(CourtCase));
         CourtSystem.PublishedCourtCases.Remove(CourtCase);
     }
     if (CourtSystem.PendingCourtCases.Contains(CourtCase))
     {
         if (Menus.PendingResultsList.Items.Count == 1)
         {
             Menus.PendingResultsList.Items.Add(new TabItem(" ")); CourtCase.PendingResultsMenuCleared = false;
         }
         Menus.PendingResultsList.Items.RemoveAt(CourtSystem.PendingCourtCases.IndexOf(CourtCase));
         CourtSystem.PendingCourtCases.Remove(CourtCase);
     }
 }
Beispiel #4
0
        private static void DeleteCourtCaseFromXMLFile(string File, CourtCase ccase)
        {
            try
            {
                XDocument       xdoc = XDocument.Load(File);
                char[]          trim = new char[] { '\'', '\"', ' ' };
                List <XElement> CourtCasesToBeDeleted = new List <XElement>();
                CourtCasesToBeDeleted = (from x in xdoc.Descendants("CourtCase") where (((string)x.Attribute("ID")).Trim(trim) == ccase.XMLIdentifier) select x).ToList <XElement>();

                if (CourtCasesToBeDeleted.Count > 0)
                {
                    foreach (XElement ele in CourtCasesToBeDeleted)
                    {
                        ele.Remove();
                    }
                }
                xdoc.Save(File);
            }
            catch (Exception e)
            {
                Game.LogTrivial("LSPDFR+ encountered an exception deleting an element from \'" + File + "\'. It was: " + e.ToString());
                Game.DisplayNotification("~r~LSPDFR+: Error while working with CourtCases.xml.");
            }
        }
Beispiel #5
0
 public static void OverwriteCourtCase(CourtCase CourtCase)
 {
     DeleteCourtCaseFromXMLFile(CourtCaseFilePath, CourtCase);
     AddCourtCaseToXMLFile(CourtCaseFilePath, CourtCase);
 }