Beispiel #1
0
 private bool IsImageAttachement(AttachmentDetailViewModel attachment)
 {
     return(attachment.Model.ContentType == ".JPG" ||
            attachment.Model.ContentType == ".TIF" ||
            attachment.Model.ContentType == ".PNG"
            );
 }
Beispiel #2
0
        private AttachmentDetailViewModel InternalAddFacilityAttachment(InvFacility facility)
        {
            var attahcment = new InvFacilityAttachment()
            {
                ID            = Guid.NewGuid(),
                IsActive      = true,
                Title         = "Attachment-00",
                InvFacilityID = Model.SYNC_ID,
                CreatedBy     = _applicationContext.ActiveUser,
                CreatedOn     = DateTime.Now,
            }
            ;

            var eventAggreggor     = IoC.Get <IEventAggregator>();
            var windowManager      = IoC.Get <IInvWindowManager>();
            var facilityService    = IoC.Get <IFacilitiesService>();
            var applicationContext = IoC.Get <IApplicationContext>();
            var attachmentVm       = new AttachmentDetailViewModel(attahcment, applicationContext, eventAggreggor, _windowManager, _facilitiesService);
            var vm       = new AttachmentCreateViewModel(attachmentVm, eventAggreggor, windowManager);
            var settings = new Dictionary <string, object>
            {
                { "ResizeMode", ResizeMode.NoResize },
                { "WindowStartupLocation", WindowStartupLocation.CenterScreen }
            };

            if (windowManager.ShowDialog(vm, null, settings) ?? false)
            {
                return(attachmentVm);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Initializes a new instance of the MainWindowViewModel class.
        /// </summary>
        public AttachmentCreateViewModel(AttachmentDetailViewModel attachment,
                                         IEventAggregator eventAggregator,
                                         IInvWindowManager windowManager
                                         )
            : base(eventAggregator)
        {
            FacilityAttachment = attachment;
            _windowManager     = windowManager;

            this.SubscribeToEvents();

            Init();
        }
Beispiel #4
0
        private void UnloadAttachment(AttachmentDetailViewModel facilityAttachment)
        {
            try
            {
                if (string.IsNullOrEmpty(facilityAttachment.ImageSource))
                {
                    return;
                }

                File.Delete(facilityAttachment.ImageSource);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
Beispiel #5
0
        private void LoadAttachment(AttachmentDetailViewModel facilityAttachment)
        {
            try
            {
                if (facilityAttachment.Model.Data == null)
                {
                    return;
                }

                var fileName = Path.Combine(_TempImagePath, Guid.NewGuid().ToString() + facilityAttachment.Model.ContentType);
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                File.WriteAllBytes(fileName, facilityAttachment.Model.Data);

                facilityAttachment.ImageSource = fileName;
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }