/// <summary>
 /// Load the internal infomration based on the Master-Detail controller
 /// </summary>
 /// <param name="masterDetailController"></param>
 public IUTreeController(IUMasterDetailController masterDetailController)
     : base()
 {
     mRefreshMenuItems = new List<ITriggerPresentation>();
     // Get the information from the MasterDetail received and convert it
     ConvertMasterDetailInfo(masterDetailController);
     // Load the Exchange Information
     mMasterDetailExchangeInfo = masterDetailController.ExchangeInformation;
     // Copy Name and Context
     Name = masterDetailController.Name;
     Context = masterDetailController.Context;
 }
        /// <summary>
        /// Initializes the 'IIU_PasajeroAeronaveIT' instance form.
        /// </summary>
        /// <param name="exchangeInfo">Exchange information.</param>
        /// <returns>IUInstanceController.</returns>
        public IUInstanceController Initialize(ExchangeInfo exchangeInfo)
        {
            // Controller factory.
            Controller = ControllerFactory.PasajeroAeronave.Instance_IIU_PasajeroAeronave(exchangeInfo);

            Controller.Scenario = new ScenarioPresentation(this, ScenarioType.Instance);

            #region Instance IIU_PasajeroAeronave Links
            // DisplaySet
            Controller.DisplaySet.Viewer = new ListViewPresentation(lstViewDisplaySet, toolStripExportExcel, toolStripExportWord, toolStripRefresh, toolStripHelp, optionsToolStripMenuItem, mnuNavigations);
            // OID Selector
            Controller.OidSelector.Label = new LabelPresentation(this.lOIDSelector);
            Controller.OidSelector.Editors[0] = new MaskedTextBoxPresentation(this.maskedTextBoxid_PasajeroAeronave1);
            Controller.OidSelector.Trigger = new ButtonPresentation(this.bOIDSelector);
            if (Controller.OidSelector.SupplementaryInfo != null)
            {
                Controller.OidSelector.SupplementaryInfo.Viewer = new LabelDisplaySetPresentation(this.lSIOIDSelector);
            }

            // Actions
            Controller.Action.ActionItems[0].Trigger = new ToolStripButtonPresentation(this.toolstripActions_0, this.mnuActions_0);
            Controller.Action.ActionItems[1].Trigger = new ToolStripButtonPresentation(this.toolstripActions_1, this.mnuActions_1);
            Controller.Action.ActionItems[2].Trigger = new ToolStripButtonPresentation(this.toolstripActions_2, this.mnuActions_2);
            Controller.Action.ActionItems[3].Trigger = new ToolStripButtonPresentation(this.toolstripActions_3, this.mnuActions_3);
            Controller.Action.ActionItems[4].Trigger = new ToolStripButtonPresentation(this.toolstripActions_4, this.mnuActions_4);
            Controller.Action.ActionItems[5].Trigger = new ToolStripButtonPresentation(this.toolStripPrint, this.mnuPrint);

            // Navigations
            Controller.Navigation.NavigationItems[0].Trigger = new ToolStripButtonPresentation(this.toolstripNavigations_0, this.mnuNavigations_0);
            Controller.Navigation.NavigationItems[1].Trigger = new ToolStripButtonPresentation(this.toolstripNavigations_1, this.mnuNavigations_1);
            Controller.Navigation.NavigationItems[2].Trigger = new ToolStripButtonPresentation(this.toolstripNavigations_2, this.mnuNavigations_2);
            this.pnlDisplaySet.ContextMenuStrip = contextMenuStrip;
            Controller.DisplaySet.PreferencesTrigger = new ToolStripMenuItemPresentation(this.toolStripPreferences);
            #endregion Instance IIU_PasajeroAeronave Links

            // Save position trigger
            Controller.SavePositionTrigger = new ToolStripMenuItemPresentation(toolStripSavePositions);

            // Close Button
            Controller.CancelTrigger = new ButtonPresentation(this.bCancel);

            // Initialize controller.
            Controller.Initialize();

            return Controller;
        }
        /// <summary>
        /// Executes the service, including multiexecution and conditional navigation if defined.
        /// </summary>
        /// <returns>True if the service has been successfully executed, False in the other cases.</returns>
        public override bool Execute()
        {
            // Check if the inbound argument values are correct.
            if (!this.CheckNullAndFormatArgumentValues())
            {
                return false;
            }
            // Execute Service.
            bool lResult = ExecuteService(false);
            PendingChanges = !lResult;
            bool lIsMultiExecution = IsMultiexecution;

            #region Execute ConditionalNavigations
            ExchangeInfoConditionalNavigation lExchangeInfoConditionalNavigation = null;
            // Execute the conditional navigational when there is no multiexecution.
            if (!lIsMultiExecution)
            {
                // Logic API call.
                lExchangeInfoConditionalNavigation = Logic.ExecuteConditionalNavigation(Context);
            }
            #endregion Execute ConditionalNavigations

            // If don't have Conditional Navigation and the Service was not success
            if ((lExchangeInfoConditionalNavigation == null) && (!lResult))
            {
                return false;
            }

            #region Lauch Service Response Event
            // Everything is fine.
            if (ServiceResponse != null)
            {
                ServiceResponse(this, new ServiceResultEventArgs(lResult, Context.ExchangeInformation));
            }
            #endregion Lauch Service Response event

            #region Outbound Arguments. Before Conditional navigation question
            // Launch outbound arguments scenario only when there is no multiexecution
            if (lResult && lExchangeInfoConditionalNavigation != null && lExchangeInfoConditionalNavigation.ConditionalNavigationInfo.Count > 1 &&
                !lIsMultiExecution && OutboundArgumentsScenario != null && OutboundArgumentsScenario.Length > 0)
            {
                ExchangeInfo lGenericExchangeInfo = new ExchangeInfo(ExchangeType.Generic, Context.ClassName, mOutboundArgumentsScenario, Context);
                ScenarioManager.LaunchOutbountArgumentsScenario(lGenericExchangeInfo);
            }
            #endregion Outbound Arguments. Before Conditional navigation question

            #region Launch ConditionalNavigations
            try
            {
                if (lExchangeInfoConditionalNavigation != null)
                {
                    // Clean Extra information in all the Oids in order to force new queries.
                    foreach (DestinationInfo destinationInfo in lExchangeInfoConditionalNavigation.ConditionalNavigationInfo)
                    {
                        if (destinationInfo.ExchangeInfo.SelectedOids != null)
                        {
                            foreach (Oid lOid in destinationInfo.ExchangeInfo.SelectedOids)
                            {
                                lOid.ExtraInfo = null;
                            }
                        }
                        if (destinationInfo.ExchangeInfo.CustomData != null)
                        {
                            foreach (object lValue in destinationInfo.ExchangeInfo.CustomData)
                            {
                                List<Oid> lOids = lValue as List<Oid>;
                                if (lOids != null)
                                {
                                    foreach (Oid lOid in lOids)
                                    {
                                        lOid.ExtraInfo = null;
                                    }
                                }

                            }
                        }
                    }

                    // Show conditional navigation form, to allow the user to choose a response.
                    IActionItemSuscriber actionItem = null;
                    if (ServiceResponse != null)
                    {
                        actionItem = ServiceResponse.Target as IActionItemSuscriber;
                    }
                    ScenarioManager.LaunchConditionalNavigationScenario(lExchangeInfoConditionalNavigation, actionItem);
                }
            }
            catch (Exception logicException)
            {
                ScenarioManager.LaunchErrorScenario(logicException);
                return lResult;
            }
            #endregion Launch ConditionalNavigations

            #region Outbound Arguments
            // Launch outbound arguments scenario only when there is no multiexecution
            if (lResult && (lExchangeInfoConditionalNavigation == null || lExchangeInfoConditionalNavigation.ConditionalNavigationInfo.Count == 1) &&
                !lIsMultiExecution && OutboundArgumentsScenario != null && OutboundArgumentsScenario.Length > 0)
            {
                ExchangeInfo lGenericExchangeInfo = new ExchangeInfo(ExchangeType.Generic, Context.ClassName, mOutboundArgumentsScenario, Context);
                ScenarioManager.LaunchOutbountArgumentsScenario(lGenericExchangeInfo);
            }
            #endregion Outbound Arguments

            CloseScenario();

            return lResult;
        }
    static void Main(string[] args)
    {
        //declare arraylist for our in-memory data store
        ArrayList isinDataStore = new ArrayList();

        //ISINMaster XML path
        //string xmlPath = @"C:\CodeExample\Chpt3\ReadXML\ISINMaster.xml";
        string xmlPath = @"..\..\ISINMaster.xml";
        //Create XML text reader
        XmlTextReader txtReader = new XmlTextReader(xmlPath);

        //loop until we have read the entire file
        //returns true as long as there is content to be read
        while (txtReader.Read())
        {
            //check the type of node that we just read to be an Element type
            switch (txtReader.NodeType)
            {
            case XmlNodeType.Element:
                //check the name of the current node being read
                //If ISIN node is read
                if (txtReader.LocalName == "ISIN")
                {
                    //create an instance of the ISINInfo class and
                    //assign various properties by querying attribute
                    //nodes of ISIN elemeent
                    ISINInfo isinInfo = new ISINInfo();
                    isinInfo.Symbol    = txtReader.GetAttribute("Symbol");
                    isinInfo.FaceValue =
                        XmlConvert.ToDouble(txtReader.GetAttribute("FaceValue"));
                    isinInfo.MarketLot =
                        XmlConvert.ToInt32(txtReader.GetAttribute("MarketLot"));
                    isinDataStore.Add(isinInfo);
                }
                //If Exchange node is read
                if (txtReader.LocalName == "Exchange")
                {
                    //Get reference to latest isin instance added in arraylist
                    ISINInfo isinInfo = isinDataStore[isinDataStore.Count - 1] as ISINInfo;
                    //create instance of exchange and assign various properties by querying
                    //attribute node of exchange element
                    ExchangeInfo exchInfo = new ExchangeInfo();
                    exchInfo.ExchangeCode = txtReader.GetAttribute("Code");
                    exchInfo.ScripCode    = txtReader.GetAttribute("ScripCode");
                    //add exchange instance into isin exchange list
                    //reflects isin-exchange mapping
                    isinInfo.exchangeList.Add(exchInfo);
                }
                break;

            default:
                break;
            }
        }

        //close our textreader
        txtReader.Close();

        //Display the ISIN
        foreach (ISINInfo isin in isinDataStore)
        {
            Console.WriteLine("Symbol :" + isin.Symbol);
            //Display Exchange
            foreach (ExchangeInfo exchange in isin.exchangeList)
            {
                Console.WriteLine("Exchange {0} Scrip Code {1} ",
                                  exchange.ExchangeCode, exchange.ScripCode);
            }
        }
    }
