Hehehehe
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using DevExpress.Data.Filtering;
|
||||
using System;
|
||||
using DevExpress.Data.Filtering;
|
||||
using DevExpress.ExpressApp;
|
||||
using DevExpress.ExpressApp.Actions;
|
||||
using DevExpress.ExpressApp.Xpo;
|
||||
@@ -17,8 +18,16 @@ namespace Nuvolar.Module.Controllers
|
||||
protected override void OnActivated()
|
||||
{
|
||||
base.OnActivated();
|
||||
// Perform various tasks depending on the target View.
|
||||
Frame.GetController<InvoiceVC>().FireNAVmanageInvoiceFinalWork += FireNAVmanageInvoiceFinalWork;
|
||||
Frame.GetController<OrderInVC>().FireNAVmanageInvoiceFinalWork += FireNAVmanageInvoiceFinalWork;
|
||||
}
|
||||
|
||||
private void FireNAVmanageInvoiceFinalWork(InvoiceHeader _InvoiceHeader)
|
||||
{
|
||||
XPObjectSpace _ocur = View.ObjectSpace as XPObjectSpace;
|
||||
this.NAV_manageInvoice(_InvoiceHeader, _ocur);
|
||||
}
|
||||
|
||||
protected override void OnViewControlsCreated()
|
||||
{
|
||||
base.OnViewControlsCreated();
|
||||
@@ -26,7 +35,7 @@ namespace Nuvolar.Module.Controllers
|
||||
}
|
||||
protected override void OnDeactivated()
|
||||
{
|
||||
// Unsubscribe from previously subscribed events and release other references and resources.
|
||||
Frame.GetController<InvoiceVC>().FireNAVmanageInvoiceFinalWork -= FireNAVmanageInvoiceFinalWork;
|
||||
base.OnDeactivated();
|
||||
}
|
||||
/// <summary>
|
||||
@@ -96,6 +105,11 @@ namespace Nuvolar.Module.Controllers
|
||||
{
|
||||
XPObjectSpace _ocur = View.ObjectSpace as XPObjectSpace;
|
||||
InvoiceHeader _InvoiceHeader = View.SelectedObjects[0] as InvoiceHeader;
|
||||
this.NAV_manageInvoice(_InvoiceHeader,_ocur);
|
||||
(View as ListView).CollectionSource.Reload();
|
||||
}
|
||||
private void NAV_manageInvoice(InvoiceHeader _InvoiceHeader,XPObjectSpace _ocur)
|
||||
{
|
||||
string _operation = "CREATE";
|
||||
|
||||
if (_InvoiceHeader.IsStorno)
|
||||
@@ -147,7 +161,7 @@ namespace Nuvolar.Module.Controllers
|
||||
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Error, 5000, InformationPosition.Bottom);
|
||||
}
|
||||
|
||||
(View as ListView).CollectionSource.Reload();
|
||||
|
||||
}
|
||||
|
||||
private void aNAV_queryInvoiceStatus_Execute(object sender, SimpleActionExecuteEventArgs e)
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Nuvolar.Module.StaticClass
|
||||
_ResponseMessage = "";
|
||||
_UriBase = ConfigurationManager.AppSettings["Uri"];
|
||||
_GeocodeAPIKey = ConfigurationManager.AppSettings["GeocodeAPIKey"];
|
||||
Laravel.Users _Users = _onew.FindObject<Nuvolar.Module.Laravel.Users>(CriteriaOperator.Parse("email='sysadmin@emango.com'"));
|
||||
Laravel.Users _Users = _onew.FindObject<Laravel.Users>(CriteriaOperator.Parse("email='sysadmin@emango.com'"));
|
||||
if (_Users != null)
|
||||
{
|
||||
if (String.IsNullOrEmpty(_Users.api_token))
|
||||
@@ -61,82 +61,106 @@ namespace Nuvolar.Module.StaticClass
|
||||
var dd = JsonConvert.DeserializeObject(json);
|
||||
var dict = JObject.Parse(json).SelectToken("data").ToObject<Dictionary<string, string>>();
|
||||
_API_Token = dict["api_token"];
|
||||
|
||||
Tracing.Tracer.LogText(string.Format("API Token requested : {0}", _API_Token.ToString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Tracing.Tracer.LogText("API Token request fail!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_API_Token = _Users.api_token;
|
||||
Tracing.Tracer.LogText(string.Format("API Token found : {0}", _API_Token.ToString()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Tracing.Tracer.LogText("Laravel user not found!");
|
||||
}
|
||||
}
|
||||
public static string ExecuteRootePOST(string _RooteString, bool _NeedAuthentication, string _postData)
|
||||
{
|
||||
_StatusCode = 500;
|
||||
_StatusMessage = "Not respond";
|
||||
_StatusMessage = "Not respond ...";
|
||||
string json = "";
|
||||
|
||||
|
||||
Tracing.Tracer.LogText(_UriBase + _RooteString);
|
||||
|
||||
var _Uri = new Uri(_UriBase + _RooteString, UriKind.Absolute);
|
||||
var _WebRequest = WebRequest.Create(_Uri);
|
||||
HttpWebRequest _HttpWebRequest = (HttpWebRequest)_WebRequest;
|
||||
|
||||
_HttpWebRequest.Method = "POST";
|
||||
byte[] byteArray = Encoding.UTF8.GetBytes(_postData);
|
||||
|
||||
|
||||
if (_NeedAuthentication)
|
||||
{
|
||||
_HttpWebRequest.PreAuthenticate = true;
|
||||
_HttpWebRequest.Headers.Add("Authorization", "Bearer " + _API_Token);
|
||||
_HttpWebRequest.Headers.Add("cdb", GeneralFunction.GLOBAL_SQLDatabase);
|
||||
}
|
||||
|
||||
_HttpWebRequest.ContentType = "application/json";
|
||||
_HttpWebRequest.Accept = "application/json";
|
||||
_HttpWebRequest.ContentLength = byteArray.Length;
|
||||
Stream _dataStream = _HttpWebRequest.GetRequestStream();
|
||||
_dataStream.Write(byteArray, 0, byteArray.Length);
|
||||
_dataStream.Close();
|
||||
Tracing.Tracer.LogText(_postData);
|
||||
|
||||
try
|
||||
{
|
||||
WebResponse _WebResponse = _WebRequest.GetResponse();
|
||||
_StatusCode = (int)((HttpWebResponse)_WebResponse).StatusCode;
|
||||
_StatusMessage = ((HttpWebResponse)_WebResponse).StatusDescription;
|
||||
var _responseStream = _WebResponse.GetResponseStream();
|
||||
if (_responseStream == null) return json;
|
||||
var _Uri = new Uri(_UriBase + _RooteString, UriKind.Absolute);
|
||||
var _WebRequest = WebRequest.Create(_Uri);
|
||||
HttpWebRequest _HttpWebRequest = (HttpWebRequest)_WebRequest;
|
||||
|
||||
var _StreamReader = new StreamReader(_responseStream, Encoding.Default);
|
||||
json = _StreamReader.ReadToEnd();
|
||||
_HttpWebRequest.Method = "POST";
|
||||
byte[] byteArray = Encoding.UTF8.GetBytes(_postData);
|
||||
|
||||
|
||||
if (_NeedAuthentication)
|
||||
{
|
||||
_HttpWebRequest.PreAuthenticate = true;
|
||||
_HttpWebRequest.Headers.Add("Authorization", "Bearer " + _API_Token);
|
||||
_HttpWebRequest.Headers.Add("cdb", GeneralFunction.GLOBAL_SQLDatabase);
|
||||
}
|
||||
|
||||
_HttpWebRequest.ContentType = "application/json";
|
||||
_HttpWebRequest.Accept = "application/json";
|
||||
_HttpWebRequest.ContentLength = byteArray.Length;
|
||||
Stream _dataStream = _HttpWebRequest.GetRequestStream();
|
||||
_dataStream.Write(byteArray, 0, byteArray.Length);
|
||||
_dataStream.Close();
|
||||
|
||||
Tracing.Tracer.LogText("Web request initialized !");
|
||||
|
||||
try
|
||||
{
|
||||
_StatusMessage = JsonConvert.DeserializeObject(json).ToString();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
_responseStream.Close();
|
||||
_WebResponse.Close();
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
|
||||
if (ex.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
var _WebResponse = (HttpWebResponse)ex.Response;
|
||||
_StatusCode = (int)_WebResponse.StatusCode;
|
||||
WebResponse _WebResponse = _WebRequest.GetResponse();
|
||||
_StatusCode = (int)((HttpWebResponse)_WebResponse).StatusCode;
|
||||
_StatusMessage = ((HttpWebResponse)_WebResponse).StatusDescription;
|
||||
var _responseStream = _WebResponse.GetResponseStream();
|
||||
if (_responseStream != null)
|
||||
{
|
||||
var _StreamReader = new StreamReader(_responseStream, Encoding.Default);
|
||||
json = _StreamReader.ReadToEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
return json;
|
||||
}
|
||||
try
|
||||
{
|
||||
_StatusMessage = JsonConvert.DeserializeObject(json).ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Tracing.Tracer.LogText(ex.Message);
|
||||
}
|
||||
|
||||
|
||||
_responseStream.Close();
|
||||
_WebResponse.Close();
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Tracing.Tracer.LogText(ex.Message);
|
||||
|
||||
if (ex.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
var _WebResponse = (HttpWebResponse)ex.Response;
|
||||
_StatusCode = (int)_WebResponse.StatusCode;
|
||||
_StatusMessage = ((HttpWebResponse)_WebResponse).StatusDescription;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
Tracing.Tracer.LogText(ex.Message);
|
||||
}
|
||||
return json;
|
||||
|
||||
}
|
||||
public static string ExecuteRooteGET(string _RooteString, bool _NeedAuthentication)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user