private static void Logon() { var config = new JsonReader(ConfigurationManager.AppSettings["TCPConnector"].Replace('\'', '"')).Read(); ConnectorOptions options = new ConnectorOptions(config) { SecureRequest = SecureRequest.Show }; try { ClientGate.Logon(options); } catch (Exception ex) { if (ex.GetType() == typeof(TCPConnectorException)) { options.ForcePassword = true; ClientGate.Logon(options); } else { throw; } } }
public override JMXSchema GetSchema(string objectName) { JMXSchema schema = ClientGate.GetObjectSchema(objectName); schema.SchemaRepo = this; return(schema); }
private void ExecuteAction(string actionId) { using (var cd = new S031.MetaStack.WinForms.Actions.ActionExecuteForm(_grid, actionId)) { if (cd.ShowDialog() == DialogResult.OK) { OutputWindow.Show(); OutputWindow.Print(LogLevels.Information, $"Start {actionId}..."); new System.Threading.Thread(() => { Pipe.Start(); try { var dr = ClientGate.Execute(actionId, cd.GetInputParamTable()); if (dr.Read()) { OutputWindow.Print(LogLevels.Information, $"Result {dr[0]}"); } } catch (TCPConnectorException ex) { OutputWindow.Print(LogLevels.Error, $"{ex.Message}\n{ex.RemoteSource}\n{ex.RemoteStackTrace}"); } catch (Exception ex) { OutputWindow.Print(LogLevels.Error, $"{ex.Message}\n{ex.StackTrace}"); } Pipe.End(); OutputWindow.Print(LogLevels.Information, $"Finish {actionId}"); }).Start(); } } }
private void LoadRelated() { ToolStripMenuItem menuRun = (ToolStripMenuItem)(GetControl <MenuStrip>("MenuBar").Items["File"] as ToolStripMenuItem) .DropDownItems["FileOpenRelated"]; ToolStripDropDownButton tsbRun = (ToolStripDropDownButton)GetControl <ToolStrip>("Toolbar").Items["OpenRelated"]; List <ToolStripMenuItem> items = new List <ToolStripMenuItem>(); List <ToolStripMenuItem> buttons = new List <ToolStripMenuItem>(); JMXSchema schema = _grid.Schema; foreach (var att in schema.Attributes) { if (att.DataType == MdbType.@object) { JMXSchema rs = ClientGate.GetObjectSchema(att.ObjectName); if (rs.DbObjectType == DbObjectTypes.View) { items.Add(new ToolStripMenuItem(att.Name, null, MenuRel_Click) { Name = att.ObjectName, ToolTipText = att.Description }); buttons.Add(new ToolStripMenuItem(att.Name, null, MenuRel_Click) { Name = att.ObjectName, ToolTipText = att.Description }); } } } if (items.Count > 0) { menuRun.DropDownItems.AddRange(items.ToArray()); menuRun.DropDownItems.Add(new ToolStripSeparator()); tsbRun.DropDown.Items.AddRange(buttons.ToArray()); } }
public void ProcessRequest(HttpContext context) { var clientGate = new ClientGate(ConfigurationManager.AppSettings["SqlConnectionString"]); var rows = clientGate.PutClient(JsonConvert.DeserializeObject <Client>(context.Request.Form[0], datetimeConverter)); context.Response.ContentType = "text/plain"; context.Response.Write($"{rows} rows affected"); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { Logon(); } catch (Exception ex) { MessageBox.Show($"{ex.Message}\n{ex.StackTrace}", "Logon failed", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } AppDomain.CurrentDomain.ProcessExit += (s, e) => ClientGate.Logout(); Application.Run(new MainForm(ConfigurationManager.AppSettings["StartupForm"])); }
private void LoadActions() { ToolStripMenuItem menuRun = (ToolStripMenuItem)_grid.ContextMenuStrip.Items["EditRun"]; ToolStripDropDownButton tsbRun = (ToolStripDropDownButton)GetControl <ToolStrip>("Toolbar").Items["Run"]; List <ToolStripMenuItem> items = new List <ToolStripMenuItem>(); List <ToolStripMenuItem> buttons = new List <ToolStripMenuItem>(); JMXSchema schema = _grid.Schema; foreach (var att in schema.Attributes) { if (att.DataType == MdbType.@object) { JMXSchema rs = ClientGate.GetObjectSchema(att.ObjectName); if (rs.DbObjectType == DbObjectTypes.Action) { items.Add(new ToolStripMenuItem(att.Name, null, MenuRun_Click) { Name = att.AttribName, ToolTipText = att.Description }); buttons.Add(new ToolStripMenuItem(att.Name, null, MenuRun_Click) { Name = att.AttribName, ToolTipText = att.Description }); } } } if (items.Count > 0) { if (menuRun.DropDownItems.ContainsKey("Blank")) { menuRun.DropDownItems.Remove(menuRun.DropDownItems["Blank"]); } menuRun.DropDownItems.AddRange(items.ToArray()); menuRun.DropDownItems.Add(new ToolStripSeparator()); tsbRun.DropDown.Items.AddRange(buttons.ToArray()); } if ((menuRun.DropDownItems[menuRun.DropDownItems.Count - 1] is ToolStripSeparator)) { menuRun.DropDownItems.Remove(menuRun.DropDownItems[menuRun.DropDownItems.Count - 1]); } }
static void Main(string[] args) { //var connectionName = Dns.GetHostName() == "SERGEY-WRK" ? "Test" : "BankLocal"; //var connectionName = "SqliteDb"; using (FileLog l = new FileLog("TCPConnectorConnectTest", new FileLogSettings() { DateFolderMask = "yyyy-MM-dd" })) { var config = new JsonReader(ConfigurationManager.AppSettings["TCPConnector"].Replace('\'', '"')).Read(); ClientGate.Logon(new ConnectorOptions(config)); DateTime t = DateTime.Now; Console.WriteLine("Start performance test for Sys.Select"); //int i = 0; //for (int i = 0; i < 10000; i++) Parallel.For(0, 50000, (i, c) => { var dr = ClientGate.GetActionInfo("A_TestForFct") .GetInputParamTable() .AddNew() .SetValue("@ObjectName", "SysCat.SysSchemas") .SetValue("@IDs", "1") .Update(); ClientGate.Execute("A_TestForFct", dr); if (i % 1000 == 0) { //dr.Read(); Console.WriteLine($"{i}\t{dr[0]}{DateTime.Now.Second}"); } //try //{ // var dr = ClientGate.GetData("dbo.V_DealValue", // "@Date", new DateTime(2018, 10, 4), // "@BranchID", 2000, // "@DealType", ""); // if (i % 1000 == 0) // { // //dr.Read(); // Console.WriteLine($"{i}\t{dr.Rows[0][0]}{DateTime.Now.Second}"); // } //} //catch (Exception ex) //{ // Console.WriteLine($"{i}\t{ex.Message}"); // c.Break(); //} }); Console.WriteLine($"End performance test for {(DateTime.Now - t).TotalMilliseconds} ms Sys.Select"); ClientGate.Logout(); //l.Debug("Start performance test for logins"); //for (i = 0; i < 10000; i++) //{ // DataPackage dr = new DataPackage("ObjectName.String.64"); // dr.SetHeader("ConnectionName", "Test"); // dr.AddNew(); // dr["ObjectName"] = "SysCat.SysSchema"; // dr.Update(); // dr = ClientGate.Execute("Sys.GetSchema", dr); // if (i % 1000 == 0) // { // dr.Read(); // Console.WriteLine($"{i}\t{DateTime.Now.Second}"); // //Console.WriteLine(i); // } //} //l.Debug($"End performance test for {i} logins"); } }
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; } }