Ejemplo n.º 1
0
        private void OnInitialiseMapManagerCompleted(object sender, InitialiseMapManagerEventArgs e)
        {
            if (GetDomainId().HasValue)
            {
                //if the starting NodeUid is provided use that
                if (GetNodeId().HasValue)
                {
                    InitializeNavigator(GetDomainId().Value, GetNodeId().Value);
                }
                //if no starting NodeUid is provided find the domain node and use that
                else
                {
                    _mapManager.AcquireNodesByDomainCompleted.RegisterEvent(GetDomainId().Value, new EventHandler <Proxy.NodesEventArgs>(OnAcquireNodesByDomainCompleted));
                    _mapManager.AcquireNodesByDomainAsync(GetDomainId().Value);
                }
            }
            else
            {
                // If there is no domain ID supplied then provide a dialog box to select one.
                DomainSelectionDialog selectionDialog = new DomainSelectionDialog();
                // TODO: The following lines need to be modded so that the MapManager is passed through rather than the NodeService.
                selectionDialog.DataContext    = _nodeService;
                selectionDialog.MapManager     = _mapManager;
                selectionDialog.HasCloseButton = false;

                selectionDialog.Closed += delegate(object dialog, EventArgs dialogArgs)
                {
                    this.Dispatcher.BeginInvoke(delegate() { InitializeNavigator(selectionDialog.DomainId, selectionDialog.NodeId); });
                };

                selectionDialog.Show();
            }
        }
Ejemplo n.º 2
0
        private void GetAllMapTypesCompleted(object sender, Service.GetAllMapTypesCompletedEventArgs eventArgs)
        {
            if (eventArgs.Error == null)
            {
                ServiceProxy.GetAllMapTypesCompleted -= GetAllMapTypesCompleted;

                TypeManager.AddNodeTypes(eventArgs.Result.NodeTypes.Values);
                TypeManager.AddRelationshipTypes(eventArgs.Result.RelationshipTypes.Values);
                TypeManager.AddConnectionTypes(eventArgs.Result.DescriptorTypes.Values);
                TypeManager.AddMetadataTypes(eventArgs.Result.MetadataTypes.Values);

                IsMapTypesLoaded = true;

                InitialiseMapManagerEventArgs initialisationEventArgs = new InitialiseMapManagerEventArgs(true);

                InitialiseMapManagerCompleted(this, initialisationEventArgs);
            }
            else
            {
                InitialiseMapManagerEventArgs initialisationEventArgs = new InitialiseMapManagerEventArgs(false);

                string errorMsg = eventArgs.Error.ToString();
                if (eventArgs.Error.InnerException != null)
                {
                    //strip off the TargetInvocationException that wraps the real exception
                    errorMsg = eventArgs.Error.InnerException.ToString();
                }
                initialisationEventArgs.ErrorMessage = errorMsg;
                InitialiseMapManagerCompleted(this, initialisationEventArgs);
            }
        }
Ejemplo n.º 3
0
 private void mapManager_InitialiseMapManagerCompleted(object sender, InitialiseMapManagerEventArgs e)
 {
     if (e.IsInitialised)
     {
         _mapManager = sender as IMapManager;
     }
     else
     {
         ErrorMessage = e.ErrorMessage;
     }
     Completed.Set();
 }
