I am trying to write a program that generates a specific serial number but it will be able to be accessed by multiple computers in different locations.
The serial number will look something like this:
(2 letters)AA(month)02(year)16(four numbers)0000
Full thing: AA02160000
The last 4 digits will increment by one every time the user clicks a button.
I need to be able to get that serial number from multiple computers in different locations not on the same network and edit it and rewrite it. I can't have any sort of overlap being a serial number and unique to a specific item. I also can't use a guid for the number otherwise it would be much easier.
What is the best way to do this in C#?
I have considered making a server for it but I was running into problems when trying to create directories to pull the number from because of the drive letter.
Can I access a website that is hosted on a computer in one location and have it grab that serial number and increment it and then place the new value on the website?
A bit of help here would be much appreciated.
You could use the Google Docs (or SpreadSheets) and its api.
https://developers.google.com/drive/v3/web/quickstart/dotnet
But you will need access to Internet on all the computers
Another way is to use UNC shared location in your local network for the file.
Also you could create WCF service to update it and write/read the SN to a file (no need to set up db for it)
Related
I have a app (mobile and desktop version) that synchronizes a user's files to their personal Google Drive. This data is stored in a app-specific folder (appDataFolder) within the user's account.
Want I want is to put together a mechanism that will prevent a second device (a phone?) from trying to sync data to Google Drive while the first device (maybe a PC?) is already synchronizing data to/from Google Drive. This will help prevent conflicts of all sort that could result.
Is there already a method in place to achieve this goal, or must I put together some sort of hack to achieve it? Or is it even possible to achieve for that matter?
Thanks!
I'm writing a short C# program that will iterate over each user on a given Windows system, check in their local app data folder for a specific directory, and operating on it if it exists.
I'm looking for a good way to resolve the absolute file path to each users' local app data folder. I can use Environment.SpecialFolder.LocalApplicationData but that will only work for the user that is currently running the program.
I know I can cobble together a few different utilities and make a couple assumptions about where a user's local data is usually stored to make it work for 99% of the time (determine a list of all users, go through each one and find/guess where their app data is, etc.), but I was hoping there was a more elegant solution?
I need to write an application that polls a directory which contains images on a file server and display 4 at a time.
This application will be run up to 50 times across the network at the same time.
I'm trying to think of the best architecture to complete this requirement.
I was working on the idea of opening a file with read/write access and no file share allowed so that if another PC came in to read it it would error and it would have to move on to the next one, the problem is, is that I need to access all 4 images in sequence on the same pc ensuring other pc's dont try to open them. So for example if PC1 tries to open 1.jpg it needs to be able to open 1,2,3,4.jpg. If another PC comes in at the same time to read them I need a way for it to then open 5,6,7,8.jpg and so on and so on.
It seems a simple requirement but a nightmare to try and build successfully.
You're basically dealing with a race condition here, and I don't see a way to handle it from separate instances of your application running on separate machines unless you can guarantee your file naming will always follow a standard naming convention that would allow you to work with the sequence of 4 files using only the name of the first.
The best way to handle this would be using a centralized resource to manage access to your files, either a database as was suggested in a comment or else a service (such as WCF) that would "hand out" each set of 4 files.
What about creating a 1.jpg.lock file? The presence of a the file indicates the images are locked and any other instance of the application should skip that set.
I'm writing my own serial number verification/protection for a software I wrote.
Assuming the serial number verifier is using pattern matching...once the serial number is verified, how can I change the program itself so that it doesn't ask the user for a serial number any longer?
I really don't want to have to create a separate license file. Is there a way to embed this within the program itself? Or is the registry the only other option (besides online verification, etc.)
You shouldn't really attempt to edit the program itself - it'll break signatures/strong-naming, the exe/dll file will almost certainly be locked, and even if you shadow-copy: many users won't have permission to edit it in program-files (or as click-once).
Something external such as a license file or registry setting seems appropriate (unless you want to build the app at your server per-client).
Is there a way to embed this within the program itself?
If you're hinting at modifying the assembly, then it's possible*, You'd need to have two assemblies - one that's currently executing and one that you're modifying - because the executing assembly will be locked by the file system. And you'd need to reserve enough space to store whatever new value you intend to inject.
*To prove this to myself, I created a small executable with that simply writes the value of a string, and used a hex editor to alter the value of the string.
You'd need to be quite smart about what change you made, though, otherwise registering the software and then simply copying the modified binary to other machines would circumvent your registration process.
Storing registration details in the registry is probably a far easier solution.
Personally I always generate a unique key from the machines hardware and store this in the registry.
Here is a simple example of a unique key but you may need to expand it if you want separate keys for different versions of the software.
http://www.vcskicks.com/hardware_id.php
You could save the serial key that was entered to a file or registry, and just authenticate it whenever the user starts your application.
I have an application which store files (mostly Office documents) in various distant locations. I want my users to be able to search for these files based on some criteria on its own machine. I though I could use Windows Search to create an index. I've had that idea because a few years ago and to search for email in Outlook, I had to install Windows Search. So I suppose that Outlook is leveraging Windows Search to search in the PST file.
In brief, I am wondering if I can create my own index with Windows Search. Right now, I am unable to find any example online (ideally in C#). I was able to find IFilter example, but that's it.
Thanks for the help!
G'Day Martin,
I'll point out up front that the issue is that you'll have is an index being generated per machine. Which means that every machine on the network will at some point have to index every document. All that load over your network isn't a good thing and it won't scale well if you have to add more computers.
imho, the best thing to do would be install one of the free varients of SharePoint and leverage its search abilities. This will take care of any search UI that would need to be written and OOTB it's already very good at indexing files spread over drives across a network.
Hope that helps.
Cam