コード例 #1
0
        private void dataGrid_onSelectionChanged(object sender, RangeRegionChangedEventArgs e)
        {
            if (dataGrid.SelectedDataRows.Length > 0)
            {
                OrderServiceInformation cOrderInfo = dataGrid.SelectedDataRows[0] as OrderServiceInformation;

                comboOrderService.Items.Clear();

                string[] sServices = cOrderInfo.Services;
                int      iLength   = sServices.Length;
                if (iLength == 0)
                {
                    btnOK.Enabled = false;
                }
                else
                {
                    for (int i = 0; i < iLength; i++)
                    {
                        comboOrderService.Items.Add(sServices[i]);
                    }
                    comboOrderService.SelectedIndex = 0;

                    btnOK.Enabled = true;
                }
            }
        }
コード例 #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            int    iValue = 0;
            double dValue = 0;

            if (int.TryParse(txtDefaultContracts.Text, out iValue))
            {
                __cProperty.DefaultContracts = iValue;
            }

            if (double.TryParse(txtInitCapital.Text, out dValue))
            {
                __cProperty.InitialCapital = dValue;
            }

            if (int.TryParse(txtMaxBarsReference.Text, out iValue))
            {
                __cProperty.MaximumBarsReference = iValue;
            }

            if (dataGrid.SelectedDataRows.Length > 0)
            {
                OrderServiceInformation cOrderInfo = dataGrid.SelectedDataRows[0] as OrderServiceInformation;
                __cProperty.OrderSource = string.Format("{0};{1}", cOrderInfo.ModuleName, comboOrderService.Text);
                __bCompleted            = true;
            }
            else if (!dataGrid.Enabled)
            {
                __bCompleted = true;
            }
            this.DialogResult = DialogResult.OK;
        }
コード例 #3
0
ファイル: OrderManager.cs プロジェクト: mirror222/ZeroSystem
        /// <summary>
        ///   取得所有下單元件資訊
        /// </summary>
        /// <returns>返回值:OrderServiceInformation類別的陣列</returns>
        public OrderServiceInformation[] GetOrderServiceInformations()
        {
            OrderServiceInformation[] cOrderServiceInfos = null;

            lock (__cOrderServiceInfos) {
                int iCount = __cOrderServiceInfos.Count;
                cOrderServiceInfos = new OrderServiceInformation[iCount];
                __cOrderServiceInfos.Values.CopyTo(cOrderServiceInfos, 0);
            }
            return(cOrderServiceInfos);
        }
コード例 #4
0
ファイル: OrderManager.cs プロジェクト: mirror222/ZeroSystem
        /// <summary>
        ///   更新下單元件資訊
        /// </summary>
        /// <param name="orderDirectory">下單元件資料夾</param>
        public void Refresh(string orderDirectory)
        {
            string[] sDllFiles = Directory.GetFiles(orderDirectory, "*.dll", SearchOption.AllDirectories);

            int iLength = sDllFiles.Length;

            if (iLength > 0)
            {
                for (int i = 0; i < iLength; i++)
                {
                    string          sDllFile  = sDllFiles[i];
                    string          sAssembly = Path.GetFileNameWithoutExtension(sDllFile);
                    FileVersionInfo cFileInfo = FileVersionInfo.GetVersionInfo(sDllFile);

                    OrderServiceInformation cOrderInfo = null;
                    lock (__cOrderServiceInfos) {
                        if (!__cOrderServiceInfos.TryGetValue(sAssembly, out cOrderInfo))
                        {
                            List <string> cServices = new List <string>();
                            Assembly      cAssembly = Assembly.LoadFile(Path.GetFullPath(sDllFile));

                            Type[] cTypes = cAssembly.GetTypes();
                            foreach (Type cType in cTypes)
                            {
                                if (CheckAbstractOrderService(cType))
                                {
                                    cServices.Add(cType.FullName);
                                }
                            }

                            cOrderInfo          = new OrderServiceInformation();
                            cOrderInfo.Services = cServices.ToArray();

                            __cOrderServiceInfos.Add(sAssembly, cOrderInfo);
                        }
                    }

                    //更新下單資訊
                    cOrderInfo.Company        = cFileInfo.CompanyName;
                    cOrderInfo.Description    = cFileInfo.Comments;
                    cOrderInfo.FileVersion    = cFileInfo.FileVersion;
                    cOrderInfo.ModuleName     = sAssembly;
                    cOrderInfo.Location       = sDllFile;
                    cOrderInfo.ProductVersion = cFileInfo.ProductVersion;
                }
            }
        }
コード例 #5
0
ファイル: OrderManager.cs プロジェクト: mirror222/ZeroSystem
        /// <summary>
        ///   建立下單元件服務
        /// </summary>
        /// <param name="orderSource">下單來源名稱(format: 下單組件名稱;下單服務類別名稱)</param>
        /// <returns>返回值:AbstractOrderService類別</returns>
        public AbstractOrderService CreateOrderService(string orderSource)
        {
            AbstractOrderService cOrderService = null;

            if (orderSource != null)
            {
                string[] sOrderParams = orderSource.Split(';');                  //格式:元件模組名稱;下單服務名稱
                OrderServiceInformation cOrderInfo = null;
                lock (__cOrderServiceInfos) {
                    __cOrderServiceInfos.TryGetValue(sOrderParams[0], out cOrderInfo);
                }

                if (cOrderInfo != null)
                {
                    string   sPath     = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    Assembly cAssembly = Assembly.LoadFile(Path.GetFullPath(sPath + "\\" + cOrderInfo.Location));
                    Type     cType     = cAssembly.GetType(sOrderParams[1]);

                    cOrderService = Activator.CreateInstance(cType) as AbstractOrderService;
                    cOrderService.Load();                       //讀取資訊
                }
            }
            return(cOrderService);
        }