What do the parameters in Hangfire's BackgroundJobServerOptions mean, such as ShutdownTimeout, StopTimeout and ServerTimeout - hangfire

I found the constructor of BackgroundJobServerOptions in the official git code base. But there is no comment explaining their respective functions, nor is it stated in the official documentation. Can someone explain?
Thanks!
public BackgroundJobServerOptions()
{
WorkerCount = Math.Min(Environment.ProcessorCount * 5, MaxDefaultWorkerCount);
Queues = new[] { EnqueuedState.DefaultQueue };
StopTimeout = BackgroundProcessingServerOptions.DefaultStopTimeout;
ShutdownTimeout = BackgroundProcessingServer.DefaultShutdownTimeout;
SchedulePollingInterval = DelayedJobScheduler.DefaultPollingDelay;
HeartbeatInterval = BackgroundProcessingServerOptions.DefaultHeartbeatInterval;
ServerTimeout = ServerWatchdog.DefaultServerTimeout;
ServerCheckInterval = ServerWatchdog.DefaultCheckInterval;
CancellationCheckInterval = ServerJobCancellationWatcher.DefaultCheckInterval;
FilterProvider = null;
Activator = null;
TimeZoneResolver = null;
TaskScheduler = TaskScheduler.Default;
}

Related

WCF - CustomBinding for signing timestamp, body and BinarySecirityToken

I need to call a java/Oracle partner which has strict format requirements.
My request should look like this :
sample request
But it actually looks like this :
my request
The BinarySecurityToken is duplicated for some reason.
My custom binding :
UPLVaccinatieGegevensClient client = new UPLVaccinatieGegevensClient(GetBinding(), new EndpointAddress(new Uri("https://...."), EndpointIdentity.CreateDnsIdentity("...")));
client.ClientCredentials.ClientCertificate.SetCertificate(System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine, System.Security.Cryptography.X509Certificates.StoreName.My, System.Security.Cryptography.X509Certificates.X509FindType.FindByThumbprint, "...");
client.ClientCredentials.ServiceCertificate.SetDefaultCertificate(System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine, System.Security.Cryptography.X509Certificates.StoreName.My, System.Security.Cryptography.X509Certificates.X509FindType.FindByThumbprint, "...");
var vs = client.Endpoint.EndpointBehaviors.FirstOrDefault((i) => i.GetType().Namespace == "Microsoft.VisualStudio.Diagnostics.ServiceModelSink");
if (vs != null)
{
client.Endpoint.Behaviors.Remove(vs);
}
client.Endpoint.Contract.ProtectionLevel = System.Net.Security.ProtectionLevel.Sign;
//UPLVaccinatieGegevensClient client = new UPLVaccinatieGegevensClient("UPLVaccinatieGegevens1");
var request = GetRequest();
var response = client.GetAanleverenVaccinatieGegevens(request);
}
private static CustomBinding GetBinding()
{
var messageSecurity = new AsymmetricSecurityBindingElement
{
MessageSecurityVersion = MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10,
InitiatorTokenParameters = new X509SecurityTokenParameters
{
InclusionMode = SecurityTokenInclusionMode.AlwaysToRecipient,
ReferenceStyle = SecurityTokenReferenceStyle.External,
X509ReferenceStyle = X509KeyIdentifierClauseType.RawDataKeyIdentifier,
RequireDerivedKeys = false
},
RecipientTokenParameters = new X509SecurityTokenParameters
{
InclusionMode = SecurityTokenInclusionMode.Never,
ReferenceStyle = SecurityTokenReferenceStyle.External,
X509ReferenceStyle = X509KeyIdentifierClauseType.Any,
RequireDerivedKeys = false
},
};
messageSecurity.EnableUnsecuredResponse = true;
messageSecurity.IncludeTimestamp = true;
messageSecurity.SecurityHeaderLayout = SecurityHeaderLayout.LaxTimestampFirst;
messageSecurity.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic256;
messageSecurity.MessageSecurityVersion = MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
messageSecurity.SetKeyDerivation(false);
messageSecurity.EndpointSupportingTokenParameters.Signed.Add(messageSecurity.InitiatorTokenParameters);
messageSecurity.LocalClientSettings.TimestampValidityDuration = new TimeSpan(0, 1, 0);
HttpsTransportBindingElement elem = new HttpsTransportBindingElement { RequireClientCertificate = true };
CustomBinding binding = new CustomBinding(messageSecurity, new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), elem);
return binding;
}
What am I missing ?
It appears that the extra token was being added when X509SecurityTokenParameters.InclusionMode was set to anything else than SecurityTokenInclusionMode.Never on the either of InitiatorTokenParameters, RecipientTokenParameters or EndpointSupportingTokenParameters.Signed.
You can try to set the value of InclusionMode to SecurityTokenInclusionMode.Never:
InclusionMode = SecurityTokenInclusionMode.Never