Ejemplo n.º 4
0
        private void GetGlymaVersionCompleted(object sender, Service.GetApplicationVersionCompletedEventArgs eventArgs)
        {
            if (eventArgs.Error == null)
            {
                ServiceProxy.GetApplicationVersionCompleted -= GetGlymaVersionCompleted;

                Service.GlymaVersion serverVersion = eventArgs.Result;

                if (GlymaClientVersion.RequiresRefresh(serverVersion))
                {
                    InitialiseMapManagerEventArgs initialisationEventArgs = new InitialiseMapManagerEventArgs(false);

                    initialisationEventArgs.ErrorMessage = "The version of Glyma your browser is using is out-of-date. Please clear your browser's cache and refresh your browser to download the latest version of Glyma.";

                    InitialiseMapManagerCompleted(this, initialisationEventArgs);
                }
                else
                {
                    ServiceProxy.GetAllMapTypesCompleted += GetAllMapTypesCompleted;
                    ServiceProxy.GetAllMapTypesAsync(CallingUrl.Url);
                }
            }
            else
            {
                InitialiseMapManagerEventArgs initialisationEventArgs = new InitialiseMapManagerEventArgs(false);

                string errorMsg = eventArgs.Error.ToString();
                if (eventArgs.Error.InnerException != null)
                {
                    //strip off the TargetInvocationException that wraps the real exception
                    errorMsg = eventArgs.Error.InnerException.ToString();
                }
                initialisationEventArgs.ErrorMessage = errorMsg;
                InitialiseMapManagerCompleted(this, initialisationEventArgs);
            }
        }
Ejemplo n.º 5
0
        private void OnInitialiseMapManagerCompleted(object sender, InitialiseMapManagerEventArgs e)
        {
            if (e.IsInitialised)
            {
                ProgressRecord progressRecord = new ProgressRecord(0, "Exporting Glyma Map", string.Format("Initialising {0} export processor", ExportFormat.ToString()));
                progressRecord.SecondsRemaining = -1;
                progressRecord.PercentComplete  = 5;
                progressRecord.RecordType       = ProgressRecordType.Processing;

                lock (pr_lock)
                {
                    this.ProgressRecord = progressRecord;
                    ProgressEvent.Set(); //notify of change to progress
                }

                ExportUtilityFactory exportFactory = new ExportUtilityFactory(MapManager);
                IExportUtility       exportUtil    = null;
                switch (MapSchema)
                {
                case "IBIS":
                    switch (ExportFormat)
                    {
                    case "Compendium":
                        exportUtil = exportFactory.CreateExportUtility(MapType.IBIS, ExportType.Compendium);
                        break;

                    case "Word":
                        exportUtil = exportFactory.CreateExportUtility(MapType.IBIS, ExportType.Word);
                        break;

                    case "PDF":
                        exportUtil = exportFactory.CreateExportUtility(MapType.IBIS, ExportType.PDF);
                        break;

                    case "GlymaXML":
                        //exportUtil = exportFactory.CreateExportUtility(MapType.IBIS, ExportType.GlymaXml);
                        lock (msg_lock)
                        {
                            Message = "Exporting to GlymaXML format is currently not supported";
                            LogMessageEvent.Set();
                        }
                        break;
                    }
                    break;
                }
                exportUtil.ExportCompleted += OnExportCompleted;
                exportUtil.ProgressChanged += OnProgressChanged;


                ExportPropertiesDictionary exportProps = CreateExportProperties();
                GlymaExportUserState       userState   = new GlymaExportUserState(Output);

                progressRecord = new ProgressRecord(0, "Exporting Glyma Map", "Export Progress: 0%");
                progressRecord.SecondsRemaining = -1;
                progressRecord.PercentComplete  = 10;
                progressRecord.RecordType       = ProgressRecordType.Processing;

                lock (pr_lock)
                {
                    this.ProgressRecord = progressRecord;
                    ProgressEvent.Set(); //notify of change to progress
                }

                exportUtil.ExportMap(Domain, Map, exportProps, null, userState);
                bool signalled = userState.Completed.WaitOne(Timeout.Infinite); //wait for the export to completed
                if (!signalled)
                {
                    Completed.Set(); //since it's inifinite timeout this shouldn't happen
                }
            }
            else
            {
                lock (msg_lock)
                {
                    this.Message = string.Format("Failed to initialise the web service client: {0}", e.ErrorMessage);
                    LogMessageEvent.Set();
                }

                Completed.Set();
            }
        }