예제 #1
0
        /// <summary>
        /// Display certificate file
        /// </summary>
        /// <param name="item">Document file information</param>
        public void DisplayCertificateFile(Document item)
        {
            if (item == null)
            {
                AlertDisplay(Strings.CertificateNotHaveDocumentDisplay);
                return;
            }
            string path = string.Concat(App.CurrentUser.FilePath, item.FilePath, item.Filename).Replace("/", "\\");
            //Check if it is border agent and try to open a document of different entry point, return document using a webpage
            bool isBorderAgent = App.CurrentUser.IsInRole(UserRoleEnum.BorderAgent, UserRoleEnum.LOAdmin);
            bool isFileFromServer = false;
            //This applies for border agents less agents of LO entrypoint. LO entry point always open files from its machine
            if (isBorderAgent && !App.CurrentUser.IsEntryPointLo)
            {
                if (App.CurrentUser.EntryPointId.HasValue && Certificate.EntryPointId.HasValue)
                {
                    if (App.CurrentUser.EntryPointId != Certificate.EntryPointId)
                    {
                        path = GetUrlToOpenFileFromServer(item, path);
                        isFileFromServer = true;
                    }
                }
            }
            if (!isFileFromServer)
            {
                if (!File.Exists(@path))
                {
                    if (isBorderAgent)
                    {
                        path = GetUrlToOpenFileFromServer(item, path);
                        isFileFromServer = true;
                    }
                    else
                    {
                    AlertDisplay(string.Concat(Strings.FileNotExist, item.Filename));
                    return;
                }
            }
            }
            if (App.Current.IsRunningOutOfBrowser)
            {
                MyHyperlinkButton button = new MyHyperlinkButton();
                button.NavigateUri = new Uri(path);
                button.TargetName = "_blank";
                button.ClickMe();
            }
            else
                //this option not work for in browser
                System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(path), "_blank");

            if (isFileFromServer)
                GlobalAccessor.Instance.MessageStatus = string.Format(Strings.OpeningDocumentFromServer, item.Filename);
            else
            GlobalAccessor.Instance.MessageStatus = string.Format(Strings.OpeningDocument, item.Filename);
        }
예제 #2
0
        /// <summary>
        /// Execute when a documents were loaded
        /// </summary>
        /// <param name="operation">Operation result</param>
        private void LoadDocumentCompleted(LoadOperation<Document> operation)
        {
            HandleLoadOperation(operation, () =>
            {
                _currentDocument = null;
                DocumentList.Clear();
                foreach (var document in operation.Entities.OrderBy(x => x.IsSupporting).ThenBy(x => x.CreationDate))
                    DocumentList.Add(document);

                foreach (Document item in DocumentList)
                {
                    item.PropertyChanged += DocumentPropertyChanged;
                }

                _context.Load(_context.GetReleaseNotesByCertificateIdQuery(Certificate.CertificateId), LoadBehavior.RefreshCurrent, GetReleaseNotesByCertificateIdCompleted, null);
            });
        }
예제 #3
0
        /// <summary>
        /// Download the corresponding template
        /// </summary>
        /// <param name="item">document item parameter</param>
        private void Download(Document item)
        {
            //if item null, downoad new word template
            if (item == null)
            {
                var serviceUri = System.Windows.Application.Current.Host.Source.AbsoluteUri;
                string currentUri = serviceUri.Replace(serviceUri.Split('/').Last(), "");
                currentUri = currentUri.Replace("ClientBin/", "");
                string fullFilePath = string.Format("{0}DownloadFile.aspx?CertificateId={1}",
                        currentUri,
                        Certificate.CertificateId);

                Uri url = new Uri(fullFilePath);
                if (App.Current.IsRunningOutOfBrowser)
                {
                    MyHyperlinkButton button = new MyHyperlinkButton();
                    button.NavigateUri = url;
                    button.TargetName = "_blank";
                    button.ClickMe();
                }
                else
                    System.Windows.Browser.HtmlPage.Window.Navigate(url, "_newWindow", "toolbar=0,menubar=0,resizable=1,scrollbars=1,top=0,left=0");
            }
            //When exist document, download this document
            else
            {
                DisplayCertificateFile(item);
            }
        }
예제 #4
0
 /// <summary>
 /// Command to edit document
 /// </summary>
 /// <param name="item">Document item parameter</param>
 private void EditDocument(Document item)
 {
     if (DocumentEditionRequested != null)
     {
         DocumentViewModel model = new DocumentViewModel(item);
         model.SavedItem += OnDocumentSaved;
         DocumentEditionRequested(this, new ContextEditionEventArgs<DocumentViewModel>(model));
     }
 }
예제 #5
0
 private static string GetUrlToOpenFileFromServer(Document item, string path)
 {
     var serviceUri = System.Windows.Application.Current.Host.Source.AbsoluteUri;
     string currentUri = serviceUri.Replace(serviceUri.Split('/').Last(), "");
     currentUri = currentUri.Replace("ClientBin/", "");
     path = string.Format("{0}DownloadFile.aspx?DocumentId={1}",
             currentUri,
            item.DocumentId
             );
     return path;
 }