hooking excel to historical_query for testing
This commit is contained in:
1 parent
6a8930f594
commit
f025eed845
6 files changed
+73
-4
No files matched your search
Vendored
+1
-1
@@ -142,7 +142,7 @@
|
||||
"name": "Excel Launch",
|
||||
"type": "clr",
|
||||
"request": "launch",
|
||||
"program": "C:/Program Files/Microsoft Office/Office14/EXCEL.EXE",
|
||||
"program": "C:/Program Files/Microsoft Office/Office16/EXCEL.EXE",
|
||||
"args": [
|
||||
"${workspaceRoot}/build/Debug/bin/net471/spark_excel-addin64-packed.xll"
|
||||
],
|
||||
|
||||
Binary file not shown.
@@ -90,7 +90,14 @@ namespace bts.excel
|
||||
{
|
||||
if(string.IsNullOrEmpty(json))
|
||||
json = "{}";
|
||||
request = JsonParser.Default.Parse(json, desc);
|
||||
try
|
||||
{
|
||||
request = JsonParser.Default.Parse(json, desc);
|
||||
}
|
||||
catch(InvalidProtocolBufferException)
|
||||
{
|
||||
request = (IMessage) Newtonsoft.Json.JsonConvert.DeserializeObject(json, desc.ClrType);
|
||||
}
|
||||
}
|
||||
}
|
||||
return request;
|
||||
|
||||
@@ -25,7 +25,68 @@ namespace bts.excel
|
||||
else if (!string.IsNullOrEmpty(key1))
|
||||
val = jo[key1];
|
||||
return val.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
static Google.Protobuf.JsonFormatter _formatter =
|
||||
new Google.Protobuf.JsonFormatter(new Google.Protobuf.JsonFormatter.Settings(true));
|
||||
[ExcelFunction]
|
||||
public static object bts_json_create(string type)
|
||||
{
|
||||
System.Type t = find_full_type_in_all_assemblies(type);
|
||||
object obj = Activator.CreateInstance(t);
|
||||
foreach(var pr in t.GetProperties())
|
||||
{
|
||||
object val = null;
|
||||
try
|
||||
{
|
||||
val = Activator.CreateInstance(pr.PropertyType);
|
||||
}
|
||||
catch {}
|
||||
try
|
||||
{
|
||||
pr.SetValue(obj, val);
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
string s = "{}";
|
||||
if(obj is Google.Protobuf.IMessage imsg)
|
||||
s = _formatter.Format(imsg);
|
||||
else
|
||||
s = JsonConvert.SerializeObject(obj, Formatting.Indented);
|
||||
return s;
|
||||
}
|
||||
[ExcelFunction]
|
||||
public static object bts_json_fill(string root, string key, string value)
|
||||
{
|
||||
var jo = JObject.Parse(root);
|
||||
jo[key] = value;
|
||||
var s = jo.ToString();
|
||||
return s;
|
||||
}
|
||||
|
||||
[ExcelFunction]
|
||||
public static object bts_date_to_json(object dt, bool is_duration = false)
|
||||
{
|
||||
string s = "{}";
|
||||
if(is_duration)
|
||||
{
|
||||
var span = TimeSpan.FromDays((double)dt);
|
||||
var ts = Google.Protobuf.WellKnownTypes.Duration.FromTimeSpan(span);
|
||||
s = JsonConvert.SerializeObject(ts, Formatting.None);
|
||||
s = _formatter.Format(ts);
|
||||
s = s.Replace(@"""", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
var dd = DateTime.FromOADate((double)dt);
|
||||
var utc = dd.ToUniversalTime();
|
||||
var ts = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(utc);
|
||||
s = JsonConvert.SerializeObject(ts, Formatting.None);
|
||||
s = _formatter.Format(ts);
|
||||
s = s.Replace(@"""", "");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static bool parse_venue(string exch, out Venue ven)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ package bts.history;
|
||||
option csharp_namespace="bts.history";
|
||||
option cc_enable_arenas=true;
|
||||
import "lib/api/Apioptions.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "lib/domain_model/Security.proto";
|
||||
|
||||
@@ -43,7 +43,7 @@ REM can't share externals because of symlinks
|
||||
REM docker exec spark_sdk ln -s /home/bts/spark_host/externals /home/bts/spark/externals
|
||||
echo installing protobuf pybars3 markdown, remove this line if we fixed docker
|
||||
docker exec spark_sdk pip install protobuf pybars3 markdown
|
||||
echo now run git clone git@bitbucket.org:bluetradesys/externals.git in /home/bts/sparknm
|
||||
echo now run git clone git@bitbucket.org:bluetradesys/externals.git in /home/bts/spark
|
||||
echo also remove node_modules directories because they can't be shared between windows and linux,
|
||||
echo remove src/web/ui/node_modules and src/web/api/node_modules
|
||||
|
||||
|
||||
Reference in new issue
Block a user