I create the Custom tracking method in magento 1.9
Only show Tracking method dropdown in backend but the popup not show my tracking method
Post service is my custom tracking method
public function isTrackingAvailable()
{
return true;
}
Related
I'm trying to develop an application using C# wiforms. I want to execute void sendEmail(){} function in a class only when internet connection is up. The method that I used is bool checkConnection(){} function infinitely loops a while loop and sending ping requests to google.com. if the ping is successful, sendEmail(){} function is called by the checkConnection() function.
But i know this is not the best practice of doing this. I'm very confusing about custom events in C#. how to use custom events to accomplish this task. expecting an answer with simple explanation.
Thanks in advance
I understand that you are trying to build a scheduler task like functionality in c#. Based on my understanding, a windows service would do the task for you like listening for the availability of internet and then performing the mail sending operation when the application goes online.
W.R.To Events, you can build your own event engine that the one that raises the application events when the app runs and then there will be database entries that lists the pending tasks. There will be a background job like a windows service that reads the database and based on the availability of internet or on some condition executes the job.
If you can be more clear on the exact use-case and what you have tried so far the community can help you better.
Sample
class Observable
{
public event ImageUploadeventHandler InternetcOnnected;
public void DoSomething()
{
ImageUploadeventHandler handler = InternetcOnnected;
if (handler != null)
{
handler(this, EventArgs.Empty);
}
}
}
class Observer
{
public void HandleEvent(object sender, EventArgs args)
{
// upload the image to the online service
}
}
I am new to web development. I am planning to create a web service which is going to act as a back end for both web site and mobile application. I want to know if it is possible to use same method to return data in different type.
For example:
If i use http://somewebsite/getdetails.jsp should give me and modelView return type and http://somewebsite/getdetails.json should give the model in json format.
I don't want to create two different controller to handle this.
If there is any other better way also please share your comments.
I am open for alternative solutions too
Spring 4.0 / Spring Boot enables you to achieve this quite easily. I am currently developing web-service (API) for mobile and backend for browser based clients and I just simply split API for mobile under URL #RequestMapping("/api"). In addition, Spring allows you to easily implement RESTful url based application. I recommend you to have two different controllers for API and Web MVC because it ensures complete separation between two different logics. E.g.
Would you really like to implement something like following?
#SuppressWarnings("unchecked")
public Map<Object, Object> test(#RequestParam(value="mobileyes") boolean mobile){
if(mobile){
Map<Object, Object> m = new HashMap<Object, Object>();
m.put("test", "test")
return m;
} else {
ModelAndView mv = new ModelAndView();
mv.addObject("test", "test");
mv.setViewName("test");
return (Map<Object, Object>) mv;
}
}
Above example might work, but ugly and will certainly cause maintenance disaster in near future.
This is my overall structure of Spring MVC using Spring Boot :
Ordinary URL accessed by desktop based and mobile based browsers
These controllers use
#Controller annotation because it doesn't automatically enables #ResponseBody
www.mybusinesscard.com.au/ -> Index
//Displaying all businesscards
www.mybusinesscard.com.au/businesscards -> view all
//For saving from form
www.mybusinesscard.com.au/businesscard/save -> save a card
Following controller examples are for mobile API:
Following controllers use #RestController annotation to automatically enable requirements necessary for WebServices. E.g: #ResponseBody
www.mybusinesscard.com.au/api -> Index
//Displaying all businesscards
www.mybusinesscard.com.au/api/businesscards -> view all
//For saving from form
www.mybusinesscard.com.au/api/businesscard/save -> save a card
I have created a service interface:
public interface IMessageDialogService
{
void ShowDialog(object context,string title,string message,string buttonTitle);
}
I have implemented that interface on both Android and iOS. The context is only used on Android where an Android Context is needed to display a message dialog. I pass this interface into my ViewModel to be injected by IoC. My problem is in my platform independent ViewModel which calls a WebService and then handles the return value. It checks the return value for an error condition and needs to display a message dialog. iOS does not need any context to display a UIAlertView, but on Android how do I get a hold of an Android context to pass in as the first argument?
Is there an easier way to display a simple informational dialog from a ViewModel?
After inspecting the source for the WebBrowserTask, it looks like I can always grab the current Activity by:
var activity = Mvx.Resolve<IMvxAndroidCurrentTopActivity> ().Activity;
so I don't have to pass it down, but have my implementation of IMessageDialogService on Android grab it and use it to display the message dialog.
I implemented the exception filter like here: http://www.asp.net/web-api/overview/web-api-routing-and-actions/exception-handling
And registered it globally, like microsoft or stackoverflow-users ( How to add global ASP.Net Web Api Filters? ) explained.
public static void RegisterWebApiFilters(System.Web.Http.Filters.GlobalFilterCollection filters)
{
//other filters
filters.Add(new MyExceptionFilter());
}
But if I throw an exception, my method is not called.
My exception-handling method is called only if I add the attribute [MyExceptionFilter] to the controller-method, but I hoped I can avoid that for all methods by registering the filter globally.
I tried to set a order for the filters, but this had no effect.
Edit: I have noticed, that in the new Wep Api RC the method is called "RegisterGlobalFilters" and this seems to be the MVC filter collection.
If I call
GlobalConfiguration.Configuration.Filters.Add(new MyExceptionFilter());
it works. This is the collection for the Web Api.
Looks like I have to build my own "FilterConfig" class for the web api...
Like I mentioned in my question: There are different filter collections. One for MVC and one for the web api.
If you want to add the filter to the web api, add this line of code to the global.asax
GlobalConfiguration.Configuration.Filters.Add(new MyExceptionFilter());
I have a ASP.NET MVC3 solution named "SampleProject". I have 4 projects in the solution.
The project names of the solution are
SampleProject.Data (holds entity classes, DAL classes, and filter classes)
SampleProject.Service (something like BLL in standard ERP)
SampleProject.Tests (test project)
SampleProject.Web (holds controllers and views)
I am calling the Service classes from my controllers. The service classes are calling Data classes and data classes are performing the database operations.
I have done create, list and details part. Now I stucked in Edit part. None of the examples (NerdDinner,MVCMusicStore etc) using my architecture. In the provided examples(NerdDinner,MVCMusicStore etc or in ASP.NET website tutorials), they are just using built in UpdateModel method which I don't want to use. I want to manually get the model object from my view and send it to my Data layer for update.
My question is, how can I update the models through different project layer?
I solved the porblem. Here is the code.Just for reference, CResult is a class which contains IsSuccess(bool), Message(string) properties in it.
CResult oCResult;
[HttpPost]
public ActionResult Edit(Restaurant model)
{
try
{
oCResult = restaurantService.Update(model);
if (oCResult.IsSuccess)
{
return RedirectToAction("Index");
}
return View("Error");
}
catch
{
return View();
}
}
The view engine prepares the object (in my case, it is Restaurant type of object) it inherits with new values and send back to controller. this is my understanding.