Is it possible to get server name from nativePath in Flex Air? - apache-flex

I have a nativePath of a file somewhere hosted in server and the value of this nativePath as flex shows me as
Z:\myFolder\myFile.ext
which, I know is also equivalent to
http://particularDomain.myCompany.com/myFolder/myFile.ext
(Note - Z: maps to http://particularDomain.myCompany.com/ which is true in my system and my colleague can have it mapped the same sever to A: in his system)
Now my question is - Can this mapping be realized through Air application in any way? i.e if the native file lies in http://particularDomain.myCompany.com/myFolder/myFile.ext, it says that it lies in that particular server irrespective of whatever it is mapped to?

No, this mapping cannot be realized through any functionality provided in AIR.
How would your AIR app know that there is a web server whose root directory is 'Z:\'? It can't unless you tell it to.
Now, it may be possible to create this functionality on your own as long as you give it a few specific parameters.
If you're app knows that particluarDomain.myCompany.com points to Z:\ it should be easy to write some code to map the two. You could even encapsulate out the domain name and the root in order to easily change them in the future.
You may, also, in theory parse the config file of an Apache Web Server in order to determine the server root and directory location. Assuming that your local machine has access to both. If you're mapping network locations to a local drive; this could potentially complicate things, though.

Related

How can I get the root of my project in ASP.NET and not the location of IIS Express using .CurrentDirectory()?

I have an ASP.NET Core project that I'm developing and I'm making use of LiteDB as a database solution. In order to instantiate my database I need to provide a URI so that the program knows where to create the database.
Usually I'd do something like System.Environment.CurrentDirectory() to find the current directory I'm in and modify that, however the result of this command turns out to be C:\program files\IIS Express or something similar. Basically the current directory points to the location of IIS Express.
Instead I want to get the root of my ASP.NET project, the location that contains my controllers folder, appsettings.json, bin and obj folders.
What command do I need to use to get a string representing this location? I don't want to use a hard coded string for obvious reasons.
If you don't have access to DI you could try:
Assembly.GetExecutingAssembly().Location
If you have access to DI, try this:
Inject the IHostingEnvironment and call environment.ContentRootPath
How to get root directory of project in asp.net core. Directory.GetCurrentDirectory() doesn't seem to work correctly on a mac
You may be better served by using a dedicated location (such as a network share) rather than the folder that contains the executable code. Having user data mixed into deployed code comes with a lot of headaches:
Deployments become more complex as they need to account for the presence of user data. This is especially true if you need to delete pre-existing code during a deployment.
If the user data is sensitive, developers may be denied access to read the deployed code. This can make troubleshooting issues much harder.
Backups of deployed code will contain user data, which means they will always appear to be different even if nothing (code-wise) has changed.
Of course, this all assumes that the production environment is configured differently from developers' local machines.

Best practices place to put URL that configs my app?

We have a Qt app that when it starts tries to connect to a servlet to get config parameters that it needs to keep running.
The URL may change frequently because we have to test the application in several environments. Right now (as a temporary solution) the URL is a constant in source code, but it is a little bit ugly.
Where is the best place to mainting this URL, so that we do not need to change the source code every time I want to change the environment target?
In a database table maybe (my application uses a SQLite DB), in a settings file, or in some other way?
Thank you for you replies.
You have a number of options:
Hard coded (like you have already)
Run-time user input
Command line arguments
QSettings
Read from a bespoke file as text.
I would think option 3 would be the most simple to implement without being intrusive, but it does depend on what kind of application you have.
I would keep the list of url in a document, e.g. a XML, stored in a central, well known place, e.g. a known web server, and hardcode the url of the known place in the app.
The list could then be edited externally without recompiling your app;
The app would at startup download and parse the list, pointing to the right servlet based upon an environment specified as a command line parameter.

ASP.NET SaaS Application File Storage: Drive Letter Paths or UNC paths

The file system part of our asp.net application framework requires updating to fall inline with our SaaS / Multi-Tenancy approach and in particular with regards scaling up.
Our current file system stores files on disk in separate folders for each tenant.
ie: X:\FilesFolder\ApplicationInstance\TenantA etc where the Tenant names and file names are Guids. We have an HttpHandler that retrieves files and resolves all the paths and names and returns the original file names etc. We store the root path for each Tenant, ie : X:\FilesFolder\ApplicationInstance\ on the basis we can move them at some point and to different locations if required.
With regards concerns for scaling this system up, I have some questions... (please excuse my ignorance to the hardware/ windows infrastructure side of things, and my questions are more about implementing the update to our filesystem code)
1) It seems obvious that the files should all be stored on a NAS device?
2) If we add a NAS device and build a server farm, do we need to start running domain controllers? and how does this effect references to paths?
Edit:
Found out that Domains are not required for server farms, which is great, still not sure how this effects usable paths etc
3) Should we be using drive letter paths (mapped drives) or UNC paths?
4) Is there any performance hit in referencing UNC instead of names drive letters (even in the same machine)
5) What permissions issues can we expect and how does this effect running on a domain or not?
Edit:
Having a domain would make permissions easier, but still still dont know what the differences are.
Any comments on this approach, best practices or a better approach appreciated.
Thanks
What you should do is abstract your storage code so that the path is only an implementation detail. This way, you can change the path architecture completely, as may be required by your storage technology.

