Ejemplo n.º 1
0
        /// <summary>
        /// Executes the actions related to OnFiltered event.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="eventArgs">FilterEventArgs.</param>
        private void HandleFilterExecute(object sender, ExecuteFilterEventArgs executeFilterEventArgs)
        {
            // Checking pending changes
            if (!CheckPendingChanges(true, true))
            {
                return;
            }

            try
            {
                // Set in the beginning.
                Context.LastOids.Clear();
                DisplaySet.FirstVisibleRow = 0;

                // Change Selected filter.
                if (executeFilterEventArgs.Arguments != null)
                {
                    InternalFilters.ExecutedFilterName = executeFilterEventArgs.Arguments.Name;
                }

                // Update data.
                UpdateData(true);
            }
            catch (Exception e)
            {
                ScenarioManager.LaunchErrorScenario(e);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the input fields properties.
        /// </summary>
        public override void Initialize()
        {
            #region Initialize Arguments Controller

            InternalInputFields.Initialize();

            #endregion Initialize Arguments Controller

            #region Initial Context Arguments Configuration
            // Initial Context Arguments Configuration
            ConfigureInitialContext();
            #endregion Initial Context Arguments Configuration

            try
            {
                #region Exectute Logic Default Values
                // Load default values.

                // Call Logic API ExecuteDefaultValues().
                ExecuteDefaultValues(Context);

                #endregion Exectute Logic Default Values

                #region Execue Load From Context
                // Load valued from context.
                ExecuteLoadFromContext(Context);
                #endregion xecue Load From Context
            }
            catch (Exception logicException)
            {
                ScenarioManager.LaunchErrorScenario(logicException);
            }

            base.Initialize();
        }
        /// <summary>
        /// Showes the data of the instance.
        /// </summary>
        /// <param name="lOids">The instance Oid list</param>
        private void ShowData(List <Oid> lOids)
        {
            // Query by instance
            DataTable lData = null;

            if (lOids != null && lOids.Count > 0)
            {
                try
                {
                    // Logic API call.
                    lData = Logic.ExecuteQueryInstance(Logic.Agent, OidSelector.Domain, lOids[0], this.BuildDisplaySetAttributes());
                }
                catch (Exception logicException)
                {
                    ScenarioManager.LaunchErrorScenario(logicException);
                }
            }

            // Clear Oid Selector value.
            if (lData != null && lData.Rows.Count == 0)
            {
                mOidSelector.Value = null;
            }

            // Show Population.
            SetPopulation(lData, true, lOids);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initialize the form
        /// </summary>
        public void Initialize(List <Oid> selectedOids)
        {
            mSelectedOids = selectedOids;

            // If no instances selected, inform and exit
            if (mSelectedOids == null || mSelectedOids.Count == 0)
            {
                string    lMessageError = CultureManager.TranslateString(LanguageConstantKeys.L_NO_SELECTION, LanguageConstantValues.L_NO_SELECTION);
                Exception lException    = new Exception(lMessageError, null);
                ScenarioManager.LaunchErrorScenario(lException);
                return;
            }

            cmbBoxSelectTemplate.SelectedIndexChanged += new EventHandler(HandlecmbBoxSelectTemplate_SelectedIndexChanged);

            // Load the templates from configuration file and fill the Combo
            LoadReportTemplates();

            // Show the number of selected instances in the Title.
            Text = CultureManager.TranslateStringWithParams(LanguageConstantKeys.L_ELEMENTSELECTED, LanguageConstantValues.L_ELEMENTSELECTED, mSelectedOids.Count);
            // Set the default printer
            lblNameOfPrint.Text = printDlg.PrinterSettings.PrinterName;

            ShowDialog();
        }
        /// <summary>
        /// Checks if the instances exist.
        /// </summary>
        /// <param name="values">List of instances.</param>
        private void CheckInstance(List <Oid> values)
        {
            Oid lOidToCheck = values[0];

            // Check if the Instance with received Oid exists.
            string displaySet = string.Empty;

            if (mSupplementaryInfo != null)
            {
                displaySet = mSupplementaryInfo.DisplaySetAttributes;
            }

            try
            {
                // Execute query.
                DataTable dataTable = null;
                try
                {
                    // Logic API call.
                    lOidToCheck = lOidToCheck.GetAlternateKey(AlternateKeyName) == null ? lOidToCheck : (Oid)lOidToCheck.GetAlternateKey(AlternateKeyName);
                    dataTable   = Logic.ExecuteQueryInstance(Logic.Agent, Domain, AlternateKeyName, lOidToCheck, displaySet);
                }
                catch (Exception logicException)
                {
                    ScenarioManager.LaunchErrorScenario(logicException);
                }

                // If there are no rows, launch error scenario.
                if (dataTable == null || (dataTable != null && dataTable.Rows.Count == 0))
                {
                    ScenarioManager.LaunchErrorScenario(new Exception(CultureManager.TranslateString(LanguageConstantKeys.L_ERROR_NO_EXIST_INSTANCE, LanguageConstantValues.L_ERROR_NO_EXIST_INSTANCE)));
                }
                else
                {
                    // If the instance exists, set its Oid fields from the datatable retrieved.
                    if ((AlternateKeyName != string.Empty) && (dataTable != null) && (dataTable.Rows.Count == 1))
                    {
                        lOidToCheck = Adaptor.ServerConnection.GetOid(dataTable, dataTable.Rows[0], AlternateKeyName);
                        values.Clear();
                        values.Add(lOidToCheck);
                    }
                }

                // Show supplementary information.
                if (mSupplementaryInfo != null)
                {
                    mSupplementaryInfo.SetPopulation(dataTable, true, null);
                }
            }
            catch
            {
                // If something wrong happens, clear the supplementary information.
                if (mSupplementaryInfo != null)
                {
                    mSupplementaryInfo.SetPopulation(null, true, null);
                }
            }
        }
 /// <summary>
 /// Executes the Report leaf associated method.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="e">TriggerEventArgs object.</param>
 public void Execute(object sender, TriggerEventArgs e)
 {
     try
     {
         // Launch Filter scenario.
         ScenarioManager.LaunchFilterForReportScenario(ClassName, FilterName, DataSetFile, ReportFile, WindowTitle);
     }
     catch (Exception err)
     {
         ScenarioManager.LaunchErrorScenario(err);
     }
 }
        /// <summary>
        /// Shows the supplementary information of the instance.
        /// </summary>
        /// <param name="oids">List of Oids.</param>
        private void ShowSupplementaryInfo(List <Oid> oids)
        {
            if (mSupplementaryInfo == null)
            {
                return;
            }

            // Clear supplementary information.
            if ((oids == null) || (oids.Count == 0))
            {
                mSupplementaryInfo.SetPopulation(null, true, null);
                return;
            }

            // If there is only one instance.
            if (oids.Count == 1)
            {
                try
                {
                    DataTable dataTable  = null;
                    string    attributes = mSupplementaryInfo.DisplaySetAttributes;
                    attributes = UtilFunctions.ReturnMissingAttributes(oids[0].ExtraInfo, attributes);
                    if (attributes != "")
                    {
                        try
                        {
                            // Logic API call.
                            dataTable = Logic.ExecuteQueryInstance(Logic.Agent, Domain, oids[0], attributes);
                        }
                        catch (Exception logicException)
                        {
                            ScenarioManager.LaunchErrorScenario(logicException);
                        }
                        oids[0].ExtraInfo.Merge(dataTable);
                    }
                    // Set the supplementary information.
                    mSupplementaryInfo.SetPopulation(oids[0].ExtraInfo, true, null);
                }
                catch
                {
                    // If there is something wrong, clear the supplementary information.
                    mSupplementaryInfo.SetPopulation(null, true, null);
                }
            }
            else
            {
                // If there is more than one instance, show warning message.
                object[] lArgs = new object[1];
                lArgs[0] = oids.Count.ToString();
                string lMessage = CultureManager.TranslateStringWithParams(LanguageConstantKeys.L_ELEMENTSELECTED, LanguageConstantValues.L_ELEMENTSELECTED, lArgs);
                mSupplementaryInfo.SetMessage(lMessage);
            }
        }
 /// <summary>
 /// Refreshes the data of the instance.
 /// </summary>
 public override void Refresh()
 {
     try
     {
         // Update data
         UpdateData(true);
     }
     catch (Exception e)
     {
         ScenarioManager.LaunchErrorScenario(e);
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Refreshs the data in the viewer
 /// </summary>
 public override void Refresh()
 {
     // Set in the beginning.
     DisplaySet.FirstVisibleRow = 0;
     try
     {
         // Update data
         UpdateData(true);
     }
     catch (Exception e)
     {
         ScenarioManager.LaunchErrorScenario(e);
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Executes the HAT leaf associated method.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="e">TriggerEventArgs.</param>
 public void Execute(object sender, TriggerEventArgs e)
 {
     try
     {
         // Create exchange information.
         ExchangeInfoAction lExchangeInfo = new ExchangeInfoAction(this.ClassIUName, this.IUName, NavigationalFilteringIdentity, null, null);
         // Launch scenario.
         ScenarioManager.LaunchActionScenario(lExchangeInfo, null);
     }
     catch (Exception err)
     {
         ScenarioManager.LaunchErrorScenario(err);
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Execute a <b>Query Related</b> or <b>Query Populaton</b> depending of exchange type.
        /// <b>ExchangeType.Navigation</b> execute Query Related.
        /// <b>ExchangeType.Action or SelectinForward</b> execute Query Population.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        protected virtual DataTable GetQueryPopulation(IUPopulationContext context)
        {
            DataTable lData = null;

            // Depending on the ExchangeInfo Type
            switch (Context.ExchangeInformation.ExchangeType)
            {
            case ExchangeType.Navigation:
                try
                {
                    // Logic API call.
                    lData = Logic.ExecuteQueryRelated(context);
                }
                catch (Exception logicException)
                {
                    ScenarioManager.LaunchErrorScenario(logicException);
                }
                break;

            case ExchangeType.Action:
            case ExchangeType.SelectionForward:
                // If this Population doesn't contain filters, search all population
                if (Filters.Count == 0)
                {
                    try
                    {
                        // Logic API call.
                        lData = Logic.ExecuteQueryPopulation(context);
                    }
                    catch (Exception logicException)
                    {
                        ScenarioManager.LaunchErrorScenario(logicException);
                    }
                }
                else
                {
                    // If there are no filters executed, set the last block true to do not
                    //  retrieve all the instances
                    this.Context.LastBlock = true;
                }
                break;

            default:
                lData = null;
                break;
            }

            return(lData);
        }
        /// <summary>
        /// Executes a Navigation Item navigation trigger associated.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">TriggerEventArgs.</param>
        public void Execute(Object sender, TriggerEventArgs e)
        {
            try
            {
                // Update context.
                ContextRequiredEventArgs contextEventArgs = new ContextRequiredEventArgs();
                OnContextRequired(contextEventArgs);

                SelectedInstancesRequiredEventArgs lSelectedInstancesEventArgs = new SelectedInstancesRequiredEventArgs();
                OnSelectedInstancesRequired(lSelectedInstancesEventArgs);

                if ((lSelectedInstancesEventArgs.SelectedInstances != null) && (lSelectedInstancesEventArgs.SelectedInstances.Count > 0))
                {
                    // Launch scenario.
                    // Calculate the title text for the target scenario.
                    string text2Title = "";
                    if (lSelectedInstancesEventArgs.SelectedInstances.Count == 1)
                    {
                        Oid lAuxOid = lSelectedInstancesEventArgs.SelectedInstances[0];
                        if (AlternateKeyName != string.Empty)
                        {
                            lAuxOid = Logics.Logic.GetAlternateKeyFromOid(lAuxOid, AlternateKeyName);
                        }
                        text2Title = UtilFunctions.GetText2Title(TargetScenarioAlias,
                                                                 InstanceAlias,
                                                                 lAuxOid,
                                                                 DisplaySet2TargetScenario);
                    }
                    ScenarioManager.LaunchNavigationScenario(
                        new ExchangeInfoNavigation(
                            ClassIUName,
                            IUName,
                            RolePath,
                            NavigationalFilteringIdentity,
                            lSelectedInstancesEventArgs.SelectedInstances,
                            contextEventArgs.Context,
                            text2Title, DefaultOrderCriteria), this);
                }
                else
                {
                    string lMessage = CultureManager.TranslateString(LanguageConstantKeys.L_NO_SELECTION, LanguageConstantValues.L_NO_SELECTION);
                    ScenarioManager.LaunchErrorScenario(new Exception(lMessage));
                }
            }
            catch (Exception err)
            {
                ScenarioManager.LaunchErrorScenario(err);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Executes the actions related to FirstPage event.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="eventArgs">FirstPageEventArgs.</param>
        protected void HandleDisplaySetFirstPage(object sender, FirstPageEventArgs eventArgs)
        {
            try
            {
                // Clear Oids stack
                Context.LastOids.Clear();

                // Update data
                UpdateData(true);
            }
            catch (Exception e)
            {
                ScenarioManager.LaunchErrorScenario(e);
            }
        }
        /// <summary>
        /// Execute Dependence Rules.
        /// </summary>
        public virtual void ExecuteDependenceRules(ArgumentEventArgs argumentEventArgs)
        {
            if (!mEnabledChangeArgument)
            {
                return;
            }

            UpdateContext();

            Context.SelectedInputField = argumentEventArgs.Name;

            // Execute Dependency Rules
            try
            {
                // if the change is from value.
                ValueChangedEventArgs lChangeValueEventArgs = argumentEventArgs as ValueChangedEventArgs;
                if (lChangeValueEventArgs != null)
                {
                    PendingChanges = true;
                    Logic.ExecuteDependencyRules(
                        Context,
                        lChangeValueEventArgs.OldValue,
                        DependencyRulesEventLogic.SetValue,
                        argumentEventArgs.Agent);
                }

                // if the change is from enable.
                EnabledChangedEventArgs lChangeEnableEventArgs = argumentEventArgs as EnabledChangedEventArgs;
                if (lChangeEnableEventArgs != null)
                {
                    Logic.ExecuteDependencyRules(
                        Context,
                        lChangeEnableEventArgs.Enabled,
                        DependencyRulesEventLogic.SetActive,
                        argumentEventArgs.Agent);
                }
            }
            catch (Exception logicException)
            {
                ScenarioManager.LaunchErrorScenario(logicException);
            }

            // Delete argument selection
            Context.SelectedInputField = string.Empty;

            // Set context
            ConfigureByContext(Context);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Executes the actions related to NextPage event.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="eventArgs">NextPageEventArgs.</param>
        protected void HandleDisplaySetNextPage(object sender, NextPageEventArgs eventArgs)
        {
            try
            {
                // Return if it is last block
                if (Context.LastBlock)
                {
                    return;
                }

                // Update data.
                UpdateData(false);
            }
            catch (Exception e)
            {
                ScenarioManager.LaunchErrorScenario(e);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Executes the actions related to PreviousPage event.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="eventArgs">PreviousPageEventArgs.</param>
        protected void HandleDisplaySetPreviousPage(object sender, PreviousPageEventArgs eventArgs)
        {
            try
            {
                // Pops the top item of the Oids stack
                if (Context.LastOids.Count > 0)
                {
                    Context.LastOids.Pop();
                }

                // Update data
                UpdateData(false);
            }
            catch (Exception e)
            {
                ScenarioManager.LaunchErrorScenario(e);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Executes the Action Item.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">TriggerEventArgs</param>
        public void Execute(object sender, TriggerEventArgs e)
        {
            try
            {
                // Validate if there are pending changes in the interaction unit
                // which contains the action item.
                CheckForPendingChangesEventArgs eventArg = new CheckForPendingChangesEventArgs();
                OnBeforeExecute(eventArg);
                if (eventArg.Cancel)
                {
                    return;
                }

                ContextRequiredEventArgs contextEventArgs = new ContextRequiredEventArgs();
                OnContextRequired(contextEventArgs);

                SelectedInstancesRequiredEventArgs lSelectedInstancesEventArgs = new SelectedInstancesRequiredEventArgs();
                OnSelectedInstancesRequired(lSelectedInstancesEventArgs);
                ExchangeInfoAction lExchangeInfoAction = null;
                if (this.IsNavigationalFilter)
                {
                    lExchangeInfoAction = new ExchangeInfoAction(ClassIUName, IUName, NavigationalFilteringIdentity, lSelectedInstancesEventArgs.SelectedInstances, contextEventArgs.Context);
                }
                else
                {
                    lExchangeInfoAction = new ExchangeInfoAction(ClassIUName, IUName, lSelectedInstancesEventArgs.SelectedInstances, contextEventArgs.Context);
                }

                // Set default order criteria
                lExchangeInfoAction.DefaultOrderCriteria = DefaultOrderCriteria;

                // Raise the event Launching Scenario.
                LaunchingScenarioEventArgs lLaunchScenarioArgs = new LaunchingScenarioEventArgs(lExchangeInfoAction);
                OnLaunchingScenario(lLaunchScenarioArgs);

                // Launch scenario.
                ScenarioManager.LaunchActionScenario(lExchangeInfoAction, this);
            }
            catch (Exception err)
            {
                ScenarioManager.LaunchErrorScenario(err);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// This method builds a list of Oids from the editor presentation values.
        /// </summary>
        /// <param name="executeQuery">Indicates wheter a quey must be executed to retrieve the primary Oid.</param>
        /// <returns>List of Oids.</returns>
        private List <Oid> BuildOidsFromEditorsValue(bool executeQuery)
        {
            // Get the editor's values.
            List <object> lFields = new List <object>();

            foreach (IEditorPresentation lEditor in mEditors)
            {
                // Check the editor null values.
                if ((lEditor.Value == null) || (lEditor.Value.ToString().Trim().Length == 0))
                {
                    return(null);
                }
                lFields.Add(lEditor.Value);
            }
            // Build the AlternateKey object from the 'editor' values.
            List <Oid> lOids = new List <Oid>();
            Oid        lOid  = null;

            try
            {
                // Logic API call.
                lOid = Logic.CreateOidFromOidFields(Domain, lFields, AlternateKeyName, executeQuery);
            }
            catch (Exception logicException)
            {
                //Exception lcustomException = new Exception(CultureManager.TranslateFixedString(LanguageConstantKeys.L_CONTROLLER_EXCEPTION, LanguageConstantValues.L_CONTROLLER_EXCEPTION), logicException);
                ScenarioManager.LaunchErrorScenario(logicException);
            }
            lOids.Add(lOid);

            // If current Oid is equals to the Last one, return it
            if (UtilFunctions.OidListEquals(lOids, LastValueListOids))
            {
                return(LastValueListOids);
            }

            // Get SCD attribute values
            GetValuesForSCD(lOids);

            return(lOids);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Updates the data of the IU
        /// </summary>
        public override void UpdateData(bool refresh)
        {
            // Execute default update
            UpdateContext();
            DataTable lData = null;

            // Search the Oid of the instance to be presented
            // Depending on the ExchangeInfo Type
            if (Context.ExchangeInformation.ExchangeType == ExchangeType.Navigation)
            {
                List <Oid> lOids = new List <Oid>(1);
                if (Context.ExchangeInformation.SelectedOids.Count != 0)
                {
                    try
                    {
                        // Logic API call.
                        lData = Logic.ExecuteQueryRelated(Context);
                    }
                    catch (Exception logicException)
                    {
                        //Exception lcustomException = new Exception(CultureManager.TranslateFixedString(LanguageConstantKeys.L_CONTROLLER_EXCEPTION, LanguageConstantValues.L_CONTROLLER_EXCEPTION), logicException);
                        ScenarioManager.LaunchErrorScenario(logicException);
                    }
                    Oid lOid = Adaptor.ServerConnection.GetLastOid(lData);
                    if (lOid != null)
                    {
                        lOids.Add(lOid);
                    }
                }
                // Keep the previous value
                DisplaySet.PreviousValue = OidSelector.Value as List <Oid>;
                // If one instance is selected, set the value and disable the Oid Selector
                OidSelector.Value = lOids;
                // Disable the Oid Selector
                OidSelector.Enabled = false;
            }

            List <Oid> lInstancesSelected = InstancesSelected;

            ShowData(lInstancesSelected);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Obtain the report information from the received files.
        /// </summary>
        /// <returns></returns>
        private bool ReadReportInfo()
        {
            DataSet lDataSet = new DataSet();

            try
            {
                lDataSet.ReadXmlSchema(mDataSetFile);
            }
            catch (Exception e)
            {
                Exception excReadingFile = new Exception(CultureManager.TranslateString(LanguageConstantKeys.L_ERROR_LOADING_REPORTSCONFIG, LanguageConstantValues.L_ERROR_LOADING_REPORTSCONFIG), e);
                ScenarioManager.LaunchErrorScenario(excReadingFile);
                return(false);
            }

            DataTable lStartingClass = lDataSet.Tables[this.ClassName];

            if (lStartingClass == null)
            {
                object[] lArgs = new object[2];
                lArgs[0] = this.ClassName;
                lArgs[1] = lDataSet.DataSetName;
                string lErrorMessage = CultureManager.TranslateStringWithParams(LanguageConstantKeys.L_ERROR_DATASET_TABLENOTFOUND, LanguageConstantValues.L_ERROR_DATASET_TABLENOTFOUND, lArgs);

                ScenarioManager.LaunchErrorScenario(new Exception(lErrorMessage));
                return(false);
            }

            foreach (DataColumn lCol in lStartingClass.Columns)
            {
                if (!string.IsNullOrEmpty(mPopulationContext.DisplaySetAttributes))
                {
                    mPopulationContext.DisplaySetAttributes += ",";
                }
                mPopulationContext.DisplaySetAttributes += lCol.ColumnName;
            }

            return(true);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Execute a Query Filter or Query Population depending if has <b>FilterNameSelected</b> or not.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        protected virtual DataTable GetQuery(IUPopulationContext context)
        {
            DataTable lData = null;

            // If one filters is selected. use the Filter search
            if (Context.ExecutedFilter != string.Empty)
            {
                try
                {
                    // Logic API call.
                    lData = Logic.ExecuteQueryFilter(Context);
                }
                catch (Exception logicException)
                {
                    ScenarioManager.LaunchErrorScenario(logicException);
                }
            }
            else
            {
                lData = GetQueryPopulation(context);
            }

            return(lData);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Execute a query related with other instance.
        /// </summary>
        /// <param name="context">Current context.</param>
        /// <returns>A DataTable with the instances searched.</returns>
        public static DataTable ExecuteQueryRelated(IUQueryContext context)
        {
            try
            {
                ExchangeInfo lExchangeInfo = context.ExchangeInformation;

                if (lExchangeInfo.ExchangeType != ExchangeType.Navigation || lExchangeInfo.SelectedOids.Count == 0)
                {
                    return(null);
                }

                IUPopulationContext lIUContext = context as IUPopulationContext;
                int blockSize = 1;
                if (lIUContext != null)
                {
                    blockSize = lIUContext.BlockSize;
                }
                ExchangeInfoNavigation lNavInfo = lExchangeInfo as ExchangeInfoNavigation;
                // Specific case. No role name indicates Query by Instance.
                if (lNavInfo.RolePath == "")
                {
                    if (lIUContext != null)
                    {
                        lIUContext.LastBlock = true;
                    }

                    PasajeroOid lOidInstance = new PasajeroOid(lNavInfo.SelectedOids[0]);
                    return(ExecuteQueryInstance(context.Agent, lOidInstance, context.DisplaySetAttributes));
                }

                // Get link items.
                Oid lOid = lNavInfo.SelectedOids[0];
                Dictionary <string, Oid> lLinkItems = new Dictionary <string, Oid>(StringComparer.CurrentCultureIgnoreCase);
                lLinkItems.Add(lNavInfo.RolePath, lOid);

                bool        lLastBlock     = true;
                PasajeroOid lLastOid       = null;
                string      lOrderCriteria = string.Empty;

                // Get population members.
                if (lIUContext != null)
                {
                    if (lIUContext.LastOid != null)
                    {
                        lLastOid = new PasajeroOid(lIUContext.LastOid);
                    }
                    lOrderCriteria = lIUContext.OrderCriteriaNameSelected;
                }
                NavigationalFiltering navigationalFiltering = NavigationalFiltering.GetNavigationalFiltering(context);
                DataTable             lDataTable            = ExecuteQueryRelated(context.Agent, lLinkItems, context.DisplaySetAttributes, lOrderCriteria, navigationalFiltering, lLastOid, blockSize, ref lLastBlock);

                if (lIUContext != null)
                {
                    lIUContext.LastBlock = lLastBlock;
                }

                return(lDataTable);
            }
            catch (Exception e)
            {
                ScenarioManager.LaunchErrorScenario(e);
                return(null);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Add report menu items recursively, from the XML node.
        /// </summary>
        /// <param name="xmlNodeList">List of nodes that represent reports or submenu entries.</param>
        /// <param name="menuItem">ToolStripMenuItem object to be filled with nodes information.</param>
        private void AddReportMenuItems(XmlNodeList xmlNodeList, ToolStripMenuItem menuItem)
        {
            char[] lSeparators = new char[] { ',' };

            // Process each node: Report or SubMenu.
            foreach (XmlNode node in xmlNodeList)
            {
                try
                {
                    if (node.Name.Equals("Report", StringComparison.InvariantCultureIgnoreCase))
                    {
                        #region Get Report information
                        string lAgentsWithoutBlanks = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, node, "agents");
                        lAgentsWithoutBlanks = lAgentsWithoutBlanks.Replace(" ", string.Empty);
                        string[] lAgents = lAgentsWithoutBlanks.Split(lSeparators, StringSplitOptions.RemoveEmptyEntries);
                        if (lAgents.Length > 0 && !Logics.Logic.Agent.IsActiveFacet(lAgents))
                        {
                            continue;
                        }

                        // Connected agent can see this report.
                        lAgents = Logics.Agents.All;
                        string lClassName       = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, node, "class");
                        string lFilterName      = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, node, "filtername");
                        string lDataSetFileName = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, node, "datasetfile");
                        if (File.Exists(lDataSetFileName))
                        {
                            FileInfo lDataSetFileInfo = new FileInfo(lDataSetFileName);
                            lDataSetFileName = lDataSetFileInfo.FullName;
                        }

                        #region Get report language information
                        XmlNodeList lLanguageNodeList = node.SelectNodes("Language");
                        bool        lExistLanguage    = false;
                        string      lAlias            = "";
                        string      lTitle            = "";
                        string      lReportFileName   = "";
                        foreach (XmlNode lNodeLanguage in lLanguageNodeList)
                        {
                            string lLanguageKey = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, lNodeLanguage, "key");
                            if (lLanguageKey.Length == 0 ||
                                lLanguageKey.Equals(CultureManager.Culture.Name, StringComparison.InvariantCultureIgnoreCase))
                            {
                                lAlias          = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, lNodeLanguage, "alias");
                                lTitle          = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, lNodeLanguage, "title");
                                lReportFileName = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, lNodeLanguage, "reportfilepath");
                                lExistLanguage  = true;
                                break;
                            }
                        }
                        #endregion Get report language information

                        // If report is not for current language, skip it.
                        if (!lExistLanguage)
                        {
                            continue;
                        }

                        if (File.Exists(lReportFileName))
                        {
                            FileInfo lReportFileInfo = new FileInfo(lReportFileName);
                            lReportFileName = lReportFileInfo.FullName;
                        }

                        // Create the Menu Report Controller.
                        HatLeafReportController lController = new HatLeafReportController("Report_" + mController.HatElementNodes.Count.ToString(), lClassName, lFilterName, lAlias, lDataSetFileName, lReportFileName, lTitle, lAgents);

                        // Add the option to the menu.
                        ToolStripMenuItem lItem = new ToolStripMenuItem(lController.Alias);
                        menuItem.DropDownItems.Add(lItem);
                        // Assign the presentation to the controller.
                        lController.Trigger = new ToolStripMenuItemPresentation(lItem, true);
                        // Add the controller item to the Hat list.
                        mController.HatElementNodes.Add(lController);
                        #endregion Get Report information
                    }

                    if (node.Name.Equals("SubMenu", StringComparison.InvariantCultureIgnoreCase))
                    {
                        #region Get SubMenu information
                        string lAgentsWithoutBlanks = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, node, "agents");
                        lAgentsWithoutBlanks = lAgentsWithoutBlanks.Replace(" ", string.Empty);
                        string[] lAgents = lAgentsWithoutBlanks.Split(lSeparators, StringSplitOptions.RemoveEmptyEntries);
                        if (lAgents.Length > 0 && !Logics.Logic.Agent.IsActiveFacet(lAgents))
                        {
                            continue;
                        }

                        // Connected agent can see this report.
                        lAgents = Logics.Agents.All;

                        #region Get submenu language information
                        XmlNodeList lLanguageNodeList = node.SelectNodes("Language");
                        bool        lExistLanguage    = false;
                        string      lAlias            = "";
                        foreach (XmlNode lNodeLanguage in lLanguageNodeList)
                        {
                            string lLanguageKey = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, lNodeLanguage, "key");
                            if (lLanguageKey.Length == 0 ||
                                lLanguageKey.Equals(CultureManager.Culture.Name, StringComparison.InvariantCultureIgnoreCase))
                            {
                                lAlias         = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, lNodeLanguage, "alias");
                                lExistLanguage = true;
                                break;
                            }
                        }
                        #endregion Get submenu language information

                        // If report is not for current language, skip it.
                        if (!lExistLanguage)
                        {
                            continue;
                        }

                        // Create the Sub Menu Controller.
                        HatNodeController lController = new HatNodeController("Report_" + mController.HatElementNodes.Count.ToString(), lAlias, "", lAgents);

                        // Add the option to the menu.
                        ToolStripMenuItem lItem = new ToolStripMenuItem(lController.Alias);
                        menuItem.DropDownItems.Add(lItem);
                        // Add the controller item to the Hat list.
                        mController.HatElementNodes.Add(lController);

                        // Add the sub elements of this sub menu.
                        if (node.ChildNodes.Count > 0)
                        {
                            AddReportMenuItems(node.ChildNodes, lItem);
                        }
                        #endregion Get SubMenu information
                    }
                }
                catch (Exception e)
                {
                    Exception exc = new Exception(CultureManager.TranslateString(LanguageConstantKeys.L_ERROR_LOADING_REPORTSCONFIG, LanguageConstantValues.L_ERROR_LOADING_REPORTSCONFIG), e);
                    ScenarioManager.LaunchErrorScenario(exc);
                }
            }
        }
Ejemplo n.º 24
0
        private void LoadConfigurationReportsFile()
        {
            // Remove Report item controller and the report menu entries.
            if (mController.HatElementNodes.Exist("Report_0"))
            {
                mController.HatElementNodes.Remove(mController.HatElementNodes["Report_0"]);
                mnuReports.DropDownItems.Clear();
            }
            // Hide Reports menu option.
            mnuReports.Visible = false;

            HatNodeController lController = null;

            try
            {
                // Verify the path and file specified in MainMenuReports Settings.
                string lFilePath = Properties.Settings.Default.MainMenuReports;
                if (!System.IO.File.Exists(lFilePath))
                {
                    lFilePath = System.Windows.Forms.Application.StartupPath + "\\" + lFilePath;
                    if (!System.IO.File.Exists(lFilePath))
                    {
                        return;
                    }
                }


                XmlDocument lXMLDoc = new XmlDocument();
                lXMLDoc.Load(lFilePath);

                XmlNodeList lMainNodeList = lXMLDoc.GetElementsByTagName("Reports");
                if (lMainNodeList.Count != 1)
                {
                    return;
                }

                // Main Reports node.
                XmlNode lMainNode = lMainNodeList[0];

                // Get the Reports Menu information.
                char[] lSeparators          = new char[] { ',' };
                string lAgentsWithoutBlanks = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, lMainNode, "agents");
                lAgentsWithoutBlanks = lAgentsWithoutBlanks.Replace(" ", string.Empty);
                string[] lAgents = lAgentsWithoutBlanks.Split(lSeparators, StringSplitOptions.RemoveEmptyEntries);
                if (lAgents.Length > 0 && !Logics.Logic.Agent.IsActiveFacet(lAgents))
                {
                    return;
                }

                // No agent specified means all the agents of the application.
                lAgents = Logics.Agents.All;

                XmlNodeList lLanguageNodeList = lMainNode.SelectNodes("Language");
                bool        lExistLanguage    = false;
                string      lAlias            = "";
                foreach (XmlNode lNodeLanguage in lLanguageNodeList)
                {
                    string lLanguageKey = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, lNodeLanguage, "key");
                    if (lLanguageKey.Length == 0 ||
                        lLanguageKey.Equals(CultureManager.Culture.Name, StringComparison.InvariantCultureIgnoreCase))
                    {
                        lAlias         = UtilFunctions.GetProtectedXmlNodeValue(Properties.Settings.Default.MainMenuReports, lNodeLanguage, "alias");
                        lExistLanguage = true;
                        break;
                    }
                }

                // If report is not for current language, skip it.
                if (lExistLanguage)
                {
                    lController = new HatNodeController("Report_0", lAlias, "", lAgents);

                    // Assign the presentation to the controller.
                    lController.Label = new ToolStripMenuItemPresentation(mnuReports, false);

                    // Add the controller item to the Hat list.
                    mController.HatElementNodes.Add(lController);

                    // Get the sub menu items.
                    AddReportMenuItems(lMainNode.ChildNodes, mnuReports);
                }
            }
            catch (Exception e)
            {
                Exception exc = new Exception(CultureManager.TranslateString(LanguageConstantKeys.L_ERROR_LOADING_REPORTSCONFIG, LanguageConstantValues.L_ERROR_LOADING_REPORTSCONFIG), e);
                ScenarioManager.LaunchErrorScenario(exc);
            }

            if (mnuReports.DropDownItems.Count > 0)
            {
                mnuReports.Visible = true;
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Validates the format and null allowed of the filter variables
        /// </summary>
        /// <returns></returns>
        protected bool CheckNullAndFormatFilterVariablesValues()
        {
            bool lResult = true;

            object[] lArgs = new object[1];

            // Control the null - not null allowed for all the filter variables arguments.
            foreach (ArgumentController lFilterVariable in InputFields)
            {
                // Argument data-valued validation.
                ArgumentDVController lFilterVariableDV = lFilterVariable as ArgumentDVController;
                if ((lFilterVariableDV != null) && (lFilterVariableDV.Editor != null))
                {
                    lArgs[0] = lFilterVariable.Alias;
                    lResult  = lResult & lFilterVariableDV.Editor.Validate(CultureManager.TranslateStringWithParams(LanguageConstantKeys.L_VALIDATION_NECESARY, LanguageConstantValues.L_VALIDATION_NECESARY, lArgs));
                }
                // Argument object-valued validation.
                else
                {
                    ArgumentOVController lFilterVariableOV = lFilterVariable as ArgumentOVController;
                    if (lFilterVariableOV != null)
                    {
                        List <Object> lEditorFields = new List <object>();
                        foreach (IEditorPresentation lEditor in lFilterVariableOV.Editors)
                        {
                            if (lEditor != null)
                            {
                                lArgs[0] = lFilterVariable.Alias;
                                // Shows the validation error only for the last editor field.
                                lResult = lResult & lEditor.Validate(CultureManager.TranslateStringWithParams(LanguageConstantKeys.L_VALIDATION_NECESARY, LanguageConstantValues.L_VALIDATION_NECESARY, lArgs));
                                if (lEditor.Value != null)
                                {
                                    // Fill the auxiliar list of values, in order to check if the Alternate Key is valid.
                                    lEditorFields.Add(lEditor.Value);
                                }
                            }
                        }

                        // If the OV filter variable has to work with an Alternate Key, check that the values specified
                        // in the editors are valid (It exist an instance that mach with this Alternate Key).
                        if (lFilterVariableOV.AlternateKeyName != string.Empty && lFilterVariableOV.Editors.Count == lEditorFields.Count)
                        {
                            Oid          lOid          = Oid.Create(lFilterVariableOV.Domain);
                            AlternateKey lAlternateKey = (AlternateKey)lOid.GetAlternateKey(lFilterVariableOV.AlternateKeyName);
                            lAlternateKey.SetValues(lEditorFields);

                            // Check if the Alternate Key is a valid one.
                            Oid lResultOid = Logic.GetOidFromAlternateKey(lAlternateKey, lFilterVariableOV.AlternateKeyName);
                            // If the Oid is not found, it is because the Alternate Key is not a valid one.
                            if (lResultOid == null)
                            {
                                ScenarioManager.LaunchErrorScenario(new Exception(CultureManager.TranslateString(LanguageConstantKeys.L_ERROR_NO_EXIST_INSTANCE, LanguageConstantValues.L_ERROR_NO_EXIST_INSTANCE)));
                                return(false);
                            }
                        }
                    }
                }
            }

            return(lResult);
        }