Exemplo n.º 1
0
 public DuplicateItemOptions(Multimedia duplicate, int sizeInBytes, Boolean managerMode = false)
 {
     InitializeComponent();
     this.DuplicateItem = duplicate;
     lblDescription.Content = "There already exists a multimedia item with the name and size ('" + duplicate.Name + "', " +  ByteLengthConverter.FormatBytes(sizeInBytes) + ").";
     if (managerMode) {
         optContinue.IsChecked = true;
         optLinkToExisting.IsEnabled = false;
         optLinkToExisting.IsChecked = false;
     }
 }
Exemplo n.º 2
0
        public override FileInfo GenerateLoanForm(Multimedia template, Loan loan, List<LoanMaterial> material, List<Trait> traits, Contact originator, Contact requestor, Contact receiver)
        {
            var tempFile = TempFileManager.NewTempFilename(".docx");
            var bytes = SupportService.GetMultimediaBytes(template.MultimediaID);

            Func<String, String> fieldDataFunc = (String fieldName) => {
                return base.SubstitutePlaceHolder(NormaliseFieldName(fieldName), loan, material, traits, originator, requestor, receiver);
            };

            Merge(fieldDataFunc, bytes, tempFile);
            return new FileInfo(tempFile);
        }
Exemplo n.º 3
0
        public MultimediaDetails(Multimedia multimedia, User user)
            : base(user, "Multimedia::" + multimedia.MultimediaID)
        {
            InitializeComponent();
            this.Multimedia = new MultimediaViewModel(multimedia);
            AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Multimedia, Multimedia));
            AddTabItem("Ownership", new OwnershipDetails(multimedia));
            txtArtist.BindUser(user, "tblMultimedia", "vchrArtist");
            txtOwner.BindUser(user, "tblMultimedia", "vchrOwner");
            txtIDNumber.BindUser(user, "MultimediaID", "tblMultimedia", "vchrNumber");
            this.DataContext = this.Multimedia;

            Multimedia.DataChanged += new DataChangedHandler(Multimedia_DataChanged);
        }
Exemplo n.º 4
0
 public abstract FileInfo GenerateLoanForm(Multimedia template, Loan loan, List<LoanMaterial> material, List<Trait> traits, Contact originator, Contact requestor, Contact receiver);
Exemplo n.º 5
0
        public static AbstractLoanFormGenerator GetLoanFormGenerator(Multimedia template)
        {
            var extension = (template == null ? "" : (template.FileExtension == null ? "" : template.FileExtension));

            if (extension.Equals("docx", StringComparison.CurrentCultureIgnoreCase)) {
                // Do OpenXML template substitution
                return new OpenXMLLoanFormGenerator();
            } else if (extension.Equals("rtf", StringComparison.CurrentCultureIgnoreCase)) {
                // Old fashioned RTF field substitution
                return new RTFLoanFormGenerator();
            }

            return null;
        }
Exemplo n.º 6
0
        private string ChooseFilename(Loan loan, Multimedia template)
        {
            var dlg = new SaveFileDialog();
            var defaultDir = Config.GetUser(User, "Loans.Forms.DefaultOutputDirectory", dlg.InitialDirectory);
            if (!string.IsNullOrWhiteSpace(defaultDir)) {
                var dirinfo = new DirectoryInfo(defaultDir);
                if (dirinfo.Exists) {
                    dlg.InitialDirectory = dirinfo.FullName;
                }
            }

            var borrowerName = LoanService.FormatName("", loan.RequestorGivenName, loan.RequestorName);
            dlg.FileName = SystemUtils.StripIllegalFilenameChars(string.Format("{0}_{1}_{2:yyyy-MM-dd}.{3}", loan.LoanNumber, borrowerName, DateTime.Now, template.FileExtension));
            if (dlg.ShowDialog() == true) {
                var finfo = new FileInfo(dlg.FileName);
                Config.SetUser(User, "Loans.Forms.DefaultOutputDirectory", finfo.DirectoryName);
                return dlg.FileName;
            }
            return null;
        }
Exemplo n.º 7
0
 public MultimediaDuplicateAction CheckDuplicate(FileInfo file, out Multimedia duplicate)
 {
     int sizeInBytes = 0;
     duplicate = Service.FindDuplicateMultimedia(file, out sizeInBytes);
     if (duplicate != null) {
         var frm = new DuplicateItemOptions(duplicate, sizeInBytes);
         frm.Owner = this.FindParentWindow();
         if (frm.ShowDialog().ValueOrFalse()) {
             return frm.SelectedAction;
         } else {
             return MultimediaDuplicateAction.Cancel;
         }
     }
     return MultimediaDuplicateAction.NoDuplicate;
 }