Skip to content

Commit dc99662

Browse files
committed
Bulk upload for 046 RC
1 parent b5a61e1 commit dc99662

12 files changed

Lines changed: 135 additions & 36 deletions

File tree

OSAE.API/OSAEScript/OSAEScriptManager.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,18 @@ public static string GetScriptByName(string scriptName)
445445
return script;
446446
}
447447

448+
public static string ExportScript(string scriptName)
449+
{
450+
using (MySqlCommand command = new MySqlCommand())
451+
{
452+
453+
command.CommandText = "CALL osae_sp_script_export (@ScriptName)";
454+
command.Parameters.AddWithValue("@ScriptName", scriptName);
455+
DataSet ds = OSAESql.RunQuery(command);
456+
457+
return ds.Tables[0].Rows[0][0].ToString();
458+
}
459+
}
448460

449461
public static void RunPatternScript(string pattern, string parameter, string from)
450462
{

Plugins/OSAE.Insteon/Class1.vb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,7 @@
576576
Log.Info("Unrecognized X10: " & GetHex(x(ms + 2)) & " " & GetHex(x(ms + 3)))
577577
End Select
578578
End If
579-
Case 98 ' 0x062 Send Insteon standard OR extended message
580-
' just echoing command sent, discard: 7 or 21 bytes
579+
Case 98 ' 0x062 Send Insteon standard OR extended message just echoing command sent, discard: 7 or 21 bytes
581580
MessageEnd = ms + 8
582581
If MessageEnd > 1000 Then MessageEnd = MessageEnd - 1000
583582
If DataAvailable >= 8 Then

Plugins/OSAE.Rest/OSAE.Rest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<Reference Include="System.Drawing" />
3838
<Reference Include="System.ServiceModel" />
3939
<Reference Include="System.ServiceModel.Web" />
40+
<Reference Include="System.Speech" />
4041
<Reference Include="System.Xml.Linq" />
4142
<Reference Include="System.Data.DataSetExtensions" />
4243
<Reference Include="Microsoft.CSharp" />

Plugins/OSAE.Rest/Rest.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,35 +52,25 @@ public override void RunInterface(string pluginName)
5252
try
5353
{
5454
restPort = int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "REST Port").Value);
55+
this.Log.Info("Rest Port read in as: " + restPort);
5556
}
5657
catch (FormatException ex)
57-
{
58-
this.Log.Error("Error pulling REST port from property (not a valid number)", ex);
59-
}
58+
{ this.Log.Error("Error pulling REST port from property (not a valid number)", ex); }
6059
catch (OverflowException ex)
61-
{
62-
this.Log.Error("Error pulling REST port from property (too large)", ex);
63-
}
60+
{ this.Log.Error("Error pulling REST port from property (too large)", ex); }
6461
catch (ArgumentNullException ex)
65-
{
66-
this.Log.Error("Error pulling REST port from property (null)", ex);
67-
}
62+
{ this.Log.Error("Error pulling REST port from property (null)", ex); }
6863
}
6964

7065
String restUrl = "http://localhost:"+restPort.ToString()+"/api";
7166
serviceHost = new WebServiceHost(typeof(OSAERest.api), new Uri(restUrl));
7267
WebHttpBinding binding = new WebHttpBinding(WebHttpSecurityMode.None);
7368
binding.CrossDomainScriptAccessEnabled = true;
74-
7569
var endpoint = serviceHost.AddServiceEndpoint(typeof(IRestService), binding, "");
7670

7771
ServiceDebugBehavior sdb = serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
7872
sdb.HttpHelpPageEnabled = false;
79-
80-
if (showHelp)
81-
{
82-
serviceHost.Description.Endpoints[0].Behaviors.Add(new WebHttpBehavior { HelpEnabled = true });
83-
}
73+
if (showHelp) serviceHost.Description.Endpoints[0].Behaviors.Add(new WebHttpBehavior { HelpEnabled = true });
8474

8575
this.Log.Info("Starting Rest Interface");
8676
serviceHost.Open();

Plugins/OSAE.Rest/WebService.cs

Lines changed: 86 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using System.ServiceModel;
77
using System.ServiceModel.Web;
88
using System.Drawing;
9+
using System.Speech;
10+
using System.Speech.Recognition;
911
using OSAE;
1012

1113
[ServiceContract]
@@ -25,19 +27,23 @@ public interface IRestService
2527
Boolean ExecuteMethod(string name, string method, string param1, string param2);
2628

