Exemplo n.º 1
0
        /// <summary>
        /// Export Train
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnExport(object sender, EventArgs e)
        {
            SaveFileDialog export = new SaveFileDialog();

            export.Title            = train.Baureihe + " Exportieren, Wähle das Verzeichniss";
            export.InitialDirectory = Log.GetExportFolder;
            export.DefaultExt       = ".train";
            export.Filter           = "Train File (*.train)|*.train";
            export.FileName         = $"{((Hersteller)train.Hersteller).ToString()}-{train.Baureihe}-{train.Farbe}";

            string path = "";

            if (export.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    ///Count Export Trains +1
                    train.FileExported++;
                    ///Convert and Collect data
                    ExportTrain newtrain = Api.GetExporttrain(train);
                    path = export.FileName;
                    Api.ExportTrain(newtrain, path);
                    ///Update Local Data
                    Loader.SaveData(Loader.GetDatabase);

                    Form1.instance.PrintPanelMessage("Lok Exportiert nach: " + path, false, null, 1);
                }
                catch (Exception ex)
                {
                    Form1.instance.PrintPanelMessage("Fehler beim Exportieren der Lok ", true, ex);
                }
            }
            Api.CollectRam();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Export an Train
        /// </summary>
        /// <param name="train"></param>
        /// <param name="path"></param>
        public static void ExportTrain(ExportTrain train, string path)
        {
            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream(path, FileMode.Create, FileAccess.Write);

            formatter.Serialize(stream, train);
            stream.Close();
            stream.Dispose();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Convert Train to Export Train
        /// </summary>
        /// <param name="train"></param>
        /// <returns></returns>
        public static ExportTrain GetExporttrain(Trains train)
        {
            ExportTrain tmp;

            byte[] image;

            if (!String.IsNullOrEmpty(train.ImagePath))
            {
                ///Get Image
                byte[] data = File.ReadAllBytes(train.ImagePath);
                image = new byte[data.Length];
                image = data;
                ///Train Export with Image
                tmp = new ExportTrain
                {
                    Baureihe             = train.Baureihe,
                    Farbe                = train.Farbe,
                    Erstellt             = train.Erstellt,
                    Katalognummer        = train.Katalognummer,
                    Seriennummer         = train.Seriennummer,
                    Kaufdatum            = train.Kaufdatum,
                    WartungsTag          = train.WartungsTag,
                    WartungsMonat        = train.WartungsMonat,
                    WartungsJahr         = train.WartungsJahr,
                    Decoderhersteller    = train.Decoderhersteller,
                    KaufTag              = train.KaufTag,
                    KaufMonat            = train.KaufMonat,
                    KaufJahr             = train.KaufJahr,
                    ImagePath            = train.ImagePath,
                    Idendifyer           = train.Idendifyer,
                    HatRauch             = train.HatRauch,
                    HatSound             = train.HatSound,
                    HatLichtWechsel      = train.HatLichtWechsel,
                    HatElektrischePandos = train.HatElektrischePandos,
                    HatTelex             = train.HatTelex,
                    HatStromKupplung     = train.HatStromKupplung,
                    CV1          = train.CV1,
                    CV2          = train.CV2,
                    CV3          = train.CV3,
                    CV4          = train.CV4,
                    CV5          = train.CV5,
                    Adresse      = train.Adresse,
                    Fahrstufen   = train.Fahrstufen,
                    Preis        = train.Preis,
                    FileExported = train.FileExported,
                    WebExported  = train.WebExported,
                    RPCExported  = train.RPCExported,
                    FileImported = train.FileImported,
                    WebImported  = train.WebImported,
                    RPCImported  = train.RPCImported,
                    LagerOrt     = train.LagerOrt,
                    LokType      = train.LokType,
                    Hersteller   = train.Hersteller,
                    SpurWeite    = train.SpurWeite,
                    LokProtokoll = train.LokProtokoll,
                    TrainImage   = image,
                };
                return(tmp);
            }
            else
            {
                ///Train Export Without Image
                tmp = new ExportTrain
                {
                    Baureihe             = train.Baureihe,
                    Farbe                = train.Farbe,
                    Erstellt             = train.Erstellt,
                    Katalognummer        = train.Katalognummer,
                    Seriennummer         = train.Seriennummer,
                    Kaufdatum            = train.Kaufdatum,
                    WartungsTag          = train.WartungsTag,
                    WartungsMonat        = train.WartungsMonat,
                    WartungsJahr         = train.WartungsJahr,
                    Decoderhersteller    = train.Decoderhersteller,
                    KaufTag              = train.KaufTag,
                    KaufMonat            = train.KaufMonat,
                    KaufJahr             = train.KaufJahr,
                    ImagePath            = train.ImagePath,
                    Idendifyer           = train.Idendifyer,
                    HatRauch             = train.HatRauch,
                    HatSound             = train.HatSound,
                    HatLichtWechsel      = train.HatLichtWechsel,
                    HatElektrischePandos = train.HatElektrischePandos,
                    HatTelex             = train.HatTelex,
                    HatStromKupplung     = train.HatStromKupplung,
                    CV1          = train.CV1,
                    CV2          = train.CV2,
                    CV3          = train.CV3,
                    CV4          = train.CV4,
                    CV5          = train.CV5,
                    Adresse      = train.Adresse,
                    Fahrstufen   = train.Fahrstufen,
                    Preis        = train.Preis,
                    FileExported = train.FileExported,
                    WebExported  = train.WebExported,
                    RPCExported  = train.RPCExported,
                    FileImported = train.FileImported,
                    WebImported  = train.WebImported,
                    RPCImported  = train.RPCImported,
                    LagerOrt     = train.LagerOrt,
                    LokType      = train.LokType,
                    Hersteller   = train.Hersteller,
                    SpurWeite    = train.SpurWeite,
                    LokProtokoll = train.LokProtokoll,
                };
                return(tmp);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Convert an Import train to System Train
        /// </summary>
        /// <param name="train"></param>
        /// <returns></returns>
        public static Trains GetInportTrain(ExportTrain train)
        {
            try
            {
                if (train.TrainImage.Length >= 8)
                {
                    File.WriteAllBytes(Log.GetTrainImageFolder + train.Baureihe + ".png", train.TrainImage);
                }
                ///Train Export Without Image
                Trains tmp = new Trains
                {
                    Baureihe             = train.Baureihe,
                    Farbe                = train.Farbe,
                    Erstellt             = train.Erstellt,
                    Katalognummer        = train.Katalognummer,
                    Seriennummer         = train.Seriennummer,
                    Kaufdatum            = train.Kaufdatum,
                    WartungsTag          = train.WartungsTag,
                    WartungsMonat        = train.WartungsMonat,
                    WartungsJahr         = train.WartungsJahr,
                    Decoderhersteller    = train.Decoderhersteller,
                    KaufTag              = train.KaufTag,
                    KaufMonat            = train.KaufMonat,
                    KaufJahr             = train.KaufJahr,
                    ImagePath            = Log.GetTrainImageFolder + train.Baureihe + ".png",
                    Idendifyer           = Guid.NewGuid().ToString(),
                    HatRauch             = train.HatRauch,
                    HatSound             = train.HatSound,
                    HatLichtWechsel      = train.HatLichtWechsel,
                    HatElektrischePandos = train.HatElektrischePandos,
                    HatTelex             = train.HatTelex,
                    HatStromKupplung     = train.HatStromKupplung,
                    CV1          = train.CV1,
                    CV2          = train.CV2,
                    CV3          = train.CV3,
                    CV4          = train.CV4,
                    CV5          = train.CV5,
                    Adresse      = train.Adresse,
                    Fahrstufen   = train.Fahrstufen,
                    Preis        = train.Preis,
                    FileExported = train.FileExported,
                    WebExported  = train.WebExported,
                    RPCExported  = train.RPCExported,
                    FileImported = train.FileImported++,
                    WebImported  = train.WebImported,
                    RPCImported  = train.RPCImported,
                    LagerOrt     = train.LagerOrt,
                    LokType      = train.LokType,
                    Hersteller   = train.Hersteller,
                    SpurWeite    = train.SpurWeite,
                    LokProtokoll = train.LokProtokoll,
                };

                Loader.AddTrain(tmp);
                Form1.instance.PrintPanelMessage("Lok wurde in das System Importiert.", false, null, 1);
                Form1.instance.RefreschList();
                return(tmp);
            }
            catch (Exception ex)
            {
                Form1.instance.PrintPanelMessage("Fehler beim Inportieren der Lok", true, ex);
                return(null);
            }
        }
Exemplo n.º 5
0
 public TrainPreview(string path)
 {
     InitializeComponent();
     train = Api.GetRawTrain(path);
     ShowInfos();
 }