コード例 #1
0
        private bool CheckRequiredFields()
        {
            var bezeichnung     = !string.IsNullOrEmpty(Bezeichnung);
            var valutaDatum     = !string.IsNullOrEmpty(ValutaDatum.ToString());
            var selectedTypItem = !string.IsNullOrEmpty(SelectedTypItem);

            return(bezeichnung && valutaDatum && selectedTypItem);
        }
コード例 #2
0
        private async void OnCmdSpeichern()
        {
            if (string.IsNullOrEmpty(Bezeichnung) || string.IsNullOrEmpty(SelectedTypItem) ||
                string.IsNullOrEmpty(Stichwoerter) || ValutaDatum == null)
            {
                MessageBox.Show("Es müssen alle Pflichtfelder ausgefüllt werden!", "Achtung!", MessageBoxButton.OK,
                                MessageBoxImage.Warning);
                return;
            }

            var storage = LoginView.ServiceProvider.GetService <IStorageService>();

            try
            {
                using (var stream = File.OpenRead(_filePath))
                {
                    var doc = new Document()
                    {
                        Id       = Guid.NewGuid(),
                        File     = stream,
                        Metadata = new MetadataItem()
                        {
                            CreationTime = Erfassungsdatum,
                            FileEnding   = Path.GetExtension(_filePath),
                            FileName     = Bezeichnung,
                            Keywords     = Stichwoerter,
                            Typ          = SelectedTypItem,
                            Username     = Benutzer,
                            Valuta       = ValutaDatum.GetValueOrDefault()
                        }
                    };

                    await storage.SaveDocument(doc);
                }

                if (IsRemoveFileEnabled)
                {
                    File.Delete(_filePath);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Failed to Save!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            _navigateBack();
        }
コード例 #3
0
        private void CreateXML(String _fileGUID)
        {
            String _XMLfileName     = _fileGUID + "_Metadata.xml";
            String _XMLfullFilePath = _fullPathDestination + "\\" + _XMLfileName;

            XmlWriter xml = XmlWriter.Create(_XMLfullFilePath);

            xml.WriteStartElement("Document");
            xml.WriteElementString("Bezeichnung", Bezeichnung);
            xml.WriteElementString("ValutaDatum", ValutaDatum.ToString());
            xml.WriteElementString("Typ", SelectedTypItem);
            xml.WriteElementString("Stichwoerter", Stichwoerter);
            xml.WriteElementString("ErfassungsDatum", Erfassungsdatum.ToString());
            xml.WriteElementString("Benutzer", Benutzer);
            xml.WriteEndElement();
            xml.Flush();
        }