// ------------------------------------------- /* * OnUIEvent */ private void OnUIEvent(string _nameEvent, params object[] _list) { if (_nameEvent == ImagesController.EVENT_IMAGES_UPLOAD_TO_SERVER_NEW_IMAGE) { string tabla = (string)_list[1]; long idRequests = (long)_list[2]; int typeImage = (int)_list[3]; if (tabla == MenusScreenController.TABLE_REQUESTS) { if (typeImage == RequestModel.IMAGE_TYPE_FINISHED) { RequestModel localRequest = GetLocalRequest(idRequests); if (localRequest != null) { localRequest.IsDataFull = false; } } } } if (_nameEvent == EVENT_REQUEST_CALL_CREATE_OR_UPDATE_REQUEST) { RequestModel request = (RequestModel)_list[0]; RequestModel localRequest = GetLocalRequest(request.Id); if (localRequest != null) { localRequest.Copy(request, true); localRequest.IsDataFull = false; } CommsHTTPConstants.CreateNewRequestDress(UsersController.Instance.CurrentUser.Id.ToString(), UsersController.Instance.CurrentUser.Password, request); } if (_nameEvent == EVENT_REQUEST_RESULT_CREATED_RECORD_CONFIRMATION) { if ((bool)_list[0]) { UsersController.Instance.CurrentUser.Additionalrequest = 0; } } if (_nameEvent == EVENT_REQUEST_CALL_CONSULT_RECORDS_BY_USER) { int idUser = UsersController.Instance.CurrentUser.Id; if (_list.Length > 0) { idUser = (int)_list[0]; } if (m_mustReloadRequests || (idUser != UsersController.Instance.CurrentUser.Id)) { if (m_otherUserIDLastConsult == idUser) { if (m_otherUserRequests.Count == 0) { CommsHTTPConstants.RequestConsultRecordsByUser(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, idUser); } else { UIEventController.Instance.DispatchUIEvent(EVENT_REQUEST_RESULT_FORMATTED_RECORDS, m_otherUserRequests, TYPE_CONSULT_BY_USER, idUser); } } else { CommsHTTPConstants.RequestConsultRecordsByUser(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, idUser); } } else { if (m_userRequests.Count == 0) { CommsHTTPConstants.RequestConsultRecordsByUser(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, idUser); } else { UIEventController.Instance.DispatchUIEvent(EVENT_REQUEST_RESULT_FORMATTED_RECORDS, m_userRequests, TYPE_CONSULT_BY_USER, idUser); } } } if (_nameEvent == EVENT_REQUEST_CALL_CONSULT_BY_PROVIDER) { int idProvider = (int)_list[0]; bool requestAll = (bool)_list[1]; if (m_mustReloadProviderRequests || (idProvider != UsersController.Instance.CurrentUser.Id)) { if (m_otherProviderIDLastConsult == idProvider) { if (m_otherProviderRequests.Count == 0) { CommsHTTPConstants.RequestConsultRecordsByProvider(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, idProvider, requestAll); } else { UIEventController.Instance.DispatchUIEvent(EVENT_REQUEST_RESULT_FORMATTED_RECORDS, m_otherProviderRequests, TYPE_CONSULT_BY_PROVIDER); } } else { CommsHTTPConstants.RequestConsultRecordsByProvider(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, idProvider, requestAll); } } else { if (m_providerRequests.Count == 0) { CommsHTTPConstants.RequestConsultRecordsByProvider(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, idProvider, requestAll); } else { UIEventController.Instance.DispatchUIEvent(EVENT_REQUEST_RESULT_FORMATTED_RECORDS, m_providerRequests, TYPE_CONSULT_BY_PROVIDER); } } } if (_nameEvent == EVENT_REQUEST_CALL_CONSULT_BY_DISTANCE_RECORDS) { MenusScreenController.Instance.CreateNewInformationScreen(ScreenInformationView.SCREEN_WAIT, UIScreenTypePreviousAction.KEEP_CURRENT_SCREEN, LanguageController.Instance.GetText("message.info"), LanguageController.Instance.GetText("message.loading"), null, ""); CommsHTTPConstants.RequestConsultRecordsByDistance(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, (SearchModel)_list[0], RequestModel.STATE_REQUEST_OPEN); } if (_nameEvent == EVENT_REQUEST_CALL_CONSULT_SINGLE_RECORD) { long idRequest = (long)_list[0]; RequestModel request = GetLocalRequest(idRequest); bool makeServerCall = true; if (request != null) { if (request.IsDataFull) { makeServerCall = false; } } if (makeServerCall) { MenusScreenController.Instance.CreateNewInformationScreen(ScreenInformationView.SCREEN_WAIT, UIScreenTypePreviousAction.KEEP_CURRENT_SCREEN, LanguageController.Instance.GetText("message.info"), LanguageController.Instance.GetText("message.loading"), null, ""); CommsHTTPConstants.RequestConsultSingleRequest(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, idRequest); } else { UIEventController.Instance.DispatchUIEvent(EVENT_REQUEST_RESULT_FORMATTED_SINGLE_RECORD, request); } } if (_nameEvent == EVENT_REQUEST_RESULT_CONSULT_SINGLE_RECORD) { if (_list == null) { return; } if (_list.Length == 0) { return; } string buf = (string)_list[0]; string[] lines = buf.Split(new string[] { CommController.TOKEN_SEPARATOR_LINES }, StringSplitOptions.None); RequestModel singleRecord = null; for (int k = 0; k < lines.Length; k++) { string[] tokens = lines[k].Split(new string[] { CommController.TOKEN_SEPARATOR_EVENTS }, StringSplitOptions.None); if (k == 0) { if (MenusScreenController.Instance.DebugMode) { Debug.Log("EVENT_REQUEST_RESULT_CONSULT_SINGLE_RECORD::tokens[" + tokens.Length + "]=" + lines[k]); } if (tokens.Length == 31) { singleRecord = new RequestModel(long.Parse(tokens[0]), int.Parse(tokens[1]), int.Parse(tokens[2]), tokens[3], tokens[4], int.Parse(tokens[5]), long.Parse(tokens[6]), tokens[7], tokens[8], float.Parse(tokens[9]), float.Parse(tokens[10]), int.Parse(tokens[11]), tokens[12], int.Parse(tokens[13]), tokens[14], int.Parse(tokens[15]), long.Parse(tokens[16]), long.Parse(tokens[17]), int.Parse(tokens[18]), long.Parse(tokens[19]), int.Parse(tokens[20]), false, true, null, long.Parse(tokens[21]), tokens[22], int.Parse(tokens[23]), tokens[24], int.Parse(tokens[25]), tokens[26], int.Parse(tokens[27]), tokens[28], tokens[29], tokens[30]); } } else { if (MenusScreenController.Instance.DebugMode) { Debug.Log("EVENT_REQUEST_RESULT_CONSULT_SINGLE_RECORD::((IMAGE)) tokens[" + tokens.Length + "]=" + lines[k]); } if (tokens.Length == 6) { ImageModel img = new ImageModel(); img.Id = long.Parse(tokens[0]); img.Table = tokens[1]; img.IdOrigin = long.Parse(tokens[2]); img.Size = int.Parse(tokens[3]); img.Type = int.Parse(tokens[4]); img.Url = tokens[5]; singleRecord.TemporalImageReferences.Add(img); } } } if (singleRecord != null) { m_lastRequestConsulted = singleRecord.CloneNoImages(); UpdateLocalRequest(singleRecord); UIEventController.Instance.DispatchUIEvent(EVENT_REQUEST_RESULT_FORMATTED_SINGLE_RECORD, singleRecord); } else { UIEventController.Instance.DispatchUIEvent(EVENT_REQUEST_RESULT_FORMATTED_SINGLE_RECORD); } } if (_nameEvent == EVENT_REQUEST_RESULT_CONSULT_RECORDS) { ParseRecordsData(TYPE_CONSULT_BY_USER, (string)_list[0]); } if (_nameEvent == EVENT_REQUEST_RESULT_CONSULT_DISTANCE_RECORDS) { ParseRecordsData(TYPE_CONSULT_BY_DISTANCE, (string)_list[0]); } if (_nameEvent == EVENT_REQUEST_RESULT_CONSULT_BY_PROVIDER_RECORDS) { ParseRecordsData(TYPE_CONSULT_BY_PROVIDER, (string)_list[0]); } if (_nameEvent == EVENT_REQUEST_CALL_DELETE_RECORDS) { long idRequest = (long)_list[0]; RemoveLocalRequests(idRequest); CommsHTTPConstants.DeleteRequest(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, idRequest); } if (_nameEvent == EVENT_REQUEST_CALL_UPDATE_IMG_REF) { long idRequest = (long)_list[0]; long idImageReference = (long)_list[1]; RequestModel request = GetLocalRequest(idRequest); if (request != null) { request.Referenceimg = idImageReference; } CommsHTTPConstants.UpdateImageReferenceRequest(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, idRequest, idImageReference); } if (_nameEvent == EVENT_REQUEST_CALL_CONSULT_IMAGES_REQUEST) { CommsHTTPConstants.ConsultImagesRequest(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, (long)_list[0], MenusScreenController.TABLE_REQUESTS); } if (_nameEvent == EVENT_REQUEST_RESULT_CONSULT_IMAGES_REQUEST) { if (_list == null) { return; } if (_list.Length == 0) { return; } string buf = (string)_list[0]; string[] lines = buf.Split(new string[] { CommController.TOKEN_SEPARATOR_LINES }, StringSplitOptions.None); List <ImageModel> imagesForRequest = new List <ImageModel>(); for (int k = 0; k < lines.Length; k++) { string[] tokens = lines[k].Split(new string[] { CommController.TOKEN_SEPARATOR_EVENTS }, StringSplitOptions.None); if (tokens.Length == 6) { ImageModel img = new ImageModel(); img.Id = long.Parse(tokens[0]); img.Table = tokens[1]; img.IdOrigin = long.Parse(tokens[2]); img.Size = int.Parse(tokens[3]); img.Type = int.Parse(tokens[4]); img.Url = tokens[5]; imagesForRequest.Add(img); } } UIEventController.Instance.DispatchUIEvent(EVENT_REQUEST_RESULT_FORMATTED_IMAGES_REQUEST, imagesForRequest); } if (_nameEvent == ProposalsController.EVENT_PROPOSAL_CALL_UPDATE_PROPOSAL) { ProposalModel proposalData = (ProposalModel)_list[0]; RequestModel request = GetLocalRequest(proposalData.Request); if (request != null) { request.Price = proposalData.Price; request.Deadline = proposalData.Deadline; if (proposalData.Accepted == ProposalModel.STATE_PROPOSAL_ACCEPTED_AND_FIXED) { request.Provider = (int)proposalData.User; MustReloadRequests = true; } } } if (_nameEvent == EVENT_REQUEST_CALL_SET_JOB_AS_FINISHED) { long idRequest = (long)_list[0]; bool broken = (bool)_list[1]; RequestModel localRequest = GetLocalRequest(idRequest); if (localRequest != null) { localRequest.IsDataFull = false; localRequest.Deliverydate = 0; } CommsHTTPConstants.SetRequestAsFinished(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, idRequest, broken); } if (_nameEvent == EVENT_REQUEST_CALL_SCORE_AND_FEEDBACK_UPDATE) { long idRequest = (long)_list[0]; RequestModel localRequest = GetLocalRequest(idRequest); int scoreConsumer = (int)_list[1]; string feedbackConsumer = (string)_list[2]; int scoreProvider = (int)_list[3]; string feedbackProvider = (string)_list[4]; string signatureCustomer = (string)_list[5]; string signatureProvider = (string)_list[6]; if (localRequest != null) { localRequest.IsDataFull = false; localRequest.ScoreCustomerGivesToTheProvider = scoreConsumer; localRequest.ScoreProviderGivesToTheCustomer = scoreProvider; localRequest.FeedbackCustomerGivesToTheProvider = feedbackConsumer; localRequest.FeedbackProviderGivesToTheCustomer = feedbackProvider; } CommsHTTPConstants.UpdateRequestScoreAndFeedback(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, idRequest, scoreConsumer, feedbackConsumer, scoreProvider, feedbackProvider, signatureCustomer, signatureProvider); } if (_nameEvent == ProposalsController.EVENT_PROPOSAL_RESULT_INSERTED_PROPOSAL) { if ((bool)_list[0]) { long proposalType = (int)_list[2]; long requestID = (long)_list[3]; string reportedByUsersID = (string)_list[4]; if (proposalType == ProposalModel.TYPE_REPORT) { RequestModel localRequest = GetLocalRequest(requestID); if (localRequest != null) { localRequest.Reported = reportedByUsersID; } } } } }