Unique id/code of every deployed application - visual-studio-2010

I believe every deployed product (application) from VS has a unique id or smth like that, that doesn't change over distribution. What I mean is that I publish an app and give it to a company with 100 employees and the product remains with the same unique ID on every single PC it is installed.
I have come across GUID from Assembly Information of the program's project, but I am not sure it is that one. So is there anything like such unique id of the product, and if yes - where can I find it AND how can I access it in the code itself.
I.e.: string uniqueID = Something.getProductID() or whatever...

There are two methods to get GUID,
Fristly, you can get GUID in Assembly Information.
//Gets the assembly that contains the code that is currently executing.
Assembly asm = Assembly.GetExecutingAssembly();
Guid id= asm.GetType().GUID;
Secondly, It is not taken from the Assembly Information.Stored as a real custom attribute.
var attribute = (GuidAttribute)asm.GetCustomAttributes(typeof(GuidAttribute),true)[0].;
var id = attribute.Value;
More info you can see
Assembly.GetCustomAttributes Method (Type, Boolean)
http://msdn.microsoft.com/en-us/library/88d17d13.aspx
Assembly.GetExecutingAssembly Method
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getexecutingassembly.aspx

Related

Simulate the assembly of parts in Arena Simulation Software

I am simulating an assembly process in Arena. To keep things simple, suppose a model that assigns bags to passengers.
Each entity has a different ID (Entity.SerialNumber): I would like to check which bag has been assigned to which passenger.
How could I write a log file saving the ID of passenger and ID of the assigned bag?
First you must declare an attribute for the original entity that I understand that in this case would be the passenger, for example: ID = ID + 1, then with the separate module you duplicate the original entity, now both entities can have their independent flow and when you want to put them together again you can do it with a batch module using the rule: by attribute or with a match module using the type: based on attribute.

Get executive workflow name - CRM 4

I have started to write a workflow assembly for CRM 4.0 that should kill any other running workflows with the given name (in my case, all other workflows except him self).
ConditionExpression ce = new ConditionExpression();
ce.AttributeName = "name";
ce.Values = new Object[]{this.WorkflowName}; // Dependency Property
query.EntityName = EntityName.asyncoperation.ToString();
Has anyone an idea, how to get the current workflow name out of the IContextService or something like that?
Best regards
Its a bit of a long way around, but you could use IWorkflowContext.AsyncOperationId to get the ID of the current workflow.
Using that ID you can then query the asyncoperation to get the name of the workflow.

Modify resource for String table type in win32 native exe

I want to modify some string in my exe resource. That resource type is a string table,
but when i use UpdateResource function i don't know what parameter must be pass to it so it's pointing to the exact raw in the string table.
The type parameter is RT_STRING, but what should I send to MAKEINTRESOURCEW()?
HANDLE hExeFile = BeginUpdateResource(L"d:\\m.exe", FALSE);
WCHAR mail[]={L"ddddddd#gmail.com"};
UpdateResource(hExeFile,RT_STRING,MAKEINTRESOURCEW(?????), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (LPVOID)mail, wcslen(mail)*2);
EndUpdateResource(hExeFile, FALSE);
An exe file cannot update its own resources while it is running. The resources are locked by the OS and are read-only. But if you could update the resources, then obviously you have to know the ID of your resource in order to update it. If it is a compiler-generated resource, then you are probably out of luck unless your compiler uses a predictable ID number, like 1. Otherwise, use an .rc file to define your own resource data, then you can use whatever ID you want.

Getting new PurchId via .NET BusinessConnector

I am trying to find a .NET BusinessConnector equivalent call for the below line:
PurchId = NumberSeq::newGetNum(SalesParameters::numRefSalesId()).num();
I am manually entering purchase order information into the purchase order table, which is fine, but the problem lies in the fact that it is the PurchID that ties purchase table (PURCHTABLE) and the individual purchase order lines (PURCHLINE) is the PURCHID field, which is not automatically populated when saving a purchase order.
Currently I am:
ax.TTSBegin();
axRecord.set_Field("ORDERACCOUNT", purchaseOrder.OrderAccount);
(etc)
axRecord.Insert();
However, while this will insert a record into the database, it has no purchID, which has to be generated. You need a purchID to link the purchase line items in. I found the above code (second line) for X++, but does anyone know of a .NET BusinessConnector call that can be used instead?
Any assistance would be greatly appreciated.
Regards,
Steve
I would go for a change in the insert() method of the PurchTable table:
if (!purchTable.PurchId)
purchTable.PurchId = NumberSeq::newGetNum(purchParameters::numRefPurchId()).num();
Placed after the ttsbegin.
This to avoid complicated C# code. You probably could do it in C# code alone using CallStaticClassMethod and cousins, but it is better do put the buisness logic on the X++ side.
See How to: Call Business Logic Using .NET Business Connector.
Be sure to execute inside a TTSBegin/ TTSCommitblock, otherwise you will get error error messages like this one.
// ax is a reference to an "Axapta" business connector object
var numRef = ax.CallStaticRecordMethod("SalesParameters", "numRefSalesId");
var numSeq = (AxaptaObject)ax.CallStaticClassMethod("NumberSeq", "newGetNum", numRef);
var purchId = numSeq.Call("num");

Creating a unique ID in a form

I have a form that I have users fill out and then it gets e-mailed to me.
I am trying to get an example of how I would create an ID (based on my own conventions) that I can use to keep track of responses (and send back to the user so they can reference it later).
This is the convention I am striving for:
[YEAR]-[SERVICE CODE]-[DATE(MMDD)]-[TIME]
For example: "2012-ABC-0204-1344". I figured to add the TIME convention in the instance that two different users pick the same service on the same date rather than try to figure out how to only apply it IF two users picked the same service on the same date.
So, the scenario is that after the user goes through my wizards inputting their information and then click "Submit" that this unique ID would be created and attached to the model. Maybe something like #Model.UniqueID so that in an e-mail response I send to the user it shows up and says "Reference this ID for any future communication".
Thanks for any advice/help/examples.
In your post action
[HttpPost]
public ActionResult Create(YourModel model)
{
model.UniqueId = GenerateUniqueId(serviceCode);
}
public string GenerateUniqueId(string serviceCode)
{
return string.Format("{0}-{1}-{2}", DateTime.Now.Year, serviceCode, Guid.NewGuid().ToString().Replace("-",""); //remove dashes so its fits into your convention
}
but this seems as I'm missing part of your question. If you really want unique, use a Guid. This is what we've used in the past to give to customers - a guid or a portion of one. IF you use a portion of one ensure you have logic to handle a duplicate key. You don't need to worry about this though if using a full guid. If the idea is just to give to a customer then ignore the rest of the data and just use a guid, since it can easily be looked up in the database.

Resources