/// <summary> /// Fetch a place from the Plot back-end server /// </summary> /// <param name="placeId">Id of the place to fetch</param> /// <returns>Entity containing the data of the place (in fact it is a store entity)</returns> public SelectStore GetPlace(string placeId) { const string Function = "place"; CheckNotAdmin(); HttpWebRequest webRequest = GetWebRequest("GET", Function, null, placeId); GetPlaceResponse response = GetJSONresponse <GetPlaceResponse>(webRequest); if (response == null) { throw new Exception("No response."); } // check the result codes: response.Check(); SelectStore ret = null; if (response.Result != null) { ret = new SelectStore() { ID = response.Result.ID, Name = response.Result.Name, Latitude = response.Result.Location.Latitude, Longitude = response.Result.Location.Longitude, Created = response.Result.Created.AsDateTime(true).Value } } ; return(ret); }
private void selectStoreFormNavAction(object sender, object data) { NavBox selectStoreNavBox = (NavBox)sender; SelectStore selectStoreForm = (SelectStore)data; NavBox.NavAction action = selectStoreNavBox.Action; if (action == NavBox.NavAction.BACKANDSUBMIT) { DesktopSession.HistorySession.Back(); action = NavBox.NavAction.SUBMIT; } switch (action) { case NavBox.NavAction.SUBMIT: //Default happy path next state this.parentForm = selectStoreForm; selectStoreForm.Hide(); this.nextState = InventoryAuditFlowState.InitiateAudit; break; case NavBox.NavAction.CANCEL: this.nextState = InventoryAuditFlowState.CancelFlow; break; default: throw new ApplicationException("" + action.ToString() + " is not a valid state for SelectStore"); } this.executeNextState(); }
private void getPlaceButton_Click(object sender, EventArgs e) { if (storeID == null) { throw new Exception("No storeId/placeId known"); } using (Connection conn = NewConnection()) { SelectStore result = conn.GetPlace(storeID); AddLogLine(string.Format("ID of the place: {0}; name: {1}", result.ID, result.Name)); } }
public ShowForm CreateSelectStoreShowBlock( Form parentForm, NavBox.NavBoxActionFired fxn) { var selectStore = new SelectStore(); var selectStoreBlk = this.createShowFormBlock( ValidFormBlockTypes.None, parentForm, selectStore, selectStore.NavControlBox, fxn); return(selectStoreBlk); }
private object executorFxn(object inputData) { if (inputData == null) { inputData = suspendedState; } InventoryAuditFlowState inputState = (InventoryAuditFlowState)inputData; Form currForm; switch (inputState) { case InventoryAuditFlowState.SelectAudit: SelectAudit selectAudit = new SelectAudit(); currForm = DesktopSession.HistorySession.Lookup(selectAudit); if (currForm.GetType() == typeof(SelectAudit)) { currForm.Show(); } else { ShowForm selectAuditBlk = CommonAppBlocks.Instance.CreateSelectAuditShowBlock(this.parentForm, this.selectAuditFormNavAction); if (!selectAuditBlk.execute()) { throw new ApplicationException("Cannot execute Select Audit block"); } } break; case InventoryAuditFlowState.SelectStore: SelectStore selectStore = new SelectStore(); currForm = DesktopSession.HistorySession.Lookup(selectStore); if (currForm.GetType() == typeof(SelectStore)) { currForm.Show(); } else { ShowForm selectStoreBlk = CommonAppBlocks.Instance.CreateSelectStoreShowBlock(this.parentForm, this.selectStoreFormNavAction); if (!selectStoreBlk.execute()) { throw new ApplicationException("Cannot execute Select Store block"); } } break; case InventoryAuditFlowState.InitiateAudit: InitiateAudit initiateAudit = new InitiateAudit(); currForm = DesktopSession.HistorySession.Lookup(initiateAudit); if (currForm.GetType() == typeof(InitiateAudit)) { currForm.Show(); } else { ShowForm initiateAuditBlk = CommonAppBlocks.Instance.CreateInitiateAuditShowBlock(this.parentForm, this.initiateAuditFormNavAction); if (!initiateAuditBlk.execute()) { throw new ApplicationException("Cannot execute Initiate Audit block"); } } break; case InventoryAuditFlowState.AuditManager: AuditManager auditManager = new AuditManager(); currForm = DesktopSession.HistorySession.Lookup(auditManager); if (currForm.GetType() == typeof(AuditManager)) { currForm.Show(); } else { ShowForm auditManagerBlk = CommonAppBlocks.Instance.CreateAuditManagerShowBlock(this.parentForm, this.auditManagerFormNavAction); if (!auditManagerBlk.execute()) { throw new ApplicationException("Cannot execute Audit Manager block"); } } break; case InventoryAuditFlowState.InventorySummary: InventorySummary inventorySummary = new InventorySummary(); currForm = DesktopSession.HistorySession.Lookup(inventorySummary); ShowForm inventorySummaryBlk = CommonAppBlocks.Instance.CreateInventorySummaryShowBlock(this.parentForm, this.inventorySummaryFormNavAction); if (!inventorySummaryBlk.execute()) { throw new ApplicationException("Cannot execute Inventory Summary block"); } break; case InventoryAuditFlowState.InventoryQuestions: InventoryQuestions inventoryQuestions = new InventoryQuestions(); currForm = DesktopSession.HistorySession.Lookup(inventoryQuestions); if (currForm.GetType() == typeof(InventoryQuestions)) { currForm.Show(); } else { ShowForm inventoryQuestionsBlk = CommonAppBlocks.Instance.CreateInventoryQuestionsShowBlock(this.parentForm, this.inventoryQuestionsFormNavAction); if (!inventoryQuestionsBlk.execute()) { throw new ApplicationException("Cannot execute Inventory Questions block"); } } break; case InventoryAuditFlowState.DownloadToTrakker: //DownloadToTrakker downloadToTrakker = new DownloadToTrakker(); //currForm = DesktopSession.HistorySession.Lookup(downloadToTrakker); //if (currForm.GetType() == typeof(DownloadToTrakker)) //{ // currForm.Show(); //} //else //{ ShowForm downloadToTrakkerBlk = CommonAppBlocks.Instance.CreateDownloadToTrakkerShowBlock(this.parentForm, this.downloadToTrakkerFormNavAction); if (!downloadToTrakkerBlk.execute()) { throw new ApplicationException("Cannot execute Download to Trakker block"); } //} break; case InventoryAuditFlowState.UploadFromTrakker: //UploadFromTrakker uploadFromTrakker = new UploadFromTrakker(); //currForm = DesktopSession.HistorySession.Lookup(uploadFromTrakker); //if (currForm.GetType() == typeof(DownloadToTrakker)) //{ // currForm.Show(); //} //else //{ ShowForm uploadFromTrakkerBlk = CommonAppBlocks.Instance.CreateUploadFromTrakkerShowBlock(this.parentForm, this.uploadFromTrakkerFormNavAction); if (!uploadFromTrakkerBlk.execute()) { throw new ApplicationException("Cannot execute Upload from Trakker block"); } //} break; case InventoryAuditFlowState.ProcessMissing: //ProcessMissingItems processMissingItems = new ProcessMissingItems(); //currForm = DesktopSession.HistorySession.Lookup(processMissingItems); //if (currForm.GetType() == typeof(ProcessMissingItems)) //{ // currForm.Show(); //} //else //{ ShowForm processMissingItemsBlk = CommonAppBlocks.Instance.CreateProcessMissingItemsShowBlock(this.parentForm, this.processMissingItemsFormNavAction); if (!processMissingItemsBlk.execute()) { throw new ApplicationException("Cannot execute Process Missing Items block"); } //} break; case InventoryAuditFlowState.ProcessUnexpected: //ProcessUnexpectedItems processUnexpectedItems = new ProcessUnexpectedItems(); //currForm = DesktopSession.HistorySession.Lookup(processUnexpectedItems); //if (currForm.GetType() == typeof(ProcessUnexpectedItems)) //{ // currForm.Show(); //} //else //{ ShowForm processUnexpectedItemsBlk = CommonAppBlocks.Instance.CreateProcessUnexpectedItemsShowBlock(this.parentForm, this.processUnexpectedItemsFormNavAction); if (!processUnexpectedItemsBlk.execute()) { throw new ApplicationException("Cannot execute Process Unexpected Items block"); } //} break; case InventoryAuditFlowState.CountCACC: EnterCaccItems enterCaccItems = new EnterCaccItems(); currForm = DesktopSession.HistorySession.Lookup(enterCaccItems); if (currForm.GetType() == typeof(EnterCaccItems)) { currForm.Show(); } else { ShowForm enterCaccItemsBlk = CommonAppBlocks.Instance.CreateEnterCaccItemsShowBlock(this.parentForm, this.enterCaccItemsFormNavAction); if (!enterCaccItemsBlk.execute()) { throw new ApplicationException("Cannot execute Enter Cacc Items block"); } } break; case InventoryAuditFlowState.AuditResults: ClosedAudit closedAudit = new ClosedAudit(); currForm = DesktopSession.HistorySession.Lookup(closedAudit); if (currForm.GetType() == typeof(ClosedAudit)) { currForm.Show(); } else { ShowForm closedAuditBlk = CommonAppBlocks.Instance.CreateClosedAuditShowBlock(this.parentForm, this.closedAuditFormNavAction); if (!closedAuditBlk.execute()) { throw new ApplicationException("Cannot execute Closed Audit block"); } } break; case InventoryAuditFlowState.ChargeOn: ShowForm describeMerchBlk = CommonAppBlocks.Instance.DescribeMerchChargeOnBlock(this.parentForm, this.describeMerchFormAction, DesktopSession); if (!describeMerchBlk.execute()) { throw new ApplicationException("Cannot execute Describe Merchandise Block"); } break; case InventoryAuditFlowState.DescribeItem: ShowForm describeItemBlk = CommonAppBlocks.Instance.DescribeItemBlock(this.parentForm, this.describeItemFormAction, DesktopSession); if (!describeItemBlk.execute()) { throw new ApplicationException("Cannot execute Describe Item Block"); } break; case InventoryAuditFlowState.CancelFlow: AuditDesktopSession.Instance.ClearLoggedInUser(); if (this.endStateNotifier != null) { this.endStateNotifier.execute(); } break; case InventoryAuditFlowState.ExitFlow: AuditDesktopSession.Instance.ClearLoggedInUser(); break; default: throw new ApplicationException("Invalid inventory audit flow state"); } return(true); }