public void AddMobileResult(string requestID, Result result) { Console.WriteLine("{0} A {1} is ready",LogTimestamp,result.GetType().Name); resultsLock.EnterWriteLock(); try { results.Add(requestID, result); } finally { resultsLock.ExitWriteLock(); } }
public DeleteReturn(APIObject theObject) { string OverallStatus = string.Empty, RequestID = string.Empty; Result[] requestResults = new Result[0]; theObject.AuthStub.refreshToken(); using (var scope = new OperationContextScope(theObject.AuthStub.soapclient.InnerChannel)) { //Add oAuth token to SOAP header. XNamespace ns = "http://exacttarget.com"; var oauthElement = new XElement(ns + "oAuthToken", theObject.AuthStub.internalAuthToken); var xmlHeader = MessageHeader.CreateHeader("oAuth", "http://exacttarget.com", oauthElement); OperationContext.Current.OutgoingMessageHeaders.Add(xmlHeader); var httpRequest = new System.ServiceModel.Channels.HttpRequestMessageProperty(); OperationContext.Current.OutgoingMessageProperties.Add(System.ServiceModel.Channels.HttpRequestMessageProperty.Name, httpRequest); httpRequest.Headers.Add(HttpRequestHeader.UserAgent, theObject.AuthStub.SDKVersion); theObject = this.TranslateObject(theObject); requestResults = theObject.AuthStub.soapclient.Delete(new DeleteOptions(), new APIObject[] { theObject }, out RequestID, out OverallStatus); this.Status = true; this.Code = 200; this.MoreResults = false; this.Message = ""; if (OverallStatus != "OK") { this.Status = false; } if (requestResults.GetType() == typeof(DeleteResult[]) && requestResults.Length > 0) { List<ResultDetail> results = new List<ResultDetail>(); foreach (DeleteResult cr in requestResults) { ResultDetail detail = new ResultDetail(); if (cr.StatusCode != null) detail.StatusCode = cr.StatusCode; if (cr.StatusMessage != null) detail.StatusMessage = cr.StatusMessage; if (cr.Object != null) detail.Object = this.TranslateObject(cr.Object); detail.OrdinalID = cr.OrdinalID; detail.ErrorCode = cr.ErrorCode; results.Add(detail); } this.Results = results.ToArray(); } } }
private void ReturnResultToClient(Result finalResult, IDarPoolingCallback destination) { /** Apply changes on the service. */ RegisterResult(finalResult); if (debug) Console.WriteLine("{0} {1} return a {2}",LogTimestamp,receiver.NodeName.ToUpper(), finalResult.GetType().Name); destination.GetResult(finalResult); bool closeConnection = IsFinalInteraction(finalResult); if (closeConnection) { Console.WriteLine("{0} End of communication with client.",LogTimestamp); ((IClientChannel)destination).Close(); } }
bool getresult(Result r, out decimal result) { result = 0; if (resultproperty == null) { foreach (var pr in r.GetType().GetProperties()) { if (pr.Name == OptimizeDecisionsName) { resultproperty = pr; break; } } } try { var o = resultproperty.GetValue(r, null); result = (decimal)o; return true; } catch (Exception ex) { debug("error getting result from OptimizeDecision name: " + OptimizeDecisionsName + " err: " + ex.Message + ex.StackTrace); } return false; }
private void onResultReceive(Result result) { Type type = result.GetType(); if (type == typeof(LoginOkResult) || type == typeof(RegisterOkResult)) state = new JointState(); else if (type == typeof(LoginErrorResult)) ServiceProxy = null; // and state does not change // In practice, this is never used, since the core changes its state // right after it has sent the UnjoinCommand, without waiting confirmation else if (type == typeof(Communication.UnjoinConfirmedResult)) state = new UnjointState(); }
void DisplayResults(Result r) { CurrentResults = r; dt.BeginLoadData(); dt.Clear(); Type t = r.GetType(); FieldInfo[] fis = t.GetFields(); foreach (FieldInfo fi in fis) { string format = null; if (fi.FieldType == typeof(Decimal)) format = "{0:N2}"; dt.Rows.Add(fi.Name, (format != null) ? string.Format(format, fi.GetValue(r)) : fi.GetValue(r).ToString()); } PropertyInfo[] pis = t.GetProperties(); foreach (PropertyInfo pi in pis) { if (pi.Name == "PerSymbolStats") continue; string format = null; if (pi.PropertyType == typeof(Decimal)) format = "{0:N2}"; dt.Rows.Add(pi.Name, (format != null) ? string.Format(format, pi.GetValue(r, null)) : pi.GetValue(r, null).ToString()); } foreach (string ps in r.PerSymbolStats) { string[] rs= ps.Split(':'); if (rs.Length != 2) continue; dt.Rows.Add(rs[0], rs[1]); } dt.EndLoadData(); refreshgrid(); }