Esempio n. 1
0
 public void speedTest()
 {
     using (FileLog l = new FileLog("MdbTypeTest", new FileLogSettings()
     {
         DateFolderMask = "yyyy-MM-dd"
     }))
     {
         Type        t    = null;
         MdbTypeInfo info = new MdbTypeInfo();
         l.Debug("SpeedTest 1 Start ");
         int i = 0;
         for (i = 0; i < 1000000; i++)
         {
             t = MdbTypeMap.GetType("object", typeof(string));
         }
         l.Debug($"SpeedTest 1 Finish {i} count result {t}");
         for (i = 0; i < 1000000; i++)
         {
             t = MdbTypeMap.GetType("failed", typeof(string));
         }
         l.Debug($"SpeedTest 2 Finish {i} count result {t}");
         for (i = 0; i < 1000000; i++)
         {
             info = MdbTypeMap.GetTypeInfo(typeof(string));
         }
         l.Debug($"SpeedTest 3 Finish {i} count result {info.Name}");
     }
 }
Esempio n. 2
0
        public DBGridParam(JMXSchema schema, DBGrid grid)
        {
            _grid = grid;
            int count = schema.Parameters.Count;
            List <WinFormItem> listItems = new List <WinFormItem>(count);

            foreach (var p in schema.Parameters)
            {
                WinFormItem item = new WinFormItem(p.ParamName)
                {
                    Caption          = p.Name,
                    DataType         = MdbTypeMap.GetType(p.DataType),
                    Width            = p.DisplayWidth,
                    DataSize         = p.Width,
                    Format           = p.Format,
                    SuperForm        = p.SuperForm,
                    SuperMethod      = p.SuperMethod,
                    ConstName        = p.ConstName,
                    PresentationType = Type.GetType(p.PresentationType),
                    Value            = p.DefaultValue
                };
                if (p.ListData.Count > 0)
                {
                    for (int i = 0; i < p.ListData.Count; i++)
                    {
                        item.Add(new WinFormItem(p.ListItems[i])
                        {
                            Caption  = p.ListItems[i],
                            DataType = item.DataType,
                            Value    = p.ListData[i]
                        });
                    }
                    item.Mask = "lock";
                }
                //!!! Добавить добавление констант в расширениях (class UserConstants.GetConst(), AddConst()
                switch (item.ConstName.ToLower())
                {
                case "bs_datecurrent":
                    item.Value = vbo.Date();
                    break;

                case "bs_datestart":
                    item.Value = rth.DateStart;
                    break;

                case "bs_datefinish":
                    item.Value = rth.DateFinish;
                    break;

                case "bs_username":
                    item.Value = PathHelper.UserName;
                    break;

                default:
                    if (item.ConstName.Left(1) == "=")
                    {
                        //!!! item.Value = Evaluator.Eval(item.ConstName.Substring(1), schema);
                    }
                    else
                    {
                        //!!!
                        //string localSetting = schema[path + "ConstName"];
                        //if (localSetting.IndexOf(vbo.chrSep) > -1)
                        //	localSetting = dbs.GetSetting(localSetting);
                        //else
                        //	localSetting = dbs.GetSetting(setPath + localSetting);
                        //if (string.IsNullOrEmpty(localSetting))
                        //	localSetting = dbs.GetSetting(schema["ObjectName"] + vbo.chrSep + "Setup" + vbo.chrSep +
                        //		schema[path + "ConstName"]);
                        //if (!string.IsNullOrEmpty(localSetting))
                        //	item.Value = localSetting;
                    }
                    break;
                }
                if (item.OriginalValue == null && _grid.ParentRow != null && !string.IsNullOrEmpty(p.FieldName))
                {
                    try
                    {
                        item.Value = _grid.ParentRow[p.FieldName];
                    }
                    finally
                    {
                        if (vbo.IsEmpty(item.Value))
                        {
                            item.Value = null;
                        }
                    }
                }
                if ((item.Visible = (vbo.IsEmpty(item.Value))) && _paramCash.ContainsKey(item.Name))
                {
                    item.Value = _paramCash[item.Name];
                }
                listItems.Add(item);
            }
            _items = listItems.ToArray();
        }
