public static Dictionary <string, object> SelectCustomData(string serviceUrl, string serviceMethod, List <string> filterParam) // Return Rowcount { try { var _client = new RestClient(serviceUrl); var request = new RestRequest(serviceMethod, Method.PATCH) { RequestFormat = DataFormat.Json }; GetDataRequest dataRequest = new GetDataRequest(); request.AddBody(dataRequest); var response = _client.Execute(request); GetDataResponse responseData = JsonConvert.DeserializeObject <GetDataResponse>(response.Content); Dictionary <string, object> dataObject = new Dictionary <string, object>(); if (responseData != null) { dataObject = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseData.Content.ToString()); } return(dataObject); } catch (Exception ex) { return(new Dictionary <string, object>()); } }
public static List <T> GetList <T>(string serviceUrl, string serviceMethod, string tokenKey, List <string> parms, Method method = Method.POST) where T : BusinessObject // Return List Object { try { var _client = new RestClient(serviceUrl); var request = new RestRequest(serviceMethod, method) { RequestFormat = DataFormat.Json }; GetDataRequest dataRequest = new GetDataRequest(); dataRequest.Params = parms; if (!String.IsNullOrEmpty(tokenKey)) { request.AddHeader("tokenKey", tokenKey); } request.AddBody(dataRequest); var response = _client.Execute(request); GetDataResponse responseData = JsonConvert.DeserializeObject <GetDataResponse>(response.Content); List <T> dataObject = new List <T>(); DataTable dataTable = new DataTable(); if (responseData != null) { dataTable = JsonConvert.DeserializeObject <DataTable>(responseData.Content.ToString()); return(ConvertDataTableToListObject <T>(dataTable)); } } catch (Exception ex) {} return(new List <T>()); }
public string GetData(int value) { GetDataRequest request = new GetDataRequest(value); GetDataResponse response = this.GetData(request); return(response.GetDataResult); }
/// <summary> /// Return the data and the stat of the node of the given path. /// /// If the watch is non-null and the call is successful (no exception is /// thrown), a watch will be left on the node with the given path. The watch /// will be triggered by a successful operation that sets data on the node, or /// deletes the node. /// /// A KeeperException with error code KeeperException.NoNode will be thrown /// if no node with the given path exists. /// @param path the given path /// @param watcher explicit watcher /// @param stat the stat of the node /// @return the data of the node /// @throws KeeperException If the server signals an error with a non-zero error code /// @throws InterruptedException If the server transaction is interrupted. /// @throws IllegalArgumentException if an invalid path is specified /// </summary> public byte[] GetData(string path, IWatcher watcher, Stat stat) { string clientPath = path; PathUtils.ValidatePath(clientPath); // the watch contains the un-chroot path WatchRegistration wcb = null; if (watcher != null) { wcb = new DataWatchRegistration(watchManager, watcher, clientPath); } string serverPath = PrependChroot(clientPath); RequestHeader h = new RequestHeader(); h.Type = (int)OpCode.GetData; GetDataRequest request = new GetDataRequest(serverPath, watcher != null); GetDataResponse response = new GetDataResponse(); ReplyHeader r = cnxn.SubmitRequest(h, request, response, wcb); if (r.Err != 0) { throw KeeperException.Create((KeeperException.Code)Enum.ToObject(typeof(KeeperException.Code), r.Err), clientPath); } if (stat != null) { DataTree.CopyStat(response.Stat, stat); } return(response.Data); }
/// <summary> /// Asks web service for next communication package. /// </summary> /// <param name="lastReceivedXmlId">The last received communication package id.</param> /// <param name="databaseId">The database id.</param> private GetDataResponse GetNextXmlPackage(Guid?lastReceivedXmlId, Guid databaseId) { bool facadehelper_DisableThisCodeForDebugCondition = facadehelper_DisableThisCodeForDebugConditionSwitch; if (!facadehelper_DisableThisCodeForDebugCondition) { try { RoboFramework.Tools.RandomLogHelper.GetLog().Debug("PackageReceiver.cs - CommunicationServiceProxy.Instance.GetData(data)"); using (Message data = SynchronizationHelper.CreateMessage(new GetDataParameters { LastReceivedXmlId = lastReceivedXmlId, DatabaseId = databaseId }, "GetData", CommunicationServiceProxy.ProxyFactory.Endpoint.Binding.MessageVersion)) { GetDataResponse response = SynchronizationHelper.GetData <GetDataResponse>(CommunicationServiceProxy.Instance.GetData(data)); if (response == null) { return(GetDataResponse.EmptyResponse); } else { return(response); } } } catch (MessageSecurityException mse) { Log.Info("WCF MessageSecurityException"); Log.Info(mse.ToString()); Log.Info("================================================================="); try { CommunicationServiceProxy.ProxyFactory.Close(); } catch { try { CommunicationServiceProxy.ProxyFactory.Abort(); } catch { } } throw; } catch (TimeoutException e) { Log.Error(e.ToString(), true); // TODO -1 change to false when we will have a general view how often this happens. return(GetDataResponse.ExceptionResponse); } catch (CommunicationException e) { Log.Error(e.ToString()); return(GetDataResponse.ExceptionResponse); } } else { return(GetDataResponse.EmptyResponse); } }
public static GetDataResponse SetResponseResult(int _status, string _message, object _content) { GetDataResponse response = new GetDataResponse(); response.Status = _status; response.Message = _message; response.Content = _content; return(response); }
private GetDataResponse GetData(GetDataRequest request) { CFInvokeInfo info = new CFInvokeInfo(); info.Action = "http://tempuri.org/IStockService/GetData"; info.RequestIsWrapped = true; info.ReplyAction = "http://tempuri.org/IStockService/GetDataResponse"; info.ResponseIsWrapped = true; GetDataResponse retVal = base.Invoke <GetDataRequest, GetDataResponse>(info, request); return(retVal); }
public async Task <GetDataResponse> GetData(string symbol, bool intraday, bool today) { var jsonObject = await new JsonRequest("http://www.bankier.pl/new-charts/get-data") .AddArgument("symbol", symbol) .AddArgument("intraday", intraday.ToString().ToLower()) .AddArgument("type", "area") .Get(); var response = new GetDataResponse(jsonObject); return(response); }
/// <summary> /// Finds the record. /// </summary> /// <param name="id"></param> /// <returns></returns> public AmplaRecord FindRecord(int id) { IAmplaViewProperties <TModel> amplaViewProperties = GetViewProperties(null); amplaViewProperties.Enforce.CanView(); FilterValue idFilter = new FilterValue("Id", Convert.ToString(id)); FilterValue deletedFilter = new FilterValue("Deleted", ""); var request = GetDataRequest(true, idFilter, deletedFilter); GetDataResponse response = webServiceClient.GetData(request); TModel model; return(FindAmplaRecord(response, ModelProperties, amplaViewProperties, out model)); }
/// <summary> /// Task main method. /// </summary> /// <remarks> /// Run method steps: /// 1. Retrives next package. /// 2. Presists package. /// 3. Waits before repeating process. /// </remarks> protected override void Run() { Guid?lastReceivedXmlId = null; Guid?lastReceivedTransactionId = null; Guid databaseId = this.Manager.DatabaseId; lastReceivedTransactionId = GetLastTransactionId(); while (IsEnabled) { lock (Makolab.Fractus.Communication.Transmitter.TransmitterSemaphore.locker) { try { GetDataResponse response = GetNextXmlPackage(lastReceivedXmlId, databaseId); if (lastReceivedTransactionId != null && response != GetDataResponse.ExceptionResponse && (response.XmlData == null || response.XmlData.LocalTransactionId != lastReceivedTransactionId.Value)) { using (IUnitOfWork uow = Manager.CreateUnitOfWork()) { uow.MapperFactory = this.mapperFactory; CommunicationPackageRepository repo = new CommunicationPackageRepository(uow); repo.MarkTransactionAsCompleted(lastReceivedTransactionId.Value); lastReceivedTransactionId = null; } } if (response.XmlData != null && ProcessXml(response.XmlData, response.DatabaseId) == true) { lastReceivedXmlId = response.XmlData.Id; lastReceivedTransactionId = response.XmlData.LocalTransactionId; } else { lastReceivedXmlId = null; } if (response.AdditionalData != null && response.AdditionalData.UndeliveredPackagesQuantity != null) { this.WaitingPackages = response.AdditionalData.UndeliveredPackagesQuantity.Value; } } catch (Exception e) { Log.Error(String.Format(CultureInfo.InvariantCulture, "Uncaught exception in PackageReceiver: {0}", e.ToString())); } } Wait(); } }
public void GetDataReturnsLocation() { SimpleDataWebServiceClient webServiceClient = new SimpleDataWebServiceClient( database, configuration, new SimpleSecurityWebServiceClient("User")); InMemoryRecord record = ProductionRecords.NewRecord().MarkAsNew(); SubmitDataRequest submitRequest = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { record.ConvertToSubmitDataRecord() } }; SubmitDataResponse submitResponse = webServiceClient.SubmitData(submitRequest); Assert.That(submitResponse.DataSubmissionResults, Is.Not.Null); Assert.That(submitResponse.DataSubmissionResults.Length, Is.EqualTo(1)); Assert.That(submitResponse.DataSubmissionResults[0].RecordAction, Is.EqualTo(RecordAction.Insert)); Assert.That(submitResponse.DataSubmissionResults[0].SetId, Is.GreaterThan(100)); string recordId = Convert.ToString(submitResponse.DataSubmissionResults[0].SetId); Assert.That(DatabaseRecords.Count, Is.EqualTo(1)); Assert.That(DatabaseRecords[0].Location, Is.EqualTo(location)); GetDataRequest request = new GetDataRequest { Credentials = CreateCredentials(), Filter = new DataFilter { Location = record.Location, Criteria = new[] { new FilterEntry { Name = "Id", Value = recordId } } }, View = new GetDataView { Context = NavigationContext.Plant, Mode = NavigationMode.Location, Module = AmplaModules.Production }, Metadata = true, OutputOptions = new GetDataOutputOptions { ResolveIdentifiers = false }, }; GetDataResponse response = webServiceClient.GetData(request); AssertResponseContainsValue(response, "Duration", "90"); AssertResponseContainsValue(response, "Location", location); }
public int GetData(int id) { var request = new GetDataRequest() { Body = new GetDataRequestBody() { Id = id } }; GetDataResponse response = null; Execute(c => response = c.GetData(request)); return(response.Body.Value); }
public IHttpActionResult NoneQuery(NoneQueryRequest request) { GetDataResponse response = new GetDataResponse(); try { response.Content = new SqlDynamicDao <Dynamic>().GetSingleData(request.Params, request.DataSource); response.Message = Extension.ResponseMessage.Success; response.Status = (int)ResponseStatus.Success; return(Ok(response)); } catch (Exception ex) { response = Mapper.SetResponseResult((int)ResponseStatus.UnknowError, Extension.ResponseMessage.UnknowError, ex.Message); } return(Ok(response)); }
private void AssertResponseContainsValue(GetDataResponse response, string field, string value) { Assert.That(response.RowSets, Is.Not.Empty); Assert.That(response.RowSets[0].Rows, Is.Not.Empty); Assert.That(response.RowSets[0].Rows[0].Any, Is.Not.Empty); int found = 0; foreach (var rowValue in response.RowSets[0].Rows[0].Any) { if (rowValue.Name == field) { Assert.That(rowValue.InnerText, Is.EqualTo(value), "Field {0} value is not set", field); found++; } } Assert.That(found, Is.EqualTo(1), "Field: {0} not found", field); }
public GetDataResponse GetData(GetDataRequest request) { var response = new GetDataResponse(); if (request.ListPatientProfilesRequest != null) { response.ListPatientProfilesResponse = ListPatientProfiles(request.ListPatientProfilesRequest); } if (request.GetPatientProfileDetailRequest != null) { response.GetPatientProfileDetailResponse = GetPatientProfileDetail(request.GetPatientProfileDetailRequest); } if (request.ListVisitsRequest != null) { response.ListVisitsResponse = ListVisits(request.ListVisitsRequest); } if (request.GetVisitDetailRequest != null) { response.GetVisitDetailResponse = GetVisitDetail(request.GetVisitDetailRequest); } if (request.ListOrdersRequest != null) { response.ListOrdersResponse = ListOrders(request.ListOrdersRequest); } if (request.GetOrderDetailRequest != null) { response.GetOrderDetailResponse = GetOrderDetail(request.GetOrderDetailRequest); } if (request.ListReportsRequest != null) { response.ListReportsResponse = ListReports(request.ListReportsRequest); } if (request.GetReportDetailRequest != null) { response.GetReportDetailResponse = GetReportDetail(request.GetReportDetailRequest); } return(response); }
/// <summary> /// Gets all the models /// </summary> /// <returns></returns> public IList <TModel> GetAll() { IAmplaViewProperties <TModel> amplaViewProperties = GetViewProperties(null); amplaViewProperties.Enforce.CanView(); var request = GetDataRequest(true); GetDataResponse response = webServiceClient.GetData(request); List <TModel> records = new List <TModel>(); IAmplaBinding binding = new AmplaGetDataBinding <TModel>(response, records, ModelProperties); if (binding.Validate() && binding.Bind()) { return(records); } return(null); }
public void GetData_ResolveIdentifiers_True() { InMemoryRecord record = DowntimeRecords.NewRecord().MarkAsNew(); record.SetFieldIdValue("Cause", "Shutdown", 100); record.SetFieldIdValue("Classification", "Unplanned Process", 200); database.EnableModule("Downtime"); configuration.EnableModule("Downtime"); configuration.AddLocation("Downtime", "Enterprise.Site.Area.Downtime"); SimpleDataWebServiceClient webServiceClient = new SimpleDataWebServiceClient(database, configuration, new SimpleSecurityWebServiceClient("User")); record.SaveTo(webServiceClient); List <InMemoryRecord> records = new List <InMemoryRecord>(database.GetModuleRecords("Downtime").Values); Assert.That(records, Is.Not.Empty); string recordId = Convert.ToString(records[0].RecordId); GetDataRequest request = new GetDataRequest { Credentials = CreateCredentials(), Filter = new DataFilter { Location = record.Location, Criteria = new [] { new FilterEntry { Name = "Id", Value = recordId } } }, View = new GetDataView { Context = NavigationContext.Plant, Mode = NavigationMode.Location, Module = AmplaModules.Downtime }, Metadata = true, OutputOptions = new GetDataOutputOptions { ResolveIdentifiers = true } }; GetDataResponse response = webServiceClient.GetData(request); AssertResponseContainsValue(response, "Cause", "Shutdown"); AssertResponseContainsValue(response, "Classification", "Unplanned Process"); }
/// <summary> /// Called by the host to initialize the application component. /// </summary> public override void Start() { _procedureTable = new Table <ProcedureDetail>(); _procedureTable.Columns.Add(new TableColumn <ProcedureDetail, string>("Procedure", delegate(ProcedureDetail item) { return(Formatting.ProcedureFormat.Format(item)); })); _procedureViewComponentHost = new ChildComponentHost(this.Host, new ProcedureViewComponent(this)); _procedureViewComponentHost.StartComponent(); Platform.GetService <IBrowsePatientDataService>( delegate(IBrowsePatientDataService service) { GetDataRequest request = new GetDataRequest(); request.GetOrderDetailRequest = new GetOrderDetailRequest(_orderRef, false, true, false, false, false, false); GetDataResponse response = service.GetData(request); _procedureTable.Items.AddRange(response.GetOrderDetailResponse.Order.Procedures); }); base.Start(); }
private AmplaRecord FindAmplaRecord(GetDataResponse response, IModelProperties <TModel> iModelProperties, IAmplaViewProperties <TModel> amplaViewProperties, out TModel model) { List <AmplaRecord> records = new List <AmplaRecord>(); model = null; IAmplaBinding amplaBinding = new AmplaGetDataRecordBinding <TModel>(response, records, modelProperties, amplaViewProperties); if (amplaBinding.Validate() && amplaBinding.Bind()) { List <TModel> models = new List <TModel>(); IAmplaBinding modelBinding = new AmplaGetDataBinding <TModel>(response, models, iModelProperties); if (modelBinding.Validate() && modelBinding.Bind()) { model = models.Count > 0 ? models[0] : null; } return(records.Count > 0 ? records[0] : null); } return(null); }
/// <summary> /// Finds the model using the id. /// </summary> /// <param name="id">The unique identifier.</param> /// <returns></returns> public TModel FindById(int id) { IAmplaViewProperties <TModel> amplaViewProperties = GetViewProperties(null); amplaViewProperties.Enforce.CanView(); FilterValue filter = new FilterValue("Id", Convert.ToString(id)); var request = GetDataRequest(true, filter); GetDataResponse response = webServiceClient.GetData(request); List <TModel> records = new List <TModel>(); IAmplaBinding binding = new AmplaGetDataBinding <TModel>(response, records, ModelProperties); if (binding.Validate() && binding.Bind()) { return(records.Count == 1 ? records[0] : null); } return(null); }
public static T GetSingle <T>(string serviceUrl, string serviceMethod, string tokenKey, List <string> filterParam, Method method, string objectId = "") where T : BusinessObject // Return Single object { try { var _client = new RestClient(serviceUrl); var request = new RestRequest(serviceMethod, method) { RequestFormat = DataFormat.Json }; GetDataRequest dataRequest = new GetDataRequest(); dataRequest.Params = filterParam; //dataRequest.Params.Add(new ServiceParam(filterParam.name, filterParam.value)); if (!String.IsNullOrEmpty(tokenKey)) { request.AddHeader("tokenKey", tokenKey); } if (!String.IsNullOrEmpty(objectId)) { request.AddHeader("objectId", objectId); } request.AddBody(dataRequest); var response = _client.Execute(request); GetDataResponse responseData = JsonConvert.DeserializeObject <GetDataResponse>(response.Content); T dataObject = default(T); if (responseData != null) { DataTable dataTable = JsonConvert.DeserializeObject <DataTable>(responseData.Content.ToString()); if (dataTable != null) { List <T> dataObjects = ConvertDataTableToListObject <T>(dataTable); if (dataObjects != null && dataObjects.Count() > 0) { return(dataObjects.FirstOrDefault()); } } } } catch (Exception ex) {} return(default(T)); }
public GetDataResponse GetDataResponseInfo(ResultTable table) { var dataResponse = new GetDataResponse() { TableName = table.Name, }; foreach (var header in table.Headers) { dataResponse.FieldInfo.Add(new FieldInfo() { Name = header.Name, SemanticType = SemanticType.Default, FieldAttributes = new FieldAttributes() { Type = FieldAttrType.Text } }); } return(dataResponse); }
public async Task GetInformationAboutFront() { Dictionary <string, GetDataResponse> companyDatas = new Dictionary <string, GetDataResponse>(); foreach (var f in Fronts) { if (f.HoldedAmount == 0) { continue; } string companySymbol = f.CompanyName; if (companyDatas.ContainsKey(companySymbol)) { lock (Fronts) f.HoldedPrice = (decimal)companyDatas[companySymbol].ActualPrice; } else { try { var bankierService = Global.Kernel.Get <IBankierConnection>(); GetDataResponse data = await bankierService.GetData(companySymbol, true, true); lock (Fronts) { f.HoldedPrice = (decimal)data.ActualPrice; } companyDatas.Add(companySymbol, data); } catch (Exception e) { int a = 2; //i must log that. } } } }
public IHttpActionResult GetReportData(ReportRequest request) { GetDataResponse response = new GetDataResponse(); try { ServiceMethods sMethods = XmlReader.DeserializeXMLFileToObject <ServiceMethods>(System.Web.Hosting.HostingEnvironment.MapPath("/Files/Xml/RPT.xml")); ServiceMethod method = sMethods.Methods.Where(m => m.key == request.Key).FirstOrDefault(); if (method != null) { response.Content = new SqlDynamicDao <Dynamic>().GetDataTable(request.Params.ToArray(), method.datasource); response.Message = Extension.ResponseMessage.Success; response.Status = (int)ResponseStatus.Success; } return(Ok(response)); } catch (Exception ex) { response = Mapper.SetResponseResult((int)ResponseStatus.UnknowError, Extension.ResponseMessage.UnknowError, ex.Message); } return(Ok(response)); }
public void GetDataWithNullOutputOptions() { SimpleDataWebServiceClient webServiceClient = Create(); GetDataRequest request = new GetDataRequest { Credentials = CreateCredentials(), Filter = new DataFilter { Location = location, Criteria = new FilterEntry[0] }, View = new GetDataView { Context = NavigationContext.Plant, Mode = NavigationMode.Location, Module = AmplaModules.Production }, Metadata = false, OutputOptions = null }; GetDataResponse response = webServiceClient.GetData(request); Assert.That(response.RowSets, Is.Not.Empty); Assert.That(response.RowSets[0].Columns, Is.Null); Assert.That(response.Context.ResolveIdentifiers, Is.False); }
public dynamic Invoke(DynamicViewPoint point, InvokeMemberBinder binder, object[] args) { string location = point.Location; string idValue = args.Length == 1 ? Convert.ToString(args[0]) : ""; GetDataRequest request = new GetDataRequest { Credentials = GetCredentials(), Filter = new DataFilter { Location = location, Criteria = new [] { new FilterEntry { Name = "Id", Value = idValue } }, }, View = new GetDataView { Module = point.AmplaModule }, OutputOptions = new GetDataOutputOptions { ResolveIdentifiers = true }, }; GetDataResponse response = WebServiceClient.GetData(request); List <dynamic> records = new List <dynamic>(); DynamicModelProperties modelProperties = new DynamicModelProperties(point); IAmplaBinding binding = new AmplaGetDataDynamicBinding(response, records, modelProperties); if (binding.Validate() && binding.Bind()) { return(records.FirstOrDefault()); } return(null); }
public static NoneQueryResponse AddUpdate <T>(string serviceUrl, string serviceMethod, string tokenKey, T dataPost, string denyFields = "", string username = "", string permissionCode = "") // Return Single Object { try { var _client = new RestClient(serviceUrl); var request = new RestRequest(serviceMethod, Method.POST) { RequestFormat = DataFormat.Json }; PutDataRequest dataRequest = new PutDataRequest(); dataRequest.RequestObject = dataPost; dataRequest.DenyFields = denyFields; /* * For case add more param over object */ request.AddBody(dataRequest); if (!String.IsNullOrEmpty(tokenKey)) { request.AddHeader("tokenKey", tokenKey); } var response = _client.Execute(request); GetDataResponse responseData = JsonConvert.DeserializeObject <GetDataResponse>(response.Content); NoneQueryResponse dataObject = new NoneQueryResponse(); if (responseData != null) { dataObject = JsonConvert.DeserializeObject <NoneQueryResponse>(responseData.Content.ToString()); return(dataObject); } return(dataObject); } catch (Exception ex) { return(new NoneQueryResponse()); } }
//IModelProperties<TModel> modelProperties) public AmplaGetDataBinding(GetDataResponse response, List<dynamic> records) { // this.modelProperties = modelProperties; this.response = response; this.records = records; }
/// <summary> /// Gets the data. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public GetDataResponse GetData(GetDataRequest request) { return(TryCatchThrowFault(() => { XmlDocument xmlDoc = new XmlDocument(); CheckCredentials(request.Credentials); InMemoryFilterMatcher filterMatcher = new InMemoryFilterMatcher(request.Filter); List <InMemoryRecord> recordsToReturn = new List <InMemoryRecord>(); Dictionary <int, InMemoryRecord> database = amplaDatabase.GetModuleRecords(request.View.Module.ToString()); if (database.Count > 0) { recordsToReturn = database.Values.Where(filterMatcher.Matches).ToList(); } bool resolveIdentifiers = request.OutputOptions != null && request.OutputOptions.ResolveIdentifiers; List <Row> rows = new List <Row>(); foreach (InMemoryRecord record in recordsToReturn) { Row row = new Row { id = Convert.ToString(record.RecordId) }; List <XmlElement> values = new List <XmlElement>(); foreach (FieldValue value in record.Fields) { string name = XmlConvert.EncodeName(value.Name); XmlElement element = xmlDoc.CreateElement(name, "http://www.citect.com/Ampla/Data/2008/06"); element.InnerText = value.ResolveValue(resolveIdentifiers); values.Add(element); } row.Any = values.ToArray(); rows.Add(row); } string module = request.View.Module.ToString(); string location = request.Filter.Location; GetDataResponse response = new GetDataResponse { Context = new GetDataResponseContext { Context = request.View.Context, Metadata = request.Metadata, Mode = request.View.Mode, Module = request.View.Module, ResolveIdentifiers = resolveIdentifiers, ViewName = request.View.Name, Fields = request.View.Fields, ModelFields = request.View.ModelFields, }, RowSets = new[] { new RowSet { Rows = rows.ToArray(), Columns = request.Metadata ? GetColumns(module, location) : null } } }; return response; })); }
private void TestMtomService() { try { WS2007HttpBinding binding = new WS2007HttpBinding( new HttpTransportBindingConfig(new Uri("http://*****:*****@"A bedtime story is a traditional form of storytelling, where a story is told to a child at bedtime to prepare them for sleep. Bedtime stories have many advantages, for parents/adults and children alike. The fixed routine of a bedtime story before sleeping has a relaxing effect, and the soothing voice of a person telling a story makes the child fall asleep more easily. The emotional aspect creates a bond between the storyteller and the listener, often a parent and child. Bedtime stories can be read from a book, or rather, fictional stories made up by the storyteller. The stories are mostly rather short, between one and five minutes, and have a happy ending. A different form of bedtime reading is using longer stories, but dividing them up, thus creating cliffhangers. Children will look forward to their bedtime story, and a fixed routine is installed. "); m_proxy.SetData(req); GetData req2 = new GetData(); // get bytes < 1000 to test Base64 req2.value = 0; GetDataResponse resp = m_proxy.GetData(req2); Debug.Print(new string(System.Text.UTF8Encoding.UTF8.GetChars(resp.GetDataResult.Data))); // to get data > 1000 bytes to test mtom req2.value = 1; resp = m_proxy.GetData(req2); Debug.Print(new string(System.Text.UTF8Encoding.UTF8.GetChars(resp.GetDataResult.Data))); // to get data > 1000 (non-char) bytes to test mtom req2.value = 2; resp = m_proxy.GetData(req2); for (int i = 0; i < resp.GetDataResult.Data.Length; i++) { if ((byte)i != resp.GetDataResult.Data[i]) { Debug.Print("FAILURE!!!!! expected incrementing data byte values"); break; } } SetNestedData req3 = new SetNestedData(); req3.data = new schemas.datacontract.org.WcfMtomService.NestedClass(); req3.data.MTData = new schemas.datacontract.org.WcfMtomService.MtomData(); req3.data.MTData.Data = System.Text.UTF8Encoding.UTF8.GetBytes(@"A bedtime story is a traditional form of storytelling, where a story is told to a child at bedtime to prepare them for sleep."); req3.data.MyData = System.Text.UTF8Encoding.UTF8.GetBytes(@"Bedtime stories have many advantages, for parents/adults and children alike. The fixed routine of a bedtime story before sleeping has a relaxing effect, and the soothing voice of a person telling a story makes the child fall asleep more easily. The emotional aspect creates a bond between the storyteller and the listener, often a parent and child."); m_proxy.SetNestedData(req3); GetNestedData req4 = new GetNestedData(); GetNestedDataResponse resp8 = m_proxy.GetNestedData(req4); Debug.Print(new string(System.Text.UTF8Encoding.UTF8.GetChars(resp8.GetNestedDataResult.MyData))); for (int i = 0; i < resp8.GetNestedDataResult.MTData.Data.Length; i++) { if ((byte)i != resp8.GetNestedDataResult.MTData.Data[i]) { Debug.Print("FAILURE!!!!! expected incrementing data byte values"); break; } } SetFileInfo sfi = new SetFileInfo(); sfi.files = new schemas.datacontract.org.WcfMtomService.ArrayOfFileInfo(); sfi.files.FileInfo = new schemas.datacontract.org.WcfMtomService.FileInfo[2]; sfi.files.FileInfo[0] = new schemas.datacontract.org.WcfMtomService.FileInfo(); sfi.files.FileInfo[0].Name = "MyBook"; sfi.files.FileInfo[0].Size = 340; sfi.files.FileInfo[1] = new schemas.datacontract.org.WcfMtomService.FileInfo(); sfi.files.FileInfo[1].Name = "MyBook2"; sfi.files.FileInfo[1].Size = 341; m_proxy.SetFileInfo(sfi); } catch (System.IO.IOException) { // Is the web service down??? Debug.Print("Warning: could not connect to stocks web service"); } finally { if (m_proxy != null) { m_proxy.Dispose(); } } }
/// <summary> /// Respond to request for data received by web service method call. /// (TODO wtf translate the above comment to english please :) ) /// </summary> /// <param name="data">The data received via web service method call.</param> /// <returns>Response to web service client.</returns> public object DataRequested(object data) { GetDataParameters methodParams = (GetDataParameters)data; if (methodParams == null) { return(null); } DatabaseConnector.DatabaseConnectorManager dbm = GetDatabaseConnector(); dbm.StartModule(); //ICommunicationPackageMapper mapper = NullMapperFactory.Instance.CreateMapper<ICommunicationPackageMapper>(dbm); List <ICommunicationPackage> packagesQueue = null; try { using (IUnitOfWork uow = new UnitOfWork(dbm)) { uow.MapperFactory = IoC.Get <IMapperFactory>(); CommunicationPackageRepository repo = new CommunicationPackageRepository(uow); if (methodParams.LastReceivedXmlId != null) { repo.MarkAsSend(methodParams.LastReceivedXmlId.Value); } packagesQueue = repo.FindUndeliveredPackages(1, methodParams.LastReceivedXmlId, methodParams.DatabaseId); if (packagesQueue.Count == 0) { return(null); } ICommunicationPackage pkg = packagesQueue.Single(cPkg => cPkg.OrderNumber == packagesQueue.Min(communicationPackage => communicationPackage.OrderNumber)); //IEnumerable<ICommunicationPackage> tmp = packagesQueue.Where(cPkg => cPkg.BranchId == methodParams.DatabaseId); //ICommunicationPackage pkg = tmp.Single(cPkg => cPkg.OrderNumber == tmp.Min(communicationPackage => communicationPackage.OrderNumber)); //from pkg2 in packagesQueue where pkg2.OrderNumber == packagesQueue.Min(communicationPackage => communicationPackage.OrderNumber) select pkg2; //packagesQueue[packagesQueue.Min(communicationPackage => communicationPackage.OrderNumber) - 1]; if (pkg.CheckSyntax() == false) { Log.Error("Invalid xml in outgoing queue.- syntax error. Xml Id=" + pkg.XmlData.Id); return(null); } if (isValidationEnabled) { if (validator == null) { object context = IoC.Get <IContextProvider>().CreateContext(IoC.Container(), "IDatabaseConnectionManager", uow.ConnectionManager); //throws XmlSchemaValidationException this.validator = IoC.Get <IPackageValidator>(context); } this.validator.ConnectionManager = uow.ConnectionManager; this.validator.Validate(pkg); } pkg.Compress(); GetDataResponse response = new GetDataResponse(); response.XmlData = pkg.XmlData; response.DatabaseId = pkg.DatabaseId; response.AdditionalData = GetUndeliveredPackagesQuantity(response.AdditionalData, repo, methodParams); return(response); } } finally { dbm.StopModule(); } }