예제 #1
0
        private LocationHandler()
        {
            xmlFileHandler = new XMLFileHandler();
            pubList = new List<LocationData>();
            LocationData d = new LocationData();
            pubList = xmlFileHandler.readPubXMLFile();
            routeList = xmlFileHandler.readRouteXMLFile(pubList);

            foreach(LocationData location in pubList)
            {
                location.setPubdayTimes();
            }
        }
예제 #2
0
        internal string CreateArchive(string CurrentFileName)
        {
            string tempDirectory       = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            string tempArchiveFileName = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(CurrentFileName) + ".show");

            Directory.CreateDirectory(tempDirectory);
            Program.mainForm.ReportStatus("Creating Archive: Copying files");
            //get a list of the sound files
            List <string> archCues = new List <string>();

            foreach (SFX cue in Cues)
            {
                archCues.Add(cue.FileName);
            }
            archCues = archCues.Distinct().ToList();    //only need one copy of each file
            foreach (string audioFileName in archCues)
            {
                if (!string.IsNullOrEmpty(audioFileName))
                {
                    Program.mainForm.ReportStatus("Creating Archive: Copying " + Path.GetFileName(audioFileName));
                    File.Copy(audioFileName, Path.Combine(tempDirectory, Path.GetFileName(audioFileName)));
                }
            }

            Program.mainForm.ReportStatus("Creating Archive: Copying Cue List");
            //save a copy of the xml show file with audio file paths removed
            XMLFileHandler <Show> .UntrackedSave(this, Path.Combine(tempDirectory, Path.GetFileName(CurrentFileName)));

            Show tempShow = XMLFileHandler <Show> .Load(Path.Combine(tempDirectory, Path.GetFileName(CurrentFileName)));

            foreach (SFX cue in tempShow.Cues)
            {
                cue.FileName = Path.GetFileName(cue.FileName);      //remove the path
            }
            XMLFileHandler <Show> .UntrackedSave(tempShow, Path.Combine(tempDirectory, Path.GetFileName(CurrentFileName)));

            //all files now in temp folder
            Program.mainForm.ReportStatus("Creating Archive: Combining Files");
            ZipFile.CreateFromDirectory(tempDirectory, tempArchiveFileName);

            Directory.Delete(tempDirectory, true);
            Program.mainForm.ReportStatus("Creating Archive: Archive Complete");
            return(tempArchiveFileName);
        }
예제 #3
0
    private static void SaveInputFile(string fileName, InputStrings inputStrings)
    {
        string filepath = realFilePath + fileName + ".xml";

        if (File.Exists(filepath))
        {
            File.Delete(filepath);
        }

        StreamWriter writer;
        FileInfo     t = new FileInfo(filepath);

        if (!t.Exists)
        {
            writer = t.CreateText();
        }
        else
        {
            t.Delete();
            writer = t.CreateText();
        }
        writer.Write(XMLFileHandler.ObjectToXml(inputStrings));
        writer.Close();
    }