Esempio n. 3
0
        public ActionExecuteForm(DBGrid grid, string actionID)
            : base(WinFormStyle.Dialog)
        {
            this.Add <Panel>(WinFormConfig.SinglePageForm);
            TableLayoutPanel tlpRows = this.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel;
            TableLayoutPanel tp      = tlpRows.Add <TableLayoutPanel>(new WinFormItem("WorkCells")
            {
                CellsSize = new Pair <int>(2, 1)
            });

            tp.ColumnStyles[0].SizeType = SizeType.Percent;
            tp.ColumnStyles[0].Width    = 38;
            tp.ColumnStyles[1].SizeType = SizeType.Percent;
            tp.ColumnStyles[1].Width    = 62;

            int maxWidth = 480;

            _ai       = ClientGate.GetActionInfo(actionID);
            this.Text = _ai.Name;
            foreach (var p in _ai.InterfaceParameters
                     .Where(param => param.Value.Dirrect == ParamDirrect.Input)
                     .OrderBy(param => param.Value.Position)
                     .Select(param => param.Value))
            {
                WinFormItem item = new WinFormItem(p.AttribName)
                {
                    Caption          = p.Name,
                    DataType         = MdbTypeMap.GetType(p.DataType),
                    Width            = p.DisplayWidth,
                    DataSize         = p.Width,
                    Format           = p.Format,
                    SuperForm        = p.SuperForm,
                    SuperMethod      = p.SuperMethod,
                    ConstName        = p.ConstName,
                    PresentationType = Type.GetType(p.PresentationType),
                    Value            = p.DefaultValue
                };
                if (!p.ListData.IsEmpty())
                {
                    string[] data = p.ListData.Split(',');
                    string[] text = p.ListItems.Split(',');
                    for (int i = 0; i < data.Length; i++)
                    {
                        item.Add(new WinFormItem(text[i])
                        {
                            Caption  = text[i],
                            DataType = item.DataType,
                            Value    = data[i].CastAs(item.DataType)
                        });
                    }
                    item.Mask = "lock";
                }
                switch (item.ConstName.ToLower())
                {
                case "bs_datecurrent":
                    item.Value = vbo.Date();
                    break;

                case "bs_datestart":
                    item.Value = rth.DateStart;
                    break;

                case "bs_datefinish":
                    item.Value = rth.DateFinish;
                    break;

                case "bs_username":
                    item.Value = PathHelper.UserName;
                    break;

                case "bs_selection":
                    item.Value = string.Join(",", grid.CheckedRows.Select(r => r[grid.IdColName].ToString()));
                    break;

                case "bs_objectname":
                    item.Value = grid.SchemaName;
                    break;

                default:
                    if (item.ConstName.Left(1) == "=")
                    {
                        //!!! item.Value = Evaluator.Eval(item.ConstName.Substring(1), schema);
                    }
                    else
                    {
                        //!!!
                        //string localSetting = schema[path + "ConstName"];
                        //if (localSetting.IndexOf(vbo.chrSep) > -1)
                        //	localSetting = dbs.GetSetting(localSetting);
                        //else
                        //	localSetting = dbs.GetSetting(setPath + localSetting);
                        //if (string.IsNullOrEmpty(localSetting))
                        //	localSetting = dbs.GetSetting(schema["ObjectName"] + vbo.chrSep + "Setup" + vbo.chrSep +
                        //		schema[path + "ConstName"]);
                        //if (!string.IsNullOrEmpty(localSetting))
                        //	item.Value = localSetting;
                    }
                    break;
                }
                if (item.OriginalValue == null && grid.ParentRow != null && !string.IsNullOrEmpty(p.FieldName))
                {
                    try
                    {
                        item.Value = grid.ParentRow[p.FieldName];
                    }
                    finally
                    {
                        if (vbo.IsEmpty(item.Value))
                        {
                            item.Value = null;
                        }
                    }
                }
                int width = Math.Max(p.Name.Length, p.DisplayWidth) * (int)this.Font.SizeInPoints;
                if (width > maxWidth)
                {
                    maxWidth = width;
                }
                tp.Add(item);
            }
            var btp = GetItem("MainPanel")
                      .LinkedControl
                      .Add <TableLayoutPanel>(WinFormConfig.StdButtons(OKCaption: "&Выполнить"));

            this.AcceptButton = null;
            this.Width        = maxWidth;
            this.Height       = (int)(this.Width / vbo.GoldenRatio);
            if (this.Parent != null)
            {
                this.StartPosition = FormStartPosition.CenterParent;
            }
            else
            {
                this.StartPosition = FormStartPosition.CenterScreen;
            }
        }