Problemas with API Key

I'm having some difficulties trying to access the ontologias of AgroPortal, it says my api key is not valid but I created an account and it was given to me an api key.
I'm trying to do like I did with BioPortal since the API is the same but with the BioPortal it works, my code is like this:
function getAgroPortalOntologies() {
var searchString = "http://data.agroportal.lirmm.fr/ontologies?apikey=72574b5d-b741-42a4-b449-4c1b64dda19a&display_links=false&display_context=false";
// we cache results and try to retrieve them on every new execution.
var cache = CacheService.getPrivateCache();
var text;
if (cache.get("ontologies_fragments") == null) {
text = UrlFetchApp.fetch(searchString).getContentText();
splitResultAndCache(cache, "ontologies", text);
} else {
text = getCacheResultAndMerge(cache, "ontologies");
}
var doc = JSON.parse(text);
var ontologies = doc;
var ontologyDictionary = {};
for (ontologyIndex in doc) {
var ontology = doc[ontologyIndex];
ontologyDictionary[ontology.acronym] = {"name":ontology.name, "uri":ontology["#id"]};
}
return sortOnKeys(ontologyDictionary);
}
var result2 = UrlFetchApp.fetch("http://data.agroportal.lirmm.fr/annotator", options).getContentText();
And what I did with BioPortal is very similar, I did this:
function getBioPortalOntologies() {
var searchString = "http://data.bioontology.org/ontologies?apikey=df3b13de-1ff4-4396-a183-80cc845046cb&display_links=false&display_context=false";
// we cache results and try to retrieve them on every new execution.
var cache = CacheService.getPrivateCache();
var text;
if (cache.get("ontologies_fragments") == null) {
text = UrlFetchApp.fetch(searchString).getContentText();
splitResultAndCache(cache, "ontologies", text);
} else {
text = getCacheResultAndMerge(cache, "ontologies");
}
var doc = JSON.parse(text);
var ontologies = doc;
var ontologyDictionary = {};
for (ontologyIndex in doc) {
var ontology = doc[ontologyIndex];
ontologyDictionary[ontology.acronym] = {"name":ontology.name, "uri":ontology["#id"]};
}
return sortOnKeys(ontologyDictionary);
}
var result = UrlFetchApp.fetch("http://data.bioontology.org/annotator", options).getContentText();
Can someone help me?
Thanks, my regards.

Lucene 30 fuzzy search

I user LUCENE_30 for my search engine but i cannot make fuzzy search.How can i make it work?
I tried use GetFuzzyQuery but nothing happens.As i see is not supported.
Here my code :
if (searchQuery.Length < 3)
{
throw new ArgumentException("none");
}
FSDirectory dir = FSDirectory.Open(new DirectoryInfo(_indexFileLocation));
var searcher = new IndexSearcher(dir, true);
var analyzer = new RussianAnalyzer(Lucene.Net.Util.Version.LUCENE_29);
var query = MultiFieldQueryParser.Parse(Lucene.Net.Util.Version.LUCENE_30, searchQuery, new[] {"Title" }, new[] { Occur.SHOULD }, analyzer);
var hits = searcher.Search(query, 11110);
var dto = new PerformSearchResultDto();
dto.SearchResults = new List<SearchResult>();
dto.Total = hits.TotalHits;
for (int i = pagesize * page; i < hits.TotalHits && i < pagesize * page + pagesize; i++)
{
// Document doc = hits.Doc(i);
int docId = hits.ScoreDocs[i].Doc;
var doc = searcher.Doc(docId);
var result = new SearchResult();
result.Title = doc.Get("Title");
result.Type = doc.Get("Type");
result.Href = doc.Get("Href");
result.LastModified = doc.Get("LastModified");
result.Site = doc.Get("Site");
result.City = doc.Get("City");
//result.Region = doc.Get("Region");
result.Content = doc.Get("Content");
result.NoIndex = Convert.ToBoolean(doc.Get("NoIndex"));
dto.SearchResults.Add(result);
}
Fuzzy queries certainly are supported. See the FuzzyQuery class.
The query parser also supports fuzzy queries, simply with a tilde appended: misspeled~

