Ejemplo n.º 1
0
        public ExportAttachmentsModel(CommonUtils.AttachmentObject attachmentObject)
        {
            CompositionInitializer.SatisfyImports(this);

            mAttachmentObject = attachmentObject;

            var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetEquipmentAttachmentsCompleted += (s, e) =>
            {
                Attachments = new CmsObservableCollection<BaseEquipmentAttachment>(e.Result);

                var uploaderIds = (from x in Attachments select x.UploadedById).Distinct().ToList();

                var act = (from x in CMS.Cache.Users orderby x.LastName where x.ActiveUser select x).ToList();
                var inact = (from x in CMS.Cache.Users orderby x.LastName where !x.ActiveUser select x).ToList();

                Uploaders = new List<QuickUser>(act);
                Uploaders.AddRange(inact);

                var presentUploaders = (from x in Uploaders where uploaderIds.Contains(x.Id) select x).ToList();
                presentUploaders.Insert(0, new QuickUser { FirstName = ALL, Id = -1, ActiveUser = true });

                Uploaders = new List<QuickUser>(presentUploaders);
                SelectedUploader = Uploaders[0];

                mAttachmentsLoaded = true;
                OnRaiseLoaded();
            };
            cmsWebServiceClient.GetEquipmentAttachmentsAsync(attachmentObject);

            cmsWebServiceClient.GetAttachmentTypesCompleted += (s, e) =>
            {
                AttachmentTypes = new List<AttachmentType>(e.Result);
                AttachmentTypes.Insert(0, new AttachmentType { Name = ALL, Id = -1 });
                SelectedAttachmentType = AttachmentTypes[0];

                mAttachmenttypesLoaded = true;
                OnRaiseLoaded();
            };
            cmsWebServiceClient.GetAttachmentTypesAsync();

            OkCommand = new DelegateCommand<object>(OkHandler, CanExecuteOkButton);
            CancelCommand = new DelegateCommand<object>(CancelHandler);
        }
Ejemplo n.º 2
0
        //public ExportControlViewModel(Tab tab, ReportsUserControl reportUserControl,
        //    CommonUtils.SecurityObject securityObjectType, string appendage = "")
        public ExportControlViewModel(ExportControlParameters exportControlParameters)
        {
            mExportControlParameters = exportControlParameters;
            mTab = exportControlParameters.Tab;
            mAppendage = exportControlParameters.Appendage;
            mAttachmentObject = exportControlParameters.TypeCode;
            ShowAttachmentsDownload = exportControlParameters.ShowAttachmentDownload;
            //mReportUserControl = reportUserControl;

            //SetReportControlPriviledges();
            if (ShowAttachmentsDownload &&
                (mAttachmentObject == CommonUtils.AttachmentObject.Document ||
                 mAttachmentObject == CommonUtils.AttachmentObject.DocumentVersion))
            {
                ShowDocumentDownload = true;
            }

            OpenReportCommand = new DelegateCommand<object>(OpenReportHandler, CanClick);
            ExportAttachmentsCommand = new DelegateCommand<object>(ExportAttachmentsLinkHandler, CanClick);
            ExportDocumentsCommand = new DelegateCommand<object>(ExportDocumentsLinkHandler, CanClick);

            CMS.Cache.ReportLinks.CollectionChanged += (s, e) => RaisePropertyChanged("ReportLinks");
        }