Example #5
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;
                    }

                    RevisionOid lOidInstance = new RevisionOid(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;
                RevisionOid lLastOid       = null;
                string      lOrderCriteria = string.Empty;

                // Get population members.
                if (lIUContext != null)
                {
                    if (lIUContext.LastOid != null)
                    {
                        lLastOid = new RevisionOid(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);
            }
        }
 /// <summary>
 /// Initializes a new instance of 'RefreshRequiredMasterEventArgs'.
 /// Used to request a refresh from the contained elements, an action item for example.
 /// </summary>
 public RefreshRequiredMasterEventArgs(ExchangeInfo receivedExchangeInfo)
     : base(receivedExchangeInfo)
 {
     RefreshType  = RefreshRequiredType.RefreshMaster;
     mRefreshDone = false;
 }
        /// <summary>
        /// Creates a new scenario.
        /// </summary>
        /// <param name="exchangeInfo">Scenario information.</param>
        /// <returns>The scenario created.</returns>
        private static Form CreateScenarioInstance(ExchangeInfo exchangeInfo)
        {
            Form lScenario = null;

            // Instance & Initialize Scenario.
            Type lScenarioType = Type.GetType(exchangeInfo.IUName);
            if (lScenarioType != null)
            {
                // Instance Scenario.
                lScenario = Activator.CreateInstance(lScenarioType) as Form;

                // Set Form position
                if (lScenario != null && lScenario.StartPosition == FormStartPosition.WindowsDefaultLocation)
                {
                    lScenario.StartPosition = FormStartPosition.Manual;
                    lScenario.Location = new System.Drawing.Point((MainForm.ClientSize.Width - lScenario.Width) / 2, ((MainForm.ClientSize.Height - lScenario.Height) / 2) * 3/4);
                }
            }

            return lScenario;
        }
 /// <summary>
 /// Initializes a new instance of 'RefreshRequiredMasterEventArgs'.
 /// Used to request a refresh from the contained elements, an action item for example.
 /// </summary>
 public RefreshRequiredMasterEventArgs(ExchangeInfo receivedExchangeInfo)
     : base(receivedExchangeInfo)
 {
     RefreshType = RefreshRequiredType.RefreshMaster;
     mRefreshDone = false;
 }
Example #9
0
        public IList <Tuple <ExchangeInfo, OrderObj, ProductObj, ProductObj> > GetExchange(int userID, int?orderID = null)
        {
            using (dbc = new SqlHelper())
            {
                string sql = "select a.ExchangeID,a.OrderID,a.AddTime,a.Mobile,a.Phone,a.Address,a.RegionID,a.Zip,a.ReturnProductID,a.ReturnQty,a.ExchangeProductID,a.ExchangeQty,a.Reason,b.OrderCode,b.Receiver,c.Name as ExchangeProductName,c.Price as ExchangeProductPrice,c.IsOnSale as ExchangeProductIsOnSale,c.SpecialPrice as ExchangeProductSpecialPrice,d.Name as ReturnProductName,d.Price as ReturnProductPrice,d.IsOnSale as ReturnProductIsOnSale,d.SpecialPrice as ReturnProductSpecialPrice from Exchange a inner join Orders b on a.OrderID=b.OrderID inner join Products c on a.ExchangeProductID=c.ProductID inner join Products d on a.ReturnProductID=d.ProductID where UserID=@UserID";
                dbc.AddIntParameter("@UserID", userID);
                if (orderID != null)
                {
                    dbc.AddIntParameter("@OrderID", (int)orderID);
                    sql += " and a.OrderID=@OrderID";
                }

                IList <Tuple <ExchangeInfo, OrderObj, ProductObj, ProductObj> > result = null;

                dbc.Read(sql, System.Data.CommandType.Text, dr =>
                {
                    if (dr.HasRows)
                    {
                        result = new List <Tuple <ExchangeInfo, OrderObj, ProductObj, ProductObj> >();
                        ExchangeInfo exchangeInfo;
                        OrderObj orderObj;
                        ProductObj returnProduct;
                        ProductObj exchangeProduct;
                        while (dr.Read())
                        {
                            exchangeInfo                   = new ExchangeInfo();
                            exchangeInfo.ExchangeID        = dr["ExchangeID"] == DBNull.Value ? 0 : (int)dr["ExchangeID"];
                            exchangeInfo.OrderID           = dr["OrderID"] == DBNull.Value ? 0 : (int)dr["OrderID"];
                            exchangeInfo.AddTime           = dr["AddTime"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["AddTime"];
                            exchangeInfo.Mobile            = dr["Mobile"] == DBNull.Value ? null : (string)dr["Mobile"];
                            exchangeInfo.Phone             = dr["Phone"] == DBNull.Value ? null : (string)dr["Phone"];
                            exchangeInfo.Address           = dr["Address"] == DBNull.Value ? null : (string)dr["Address"];
                            exchangeInfo.RegionID          = dr["RegionID"] == DBNull.Value ? 0 : (int)dr["RegionID"];
                            exchangeInfo.Zip               = dr["Zip"] == DBNull.Value ? null : (string)dr["Zip"];
                            exchangeInfo.ReturnProductID   = dr["ReturnProductID"] == DBNull.Value ? 0 : (int)dr["ReturnProductID"];
                            exchangeInfo.ReturnQty         = dr["ReturnQty"] == DBNull.Value ? 0 : (int)dr["ReturnQty"];
                            exchangeInfo.ExchangeProductID = dr["ExchangeProductID"] == DBNull.Value ? 0 : (int)dr["ExchangeProductID"];
                            exchangeInfo.ExchangeQty       = dr["ExchangeQty"] == DBNull.Value ? 0 : (int)dr["ExchangeQty"];
                            exchangeInfo.Reason            = dr["Reason"] == DBNull.Value ? null : (string)dr["Reason"];

                            orderObj           = new OrderObj();
                            orderObj.OrderID   = exchangeInfo.OrderID;
                            orderObj.OrderCode = dr["OrderCode"] == DBNull.Value ? null : (string)dr["OrderCode"];
                            orderObj.Receiver  = dr["Receiver"] == DBNull.Value ? null : (string)dr["Receiver"];

                            returnProduct              = new ProductObj();
                            returnProduct.ProductID    = exchangeInfo.ReturnProductID;
                            returnProduct.Name         = dr["ReturnProductName"] == DBNull.Value ? null : (string)dr["ReturnProductName"];
                            returnProduct.Price        = dr["ReturnProductPrice"] == DBNull.Value ? 0 : (decimal)dr["ReturnProductPrice"];
                            returnProduct.IsOnSale     = dr["ReturnProductIsOnSale"] == DBNull.Value ? false : (bool)dr["ReturnProductIsOnSale"];
                            returnProduct.Price        = dr["ReturnProductPrice"] == DBNull.Value ? 0 : (decimal)dr["ReturnProductPrice"];
                            returnProduct.SpecialPrice = dr["ReturnProductSpecialPrice"] == DBNull.Value ? 0 : (decimal)dr["ReturnProductSpecialPrice"];

                            exchangeProduct              = new ProductObj();
                            exchangeProduct.ProductID    = exchangeInfo.ExchangeProductID;
                            exchangeProduct.Name         = dr["ExchangeProductName"] == DBNull.Value ? null : (string)dr["ExchangeProductName"];
                            exchangeProduct.Price        = dr["ExchangeProductPrice"] == DBNull.Value ? 0 : (decimal)dr["ExchangeProductPrice"];
                            exchangeProduct.IsOnSale     = dr["ExchangeProductIsOnSale"] == DBNull.Value ? false : (bool)dr["ExchangeProductIsOnSale"];
                            exchangeProduct.Price        = dr["ExchangeProductPrice"] == DBNull.Value ? 0 : (decimal)dr["ExchangeProductPrice"];
                            exchangeProduct.SpecialPrice = dr["ExchangeProductSpecialPrice"] == DBNull.Value ? 0 : (decimal)dr["ExchangeProductSpecialPrice"];

                            result.Add(new Tuple <ExchangeInfo, OrderObj, ProductObj, ProductObj>(exchangeInfo, orderObj, returnProduct, exchangeProduct));
                        }
                    }
                });

                return(result);
            }
        }
        static void Main(string[] args)
        {
            string   currency = null;
            DateTime?dateFrom = null;
            DateTime?dateTo   = null;

            if (args.Length >= 1)
            {
                try
                {
                    currency = ExchangeInfo.CheckCurrencyFormat(args[0]);
                }
                catch (FormatException)
                {
                    Console.WriteLine("Nieprawidłowy format waluty.");
                }
            }

            if (args.Length >= 2)
            {
                dateFrom = ParseDate(args[1]);
            }

            if (args.Length == 3)
            {
                dateTo = ParseDate(args[2], dateFrom: false);

                if (dateTo < dateFrom)
                {
                    Console.WriteLine("Data końcowa nie może być wcześniejsza niż data początkowa");
                    dateTo = null;
                }
            }

            while (currency == null)
            {
                Console.Write("Podaj trzyliterowy kod waluty (np. EUR): ");

                try
                {
                    currency = ExchangeInfo.CheckCurrencyFormat(Console.ReadLine());
                }
                catch (FormatException)
                {
                    Console.WriteLine("Nieprawidłowy format waluty.");
                }
            }

            Console.WriteLine("Wybrana waluta to: " + currency.ToString());

            while (dateFrom == null)
            {
                Console.Write("Podaj datÄ™ poczÄ…tkowÄ…: ");
                dateFrom = ParseDate(Console.ReadLine());
            }


            Console.WriteLine("Wybrana data poczÄ…tkowa: " + ((DateTime)dateFrom).ToString("dd.MM.yyyy"));

            while (dateTo == null)
            {
                Console.Write("Podaj datę końcową: ");
                dateTo = ParseDate(Console.ReadLine(), dateFrom: false);

                if (dateTo < dateFrom)
                {
                    Console.WriteLine("Data końcowa nie może być wcześniejsza niż data początkowa");
                    dateTo = null;
                }
            }

            Console.WriteLine("Wybrana data końcowa: " + ((DateTime)dateTo).ToString("dd.MM.yyyy"));

            Console.WriteLine();

            try
            {
                ExchangeInfo exchangeInfo = new(currency, (DateTime)dateFrom, (DateTime)dateTo);
                Console.WriteLine($"Dane dla {currency} ({exchangeInfo.CurrencyName}) w okresie od {(DateTime)dateFrom:dd.MM.yyyy} do {(DateTime)dateTo:dd.MM.yyyy}");
                Console.WriteLine($"Kurs średni: {exchangeInfo.AvgaverageExchangeRate:0.0000}");
                Console.WriteLine($"Najniższy dzienny średni kurs: {exchangeInfo.MinExchangeRate:0.0000} (w dniu {exchangeInfo.MinExchangeRateDate:dd.MM.yyyy})");
                Console.WriteLine($"Najwyższy dzienny średni kurs: {exchangeInfo.MaxExchangeRate:0.0000} (w dniu {exchangeInfo.MaxExchangeRateDate:dd.MM.yyyy})");
                Console.WriteLine();

                if (exchangeInfo.DataCount == 1)
                {
                    Console.WriteLine($"Dane na podstawie 1 raportu ze strony Nardowego Banku Polskiego.");
                }
                else
                {
                    Console.WriteLine($"Dane na podstawie {exchangeInfo.DataCount} raportów ze strony Narodowego Banku Polskiego.");
                }
            }
            catch (ArgumentNullException)
            {
                Console.WriteLine($"Brak danych dla waluty o kodzie {currency} w podanym okresie.");
            }
            catch (WebException)
            {
                Console.WriteLine("Nie można połączyć się z serwerem, sprawdź czy napewno masz połaczenie z internetem i spróbuj ponownie.");
            }
        }
        public IUController Initialize(ExchangeInfo exchangeInfo)
        {
            // ExchangeInfo with Destinations
            mExchangeInfoConditional = exchangeInfo as ExchangeInfoConditionalNavigation;

            if (mExchangeInfoConditional != null)
            {
                this.SuspendLayout();

                Text             = CultureManager.TranslateString(LanguageConstantKeys.L_QUESTION, LanguageConstantValues.L_QUESTION, Text);
                lblQuestion.Text = mExchangeInfoConditional.ConditionalNavigationInfo.Question;

                int lCount = 0;
                int lnexty = 0;
                int lseedy = 19;
                int lgrBox = 0;
                foreach (DestinationInfo lDestinationInfo in mExchangeInfoConditional.ConditionalNavigationInfo)
                {
                    #region radioButton01
                    if (lCount == 0)
                    {
                        radioButton01.AutoSize = true;
                        radioButton01.Size     = new System.Drawing.Size(14, 13);
                        radioButton01.Location = new System.Drawing.Point(12, lseedy);
                        radioButton01.TabIndex = lCount;
                        radioButton01.TabStop  = true;
                        radioButton01.UseVisualStyleBackColor = true;
                        radioButton01.Text = lDestinationInfo.AssociatedText;
                        radioButton01.Tag  = lCount;

                        lnexty = radioButton01.Location.Y;
                    }
                    #endregion radioButton01
                    else
                    {
                        lnexty += lseedy;
                        //
                        // radioButton
                        //
                        RadioButton rb = new RadioButton();
                        rb.AutoSize = true;
                        rb.Location = new System.Drawing.Point(12, lnexty);
                        rb.Size     = new System.Drawing.Size(14, 13);
                        rb.Location = new System.Drawing.Point(12, lnexty);
                        rb.Name     = "radioButton" + lCount.ToString();
                        rb.TabIndex = lCount;
                        rb.TabStop  = true;
                        rb.UseVisualStyleBackColor = true;
                        rb.Text = lDestinationInfo.AssociatedText;
                        rb.Tag  = lCount;

                        grpBoxDestinations.Controls.Add(rb);


                        lgrBox += (lnexty + 10);
                    }
                    lCount++;
                }

                // Adjust the form size
                this.Size = new Size(this.Size.Width, grpBoxDestinations.Top + panel2.Height + (lCount + 2) * lseedy);
                // Select the first option
                radioButton01.Checked = true;
                this.ResumeLayout();
            }
            return(null);
        }
 /// <summary>
 /// Initializes a new instance of 'RefreshRequiredInstancesEventArgs'.
 /// Used to request a refresh from the contained elements, an action item for example.
 /// </summary>
 public RefreshRequiredInstancesEventArgs(List<Oid> instances, ExchangeInfo receivedExchangeInfo)
     : base(receivedExchangeInfo)
 {
     RefreshType = RefreshRequiredType.RefreshInstances;
     mInstances = instances;
 }
Example #13
0
        public async Task <bool> CreateUserAsync(string username, string password)
        {
            var vhost = await _managementClient.GetVhostAsync("/");

            if ((await _managementClient.GetUsersAsync()).Any(u => string.Equals(u.Name, username, StringComparison.InvariantCultureIgnoreCase)))
            {
                _logger.LogInformation($"User '{username}' already exists");
                return(false);
            }

            var userInfo   = new UserInfo(username, password);
            var rabbitUser = await _managementClient.CreateUserAsync(userInfo);

            _logger.LogInformation($"RabbitMQ user '{username}' created");

            var logExchangeName = $"logs.{username}";
            var exchangeInfo    = new ExchangeInfo(logExchangeName, ExchangeType.Fanout);
            await _managementClient.CreateExchangeAsync(exchangeInfo, vhost);

            _logger.LogInformation($"RabbitMQ exchange for user '{username}' created");

            var logQueueName = (await _bus.Advanced.QueueDeclareAsync("", maxLength: 1, maxLengthBytes: 4096)).Name;

            var logExchange = await _managementClient.GetExchangeAsync(logExchangeName, vhost);

            var logQueue = await _managementClient.GetQueueAsync(logQueueName, vhost);

            await _managementClient.CreateBindingAsync(logExchange, logQueue, new BindingInfo(""));

            var permissionInfo = new PermissionInfo(rabbitUser, vhost)
                                 .DenyAllConfigure()
                                 .SetRead("^amq\\.")
                                 .SetWrite("^logs\\.");
            await _managementClient.CreatePermissionAsync(permissionInfo);

            _logger.LogInformation($"RabbitMQ permissions for user '{username}' set");

            var errorExchange = await _managementClient.GetExchangeAsync("errors", vhost);

            var errorQueueName = (await _bus.Advanced.QueueDeclareAsync("")).Name;

            _logger.LogInformation($"RabbitMQ error queue for user '{username}' created");

            var errorQueue = await _managementClient.GetQueueAsync(errorQueueName, vhost);

            await _managementClient.CreateBindingAsync(errorExchange, errorQueue, new BindingInfo(username));

            _logger.LogInformation($"RabbitMQ error queue for user '{username}' bound to error exchange");

            await _elasticsearchClient.CreateUserAsync(username, password);

            _logger.LogInformation($"ElasticSearch user '{username}' created");

            await _elasticsearchClient.CreateIndexAsync(username);

            _logger.LogInformation($"ElasticSearch index for '{username}' created");

            var salt         = CryptoUtils.GenerateSalt();
            var passwordHash = CryptoUtils.ComputeHash(salt, password);

            var user = new Deer.Models.User
            {
                Username        = username,
                Salt            = salt,
                PasswordHash    = passwordHash,
                LogIndexName    = username,
                LogExchangeName = logExchangeName,
                LogQueueName    = logQueueName,
                ErrorQueueName  = errorQueueName
            };
            await _userRepository.CreateAsync(user);

            _logger.LogInformation($"UserInfo for user '{username}' saved to MongoDB");

            await _logConsumerService.AddConsumerForUserAsync(username);

            _logger.LogInformation($"Added log consumer for user '{username}'");

            return(true);
        }
        /// <summary>
        /// Initializes the 'MDIU_PasajeroAeronaveIT' instance form.
        /// </summary>
        /// <param name="exchangeInfo">Exchange information</param>
        /// <returns>IUMasterDetailController</returns>
        public IUMasterDetailController Initialize(ExchangeInfo exchangeInfo)
        {
            Controller = ControllerFactory.PasajeroAeronave.MasterDetail_MDIU_PasajeroAeronave(exchangeInfo);

            Controller.Scenario = new ScenarioPresentation(this, ScenarioType.MasterDetail);

            #region Master-Detail MDIU_PasajeroAeronave Links

            IUInstanceController ControllerMaster = Controller.Master as IUInstanceController;
            #region Instance IIU_PasajeroAeronave Links
            // DisplaySet
            ControllerMaster.DisplaySet.Viewer = new ListViewPresentation(lstViewDisplaySetMaster, MastertoolStripExportExcel, MastertoolStripExportWord, MastertoolStripRefresh, MastertoolStripHelp, MasteroptionsToolStripMenuItem, mnuNavigationsMaster);
            // OID Selector
            ControllerMaster.OidSelector.Label = new LabelPresentation(this.lOIDSelectorMaster);
            ControllerMaster.OidSelector.Editors[0] = new MaskedTextBoxPresentation(this.maskedTextBoxMasterid_PasajeroAeronave1);
            ControllerMaster.OidSelector.Trigger = new ButtonPresentation(this.bOIDSelectorMaster);
            if (ControllerMaster.OidSelector.SupplementaryInfo != null)
            {
                ControllerMaster.OidSelector.SupplementaryInfo.Viewer = new LabelDisplaySetPresentation(this.lSIOIDSelectorMaster);
            }

            // Actions
            ControllerMaster.Action.ActionItems[0].Trigger = new ToolStripButtonPresentation(this.toolstripActionsMaster_0, this.mnuActionsMaster_0);
            ControllerMaster.Action.ActionItems[1].Trigger = new ToolStripButtonPresentation(this.toolstripActionsMaster_1, this.mnuActionsMaster_1);
            ControllerMaster.Action.ActionItems[2].Trigger = new ToolStripButtonPresentation(this.toolstripActionsMaster_2, this.mnuActionsMaster_2);
            ControllerMaster.Action.ActionItems[3].Trigger = new ToolStripButtonPresentation(this.toolstripActionsMaster_3, this.mnuActionsMaster_3);
            ControllerMaster.Action.ActionItems[4].Trigger = new ToolStripButtonPresentation(this.toolstripActionsMaster_4, this.mnuActionsMaster_4);
            ControllerMaster.Action.ActionItems[5].Trigger = new ToolStripButtonPresentation(this.toolStripPrintMaster, this.mnuPrintMaster);

            // Navigations
            ControllerMaster.Navigation.NavigationItems[0].Trigger = new ToolStripButtonPresentation(this.toolstripNavigationsMaster_0, this.mnuNavigationsMaster_0);
            ControllerMaster.Navigation.NavigationItems[1].Trigger = new ToolStripButtonPresentation(this.toolstripNavigationsMaster_1, this.mnuNavigationsMaster_1);
            ControllerMaster.Navigation.NavigationItems[2].Trigger = new ToolStripButtonPresentation(this.toolstripNavigationsMaster_2, this.mnuNavigationsMaster_2);
            this.pnlDisplaySetMaster.ContextMenuStrip = MastercontextMenuStrip;
            ControllerMaster.DisplaySet.PreferencesTrigger = new ToolStripMenuItemPresentation(this.MastertoolStripPreferences);
            #endregion Instance IIU_PasajeroAeronave Links

            // Save position
            Controller.SavePositionTrigger = new ToolStripMenuItemPresentation(MastertoolStripSavePositions);

            IUPopulationController ControllerDetail0 = Controller.Details[0] as IUPopulationController;
            #region Population PIU_Pasajero Links

            // Displayset
            ControllerDetail0.DisplaySet.Population = new DataGridViewPresentation(this.gPopulationDetail0, this.Detail0toolStripExportExcel, this.Detail0toolStripExportWord, this.Detail0toolStripRetrieveAll, this.Detail0toolStripRefresh, this.Detail0toolStripHelp, this.Detail0optionsToolStripMenuItem, this.mnuNavigationsDetail0, exchangeInfo);
            ControllerDetail0.DisplaySet.NumberOfInstances = new ToolStripStatusLabelNumberInstancesPresentation(this.toolStripStatusLabelCountDetail0);
            ControllerDetail0.DisplaySet.First = null;
            ControllerDetail0.DisplaySet.Previous = null;
            ControllerDetail0.DisplaySet.Refresh = null;
            ControllerDetail0.DisplaySet.Next = null;
            ControllerDetail0.DisplaySet.ExecuteServiceTrigger = new ToolStripDropDownButtonPresentation(this.toolStripDropDownButtonSaveDetail0);
            ControllerDetail0.DisplaySet.PreferencesTrigger = new ToolStripMenuItemPresentation(this.Detail0toolStripPreferences);
            ControllerDetail0.DisplaySet.SaveColumnsWidthTrigger = new ToolStripMenuItemPresentation(this.Detail0toolStripSaveColumnWidth);
            // Order Criteria

            // Actions
            ControllerDetail0.Action.ActionItems[0].Trigger = new ToolStripButtonPresentation(this.toolstripActionsDetail0_0,this.mnuActionsDetail0_0);
            ControllerDetail0.Action.ActionItems[1].Trigger = new ToolStripButtonPresentation(this.toolstripActionsDetail0_1,this.mnuActionsDetail0_1);
            ControllerDetail0.Action.ActionItems[2].Trigger = new ToolStripButtonPresentation(this.toolstripActionsDetail0_2,this.mnuActionsDetail0_2);
            ControllerDetail0.Action.ActionItems[3].Trigger = new ToolStripButtonPresentation(this.toolstripActionsDetail0_3,this.mnuActionsDetail0_3);
            ControllerDetail0.Action.ActionItems[4].Trigger = new ToolStripButtonPresentation(this.toolStripPrintDetail0,this.mnuPrintDetail0);

            // Navigations
            ControllerDetail0.Navigation.NavigationItems[0].Trigger = new ToolStripButtonPresentation(this.toolstripNavigationsDetail0_0, this.mnuNavigationsDetail0_0);

            // Contextual Menu
            this.gPopulationDetail0.ContextMenuStrip = this.Detail0contextMenuStrip;
            #endregion Population PIU_Pasajero Links
            #endregion Master-Detail MDIU_PasajeroAeronave Links

            // Close button
            Controller.CancelTrigger = new ButtonPresentation(this.bCancel);

            // Initialize scenario
            Controller.Initialize();

            return Controller;
        }
Example #15
0
 public Martingale(TradeHistoryRepository tradeHistoryRepository, TradeConfigRepository tradeConfigRepository, ExchangeInfo exchangeInfo)
 {
     this.tradeHistoryRepository = tradeHistoryRepository;
     this.tradeConfigRepository  = tradeConfigRepository;
     this.exchangeInfo           = exchangeInfo;
     logService = new LogService();
 }
        public IUController Initialize(ExchangeInfo exchangeInfo)
        {
            // ExchangeInfo with Destinations
            mExchangeInfoConditional = exchangeInfo as ExchangeInfoConditionalNavigation;

            if (mExchangeInfoConditional != null)
            {
                this.SuspendLayout();

                Text = CultureManager.TranslateString(LanguageConstantKeys.L_QUESTION, LanguageConstantValues.L_QUESTION, Text);
                lblQuestion.Text = mExchangeInfoConditional.ConditionalNavigationInfo.Question;

                int lCount = 0;
                int lnexty = 0;
                int lseedy = 19;
                int lgrBox = 0;
                foreach (DestinationInfo lDestinationInfo in mExchangeInfoConditional.ConditionalNavigationInfo)
                {
                    #region radioButton01
                    if (lCount == 0)
                    {
                        radioButton01.AutoSize = true;
                        radioButton01.Size = new System.Drawing.Size(14, 13);
                        radioButton01.Location = new System.Drawing.Point(12, lseedy);
                        radioButton01.TabIndex = lCount;
                        radioButton01.TabStop = true;
                        radioButton01.UseVisualStyleBackColor = true;
                        radioButton01.Text = lDestinationInfo.AssociatedText;
                        radioButton01.Tag = lCount;

                        lnexty = radioButton01.Location.Y;
                    }
                    #endregion radioButton01
                    else
                    {
                        lnexty += lseedy;
                        //
                        // radioButton
                        //
                        RadioButton rb = new RadioButton();
                        rb.AutoSize = true;
                        rb.Location = new System.Drawing.Point(12, lnexty);
                        rb.Size = new System.Drawing.Size(14, 13);
                        rb.Location = new System.Drawing.Point(12, lnexty);
                        rb.Name = "radioButton" + lCount.ToString();
                        rb.TabIndex = lCount;
                        rb.TabStop = true;
                        rb.UseVisualStyleBackColor = true;
                        rb.Text = lDestinationInfo.AssociatedText;
                        rb.Tag = lCount;

                        grpBoxDestinations.Controls.Add(rb);

                        lgrBox += (lnexty + 10);
                    }
                    lCount++;
                }

                // Adjust the form size
                this.Size = new Size(this.Size.Width, grpBoxDestinations.Top + panel2.Height + (lCount + 2) * lseedy);
                // Select the first option
                radioButton01.Checked = true;
                this.ResumeLayout();
            }
            return null;
        }
 /// <summary>
 /// Initializes a new instance of the 'LaunchingScenarioEventArgs' class.
 /// </summary>
 /// <param name="exchangeInformation">Exchange information.</param>
 public LaunchingScenarioEventArgs(ExchangeInfo exchangeInformation)
 {
     mExchangeInformation = exchangeInformation;
 }
        public DataGridViewPresentation(
			DataGridView dataGridView,
			ToolStripMenuItem exportToExcel,
			ToolStripMenuItem exportToWord,
			ToolStripMenuItem retriveAll,
			ToolStripMenuItem refresh,
			ToolStripMenuItem help,
			ToolStripMenuItem options,
			ToolStripMenuItem navigations,
			ExchangeInfo exchangeInfo)
        {
            mDataGridViewIT = dataGridView;
            if (mDataGridViewIT != null)
            {
                mDataGridViewIT.SelectionChanged += new EventHandler(HandleDataGridITCurrentCellChanged);
                mDataGridViewIT.Scroll += new ScrollEventHandler(HandleDataGridViewITScroll);
                mDataGridViewIT.DataError += new DataGridViewDataErrorEventHandler(HandleDataDridViewITDataError);
                mDataGridViewIT.KeyDown += new KeyEventHandler(HandleDataGridViewITKeyDown);
                mDataGridViewIT.DoubleClick += new EventHandler(HandleDataGridViewITDoubleClick);
                mDataGridViewIT.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(HandleDataGridViewITEditingControlShowing);
                mDataGridViewIT.CellBeginEdit += new DataGridViewCellCancelEventHandler(HandleDataGridViewITCellBeginEdit);
                mDataGridViewIT.CellEndEdit += new DataGridViewCellEventHandler(HandleDataGridViewITCellEndEdit);

                if (exportToExcel!= null)
                {
                    exportToExcel.Text = CultureManager.TranslateString(LanguageConstantKeys.L_POP_UP_MENU_EXPORT_TO_EXCEL, LanguageConstantValues.L_POP_UP_MENU_EXPORT_TO_EXCEL);
                    exportToExcel.Click +=new EventHandler(HandleExportToExcel);
                }
                if (exportToWord != null)
                {
                    exportToWord.Text = CultureManager.TranslateString(LanguageConstantKeys.L_POP_UP_MENU_EXPORT_TO_WORD, LanguageConstantValues.L_POP_UP_MENU_EXPORT_TO_WORD);
                    exportToWord.Click += new EventHandler(HandleExportToWord);
                }

                //If the argumet allow multiselection, the grid is configure in multiselection mode,
                //otherwise the grid is configure in simple selection mode.
                ExchangeInfoSelectionForward exchangeInfoSelection = exchangeInfo as ExchangeInfoSelectionForward;
                if (exchangeInfoSelection != null)
                {
                    mDataGridViewIT.MultiSelect = exchangeInfoSelection.MultiSelectionAllowed;
                }

                if (retriveAll != null)
                {
                    retriveAll.Text = CultureManager.TranslateString(LanguageConstantKeys.L_POP_UP_MENU_RETRIEVE_ALL, LanguageConstantValues.L_POP_UP_MENU_RETRIEVE_ALL);
                    retriveAll.Click += new EventHandler(HandleRetrieveAllClick);
                }

                if (refresh != null)
                {
                    refresh.Text = CultureManager.TranslateString(LanguageConstantKeys.L_POP_UP_MENU_REFRESH, LanguageConstantValues.L_POP_UP_MENU_REFRESH);
                    refresh.Click += new EventHandler(HandleRefreshClick);
                }

                if (help != null)
                {
                    help.Text = CultureManager.TranslateString(LanguageConstantKeys.L_POP_UP_MENU_HELP, LanguageConstantValues.L_POP_UP_MENU_HELP);
                }

                if (options != null)
                {
                    options.Text = CultureManager.TranslateString(LanguageConstantKeys.L_POP_UP_MENU_OPTIONS, LanguageConstantValues.L_POP_UP_MENU_OPTIONS);
                }

                if (navigations != null)
                {
                    navigations.Text = CultureManager.TranslateString(LanguageConstantKeys.L_POP_UP_MENU_NAVIGATIONS, LanguageConstantValues.L_POP_UP_MENU_NAVIGATIONS);
                }

                Form lContainerForm = mDataGridViewIT.FindForm();
                if (lContainerForm != null)
                {
                    lContainerForm.Shown += new EventHandler(HandleContainerForm_Shown);
                }
                else
                {
                    mRaiseEventCurrentCellChanged = true;
                }
            }
            // Assigns the default texts for boolean values
            AssignDefaultTextForBooleans();
        }
 public static void LaunchOutbountArgumentsScenario(ExchangeInfo exchangeInfo)
 {
     // Instance Scenario, initialize and return the controller instance inside the Scenario.
     Form lScenario = CreateScenarioInstance(exchangeInfo);
     IUController lController = Initialize(lScenario, exchangeInfo);
     if (lController != null)
     {
         lScenario.MdiParent = MainForm;
         LaunchShowState = ShowState.Showing;
         lScenario.Show();
         LaunchShowState = ShowState.Showed;
     }
 }
 /// Initializes a new instance of 'ServiceResultEventArgs'.
 /// </summary>
 /// <param name="success">Indicates if the service has success or not.</param>
 public ServiceResultEventArgs(bool success, ExchangeInfo exchangeInfoReceived)
     : base()
 {
     Success = success;
     ExchangeInfoReceived = exchangeInfoReceived;
 }
        /// <summary>
        /// Initializes an scenario.
        /// </summary>
        /// <param name="scenario">Scenario to initialize.</param>
        /// <param name="exchangeInfo">Scenario information.</param>
        /// <returns></returns>
        private static IUController Initialize(Form scenario, ExchangeInfo exchangeInfo)
        {
            IUController lResult = null;

            // Initialize form with context.
            #region call Initialize an show form.
            if (scenario != null)
            {
                // Find Initialize method for scenario.
                try
                {
                    MethodInfo lInitialize = scenario.GetType().GetMethod("Initialize");
                    if (lInitialize != null)
                    {
                        object[] lArgs = new object[1];
                        lArgs[0] = exchangeInfo;
                        lResult = lInitialize.Invoke(scenario, lArgs) as IUController;
                    }
                }
                catch (Exception exception)
                {
                    //throw;
                    ScenarioManager.LaunchErrorScenario(exception);
                }
            }
            #endregion call Initialize an show form.

            return lResult;
        }
 /// <summary>
 /// Initializes a new instance of 'RefreshRequiredEventArgs'.
 /// Used to request a refresh from the contained elements, an action item for example.
 /// </summary>
 public RefreshRequiredEventArgs(ExchangeInfo receivedExchangeInfo)
 {
     mRefreshType = RefreshRequiredType.Default;
     mReceivedExchangeInfo = receivedExchangeInfo;
 }