Error 10525 during express checkout in PayPal

I have the following code (using the Yii PHP framework):
error_reporting(E_ALL ^ E_NOTICE);
$libraryPath = Yii::getPathOfAlias('application.libraries.paypal');
spl_autoload_unregister(array('YiiBase','autoload'));
require_once($libraryPath . '/PPBootStrap.php');
spl_autoload_register(array('YiiBase','autoload'));
$PaymentDetails = new PaymentDetailsType();
$address = new AddressType();
$address->CityName = '';
$address->Name = '';
$address->Street1 = '';
$address->StateOrProvince = '';
$address->PostalCode = '';
$address->Country = '';
$address->Phone = '';
$PaymentDetails->ShipToAddress = $address;
$PaymentDetails->ShippingTotal = $PaymentDetails->HandlingTotal
= $PaymentDetails->InsuranceTotal = $PaymentDetails->TaxTotal
= new BasicAmountType('USD', 0);
$PaymentDetails->OrderTotal = $PaymentDetails->ItemTotal
= new BasicAmountType('USD', $subscription->price);
$PaymentDetails->PaymentAction = "Sale";
$PaymentDetails->OrderDescription = $subscription->description;
$setECReqDetails = new SetExpressCheckoutRequestDetailsType();
$setECReqDetails->PaymentDetails[0] = $PaymentDetails;
$setECReqDetails->CancelURL = $this->createAbsoluteUrl('adListing/listings');
$setECReqDetails->ReturnURL = $this->createAbsoluteUrl('adReturnFromPaypal');
$setECReqDetails->NoShipping = '0';
$setECReqDetails->AddressOverride = '';
$setECReqDetails->ReqConfirmShipping = '0';
$setECReqType = new SetExpressCheckoutRequestType();
$setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails;
$setECReq = new SetExpressCheckoutReq();
$setECReq->SetExpressCheckoutRequest = $setECReqType;
$paypalService = new PayPalAPIInterfaceServiceService();
$ok = TRUE;
try {
Yii::trace(__METHOD__ . ': Initiating PayPal API...');
// wrap API method calls on the service object with a try catch
$setECResponse = $paypalService->SetExpressCheckout($setECReq);
if($setECResponse && strtoupper($setECResponse->Ack) =='SUCCESS') {
Yii::trace(__METHOD__ . ': Got successful response from PayPal. Redirecting to it...');
$token = $setECResponse->Token;
// Redirect to paypal.com here
$this->redirect(
'https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=' . $token);
}
}
catch (Exception $ex) {
Yii::trace(__METHOD__ . ': Exception while interacting with PayPal API, error: '
. $ex->getMessage());
$ok = FALSE;
}
if (!$ok) {
Yii::app()->user->setFlash('listings', array(
'msg'=>'There was an error while interacting with PayPal. Please try again later.',
'class'=>'flash-error'));
$this->redirect(array('adListing/listings'));
}
The user is redirected to Paypal, but when they login with their sandbox account and try to pay, I get a 10525 error from Paypal:
This transaction cannot be processed. The amount to be charged is zero.
And the checkout fails. Is there a property that I'm missing to set and the process fails?
I found the problem. I forgot to include another object needed for the transaction:
$itemDetails = new PaymentDetailsItemType();
$itemDetails->Name = $subscription->description;
$itemDetails->Amount = new BasicAmountType('USD', $subscription->price);
$itemDetails->Quantity = 1;
$itemDetails->ItemCategory = 'Digital';
$PaymentDetails->PaymentDetailsItem[0] = $itemDetails;
This line
$PaymentDetails->ShippingTotal = $PaymentDetails->HandlingTotal
= $PaymentDetails->InsuranceTotal = $PaymentDetails->TaxTotal
= new BasicAmountType('USD', 0);
should also change to
$PaymentDetails->OrderTotal = $PaymentDetails->ItemTotal =
new BasicAmountType('USD', $subscription->price);

