/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="session"></param> /// <param name="executeDelegate"></param> /// <returns></returns> private FOEResult <T> Execute <T>(Guid session, ExecuteDelegate <T> executeDelegate) { FOEResult <T> result; try { ServiceRequestHandler request = new ServiceRequestHandler(session); result = new FOEResult <T>(executeDelegate(request)); } catch (FOEServiceException ex) { Trace.TraceError("{0}", ex); result = new FOEResult <T>(ex); } catch (SqlException ex) { Trace.TraceError("{0}", ex); result = new FOEResult <T>(FOEStatusCodes.DatabaseError, ex.Message); } catch (Exception ex) { Trace.TraceError("{0}", ex); result = new FOEResult <T>(FOEStatusCodes.InternalError, ex.Message); } return(result); }
protected void Dispose(bool disposing) { if (this.disposed) { return; } if (disposing) { if (this.listener != null) { if (this.listener.IsListening) { this.listener.Stop(); } this.listener.Close(); this.listener = null; } if (this.serviceEntry != null) { this.serviceEntry.Dispose(); this.serviceEntry = null; this.serviceRequestHandler = null; } } this.disposed = true; }
public async static Task <bool> SendGetAllShiftsRequest(string employeeid) { GetAllShiftsRequest getAllShiftsRequest = new GetAllShiftsRequest(employeeid); var response = await ServiceRequestHandler.MakeServiceCall <ShiftList>(getAllShiftsRequest); if (response != null) { RealmManager.RemoveAll <ShiftList>(); ShiftList parsedList = new ShiftList(); for (int i = 0; i < response.shifts.Count; i++) { Shift interShift = response.shifts.ElementAt(i); interShift.clock_in = interShift.clock_in.Substring(11, 8) + " " + interShift.clock_in.Substring(5, 2) + "/" + interShift.clock_in.Substring(8, 2) + "/" + interShift.clock_in.Substring(0, 4); if (!String.IsNullOrEmpty(interShift.clock_out)) { interShift.clock_out = interShift.clock_out.Substring(11, 8) + " " + interShift.clock_out.Substring(5, 2) + "/" + interShift.clock_out.Substring(8, 2) + "/" + interShift.clock_out.Substring(0, 4);; } parsedList.shifts.Add(interShift); } RealmManager.AddOrUpdate <ShiftList>(parsedList); return(true); } else { return(false); } }
public async static Task <bool> SendGetOrdersRequest() { GetOrdersRequest getOrdersRequest = new GetOrdersRequest(); var response = await ServiceRequestHandler.MakeServiceCall <OrdersList>(getOrdersRequest); if (response.Orders != null) { // Will filter out any properties that hold time_completed property as those are orders that are already finished List <Orders> ordersFiltered = response.Orders.Where(s => String.IsNullOrEmpty(s.time_completed)).ToList(); //removes all orders without any menu items ordersFiltered.RemoveAll(s => s.menuItems.Count == 0); //filter out all orders which are prepared within ordersFiltered and orders that have been sent to kitchen foreach (Orders o in ordersFiltered) { ordersFiltered = ordersFiltered.Where(s => s.menuItems.Any(m => !m.prepared) && s.send_to_kitchen).ToList(); } RealmManager.RemoveAll <Orders>(); RealmManager.AddOrUpdate <Orders>(ordersFiltered); return(true); } else { return(false); } }
/// <summary> /// Logs the user in returning a sessionId /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> public FOEResult <Guid> Login(string userName, string password) { FOEResult <Guid> result = new FOEResult <Guid>(); try { ServiceRequestHandler requestHandler = new ServiceRequestHandler(); result.Result = requestHandler.Login(userName, password); } catch (FOEServiceException ex) { Trace.TraceError("{0}", ex); result = new FOEResult <Guid>(ex); } catch (SqlException ex) { Trace.TraceError("{0}", ex); result = new FOEResult <Guid>(FOEStatusCodes.DatabaseError, ex.Message); } catch (Exception ex) { Trace.TraceError("{0}", ex); result = new FOEResult <Guid>(FOEStatusCodes.InternalError, ex.Message); } return(result); }
static void Main(string[] args) { // Create a request handler var requestHandler = new ServiceRequestHandler( // Define the url for your company. new Uri("https://companyname.tpondemand.com/"), // Pass the username you have defined in target process to work with services "Username", // You have to pass the password as a secure string. "password".ConvertToSecureString()); // Create the service provider by passing in the request handler var serviceProvider = new ServiceProvider(requestHandler); // Use the service CompanyCrudOps(serviceProvider.FetchInstance <ICompanyService>()); // Currently, these are the only serivces currently supported. var taskService = serviceProvider.FetchInstance <ITaskService>(); var bugService = serviceProvider.FetchInstance <IBugService>(); var programService = serviceProvider.FetchInstance <IProgramService>(); var epicService = serviceProvider.FetchInstance <IEpicService>(); var commentService = serviceProvider.FetchInstance <ICommentService>(); var featureService = serviceProvider.FetchInstance <IFeatureService>(); var timeService = serviceProvider.FetchInstance <ITimeService>(); var fetchInstance = serviceProvider.FetchInstance <IUserService>(); var requestService = serviceProvider.FetchInstance <IRequestService>(); var projectService = serviceProvider.FetchInstance <IProjectService>(); }
public void Start() { if (this.isStarted == 1) { return; } if (this.listener == null) { this.listener = new HttpListener(); } if (this.serviceEntry == null) { try { string str = this.serviceName; string str1 = str; if (str != null) { if (str1 == "Blob") { this.serviceEntry = new BlobServiceEntry(); } else if (str1 == "Queue") { this.serviceEntry = new QueueServiceEntry(); } else { if (str1 != "Table") { throw new Exception("Blob, Queue & Table configuration missing"); } this.serviceEntry = new TableServiceEntry(); } this.serviceRequestHandler = this.serviceEntry as ServiceRequestHandler; this.serviceEntry.Initialize(this); this.serviceEntry.Start(); this.listener.Prefixes.Add(this.UrlBase); this.listener.Start(); this.listenerThread = new Thread(new ThreadStart(this.Run)); this.listenerThread.Start(); return; } throw new Exception("Blob, Queue & Table configuration missing"); } catch (Exception exception1) { Exception exception = exception1; this.Stop(); Logger <IRestProtocolHeadLogger> .Instance.Error.Log(exception.Message); throw; } } }
public virtual object Invoke(string method, JObject args) { ServiceRequestHandler handler = null; object result = null; if (ApplicationServices.RequestHandlers.TryGetValue(method.ToLower(), out handler)) { result = handler.HandleRequest(this, args); } return(result); }
// Posts a tip to the database public static async Task <bool> SendFinishOrderRequest(string tableID) { //make a new request object var serviceRequest = new FinishOrderRequest(tableID); //get a response var response = await ServiceRequestHandler.MakeServiceCall <DeleteResponse>(serviceRequest); //No response is set so just assume it worked return(true); }
public async static Task <bool> SendAddMenuItemRequest(List <string> ingredients, string name, string picture, string description, double price, string nutrition, string item_type, string category) { AddMenuItemRequest addMenuItemRequest = new AddMenuItemRequest(ingredients, name, picture, description, price, nutrition, item_type, category); var response = await ServiceRequestHandler.MakeServiceCall <AddMenuItemRequestResponse>(addMenuItemRequest, addMenuItemRequest.Body); if (response.message != null) { return(true); } else { return(false); } }
public async static Task <string> SendMakeNewPromo(string couponType, string description, List <MenuItem> reqItems, List <MenuItem> appItems, string discount, string active, string repeatable) { MakeNewPromo makeNewPromo = new MakeNewPromo(couponType, description, reqItems, appItems, discount, active, repeatable); var response = await ServiceRequestHandler.MakeServiceCall <MakeNewPromoResponse>(makeNewPromo, makeNewPromo.Body); if (response.message == null) { return(null); } else { return(response._id); } }
public async static Task <bool> SendDeleteTipRequest(string id) { DeleteTipRequest deleteTipRequest = new DeleteTipRequest(id); var response = await ServiceRequestHandler.MakeServiceCall <DeleteTipResponse>(deleteTipRequest); if (response.deletedCount == 1) { return(true); } else { return(false); } }
public async static Task <bool> SendUpdateEmployeeRequest(string id, string pay, string first_name, string last_name, string username, string position) { UpdateEmployeeRequest updateEmployeeRequest = new UpdateEmployeeRequest(id, pay, first_name, last_name, username, position); var response = await ServiceRequestHandler.MakeServiceCall <UpdateEmployeeResponse>(updateEmployeeRequest, updateEmployeeRequest.Body); if (response.nModified == 1) { return(true); } else { return(false); } }
public override void AcceptRequest(RequestContext requestContext, Microsoft.Cis.Services.Nephos.Common.ServiceType serviceType) { requestContext.ServiceType = serviceType; PerRequestStorageManager perRequestStorageManager = new PerRequestStorageManager(TableServiceEntry.SharedStorageManager, requestContext.OperationStatus); AuthenticationManager authenticationManager = XFETableAuthenticationManager.CreateAuthenticationManager(TableServiceEntry.SharedStorageManager); AuthorizationManager authorizationManager = NephosAuthorizationManager.CreateAuthorizationManager(TableServiceEntry.SharedStorageManager, false); ITableManager operationStatus = TableManager.CreateTableManager(authorizationManager, TableServiceEntry.SharedTableDataFactory, TableServiceEntry.SharedStorageManager); operationStatus.Initialize(); operationStatus.OperationStatus = requestContext.OperationStatus; IProcessor processor = TableProtocolHead.Create(requestContext, perRequestStorageManager, authenticationManager, operationStatus, TableProtocolHead.HttpProcessorConfigurationDefaultInstance, new TransformExceptionDelegate(SqlExceptionManager.TransformSqlException), null); ServiceRequestHandler.DispatchRequest(processor); }
public static async Task <bool> SendUpdateIngredientRequest(string id, string oldValue, string newValue) { var sendUpdateIngredientRequest = new UpdateIngredientRequest(id, oldValue, newValue); var response = await ServiceRequestHandler.MakeServiceCall <DeleteResponse>(sendUpdateIngredientRequest, sendUpdateIngredientRequest.Body); if (response == null) { return(false); } else { return(true); } }
public async static Task <bool> SendSetCouponActive(string id, bool active) { SetCouponActive setCouponActive = new SetCouponActive(id, active); var response = await ServiceRequestHandler.MakeServiceCall <SetCouponActiveResponse>(setCouponActive, setCouponActive.Body); if (response.nModified == 1) { return(true); } else { return(false); } }
public async static Task <bool> SendUpdateMenuItemRequest(MenuItem menuItem) { UpdateHotItemRequest updateMenuItemRequestHotItem = new UpdateHotItemRequest(menuItem); var response = await ServiceRequestHandler.MakeServiceCall <DeleteResponse>(updateMenuItemRequestHotItem, updateMenuItemRequestHotItem.Body); if (response.electionId != null) { return(true); } else { return(false); } }
public async static Task <bool> SendClockInRequest(string employeeid) { ClockIn clockIn = new ClockIn(employeeid); var response = await ServiceRequestHandler.MakeServiceCall <ClockInRespoonse>(clockIn, clockIn.Body); if (response.shift_id != null) { return(true); } else { return(false); } }
public async static Task <bool> SendDeleteEmployeeRequest(string id) { DeleteEmployeeRequest deleteEmployeeRequest = new DeleteEmployeeRequest(id); var response = await ServiceRequestHandler.MakeServiceCall <DeleteEmployeeRequestResponse>(deleteEmployeeRequest); if (response.message != null) { return(true); } else { return(false); } }
public async static Task <bool> SendUpdateMenuItemRequest(string id, string category, double price, string name, string nutrition, string description) { UpdateMenuItemRequest updateMenuItemRequest = new UpdateMenuItemRequest(id, category, price, name, nutrition, description); var response = await ServiceRequestHandler.MakeServiceCall <DeleteResponse>(updateMenuItemRequest, updateMenuItemRequest.Body); if (response.electionId != null) { return(true); } else { return(false); } }
public async static Task <bool> SendResetEmployeeShift(string employeeid) { ResetEmployeeShift resetEmployeeShift = new ResetEmployeeShift(employeeid); var response = await ServiceRequestHandler.MakeServiceCall <ResetEmployeeResponse>(resetEmployeeShift, resetEmployeeShift.Body); if (response.nModified == 0) { return(false); } else if (response.nModified == 1) { return(true); } return(false); }
public async static Task <bool> SendAddEmployeeRequest(string fName, string lName, string userName, string passWord, int position, double pay) { AddEmployeeRequest addEmployeeRequest = new AddEmployeeRequest(fName, lName, userName, passWord, position, pay); var response = await ServiceRequestHandler.MakeServiceCall <AddEmployeeRequestResponse>(addEmployeeRequest, addEmployeeRequest.Body); if (response.employee != null) { return(true); } else { return(false); } }
public static async Task <bool> SendGetEmployeeListRequest() { var sendGetEmployeeListRequest = new GetEmployeeListRequest(); var response = await ServiceRequestHandler.MakeServiceCall <EmployeeList>(sendGetEmployeeListRequest); if (response != null) { RealmManager.AddOrUpdate <EmployeeList>(response); return(true); } else { return(false); } }
public static async Task <bool> SendValidateLoginRequest(string userName, string passWord) { var sendValidateLoginRequest = new ValidateLoginRequest(userName, passWord); var response = await ServiceRequestHandler.MakeServiceCall <ValidateLoginRequestResponse>(sendValidateLoginRequest, sendValidateLoginRequest.Body); if (response.employee == null) { return(false); } else { RealmManager.AddOrUpdate <Employee>(response.employee); return(true); } }
public async static Task <bool> SendClockOutRequest(string shiftid) { ClockOut clockOut = new ClockOut(shiftid); var response = await ServiceRequestHandler.MakeServiceCall <ClockOutResponse>(clockOut, clockOut.Body); if (response.nModified == 0) { return(false); } else if (response.nModified == 1) { return(true); } return(false); }
//Send Notification to database public static async Task <bool> SendAddNotificationRequest(string inID, string inSend, string inType) { var sendAddNotificationRequest = new AddNotificationRequest(inID, inSend, inType); var response = await ServiceRequestHandler.MakeServiceCall <PostResponse>(sendAddNotificationRequest, sendAddNotificationRequest.Body); if (response.message == null) { return(false); } else { return(true); } }
public async static Task <bool> SendGetCouponsRequest() { GetCouponsRequest getCouponsRequest = new GetCouponsRequest(); var response = await ServiceRequestHandler.MakeServiceCall <CouponList>(getCouponsRequest); if (response != null) { RealmManager.RemoveAll <CouponList>(); RealmManager.AddOrUpdate <CouponList>(response); return(true); } else { return(false); } }
public async static Task <bool> SendGetEmployeeTips(string id) { GetEmployeeTips getEmployeeTips = new GetEmployeeTips(id); var response = await ServiceRequestHandler.MakeServiceCall <Tips>(getEmployeeTips); if (response != null) { RealmManager.RemoveAll <Tips>(); RealmManager.RemoveAll <Tip>(); RealmManager.AddOrUpdate <Tips>(response); return(true); } else { return(false); } }
public async static Task <bool> SendAllCompsNoArgs() { GetAllComps getAllComps = new GetAllComps(); var response = await ServiceRequestHandler.MakeServiceCall <Comps>(getAllComps); if (response != null) { RealmManager.RemoveAll <Comp>(); RealmManager.RemoveAll <Comps>(); RealmManager.AddOrUpdate <Comps>(response); return(true); } else { return(false); } }
public static async Task <bool> SendAddIngredientRequest(string itemName, string itemQuantity) { //call to the constructor above var sendAddIngredientRequest = new AddIngredientRequest(itemName, itemQuantity); //call to ServiceRequestHandler, arguments are the request object (like usual), but notice that we also //add a specific reference to the BODY property of this object as a second paramater. var response = await ServiceRequestHandler.MakeServiceCall <PostResponse>(sendAddIngredientRequest, sendAddIngredientRequest.Body); if (response.message == null) { return(false); } else { return(true); } }