Hey all, I have created a WinForms to handle Persistence Activities using the Windows WorkFlow Foundation. I'm using the .NET 3.0 SQL and VS2005 as the IDE with C# as the code language. Also, the environment is mandated to me by the corporate policy for development. So until the dinosaurs decide to upgrade, I'm stuck with VS2005.
My probelm is this, I'm able to work with 1 workflow at a time, and I'd like to be able to handle Multiple workflows. As in when I click the Submit button on my form, I'd like to be able to create a new WorkFlow instance.
I created the runtime and add all the appropriate services. I hook in persistence, and when I click the Submit I start an instance of the WorkFlow. I'm relatively new to the WorkFlow Foundation, and the MSDN links have provided little to no help for me. If anyone could put me in the right direciton within my source code, that would be helpful.
I have attached a link to the source for my project.
Click Here for the Source
Thanks in Advance!
I had a look and it appears that you are creating a new workflow each time you click submit. I get a new instance id, which is a good sign :) PopulatePSUP(string instanceID) captures the instance id for the dropdown. But you are only storing one instance id at a time in Guid _instanceID. This form level variable is then used for all the button events. You could insead use the cboPSUPItems.Text.
Something like:
private void btnPSUPApprove_Click(object sender, EventArgs e)
{
string instanceId = this.cboPSUPItems.Text;
if ( instanceId.Length > 0 )
{
myArgs.Approved = true;
approved = "Yes";
this.resumeHistory[ instanceId ].Clear( );
this.resumeHistory[ instanceId ].Add( "Name: " + applicantName );
this.resumeHistory[ instanceId ].Add( "Email:" + applicantEmail );
this.resumeHistory[ instanceId ].Add( "Text:" + applicantText );
this.resumeHistory[ instanceId ].Add( "Approved:" + approved );
this.resumeHistory[ instanceId ].Add( "Denied:" + denied );
this.resumeHistory[ instanceId ].Add( "PD Approval Requested:" + pDRequest );
resumeService.RaisePSUPApprovedEvent( new Guid(instanceId) , myArgs );
this.cboPSUPItems.Items.Remove( this.cboPSUPItems.SelectedItem );
txtPSUPNotes.Clear( );
}
}
You might want to think about using a collection/list to store the instanceIds in as well. For any workflow wide logic.
Something like:
List<Guid> _instanceIds = new List<Guid>( );
...
_instanceIds.Add( instance.InstanceId );
Related
private fun shareOperation(file: File) {
val uri = Uri.fromFile(file)
val storage = FirebaseStorage.getInstance()
val pdfRef = storage.reference.child("pdf/${uri.lastPathSegment}")
pdfRef.putFile(uri).addOnFailureListener { e ->
Log.e(TAG, "Couldn't share " + e.message)
}.addOnCompleteListener{
it.addOnCompleteListener {
pdfRef.downloadUrl.addOnSuccessListener { e ->
run {
link = e.toString()
Log.i(TAG,link!!) // Here i get the link to file in firebase storage
}
}
}
}
// Here link gets null
}
i was expecting somehow i can get the link to the file and can use it for sharing intent
You are performing an asynchronous call to upload the file, that is correct since any UI blocking action must be performed in background. The variable link will be null until the run code is executed in the background thread.
You need to code inside the run block whatever you want to happen when the link is available.
BTW looks weird what you are doing with the nested addOnCompleteListener, there should be an easier way to code that. You should probably spend time learning how to code with listeners and background threads.
I'm using Cloud Firestore in my unity app, and I've attached a listener as follows:
public void ListenForFirestoreChange()
{
DocumentReference docRef = db.Collection("users").Document(user.UserId);
docRef.Listen(snapshot => {
Dictionary<string, object> userEntry = snapshot.ToDictionary();
Debug.Log("change detected: " + snapshot.Id + " " + (string)userEntry["firestoreTime"]);
});
}
This is working great, but when I stop the player and restart it, unity gets stuck loading with the message "Application.Reload". I've tried stopping the listener onApplicationQuit, as well as setting my firestore reference to null, but that didn't work. I'm forced to end the Unity process, if I try to exit normally it gets stuck on Application.Quit. I've narrowed down the app getting stuck to this listener and I'm baffled.
I'm using :
Unity 2020.1.10f1
Visual Studio 16.7.6
Firebase for Unity 6.16.1
I was finally able to fix this issue after trying tons of things.
To fix this:
In an onApplicationQuit function, call
FirebaseApp.DefaultInstance.Dispose();
It is a mistake to use "FirebaseApp.DefaultInstance.Dispose();" because you delete all Firebase related instances so you would have to re-initialize everything again.
If you do not want to close the application and you only want to log out of your application you should do it this way
According to the docu you have to use the function "listener.Stop();".
So in this case you must use it in the following way:
public void ListenForFirestoreChange(){
DocumentReference docRef = db.Collection("users").Document(user.UserId);
ListenerRegistration listener = docRef.Listen(snapshot => {
Dictionary<string, object> userEntry = snapshot.ToDictionary();
Debug.Log("change detected: " + snapshot.Id + " " + (string)userEntry["firestoreTime"]);
});}
And when you want to delete the listens you must execute the following function:
listener.Stop();
I want to implement skip lock. I am using postgres 9.6.17. I am using the following code
#Lock(LockModeType.PESSIMISTIC_WRITE)
#QueryHints({#QueryHint(name = "javax.persistence.lock.timeout", value = "-2")})
#Query("Select d from Demo d where d.id in (?1)")
List<Demo> getElementByIds(List<Long> ids);
I am making the same DB call from 2 services at the same time through cmd(parallel Curl request to both services which make DB call). From 1 server I am passing ids from 1...4 and from other I am passing ids from 1.....7.
But in case if the first service takes a lock on 1...4 row and then the second service has to wait until first service removes its lock but ideally, the second service should return rows 5...7
From the first service I am calling like this
List<Long> ids = new ArrayList<>();
ids.add(1l);
ids.add(2l);
ids.add(3l);
ids.add(4l);
List<Demo> demos = demoRepo.getElementByIds(ids);
try{
Thread.sleep(500);
} catch (Exception e) {
}
logger.info("current time: " + System.currentTimeMillis());
and from the second service I am calling like this:
List<Long> ids = new ArrayList<>();
ids.add(1l);
ids.add(2l);
ids.add(3l);
ids.add(4l);
ids.add(5l);
ids.add(6l);
ids.add(7l);
try{
Thread.sleep(100);
} catch (Exception e) {
}
logger.info("current time: " + System.currentTimeMillis());
List<Demo> demos = demoRepo.getElementByIds(ids);
logger.info("current time: " + System.currentTimeMillis());
But always both the queries returning the same rows which I am asking after waiting for another service to release the lock.
Spring JPA version I am using :
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.2.5.RELEASE</version>
I have also tried at the application level itself spring.jpa.javax.persistence.lock.timeout=-2 that also not working.
Both the methods seems to working like PESSIMISTIC_WRITE.
Please suggest how I can achieve skip locked functionality.
The Queries seem to be correct.
Hope you are using latest Dialect of Postgres which supports Skip Lock functionality.
Considering the version of Postgres you are using, below Dialect should be used.
org.hibernate.dialect.PostgreSQL95Dialect
You can refer this link for more information
Answer of RAVI SHANKAR was correct. I have tested and it realy worked. You need to specify dialect version.
For example in spring boot
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL94Dialect
Also code will be more readable if you use constants insted of strings.
#QueryHint(name = AvailableSettings.JPA_LOCK_TIMEOUT, value = LockOptions.SKIP_LOCKED.toString())
I am trying to create OrderCancelRequest using FIX.4.2 but confused with OrderID,OrigClOrdID and ClOrdID. I searched on the web but it was not clear to me. Please explain those parameters and provide snippet of code for OrderCancelRequest if possible.
Thanks in advance.
You wish to cancel an order you created with quickfix.fix42.NewOrderSingle. To send that message you had to assign it a unique quickfix.field.ClOrdID. For instance:
String instructionId = createNewInstructionId( );
quickfix.Message fixMessage = new quickfix.fix42.NewOrderSingle (
new ClOrdID( instructionId ),
new HandlInst( HandlInst.AUTOMATED_EXECUTION_ORDER_PUBLIC ),
new Symbol( symbol ),
new Side( Side.BUY ),
new TransactTime( ),
new OrdType( OrdType.LIMIT )
);
// ...
You need to store this instructionId for referencing in further messaging.
If the counterparty accepts the instruction, it does so with an EXECUTION_REPORT message (OrdStatus.NEW). This execution report will contain an quickfix.Field.OrderID field, which is a unique identifier for the order as assigned by the broker (uniqueness within single trading day, or uniqueness across days for multi-day orders). Store this OrderID for use in later instructions (orderIdBroker).
If you wish to cancel the order, you need to reference the instruction that created the order. The OrigClOrdID in this instance is the ClOrdID of the NewOrderSingle instruction that created the order. The ClOrdID field is a unique identifier for the cancel request (a new identifier you assign to the cancel request). If you wish (or the broker requires it) you can supply the OrderID you received from the broker:
String orderInstructionId = getOrderInstructionId( );
String cancelInstructionId = createNewInstructionId( );
quickfix.Message fixMessage = new quickfix.fix42.OrderCancelRequest (
new OrigClOrdID( orderInstructionId ),
new ClOrdID( cancelInstructionId ),
new Symbol( symbol ),
new Side( Side.BUY ),
new TransactTime( )
);
// If required, set the OrderID as assigned by the broker:
String orderIdBroker = getOrderIdBroker( );
fixMessage.setField( new OrderID( orderIdBroker ) );
ClOrdId is the id of the cancel order message you're going to send.
OrigClOrdId is the id of the order message you already sent.
OrderID is the internal id of the order (which may or may not mean anything to the receiver).
How you construct the cancel order depends on who you're sending it to. Here's some code:
QuoteCancel qc = new QuoteCancel();
qc.setField(new StringField(131, "RFQ123"));
qc.setField(new QuoteCancelType(1));
Have a look at Fiximate QuoteCancel for more. Here's the Fiximate front page.
In developing some of my Web Applications I use debug("stuff here"); to help me figure out whats going on. I'd rather not have to go in and find all of my debug(*); lines and remove them. Is there a way I can specify at the application level not to display debug messages in a FeedBackPanel?
You could add an ErrorLevelFeedbackMessageFilter to your FeedbackPanels (there is a constructor accepting one). If you create the filter based on your deployment mode, this should be what you need.
In Detail:
Change your new FeedbackPanel("id") to new FeedbackPanel("id", Application.getFeedbackMessageFilter()) and implement this method as
public IFeedbackMessageFilter getFeedbackMessageFilter() {
IFeedbackMessageFilter filter = null;
if (RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) {
filter = new ErrorLevelFeedbackMessageFilter(FeedbackMessage.DEBUG);
} else {
filter = new ErrorLevelFeedbackMessageFilter(FeedbackMessage.ERROR);
}
return filter;
}