Nhibernate Throws Found shared references to a collection

I have read thru a number of other questions similar to this one - but being new to Nhibernate, none of them seem to answer my question of why is Inhibernate throwing a "Found shared references to a collection: Order.ShippingAddress.Items" to the following code:
VendorOrderNotificationAcknowledgement ICheckoutVendorService.SendOrderNotification(VendorOrderNotification request)
{
OrderRepository repo = new OrderRepository();
var order =(AbstractOrder) repo.FindByCartId(request.OrderNotification.CartOrderId);
ShippingAddress billingAddress = order.ShippingAddresses[0];
var itemsFromDb = billingAddress.Items;
order.ClearAllShippingAddresses();
wcfFactory.UpdateOrder(order); //NO ERROR THROWN HERE!
ShippingAddress shippingAddress = orderHelper.CreateShippingAddress(request.ShippingDetails);
shippingAddress.Items = itemsFromDb;
order.AddShippingAddress(shippingAddress);
order.SourceCode = _sourceCode;
order.TaxAmount = 0;
order.GiftCertificateAmount = 0;
order.Status = StatusCode.Approved;
order.CreatedAt = request.OrderNotification.OrderTime.Year >2010
? request.OrderNotification.OrderTime
: DateTime.Now;
order.PurchasedDate=
request.OrderNotification.OrderTime.Year>2010
? request.OrderNotification.OrderTime
: DateTime.Now;
order.UpdatedAt = DateTime.Now;
if (request.OrderNotification.OrderCharges != null)
{
order.ShippingAmount = request.OrderNotification.OrderCharges.Shipping;
order.TaxAmount = request.OrderNotification.OrderCharges.DutyAndTaxes;
}
else
{
order.ShippingAmount = 0;
order.TaxAmount = 0;
}
order.UseGiftWrap = false;
order.SourceCode = _sourceCode;
UpdateEshopWorldOrder(order); // THROWS FOUND SHARED REFERENCES TO A COLLECTION: ORDER.SHIPPINGADDRESS.ITEMS
var orderDto = orderHelper.CreateOrderDto(billingAddress, orderHelper, order);
var dtoShippingAddresses = orderHelper.CreateDtoShippingAddresses(order);
orderDto.ShippingAddresses = dtoShippingAddresses;
ShippingMethodDto shippingMethodDto = 0;
var mine = wcfFactory.SendOrder(orderDto);
//More Code below here ...
}
public OrderDto CreateOrderDto(ShippingAddress billingAddress, OrderHelper orderHelper, AbstractOrder order)
{
OrderDto orderDto = new OrderDto();
orderDto.AlternateOrderId = order.Id.ToString();
orderDto.ConfirmationNumber = order.ConfirmationNumber;
orderDto.Coupons = new string[0];
orderDto.DiscountAmount = order.DiscountAmount;
orderDto.GiftCardAmount = order.GiftCertificateAmount;
orderDto.PurchaseDate = order.PurchasedDate;
orderDto.ShippingAmount = order.ShippingAmount;
orderDto.SourceCode = order.SourceCode;
orderDto.TaxAmount = order.TaxAmount;
orderDto.UseGiftWrap = order.UseGiftWrap;
var customerDto = orderHelper.CreateCustomerDto(billingAddress);
orderDto.SoldTo = customerDto;
return orderDto;
}
public void UpdateEshopWorldOrder(AbstractOrder order)
{
try
{
//Session.Update(order);
// transaction.Commit();
Session.Flush();
}
catch (Exception ex)
{
_logger.Debug("order saved failed with an error of " + ex.Message);
_logger.Error(ex);
throw;
}
}
Any insights are appreciated....
thnx
I think the problem is, that your itemsFromDB collection object is referenced by shippingAddress and also by billingAddress.
Both entities need their own collection-objects. Both collections however may contain references to the same address-objects.
So I assume replacing shippingAddress.Items = itemsFromDb; with something like
shippingAddress.Items.AddRange(itemsFromDb)
or
shippingAddress.Items = new List<ShippingAddress>(itemsFromDb) should do the trick