// ------------------------------------------- /* * 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; } } } } }
// ------------------------------------------- /* * OnBasicEvent */ private void OnBasicEvent(string _nameEvent, params object[] _list) { if (_nameEvent == EVENT_IMAGES_LOAD_FROM_SYSTEM_IMAGE) { UIEventController.Instance.DispatchUIEvent(EVENT_IMAGES_CLEAR_THUMBNAIL_CACHE); string fullPath = (string)_list[0]; m_lastScrollPosition = (float)_list[1]; if (fullPath.LastIndexOf('/') != -1) { m_pathLastFileBrowsed = fullPath.Substring(0, fullPath.LastIndexOf('/')); } if (fullPath.LastIndexOf('\\') != -1) { m_pathLastFileBrowsed = fullPath.Substring(0, fullPath.LastIndexOf('\\')); } Image imageContainer = (Image)_list[2]; int heightTarget = (int)_list[3]; int typeTarget = (int)_list[4]; ImageUtils.LoadImage(fullPath, imageContainer, heightTarget, MenusScreenController.Instance.SizeHeightAllowedImages); if (typeTarget != RequestModel.IMAGE_TYPE_FINISHED) { UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP); } } if (_nameEvent == EVENT_IMAGES_LOAD_REFERENCE_IMG_WITH_URL) { string pathFileURL = (string)_list[0]; Image imgContainer = (Image)_list[1]; int heightImage = (int)_list[2]; byte[] dataImage = (byte[])_list[3]; ImageUtils.LoadBytesImage(imgContainer, dataImage, heightImage, MenusScreenController.Instance.SizeHeightAllowedImages); BasicSystemEventController.Instance.DispatchBasicSystemEvent(ImageUtils.EVENT_IMAGES_LOAD_CONFIRMATION_FROM_SYSTEM, pathFileURL); } if (_nameEvent == EVENT_IMAGES_LOAD_REFERENCE_IMG_WITH_IMAGE_URL) { string pathFileURL = (string)_list[0]; Image imgContainer = (Image)_list[1]; int heightImage = (int)_list[2]; ImageURLLoader.Instance.LoadURLImage(pathFileURL, imgContainer, heightImage, MenusScreenController.Instance.SizeHeightAllowedImages); } if (_nameEvent == EVENT_IMAGES_LOAD_FROM_ID) { m_timeAcumImages = ((GetImageByID((long)_list[1]) != null) ? 1 : 0); m_queuedRequests.Add(new ImageRequestedInfo((GameObject)_list[0], (long)_list[1], (Image)_list[2], (int)_list[3], (bool)_list[4])); } if (_nameEvent == EVENT_IMAGES_LOAD_TOXIC_IMAGE) { Image imgContainer = (Image)_list[0]; int heightImage = (int)_list[1]; byte[] dataImage = (byte[])_list[2]; ImageUtils.LoadBytesImage(imgContainer, dataImage, heightImage, MenusScreenController.Instance.SizeHeightAllowedImages); } if (_nameEvent == EVENT_IMAGES_LOAD_PRIORITY_FROM_ID) { m_timeAcumImages = ((GetImageByID((long)_list[1]) != null) ? 1 : 0); m_queuedRequests.Insert(0, new ImageRequestedInfo((GameObject)_list[0], (long)_list[1], (Image)_list[2], (int)_list[3], (bool)_list[4])); } if (_nameEvent == EVENT_IMAGES_LOAD_FROM_BYTE_ARRAY) { ImageUtils.LoadBytesImage((Image)_list[1], (byte[])_list[0], (int)_list[2], MenusScreenController.Instance.SizeHeightAllowedImages); } if (_nameEvent == EVENT_IMAGES_UPLOAD_TO_SERVER_NEW_IMAGE) { byte[] dataImg = (byte[])_list[4]; m_imageTemp = new ImageModel(); m_imageTemp.Table = (string)_list[1]; m_imageTemp.IdOrigin = (long)_list[2]; m_imageTemp.Type = (int)_list[3]; m_imageTemp.Size = dataImg.Length; m_imageTemp.CopyData(dataImg); m_imageTemp.Url = (string)_list[5]; CommsHTTPConstants.UploadImage((long)_list[0], m_imageTemp.Table, m_imageTemp.IdOrigin, m_imageTemp.Type, dataImg, m_imageTemp.Url); } if (_nameEvent == EVENT_IMAGES_UPLOAD_TO_SERVER_CONFIRMATION) { if (_list.Length > 0) { if ((bool)_list[0]) { if (m_imageTemp != null) { m_imageTemp.Id = (long)_list[1]; m_imageTemp.Table = (string)_list[2]; m_imageTemp.IdOrigin = (long)_list[3]; m_images.Add(m_imageTemp.Clone()); m_imageTemp = null; } } } } if (_nameEvent == EVENT_IMAGES_LOAD_SERVER_DATA_RECEIVED) { if (m_imageReferenceTmp != null) { if ((bool)_list[0]) { ImageModel imageNew = new ImageModel(); imageNew.Id = (long)_list[1]; imageNew.Table = (string)_list[2]; imageNew.IdOrigin = (long)_list[3]; imageNew.Type = (int)_list[4]; imageNew.Url = (string)_list[5]; imageNew.Size = (int)_list[6]; imageNew.CopyData((byte[])_list[7]); m_images.Add(imageNew); ImageModel imageModel = GetImageByID(imageNew.Id); if (imageModel != null) { if (m_imageReferenceTmp != null) { if (m_imageReferenceTmp.Image != null) { ImageUtils.LoadBytesImage(m_imageReferenceTmp.Image, imageModel.Data, m_imageReferenceTmp.Height, MenusScreenController.Instance.SizeHeightAllowedImages); UIEventController.Instance.DispatchUIEvent(EVENT_IMAGE_LOADED_REPORT_SYSTEM, m_imageReferenceTmp.Image, imageNew.Url); } } } } } m_imageReferenceTmp = null; } if (_nameEvent == EVENT_IMAGES_LOAD_SERVER_LOCAL_DATA_LOADED) { m_imageReferenceTmp = null; } if (_nameEvent == EVENT_IMAGES_CALL_DELETE_IMAGE) { long idImage = (long)_list[1]; if (idImage != -1) { RemoveImageByID(idImage); CommsHTTPConstants.RemoveImage(idImage); } } if (_nameEvent == EVENT_IMAGES_CANCEL_LOADING_IMAGES) { m_queuedRequests.Clear(); // m_imageReferenceTmp = null; } if (_nameEvent == RequestsController.EVENT_REQUEST_CALL_DELETE_RECORDS) { m_images.Clear(); m_queuedRequests.Clear(); m_imageReferenceTmp = null; } if (_nameEvent == EVENT_IMAGES_LOAD_THUMBNAIL_FILE_BROWSER) { if (m_thumbnailRequests.Count < 50) { m_thumbnailRequests.Add(new ThumbnailRequestedInfo((GUIContent)_list[0], (string)_list[1], m_heightThumbnail)); } } if (_nameEvent == EVENT_IMAGES_CLEAR_THUMBNAIL_CACHE) { for (int i = 0; i < m_thumbnailRequests.Count; i++) { m_thumbnailRequests[i].Destroy(); } m_thumbnailRequests.Clear(); m_counterThumnail = 0; m_timeAcumImages = 0; } }