How do I query objects by attribute (instead of 'Filter Keys') using the Genesys Platform SDK?
Endpoint endpoint = new Endpoint("DEV", "the host", 12020);
endpoint.ServicePrincipalName = "the host/the principle";
_confServerProtocol = new ConfServerProtocol(endpoint);
_confServerProtocol.ClientApplicationType = (int)CfgAppType.CFGSCE;
_confServerProtocol.ClientName = "default";
_confServerProtocol.UserName = "the userid";
_confServerProtocol.Open();
IConfService confService = ConfServiceFactory.CreateConfService(_confServerProtocol);
CfgPersonQuery query = new CfgPersonQuery();
// Need to filter based on an Attribute Value (specifically externalID)
var foo = confService.RetrieveMultipleObjects<CfgPerson>(query);
This worked for me:
CfgXPathBasedQuery query = new CfgXPathBasedQuery(confService, CfgObjectType.CFGPerson, "CfgPerson[#externalID='the value']");
Use below:
Uri uri = new Uri("tcp://Host:Port");
Endpoint endpoint = new Endpoint(Guid.NewGuid().ToString(), uri);
ConfServerProtocol confProtocol = new ConfServerProtocol(endpoint);
confProtocol.ClientApplicationType = (int)CfgAppType.CFGSCE;
confProtocol.ClientName = "default";
confProtocol.UserName = "xxxxxx";
confProtocol.UserPassword = "xxxxxx";
//Channel Open
confProtocol.Open();
IConfService confService = ConfServiceFactory.CreateConfService(confProtocol);
CfgPersonQuery query = new CfgPersonQuery();
query.UserName = "AgentID";
CfgPerson person = confService.RetrieveObjects<CfgPerson>(query);
string ExtID = person.ExternalId;
Note: In this way, Filtering is not possible through ExternalId.
Related
Morning all,
I am trying to create a button that will copy the organisation address and populate the organisation billing address fields. I have no idea where to start.
The fields in question are:
// I want to copy these values
$organisation->email = Input::get('email');
$organisation->line_1 = Input::get('line_1');
$organisation->line_2 = Input::get('line_2');
$organisation->line_3 = Input::get('line_3');
$organisation->city = Input::get('city');
$organisation->state = Input::get('state');
$organisation->postcode = Input::get('postcode');
$organisation->country = Input::get('country');
// To these fields
$organisation->billing_line_1 = Input::get('billing_line_1');
$organisation->billing_line_2 = Input::get('billing_line_2');
$organisation->billing_line_3 = Input::get('billing_line_3');
$organisation->billing_city = Input::get('billing_city');
$organisation->billing_state = Input::get('billing_state');
$organisation->billing_postcode = Input::get('billing_postcode');
$organisation->billing_country = Input::get('billing_country');
Here is the start of my function
// Copy Address Button
public function onCopyAddress()
{
$organisation = Organisation::find($this->param('id'));
// Copy address logic here
$organisation->save();
Flash::success($organisation->name." Address has been successfully copied.");
return Redirect::to('/organisations/'.$organisation->id);
}
This is the solution I came up with.
public function onCopyAddress()
{
$organisation = Organisation::find($this->param('id'));
$organisation->billing_line_1 = Input::get('line_1');
$organisation->billing_line_2 = Input::get('line_2');
$organisation->billing_line_3 = Input::get('line_3');
$organisation->billing_city = Input::get('city');
$organisation->billing_state = Input::get('state');
$organisation->billing_postcode = Input::get('postcode');
$organisation->billing_country = Input::get('country');
$organisation->save();
Flash::success($organisation->name." Address has been successfully copied.");
return Redirect::to('/organisations/'.$organisation->id);
}
I have a concern since as I am new to using EntityFramework Core, that if I add an object, that I still do not have the id generated by the database, sending the object to it in the transaction, I would add it automatically, this is my code ,
public async Task<ServiceResult<Common.Entities.Company>> SaveCompany(Domain.Models.Company companyModel, Domain.Models.Administrator administratoModel)
{
ServiceResult<Common.Entities.Company> serviceResult = new ServiceResult<Common.Entities.Company>();
try
{
if (user == null && companyExistsRnc == false)
{
Common.Entities.Company myCompany = new Common.Entities.Company
{
CompanyId = companyModel.CompanyId, // The id has not been generated yet,
CompanyName = companyModel.CompanyName,
Rnc = companyModel.Rnc,
CountryId = companyModel.Country.CountryId,
Telephone = companyModel.Telephone,
PersonContact = companyModel.PersonContact,
Address = companyModel.Address,
PhotoPath = companyModel.PhotoPath,
IsActive = false,
};
await _companyRepository.SaveCompany(myCompany); // this is the method that I add the company object to the database and do the savechanges
Common.Entities.User myUser = new Common.Entities.User
{
FirstName = administratoModel.FirstName,
SecondName = administratoModel.SecondName,
FirstLastName = administratoModel.FirstLastName,
SecondLastName = administratoModel.SecondLastName,
GenderId = administratoModel.Gender.GenderId,
PhoneNumber = administratoModel.Telephone,
Email = administratoModel.Email,
UserName = administratoModel.Email,
IsActive = administratoModel.IsActive,
UserTypeId = (short)Common.Core.UserType.Administrator,
Company = myCompany, // here I send the my company object for when I do the savechanges, I think it will add it to me
};
await _userHelper.AddUserAsync(myUser, administratoModel.Password);
await _userHelper.AddUserToRoleAsync(myUser, Common.Core.UserType.Administrator.ToString());
Common.Entities.Administrator myAdministrator = new Common.Entities.Administrator
{
AdministratorId = administratoModel.AdministratorId,
FirstName = administratoModel.FirstName,
SecondName = administratoModel.SecondName,
FirstLastName = administratoModel.FirstLastName,
SecondLastName = administratoModel.SecondLastName,
GenderId = administratoModel.Gender.GenderId,
Email = administratoModel.Email,
Telephone = administratoModel.Telephone,
IsActive = true,
PhotoPath = administratoModel.PhotoPath,
UserTypeId = (short)Common.Core.UserType.Administrator,
Company = myCompany, // company object without the id
User = myUser, // user object without the id
};
await _administratorRepository.SaveAdministrator(myAdministrator);
serviceResult.Data = myCompany;
serviceResult.Message = "CompaƱia agregada!";
}
}
I am new to using entity framework core, and if in case I am wrong in what I am doing please indicate in which part I am doing it wrong, to correct, I await your comments and would appreciate the help,
am faced with a challenge for some time now. I have a web service (asp.net web api), that consumes a certain api, after the consumption, my api will then send the consumed data to another external api. I use REST Sharp for my data serialization and request.
But anytime i send this request. I get a null result.
Anybody to help?
Sequel to my question above #igor, below is my code snippet
public object AccountOpening(JObject exRequest)
{
var Account = new AccountViewModel(exRequest.ToString());
Account.cifID = "null";
Account.AddrCategory = "Mailing";
Account.Country = "NG";
Account.HoldMailFlag = "N";
Account.PrefAddr = "Y";
Account.Language = "UK (English)";
Account.IsMinor = "N";
Account.IsCustNRE = "N";
Account.DefaultAddrType = "Mailing";
Account.Occupation = "OTH";
Account.PhoneEmailType = "CELLPH";
var serviceAPI = ConfigurationManager.AppSettings["RemoteAPI"];
var request = new RestSharp.Serializers.Newtonsoft.Json.RestRequest();
request.AddParameter("application/json", Account, ParameterType.RequestBody);
request.RequestFormat = DataFormat.Json;
request.Method = Method.POST;
request.JsonSerializer = new RestSharp.Serializers.JsonSerializer();
var client = new RestClient(serviceAPI);
IRestResponse resp = client.Post(request);
if (resp.IsSuccessful==true)
{
return Json(new {resp.Content });
}
}
i would like to reconstruction my last project.
in past, i did't use any Web API.
can i just use the ODataQueryOptions to do $filter, $orderby , $top ,$skip
for my query in my own handler.ashx ?
some thing like.
var option = new ODataQueryOptions(request.params);
var query = option.ApplyTo(db.products);
Based on sfuqua's answer above I made my own helper class that builds OdataQueryOptions class based on Odata Uri:
using System.Linq;
using System.Net.Http;
using System.Web.Http.OData;
using System.Web.Http.OData.Builder;
using System.Web.Http.OData.Query;
namespace OdataHelpers
{
public static class ODataBuilder<T>
{
public static ODataQueryOptions<T> BuildOptions(string oDataUri)
{
var baseUri = "";
var odUri = "";
var spl = oDataUri.Split('?');
if (spl.Count() == 0)
odUri = spl[0];
else
{
baseUri = spl[0];
odUri = spl[1];
}
if (string.IsNullOrEmpty(baseUri))
baseUri = "http://localhost/api/" + typeof(T).Name;
var request = new HttpRequestMessage(HttpMethod.Get, baseUri + "?" + oDataUri.Replace("?", ""));
var modelBuilder = new ODataConventionModelBuilder();
modelBuilder.AddEntity(typeof(T));
var edmModel = modelBuilder.GetEdmModel();
var oDataQueryContext = new ODataQueryContext(edmModel, typeof(T));
return new ODataQueryOptions<T>(oDataQueryContext, request);
}
}
}
Example use:
var OdataStuff = ODataBuilder<CustomerIntView>.BuildOptions("$orderby=Id");
One way to accomplish this is by manually constructing the request URI and setting that in the request parameter of the ODataQueryOptions constructor. So this may not be precisely what the original poster was looking for (question needed some clarification).
In my case I have a unit test, and I wanted to validate that the odata options were being applied to my queryable object. In the following sample code, assume that you are testing a ProductController that has a ProductName field in it.
// Manually set an OData query parameter
const string restUrl = "http://localhost/api/product?$orderby=ProductName";
// Need to construct an HTTP Context and a Request, then inject them into the controller
var config = new HttpConfiguration();
var request = new HttpRequestMessage(HttpMethod.Post, restUrl);
var route = config.Routes.MapHttpRoute(WebApiConfig.DefaultRouteName, "api/{controller}/{id}");
var routeData = new HttpRouteData(route, new HttpRouteValueDictionary { { "controller", "Product" } });
var controller = new ProductController()
{
Request = request,
ControllerContext = new HttpControllerContext(config, routeData, request),
Url = new UrlHelper(request)
};
// Build up the OData query parameters
var modelBuilder = new ODataConventionModelBuilder();
modelBuilder.AddEntity(typeof(Product));
var edmModel = modelBuilder.GetEdmModel();
var oDataQueryContext = new ODataQueryContext(edmModel, typeof(Product));
var oDataQueryOptions = new ODataQueryOptions<Product>(oDataQueryContext, _controller.Request);
// Finally, call the controller
var result = controller.Get(oDataQueryOptions);
I do think you can if you can constructor an instance of ODataQueryOptions.
But, What's this:
var option = new ODataQueryOptions(request.params);
Web API doesn't provide such constructor. Is it your own implementation?
Thanks.
I am trying to create an order on Magento 1.7.2 using SOAP API V_2 using .NET consol.
I am always getting the same error "Payment not allowerd" using every payment method.
//create an order with Magento API
MagentoService proxy = new MagentoService();
string sessionId = proxy.login("xxx", "xxx");
int idCarrello = proxy.shoppingCartCreate(sessionId, "1");
proxy.UnsafeAuthenticatedConnectionSharing = false;
shoppingCartCustomerEntity clienteMagento = new shoppingCartCustomerEntity();
clienteMagento.firstname = "name";
clienteMagento.lastname = "surname";
clienteMagento.email = "xxx#mmmm.com";
clienteMagento.mode = "guest";
proxy.shoppingCartCustomerSet(sessionId, idCarrello, clienteMagento, "1");
shoppingCartCustomerAddressEntity indirizzoSpedizione = new shoppingCartCustomerAddressEntity();
shoppingCartCustomerAddressEntity indirizzoBill = new shoppingCartCustomerAddressEntity();
indirizzoSpedizione.mode = "shipping";
indirizzoSpedizione.firstname = clienteMagento.firstname;
indirizzoSpedizione.lastname = clienteMagento.lastname;
indirizzoSpedizione.street = "viale europa 32";
indirizzoSpedizione.city = "Foggia";
indirizzoSpedizione.region = "FG";
indirizzoSpedizione.telephone = "111";
indirizzoSpedizione.postcode = "71122";
indirizzoSpedizione.country_id = "IT";
indirizzoSpedizione.is_default_billing = 0;
indirizzoSpedizione.is_default_shipping = 0;
indirizzoBill.mode = "billing";
indirizzoBill.firstname = clienteMagento.firstname;
indirizzoBill.lastname = clienteMagento.lastname;
indirizzoBill.street = "viale europa 32";
indirizzoBill.city = "Foggia";
indirizzoBill.region = "FG";
indirizzoBill.telephone = "111";
indirizzoBill.postcode = "71122";
indirizzoBill.country_id = "IT";
indirizzoBill.is_default_billing = 0;
indirizzoBill.is_default_shipping = 0;
shoppingCartCustomerAddressEntity[] indirizzi = new shoppingCartCustomerAddressEntity[] { indirizzoSpedizione, indirizzoBill };
proxy.shoppingCartCustomerAddresses(sessionId, idCarrello, indirizzi, "1");
proxy.shoppingCartShippingMethod(sessionId, idCarrello, "flatrate_flatrate", "1");
shoppingCartPaymentMethodResponseEntity[] paymentMethods = proxy.shoppingCartPaymentList(sessionId, idCarrello, "1");
Console.WriteLine(paymentMethods); //paymentMethods is always empty!!
shoppingCartPaymentMethodEntity modoPagamento = new shoppingCartPaymentMethodEntity();
modoPagamento.po_number = null;
modoPagamento.method = "checkmo";
modoPagamento.cc_cid = null;
modoPagamento.cc_owner = null;
modoPagamento.cc_number = null;
modoPagamento.cc_type = null;
modoPagamento.cc_exp_year = null;
modoPagamento.cc_exp_month = null;
proxy.shoppingCartPaymentMethod(sessionId, idCarrello, modoPagamento, "1");
Here is the Exception:
//Payment method is not allowed (I tryed checkmo, banktransfer, etc)
//proxy.shoppingCartOrder(sessionId, idCarrello, "1", new string[] { });
Any idea?
Ifaced with the saeme issue. This is the solution - You forgot product, just add product to sale. Also you must do it according to this order (it will not works in other order):
shoppingCartCustomerSet(guest for simplicity);
shoppingCartCustomerAddresses();
shoppingCartProductAdd();
shoppingCartShippingMethod();
shoppingCartPaymentMethod();