2729
[OperationContract]
28-
[WebInvoke(UriTemplate = "object/add?name={name}&alias={alias&desc}&desc={description}&type={type}&address={address}&container={container}&enabled={enabled}",
30+
[WebInvoke(UriTemplate = "object/add?name={name}&alias={alias}&desc={description}&type={type}&address={address}&container={container}&enabled={enabled}",
2931
RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
3032
Boolean AddObject(string name, string alias, string description, string type, string address, string container, string enabled);
3133

3234
[OperationContract]
33-
[WebInvoke(UriTemplate = "object/update?oldName={oldName}&newName={newName}&alias={alias&desc}={description}&type={type}&address={address}&container={container}&enabled={enabled}",
35+
[WebInvoke(UriTemplate = "object/update?oldName={oldName}&newName={newName}&alias={alias}&desc={description}&type={type}&address={address}&container={container}&enabled={enabled}",
3436
RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
3537
Boolean UpdateObject(string oldName, string newName, string alias, string description, string type, string address, string container, string enabled);
3638

3739
[OperationContract]
3840
[WebGet(UriTemplate = "objects/type/{type}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
3941
OSAEObjectCollection GetObjectsByType(string type);
4042

43+
[OperationContract]
44+
[WebGet(UriTemplate = "objects/basetype/{type}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
45+
OSAEObjectCollection GetObjectsByBaseType(string type);
46+
4147
[OperationContract]
4248
[WebGet(UriTemplate = "objects/container/{container}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
4349
OSAEObjectCollection GetObjectsByContainer(string container);
@@ -86,7 +92,9 @@ public interface IRestService
8692
public class api : IRestService
8793
{
8894
private Logging logging = Logging.GetLogger("Rest");
89-
95+
private OSAE.General.OSAELog Log = new OSAE.General.OSAELog();
96+
SpeechRecognitionEngine oRecognizer = new SpeechRecognitionEngine();
97+
9098
public OSAEObject GetObject(string name)
9199
{
92100
// lookup object
@@ -113,6 +121,18 @@ public OSAEObjectCollection GetObjectsByType(string type)
113121
return objects;
114122
}
115123

124+
public OSAEObjectCollection GetObjectsByBaseType(string type)
125+
{
126+
OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByBaseType(type);
127+
128+
foreach (OSAEObject oObj in objects)
129+
{
130+
oObj.Properties = getProperties(oObj.Name);
131+
}
132+
133+
return objects;
134+
}
135+
116136
public OSAEObjectCollection GetObjectsByContainer(string container)
117137
{
118138
OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByContainer(container);
@@ -134,6 +154,23 @@ public Boolean ExecuteMethod(string name, string method, string param1, string p
134154

135155
public Boolean SendPattern(string match)
136156
{
157+
158+
try
159+
{
160+
oRecognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(oRecognizer_SpeechRecognized);
161+
//oRecognizer.AudioStateChanged += new EventHandler<AudioStateChangedEventArgs>(oRecognizer_StateChanged);
162+
}
163+
catch (Exception ex)
164+
{
165+
Log.Error("Unable to configure oRecognizer", ex);
166+
}
167+
168+
oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer);
169+
oRecognizer = OSAEGrammar.Load_OSA_Grammar(oRecognizer);
170+
171+
172+
173+
137174
//REPLACE WITH GRAMMAR
138175

139176

@@ -255,9 +292,7 @@ private Boolean StringToBoolean(string passedvalue)
255292
// otherwise it is probably a "1" or "0" and we will try to convert that to boolean
256293
int intvalue;
257294
if (Int32.TryParse(passedvalue, out intvalue))
258-
{
259295
booleanvalue = Convert.ToBoolean(intvalue);
260-
}
261296
}
262297

263298
return booleanvalue;
@@ -300,6 +335,52 @@ public List<OSAEStateHistory> GetStateHistory(string objName, string from, strin
300335
return list;
301336
}
302337

338+
private void oRecognizer_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
339+
{
340+
string gCurrentUser = "Unidentified Person";
341+
try
342+
{
343+
RecognitionResult result = e.Result;
344+
SemanticValue semantics = e.Result.Semantics;
345+
string scriptParameter = "";
346+
if (e.Result.Semantics.ContainsKey("PARAM1"))
347+
{
348+
string temp = e.Result.Semantics["PARAM1"].Value.ToString().Replace("'s", "").Replace("'S", "");
349+
if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY") temp = gCurrentUser;
350+
if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR") temp = "SYSTEM";
351+
scriptParameter = temp;
352+
if (e.Result.Semantics.ContainsKey("PARAM2"))
353+
{
354+
temp = e.Result.Semantics["PARAM2"].Value.ToString().Replace("'s", "").Replace("'S", "");
355+
if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY") temp = gCurrentUser;
356+
if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR") temp = "SYSTEM";
357+
scriptParameter += "," + temp;
358+
if (e.Result.Semantics.ContainsKey("PARAM3"))
359+
{
360+
temp = e.Result.Semantics["PARAM3"].Value.ToString().Replace("'s", "").Replace("'S", "");
361+
if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY") temp = gCurrentUser;
362+
if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR") temp = "SYSTEM";
363+
scriptParameter += "," + temp;
364+
}
365+
}
366+
}
367+
string sResults = "";
368+
if (result.Grammar.Name.ToString() == "Direct Match")
369+
{
370+
Log.Debug("Searching for: " + sResults);
371+
sResults = OSAEGrammar.SearchForMeaning(result.Text, scriptParameter, gCurrentUser);
372+
}
373+
else
374+
{
375+
Log.Debug("Searching for: " + sResults);
376+
sResults = OSAEGrammar.SearchForMeaning(result.Grammar.Name.ToString(), scriptParameter, gCurrentUser);
377+
}
378+
379+
Log.Info("Search Results: " + sResults);
380+
}
381+
catch (Exception ex)
382+
{ Log.Error("Error in _SpeechRecognized!", ex); }
383+
}
303384
}
304385

305386
public class OSAEPropertyHistory

UI/Manager/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ private void hypSettings_Click(object sender, RoutedEventArgs e)
449449

450450
private void hypGUI_Click(object sender, RoutedEventArgs e)
451451
{
452-
Process.Start(Common.ApiPath + "\\OSAE.GUI.exe");
452+
Process.Start(Common.ApiPath + "\\OSAE.Screens.exe");
453453
}
454454

455455
void OnChecked(object sender, RoutedEventArgs e)

UI/Web/mobile/index.aspx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
$('#propsBtn').removeClass("ui-btn-active");
3838
$('#callback').html('');
3939
40-
$.getJSON('http://' + host + ':<%= hdnRestPort.Value %>/api/objects/type/place?callback=?', null, function (data) {
40+
$.getJSON('http://' + host + ':<%= hdnRestPort.Value %>/api/objects/basetype/place?callback=?', null, function (data) {
4141
//$('#callback').html(data);
4242
$("#callback").append('<ul id="places" data-role="listview" data-theme="g">');
4343
$.each(data, function (i, obj) {

UI/Web/mobile/index.aspx.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private void getRestPort()
2626
}
2727
catch (FormatException)
2828
{
29-
// do nothing and move on
29+
// do nothing and move on
3030
}
3131
catch (OverflowException)
3232
{
@@ -39,5 +39,6 @@ private void getRestPort()
3939
}
4040

4141
hdnRestPort.Value = restPort.ToString();
42-
}
42+
}
43+
4344
}

UI/Web/objects.aspx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@
314314
</div>
315315
</div>
316316

317+
<asp:Label runat="server" ID="hdnSelectedObjectName" Visible="false"></asp:Label>
317318
<asp:Label runat="server" ID="hdnSelectedPropName" Visible="false"></asp:Label>
318319
<asp:Label runat="server" ID="hdnSelectedPropType" Visible="false"></asp:Label>
319320
<asp:HiddenField runat="server" ID="hdnEditingPropList"/>

UI/Web/objects.aspx.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public void RaisePostBackEvent(string eventArgument)
1919
{
2020
alert.Visible = false;
2121
gvObjects.SelectedIndex = Int32.Parse(args[1]);
22+
hdnSelectedObjectName.Text = gvObjects.DataKeys[gvProperties.SelectedIndex]["object_name"].ToString();
2223
panelEditForm.Visible = true;
2324
btnUpdate.Visible = true;
2425
panelPropForm.Visible = false;
@@ -171,7 +172,8 @@ public void bindGridView(string sortExp,string sortDir)
171172

172173
protected void Page_PreRender(object sender, EventArgs e)
173174
{
174-
175+
if (hdnSelectedObjectName.Text != "")
176+
txtExportScript.Text = OSAEObjectManager.ObjectExport(hdnSelectedObjectName.Text);
175177
}
176178

177179
protected void gvObjects_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)

0 commit comments

Comments
 (0)