示例#1
0
 /// <inheritdoc/>
 public (DialogResult Result, NefsArchiveSource Source) ShowNefsEditOpenFileDialog(
     ISettingsService settingsService,
     IProgressService progressService,
     INefsReader reader)
 {
     using (var dialog = new OpenFileForm(settingsService, this, progressService, reader, this.FileSystem))
     {
         var result = dialog.ShowDialog();
         var source = dialog.ArchiveSource;
         return(result, source);
     }
 }
示例#2
0
        private void 打开ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            OpenFileForm openFile = new OpenFileForm();

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                mPointSet          = PointSet.ReadFromCSV(openFile.PointSetFileName);
                this.Width         = 1000;
                this.Height        = 800;
                this.UserOperation = UserOperationType.DisplayThePointSet;
                agisControl.LoadPointSet(mPointSet, 1.2);
                agisControl.Refresh();
            }
            return;
        }
示例#3
0
        public void OpenDocument()
        {
            //Step 1: Login to DokuFlex to get the ticket;
            var ticket = Session.GetTikect();

            //Step 2: get addional info
            var community = (UserGroup)null;
            var folder    = (FileFolder)null;
            var file      = (FileFolder)null;

            using (var form = new OpenFileForm(ticket, _fileExtensions))
            {
                if (form.ShowOpenFileDialog())
                {
                    community = form.Group;
                    folder    = form.Folder;
                    file      = form.File;
                }
                else
                {
                    return;
                }
            }

            TrackingListManager.Reload();

            var trackingItem = TrackingListManager.GetByFileId(file.id);

            if (trackingItem != null && File.Exists(trackingItem.Path))
            {
                if (trackingItem.ModifiedTime < file.modifiedTime)
                {
                    using (var form = new TransferProgressForm())
                    {
                        if (form.DownloadFile(ticket, trackingItem.FileId, trackingItem.Path))
                        {
                            TrackOff();
                            Globals.ThisAddIn.Application.Documents.Open(trackingItem.Path);
                            TrackOn();
                            trackingItem.ModifiedTime = file.modifiedTime;
                            TrackingListManager.Save();
                        }
                    }
                }
                else
                {
                    //Open the document.
                    TrackOff();
                    this.Application.Documents.Open(trackingItem.Path);
                    TrackOn();
                }
            }
            else
            {
                //Step 3: Create directory and file paths
                var currentDir  = String.Format("{0}\\{1}", DFEnvironment.GetSpecialFolder(DFEnvironment.SpecialFolder.Documents), community.name);
                var currentPath = string.Format("{0}\\{1}", currentDir, file.name);

                try
                {
                    if (!Directory.Exists(currentDir))
                    {
                        try
                        {
                            Directory.CreateDirectory(currentDir);
                        }
                        catch (Exception)
                        {
                            //Silent exception
                        }
                    }
                }
                catch (Exception e)
                {
                    LogFactory.CreateLog().LogError(e);
                    MessageBox.Show(e.Message, this.Application.Name, MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }

                //Step 4: download the file
                using (var form = new TransferProgressForm())
                {
                    if (form.DownloadFile(ticket, file.id, currentPath))
                    {
                        TrackOff();
                        Globals.ThisAddIn.Application.Documents.Open(currentPath);
                        TrackOn();

                        trackingItem = new TrackingItem()
                        {
                            Name          = file.name,
                            LastWriteTime = DateTime.Now.ToFileTimeUtc(),
                            Path          = currentPath,
                            Type          = "F",
                            GroupId       = community.id,
                            FolderId      = folder.id,
                            FileId        = file.id,
                            ModifiedTime  = file.modifiedTime
                        };

                        TrackingListManager.Add(trackingItem);
                        TrackingListManager.Save();
                    }
                }
            }
        }