Question about using remoteobject in modules - apache-flex

I have a number of modules in my flex application and in each module I use a remoteobject to retrieve dynamic data from the server related to each module. Recently I read a couple of comments in some blogs people saying that remoteobjects should not be used in modules, instead they should be in the main application. Is this true and why? And if it's true, what would I do with the resulthandler in the main app, since the code is very specific to each module, there's a lot of data manipulation and code setting values of components in the module, how would the handler in the main app access the components inside the module?
Thanks

It seems ridiculous to me to avoid using RemoteObject in a module. The whole purpose of a Module is to be a self contained portion of an application. And there is no reason why remote service calls can't be part of the self contained piece.
Do you have links to blog posts making these claims? I'm sure any such claims would be context specific (as are most best practices).

Related

Net Core MVC - Layout method call

I have a bunch of environmental settings in my appsetting - directories, DB connection string etc. I'd like to call a method from the layout page (referenced by all my views as it constructs the navbar) which will return a boolean indicating if everything is accessible (i.e. it will read config, check directories exist, can connect to DB etc.). I want to do this in layout so every page will check and indicate if all environment settings are online.
Just polling here for the best practice approach. Would a new class with a method to check all environment settings which can be called from the layout razor page be an option? Or maybe I'm over complicating it by not knowing there is an easier way to do this baked into the framework. All and any feedback very welcome.
Well there's certainly no reason why you couldn't do it in the layout if you wanted to. Alternatively you could do it from a base page class that all other pages inherit from.
But that's not a standard way. I think you should consider using the built in health monitoring in ASP .NET Core, which would expose one or more endpoints for checking connections to databases, available file storage etc.
Documentation is here: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-3.1

Angular 4 application receiving ViewComponent ASP.Core server responses

I am trying to build a single-page application with an ASP.Core + Angular 4 stack. The server is supposed to provide view components, which will be rendered client-side and populated with additional data.
The best way to create components would be utilising ViewComponent mechanic on the server, which allows me to effectively create HTML layouts and populate my HTML components with data from DB. Alas, I have not yet found a way to transfer the data to my Angular 4 client app. The ViewComponents are not static resources, meaning I (most likely) can't transfer it as JSON-data, and even if I could, I'd have to teach my client how to unwrap it back into html, which would increase the load on the client.
I have confirmed that JQuery calls can be made to receive IViewComponentResult responses, but I am yet to find a way on how to achieve same results in an Angular component. Any help would be appreciated.
Usually with this stack you use .NET Core as the backend meaning you use it to write the Web API code which interacts with the database. The Angular side of things would have services which call the Web API via http methods and present/manipulate the data in component.html/.css/.ts files.
You can read through a guide such as this to get an idea of the structure and flow of the stack. Everything you mentioned in your 2nd paragraph can be achieved through this architecture without the worry of transferring ViewComponents.

How to share custom classes between a console application and a website

I currently have a visual basic console application that runs on the server nightly and that has several classes. Each class has lots of properties as well as quite a few procedures and functions doing various tasks.
I have a payer class that handles information and functions dealing with payers, a recipient class that handles information and functions dealing with recipients and I have a payment class that holds information about payments. Two of the payment class properties are of payer type and recipient type. Part of my application creates a PDF out of all of this information and faxes it to the recipient.
Now I also have a asp.net website that displays information about all of these payers, recipients, and payments. Currently it does not access anything the console application has. It just gets information from the database and displays it in various list views and things.
The client is now asking to have a button on the website that would allow them to recreate the pdf that the console application currently generates. There is a lot of code involved in this and I need a way to not duplicate it.
My thought was to make a webservice that handles creating the pdf and both the application and the website could call it. But the web service will need access to these custom classes that currently live in my console application.
What would be the best way for both my webservice and the console application to have access to these classes. Would it then be possible to pass a custom object of type payment as a parameter to the webservice?
Using a class library
I had a similar situation where I had to share some classes and functions between projects. What I did was to create a Class Library and put those classes there. Also, when I created the library I had some issues with namespaces so I had some rewriting to do on that part.
So, essentially my solution was separated in two projects
The core library (class library)
The website (ASP.NET web application)
In the core library I had all code regarding the Data Access Layer, all the entity classes of my application and a bunch of helper classes, tools etc while in the website I did not leave much code except from the code involved in the pages and user controls.
With this approach you will have an extra .dll file containing the shared classes that the console application, the webservice and the web application will share.
Keep in mind that there are some things that you need to keep in mind such as the connection string where each application might store it in a different place. Also you cannot use the Request, Response, Server etc namespaces in your library since it will be null in the case of the desktop application.
Using linked files
An other way to share code between projects is to have the code files in one project and link those files to the other.
Right click in your project and choose Add -> Existing item, and then click the down arrow next to the Add button and select Add as link:
Finally this thread is about this subject, so it might be useful.

How do I include properties file or config file in flex application (I am also using swiz framework)

I have a flex application which contains different feature that includes google maps, twitter, facebook etc.
Currently I have hardcoded api keys in the code it self but I want to use a properties file/config file where I can put such things and use anywhere I want in the application.
Is it possible to achieve this in flex?
I am using swiz framework. Is it possible to achieve this using this framework?
Thanks
Priyank
We use an external xml config file chock full of config settings for dev, staging, and production environments. Load it into your app at application complete and parse the xml nodes into a value object and store it in your model.
Jeff
ReUrgency.com
if you require LOCAL CONFIGURATION (the configuration specific for each client) then the easiest way to do in flex/air application is using sharedobject because filereference has been limited only for air application. ticlib has an easy and natural way to do local configuration, you only need to add [Config] annotation on your variable or getter then you event don't need to care about how to create and manage shared object. you can take a look at this blog post for real time use.
The Swiz Example Applications have many good examples of this. Look for anywhere they are loading a service config. I believe SwizDemoApp has an example of this, or it could be SwizPresentationModelExample (those were the two I looked at, and one of them had the method I use in my Swiz apps now). :)

API For Flex Apps To Interact

I have a large flex application (the app) running on one server, and many small flex applications (widgets) running on another server, which are to be included in the app so that visually the user see's one continuous application. Due to proprietary third party software, this structure cannot be changed. I am looking for some way to allow the app and the widgets to communicate, allowing the app to make changes to the widgets and the the widgets to notify the app when events are triggered, so that user interaction is fluid and continuous.
There are a few related questions which indicate it's possible to do this by setting up event triggers and listeners. I am wondering if there is any standardized way to do this (the answers aren't very clear) or if anyone has developed a library or API to make this easier.
Something I've had success with is using javascript as a bridge between the swf files. It's a nightmare to debug but it works quite well. Check out the tutorial here for a quick discussion of how to interact with javascript from within flash and vice versa
I assume you are running your Flex apps on a client, not a server; is that correct? You want to swfs from multiple servers to act as single application, correct?
I believe that you can communicate between two swfs using LocalConnection:
http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/net/LocalConnection.html
The other questions you link to seem to talk about loading onw swf inside the oher; which is a separate approach.
Use Modules and ModuleLoaders. You'll be able to set the security context, and if you sublcass the Module class and add your own API, you can have a consistent way to communicate with your modules.
Check here for a simple Module:
http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/

Resources