Running a SWF from file:/// without having the user change their Flash Player security settings

I have a Flex app that does a a fair amount of network traffic, it uses ExternalInterface to make some javascript calls (for SCORM), it loads XML files, images, video, audio and it has a series of modules that it could be loading at some point...
So the problem is - we now have a requirement where the user needs to run this content locally on a machine that is not connected to the internet (which means they can't connect to Adobe's site to change their security settings.) As you can imagine, when the user doubles clicks on the html page to launch this thing, they are greeted with a security warning that the swf is trying to communicate with another domain other than the one it's in. We can't wrap it in an exe or an AIR app so I unless there is some way to tweak some obscure security settings we may be hosed. Any idea's?
What you are trying to do is exactly the problem solved by AIR. You should really give it a try, it's not that hard to pick up. If you really really can't use AIR (you didn't specify why, so I assume it's just because you don't want to have to learn a new system), then modifying the security config file will solve the problem.
Basically what you need to do is create a 'trust' file in the "Global FlashPlayerTrust" directory. This can be done by your installer (which installs all the javascript, SWF, html, etc files onto the local machine). You should create the directory if it does not exist. The directory for each OS is:
Windows - %WINDIR%\System32\Macromed\Flash\FlashPlayerTrust
Mac - /Library/Application Support/Macromedia/FlashPlayerTrust
Linux - /etc/adobe/FlashPlayerTrust
Next, you need to create the trust file. You can name it anything, so pick a unique name that would be unlikely to conflict with others. Something like CompanyName.cfg. It's a text file, with one path per line. You can trust either one SWF at a time, or an entire directory. Example:
C:\Program Files\MyCompany\CoolApp
C:\Program Files\MyCompany\OtherApp\Main.swf
To test that it's working, inside your flash movie you can check System.security.sandboxType (ActionScript 1 or 2), or Security.sandboxType (ActionScript 3). It should have the value of "localTrusted"
I hesitate to say "you can't do it", but in my experience, there's no way to do what you're describing. Anyone, if I'm wrong, I'd love to know the trick.
Sorry that I haven't actually tried this to see if it works or not ... but ...
Page 20 (and/or 26) of this document may be of help. The document is referenced here. In a nutshell it describes directories which contain cfg files which in turn contain lists of locations on disk which should be regarded as trusted. An installer for the application would then be responsible for creating appropriate .cfg files in the desired location (global or for the installing user).
The short answer is that if your swf is compiled with use-network to true, it isn't going to work.
Is it possible to compile a version with use-network to false? Or is it running on an Intranet that is closed off from the Internet and still communicating with the LMS?
It is possible. Please chek that the swfs you are calling from the main swf have the "Access local files only" property enabled or not.
Did you try to specify the authorized domain with:
System.security.allowDomain("www.yourdomain.com");

Config Files for Biztalk Host Processes

A single Biztalk Server can have multiple Host processes. Is it possible to create an application config file for each host process? For example I would like to use Unity or log4net or whatever which needs such a configuration file.
Edit: Thanks at David Hall. To elaborate a bit more:
We have 12 Biztalk Servers in a group each running between 5 and 10 host processes. Some things the host processes run are unique to each process, but they also share a lot of code on the library level. The trigger for my question was the need to configure for example trace levels for the one system part (equivalent to host process) that currently gives trouble.
As an alternative it would help if I could figure out in which host process the current code is running, but I'll post that to a different question.
If I interpret your question correctly, you want to be able to have a separate version of the BTSNTSvs.exe.config file for each host instance?
So as well as the BizTalkServerApplication host instance, you have YourHostInstance host instances that you want to have a separate config for?
I don't 100% know that you cannot do this, but I am almost sure that it is not possible.
The reasons I'm fairly sure this isn't possible are:
The BTSNTSvc.exe.config file attaches to the main executable BTSNTSvc.exe
Config changes placed in BTSNTSvc.exe.config apply to all host instance regardless of their names.
I've just flipped through the BizTalk books I have to hand as well as some of the good web resources and can't find any mention of someone doing what you want.
So as far as I know, you will need to put the config settings for things like log4net into the BTSNTSvc.exe.config file, and have them the same for each host instance.
One way to get close to what you want would be to load application specific settings from the rules engine.

Resources