/// <summary>
        /// Preferences Trigger Handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HandlePreferencesTriggered(object sender, TriggerEventArgs e)
        {
            IUQueryController queryController = Parent as IUQueryController;

            if (queryController == null)
            {
                return;
            }

            if (!queryController.CheckPendingChanges(true, true))
            {
                return;
            }

            bool lRefresh = false;

            lRefresh = ScenarioManager.LaunchPreferencesScenario(queryController);

            if (!lRefresh)
            {
                return;
            }

            // Refresh all data
            OnExecuteCommand(new ExecuteCommandEventArgs(ExecuteCommandType.ExecuteRefresh));
        }
Exemplo n.º 2
0
        public static bool LaunchPreferencesScenario(IUQueryController queryController)
        {
            CustomizeForm lForm = new CustomizeForm();

            lForm.Initialize(queryController);

            if (lForm.ShowDialog() == DialogResult.OK)
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Save the information in user preferences
        /// </summary>
        protected override void SaveScenarioInfoInPrefecences()
        {
            // For population interaction unit
            IUQueryController queryController = Parent as IUQueryController;

            if (queryController == null)
            {
                return;
            }

            string nameInPreferences       = Context.ClassName + ":" + queryController.Name;
            IUPopulationContext popContext = Context as IUPopulationContext;

            Logic.UserPreferences.SavePopulationInfo(nameInPreferences, popContext.BlockSize, CurrentDisplaySet.Name, DisplaySetList);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Receives the Query controller of the scenario to be customized
        /// </summary>
        /// <param name="queryController">Query Controller</param>
        public void Initialize(IUQueryController queryController)
        {
            mQueryController = queryController;

            // Copy the DisplaySets to the temporal list
            foreach (DisplaySetInformation displaySet in mQueryController.DisplaySet.DisplaySetList)
            {
                DisplaySetInformation newDisplayset = new DisplaySetInformation(displaySet);
                mTempDisplaySets.Add(newDisplayset);
            }

            ApplyMultilanguage();

            LoadDisplaySets();

            LoadPopulationInfo();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Actions related with the DisplaySet Execute Command event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void ProcessDisplaySetExecuteCommand(object sender, ExecuteCommandEventArgs e)
        {
            // Manage the defined shortcuts
            if (e.Key != Keys.None)
            {
                // Action items
                if (Action != null)
                {
                    foreach (ActionItemController lActionItem in Action.ActionItems.Values)
                    {
                        if (lActionItem.CheckShortcutKey(e.Key))
                        {
                            if (lActionItem.Enabled)
                            {
                                lActionItem.Execute(null, new TriggerEventArgs());
                                e.Handled = true;
                                return;
                            }
                        }
                    }
                }

                // Navigation items
                if (Navigation != null)
                {
                    foreach (NavigationItemController lNavItem in Navigation.NavigationItems.Values)
                    {
                        if (lNavItem.CheckShortcutKey(e.Key))
                        {
                            if (lNavItem.Enabled)
                            {
                                lNavItem.Execute(null, new TriggerEventArgs());
                                e.Handled = true;
                                return;
                            }
                        }
                    }
                }
            }

            base.ProcessDisplaySetExecuteCommand(sender, e);

            switch (e.ExecuteCommandType)
            {
            case ExecuteCommandType.ExecuteFirstDestroyActionService:
                ExecuteCommandFirstDestroyActionService();
                break;

            case ExecuteCommandType.ExecuteFirstCreateActionService:
                ExecuteCommandFirstCreateActionService();
                break;

            case ExecuteCommandType.ExecuteFirstNotDestroyNotCreateActionService:
                ExecuteCommandFirstNotDestroyNotCreateActionService();
                break;

            case ExecuteCommandType.ExecuteRefresh:
                Refresh();
                break;

            case ExecuteCommandType.ExecuteRetriveAll:
                ExecuteCommandRetriveAll(Context);
                break;

            case ExecuteCommandType.ExecuteSelectInstance:
                // If there is an associated service set the selected instance.
                IUQueryController lIUQueryController = this as IUQueryController;
                if (lIUQueryController != null && lIUQueryController.AssociatedServiceController != null)
                {
                    ExecuteCommandFirstNotDestroyNotCreateActionService();
                    break;
                }

                if (this.OkTrigger != null && this.OkTrigger.Enabled && this.OkTrigger.Visible)
                {
                    ProcessExecuteOk();
                }
                else
                {
                    ExecuteCommandFirstNotDestroyNotCreateActionService();
                }
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// Process the Display Service execute event
        /// </summary>
        protected virtual void ProcessExecuteServiceTriggered(object sender, TriggerEventArgs e)
        {
            // Before executing the DisplaySet Service it is needed to check for pending changes in associated Service IU.
            IUQueryController queryController = Parent as IUQueryController;

            if (queryController != null && !queryController.CheckPendingChanges(false, true))
            {
                return;
            }
            if (CurrentDisplaySet.ServiceInfo == null)
            {
                return;
            }

            // Gets modified rows from the viewer
            DataTable modifiedRows = Viewer.GetModifiedRows();

            if (modifiedRows == null)
            {
                return;
            }

            // Validate the modified data
            if (!ValidateModifiedRows(modifiedRows))
            {
                return;
            }

            // Error datatable
            DataTable errorReport = new DataTable();
            // Column for the OID
            string instanceColumnsName = CurrentDisplaySet.ServiceInfo.SelectedInstanceArgumentAlias;

            errorReport.Columns.Add(instanceColumnsName);
            // Column for the error message
            string lReportMessage = CultureManager.TranslateString(LanguageConstantKeys.L_MULTIEXE_EXECUTION, LanguageConstantValues.L_MULTIEXE_EXECUTION);

            errorReport.Columns.Add(lReportMessage);

            IUServiceContext lServiceContext = null;

            // For every modified row do...
            foreach (DataRow rowValues in modifiedRows.Rows)
            {
                // Create new IUServiceContext.
                lServiceContext = new IUServiceContext(null, CurrentDisplaySet.ServiceInfo.ClassServiceName, CurrentDisplaySet.ServiceInfo.ServiceName, null);
                // Add argunment this to the service context.
                List <Oid> instanceOIDs = new List <Oid>();
                Oid        instanceOID  = Adaptor.ServerConnection.GetOid(modifiedRows, rowValues);
                instanceOIDs.Add(instanceOID);
                lServiceContext.InputFields.Add(CurrentDisplaySet.ServiceInfo.SelectedInstanceArgumentName, new IUContextArgumentInfo(CurrentDisplaySet.ServiceInfo.SelectedInstanceArgumentName, instanceOIDs, true, null));

                // Fill the collections for the other inbound arguments.
                foreach (DisplaySetServiceArgumentInfo argumentInfo in CurrentDisplaySet.ServiceInfo.ArgumentDisplaySetPairs.Values)
                {
                    object value = rowValues[argumentInfo.DSElementName];
                    if (value.GetType() == typeof(System.DBNull))
                    {
                        value = null;
                    }
                    //Add input arguments with context.
                    lServiceContext.InputFields.Add(argumentInfo.Name, new IUContextArgumentInfo(argumentInfo.Name, value, true, null));
                }
                try
                {
                    // Execute service.
                    Logic.ExecuteService(lServiceContext);
                }
                catch (Exception exc)
                {
                    string lAlternateKeyName = CurrentDisplaySet.ServiceInfo.SelectedInstanceArgumentAlternateKeyName;
                    if (lAlternateKeyName != string.Empty)
                    {
                        instanceOID = Logic.GetAlternateKeyFromOid(instanceOID, lAlternateKeyName);
                    }

                    // Add a new row in the error datatable.
                    DataRow newReportRow = errorReport.NewRow();
                    newReportRow[lReportMessage]      = exc.Message;
                    newReportRow[instanceColumnsName] = UtilFunctions.OidFieldsToString(instanceOID, ' ');
                    errorReport.Rows.Add(newReportRow);
                }
            }

            // If errors have been found, show them
            if (errorReport.Rows.Count > 0)
            {
                // Show error message to the user
                ScenarioManager.LaunchMultiExecutionReportScenario(errorReport, CurrentDisplaySet.ServiceInfo.ServiceAlias, null, null);
            }

            // Remove the Pending changes mark
            PendingChanges = false;

            // Refresh the data
            OnExecuteCommand(new ExecuteCommandRefreshEventArgs(null));
        }