-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCodeEditorViewComponent.cs
More file actions
79 lines (71 loc) · 2.92 KB
/
CodeEditorViewComponent.cs
File metadata and controls
79 lines (71 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using ExpressBase.Common;
using ExpressBase.Common.Connections;
using ExpressBase.Common.Constants;
using ExpressBase.Common.Data;
using ExpressBase.Common.Objects;
using ExpressBase.Common.Structures;
using ExpressBase.Objects;
using ExpressBase.Objects.ServiceStack_Artifacts;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using ServiceStack;
using ServiceStack.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
namespace ExpressBase.Web.Components
{
public class CodeEditorViewComponent : ViewComponent
{
protected JsonServiceClient ServiceClient { get; set; }
protected RedisClient Redis { get; set; }
public CodeEditorViewComponent(IServiceClient _client, IRedisClient _redis)
{
this.ServiceClient = _client as JsonServiceClient;
this.Redis = _redis as RedisClient;
}
public async Task<IViewComponentResult> InvokeAsync(string dsobj, int tabnum, int type, string refid, string ssurl)
{
ViewBag.dsObj = dsobj;
ViewBag.tabnum = tabnum;
ViewBag.ObjType = type;
ViewBag.Refid = refid;
//ViewBag.SqlFns = Getsqlfns((int)EbObjectTypes.SqlFunction);
ViewBag.ssurl = ssurl;
//ViewBag.TableSchema = GetTableSchemaRequest();
ViewBag.EbDbType = Enum.GetValues(typeof(EbDbTypes))
.Cast<EbDbTypes>()
.ToDictionary(t => t.ToString(), t => (int)t);
Dictionary<int, string> d = new Dictionary<int, string>();
EbConnectionsConfig _connections = this.Redis.Get<EbConnectionsConfig>(string.Format(CoreConstants.SOLUTION_INTEGRATION_REDIS_KEY, ViewBag.cid));
if (_connections != null)
{
d.Add(_connections.DataDbConfig.Id, _connections.DataDbConfig.NickName);
if (_connections.SupportingDataDbConfig != null)
foreach (EbDbConfig c in _connections.SupportingDataDbConfig)
d.Add(c.Id, c.NickName);
}
ViewBag.SupportingDataDB = JsonConvert.SerializeObject(d);
return View("codeEditor");
}
public List<string> Getsqlfns(int obj_type)
{
var fdresultlist = this.ServiceClient.Get<EbObjectObjListResponse>(new EbObjectObjListRequest { EbObjectType = obj_type });
var fdrlist = fdresultlist.Data;
List<string> objects_list = new List<string>();
foreach (var element in fdrlist)
{
objects_list.Add(element.Name);
}
return objects_list;
}
public string GetTableSchemaRequest()
{
var res = this.ServiceClient.Get<GetTbaleSchemaResponse>(new GetTableSchemaRequest());
string schema = JsonConvert.SerializeObject(res.Data);
return schema;
}
}
}