// ------------------------------------------- /* * Constructor */ public void Initialize(ProposalModel _item) { m_container = this.gameObject.transform; m_proposal = _item.Clone(); m_iconInfo = m_container.Find("IconStates/Info").gameObject; m_iconProposed = m_container.Find("IconStates/Proposed").gameObject; m_iconAccepted = m_container.Find("IconStates/Accepted").gameObject; m_iconInfo.SetActive(false); m_iconProposed.SetActive(false); m_iconAccepted.SetActive(false); m_iconCalendar = m_container.Find("Calendar").gameObject; m_iconCalendar.SetActive(false); m_container.Find("bgReported").gameObject.SetActive(false); m_container.Find("bgUnselected").gameObject.SetActive(false); m_container.Find("bgSelected").gameObject.SetActive(false); if (m_proposal.Reported.Length > 0) { m_container.Find("bgReported").gameObject.SetActive(true); } else { m_container.Find("bgUnselected").gameObject.SetActive(!m_proposal.IsSelected()); m_container.Find("bgSelected").gameObject.SetActive(m_proposal.IsSelected()); } LoadData(false); }
// ------------------------------------------- /* * AddConsultDistanceRequests */ private void AddConsultProposal(long _id, long _user, long _request, int _type, string _title, string _description, int _price, long _deadline, int _accepted, int _active, long _created, string _reported, int _confirmedReported) { ProposalModel proposal = new ProposalModel(_id, _user, _request, _type, _title, _description, _price, _deadline, _accepted, _active, _created, _reported, _confirmedReported); m_proposals.Add(proposal); }
// ------------------------------------------- /* * UpdateProposal */ public static void UpdateProposal(string _idUser, string _password, ProposalModel _proposal) { CommController.Instance.Request(EVENT_COMM_UPDATE_PROPOSAL, true, _idUser, _password, _proposal.Id.ToString(), _proposal.Request.ToString(), _proposal.Price.ToString(), _proposal.Deadline.ToString(), _proposal.User.ToString(), _proposal.Accepted.ToString()); }
// ------------------------------------------- /* * Destroy */ public override bool Destroy() { if (base.Destroy()) { return(true); } m_proposalData = null; UIEventController.Instance.UIEvent -= OnBasicEvent; UIEventController.Instance.DispatchUIEvent(UIEventController.EVENT_SCREENMANAGER_DESTROY_SCREEN, this.gameObject); return(false); }
// ------------------------------------------- /* * CreateNewProposal */ public static void CreateNewProposal(string _idUser, string _password, ProposalModel _proposal) { CommController.Instance.Request(EVENT_COMM_CREATE_NEW_PROPOSAL, true, _idUser, _password, _proposal.Id.ToString(), _proposal.User.ToString(), _proposal.Request.ToString(), _proposal.Type.ToString(), _proposal.Title, _proposal.Description, _proposal.Price.ToString(), _proposal.Deadline.ToString(), _proposal.Accepted.ToString()); }
// ------------------------------------------- /* * Copy */ public void Copy(ProposalModel _proposal) { m_id = _proposal.Id; m_user = _proposal.User; m_request = _proposal.Request; m_type = _proposal.Type; m_title = _proposal.Title; m_description = _proposal.Description; m_price = _proposal.Price; m_deadline = _proposal.Deadline; m_accepted = _proposal.Accepted; m_active = _proposal.Active; m_created = _proposal.Created; m_reported = _proposal.Reported; m_confirmedReported = _proposal.ConfirmedReported; }
// ------------------------------------------- /* * OnBasicEvent */ private void OnBasicEvent(string _nameEvent, params object[] _list) { if (_nameEvent == EVENT_PROPOSAL_CALL_INSERT_NEW_PROPOSAL) { ProposalModel proposal = (ProposalModel)_list[0]; RequestsController.Instance.MustReloadRequests = true; CommsHTTPConstants.CreateNewProposal(UsersController.Instance.CurrentUser.Id.ToString(), UsersController.Instance.CurrentUser.Password, proposal); } if (_nameEvent == EVENT_PROPOSAL_CALL_CONSULT_PROPOSALS) { CommsHTTPConstants.ConsultAllProposalsByRequest(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, (long)_list[0]); } if (_nameEvent == EVENT_PROPOSAL_RESULT_CONSULTED_PROPOSALS) { if (_list == null) { return; } if (_list.Length == 0) { return; } ParseRecordsData((string)_list[0]); } if (_nameEvent == EVENT_PROPOSAL_CALL_DELETE_PROPOSAL) { long idProposal = (long)_list[0]; RequestsController.Instance.MustReloadRequests = true; CommsHTTPConstants.RemoveProposal(UsersController.Instance.CurrentUser.Id.ToString(), UsersController.Instance.CurrentUser.Password, idProposal); } if (_nameEvent == EVENT_PROPOSAL_CALL_UPDATE_PROPOSAL) { ProposalModel proposal = (ProposalModel)_list[0]; CommsHTTPConstants.UpdateProposal(UsersController.Instance.CurrentUser.Id.ToString(), UsersController.Instance.CurrentUser.Password, proposal); } if (_nameEvent == EVENT_PROPOSAL_CALL_RESET_ALL_PROPOSALS) { long requestID = (long)_list[0]; CommsHTTPConstants.ResetProposalsForRequest(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, requestID); } if (_nameEvent == EVENT_PROPOSAL_CALL_REACTIVATE_PROPOSAL) { long proposalID = (long)_list[0]; CommsHTTPConstants.ReactivateProposal(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, proposalID); } if (_nameEvent == ProposalsController.EVENT_PROPOSAL_RESULT_REACTIVATE_PROPOSAL) { bool reactivated = (bool)_list[0]; if (reactivated) { long proposalID = (long)_list[1]; ProposalModel proposal = GetLocalProposal(proposalID); if (proposal != null) { proposal.Active = 1; } } } if (_nameEvent == EVENT_PROPOSAL_CALL_REPORT_PROPOSAL) { long proposalID = (long)_list[0]; int reporterID = (int)_list[1]; long requestID = (long)_list[2]; CommsHTTPConstants.ReportProposal(UsersController.Instance.CurrentUser.Id, UsersController.Instance.CurrentUser.Password, proposalID, reporterID, requestID); } if (_nameEvent == EVENT_PROPOSAL_RESULT_REPORT_PROPOSAL) { bool success = (bool)_list[0]; if (success) { long proposalID = (long)_list[1]; int reporterID = (int)_list[2]; ProposalModel proposal = GetLocalProposal(proposalID); if (proposal != null) { proposal.Reported = reporterID.ToString(); } } } }
// ------------------------------------------- /* * Constructor */ public override void Initialize(params object[] _list) { m_root = this.gameObject; m_container = m_root.transform.Find("Content"); m_proposalData = new ProposalModel(); bool isOnlyQuestion = false; if (_list.Length > 0) { if (_list[0] != null) { // DISPLAY EXISTING PROPOSAL if (_list[0] is ProposalModel) { m_proposalData = ((ProposalModel)_list[0]).Clone(); m_requestData = ((RequestModel)_list[1]).Clone(); } // NEW PROPOSAL FOR THE REQUEST ID if (_list[0] is RequestModel) { m_proposalData.User = UsersController.Instance.CurrentUser.Id; m_requestData = ((RequestModel)_list[0]); m_proposalData.Request = m_requestData.Id; m_proposalData.Deadline = m_requestData.Deadline; if (_list.Length > 1) { isOnlyQuestion = true; } } } } if (m_container.Find("Button_Back/Icon") != null) { m_isDisplayInfo = true; } else { m_isDisplayInfo = false; } m_container.Find("Button_Back").GetComponent <Button>().onClick.AddListener(BackPressed); if (!m_isDisplayInfo) { m_buttonSave = m_container.Find("Button_Save").gameObject; m_buttonSave.GetComponent <Button>().onClick.AddListener(SavePressed); } IsReadyToPublish = false; if (m_container.Find("TypeDropdown") != null) { m_container.Find("TypeDropdown").GetComponent <Dropdown>().onValueChanged.AddListener(OnTypeMessage); m_container.Find("TypeDropdown").GetComponent <Dropdown>().itemText.text = LanguageController.Instance.GetText("screen.proposal.type.option.proposal"); m_container.Find("TypeDropdown").GetComponent <Dropdown>().options[0].text = LanguageController.Instance.GetText("screen.proposal.type.option.proposal"); m_container.Find("TypeDropdown").GetComponent <Dropdown>().options[1].text = LanguageController.Instance.GetText("screen.proposal.type.option.information"); m_container.Find("TypeDropdown").GetComponent <Dropdown>().options[2].text = LanguageController.Instance.GetText("screen.proposal.type.option.report"); m_container.Find("TypeDropdown").GetComponent <Dropdown>().value = 2; if (m_container.Find("TypeLabel") != null) { m_container.Find("TypeLabel").GetComponent <Text>().text = LanguageController.Instance.GetText("screen.proposal.type.label"); } if (isOnlyQuestion) { m_proposalData.Type = ProposalModel.TYPE_INFO; m_container.Find("TypeDropdown").GetComponent <Dropdown>().interactable = false; } } if (m_isDisplayInfo) { Transform buttonRemove = m_root.transform.Find("Content/Button_Remove"); if (buttonRemove != null) { buttonRemove.gameObject.SetActive(false); if ((m_proposalData.User == UsersController.Instance.CurrentUser.Id) && m_proposalData.CanBeRemoved()) { buttonRemove.gameObject.SetActive(true); buttonRemove.GetComponent <Button>().onClick.AddListener(RemovePressed); } if (m_requestData.Provider != -1) { buttonRemove.gameObject.SetActive(false); } } // BUTTON REACTIVATE OFFER Transform buttonReactivateOffer = m_root.transform.Find("Content/Button_Reactivate"); if (buttonReactivateOffer != null) { buttonReactivateOffer.gameObject.SetActive(false); if (!m_proposalData.IsActiveOffer() && (m_proposalData.User == UsersController.Instance.CurrentUser.Id)) { buttonReactivateOffer.gameObject.SetActive(true); buttonReactivateOffer.Find("Text").GetComponent <Text>().text = LanguageController.Instance.GetText("screen.proposal.offer.reactive.it"); buttonReactivateOffer.GetComponent <Button>().onClick.AddListener(OnClickReactivateOffer); } } m_buttonReport = m_root.transform.Find("Content/Button_Report"); if (m_buttonReport != null) { m_buttonReport.gameObject.SetActive(false); if ((m_requestData.Customer == UsersController.Instance.CurrentUser.Id) && m_proposalData.CanBeReported() && !m_proposalData.IsSelected()) { m_buttonReport.gameObject.SetActive(true); m_buttonReport.GetComponent <Button>().onClick.AddListener(ReportPressed); } if (m_requestData.Provider != -1) { m_buttonReport.gameObject.SetActive(false); } } } m_container.Find("Title").GetComponent <Text>().text = LanguageController.Instance.GetText("screen.proposal.title"); if (m_container.Find("TitleLabel") != null) { m_container.Find("TitleLabel").GetComponent <Text>().text = LanguageController.Instance.GetText("screen.proposal.label.title"); } if (!m_isDisplayInfo) { m_container.Find("TitleValue").GetComponent <InputField>().text = m_proposalData.Title; m_container.Find("TitleValue").GetComponent <InputField>().onEndEdit.AddListener(OnProposalTitle); } else { m_container.Find("TitleValue").GetComponent <Text>().text = m_proposalData.Title; } if (m_container.Find("DescriptionLabel") != null) { m_container.Find("DescriptionLabel").GetComponent <Text>().text = LanguageController.Instance.GetText("screen.proposal.label.description"); } if (!m_isDisplayInfo) { m_container.Find("DescriptionValue").GetComponent <InputField>().text = m_proposalData.Description; m_container.Find("DescriptionValue").GetComponent <InputField>().onEndEdit.AddListener(OnProposalDescription); } else { m_container.Find("ScrollDescriptionValue/DescriptionValue").GetComponent <Text>().text = m_proposalData.Description; } // BUTTON CHECK PROVIDER PROFILE GameObject buttonCheckProviderProfile = null; if (m_container.Find("Button_CheckProviderProfile") != null) { buttonCheckProviderProfile = m_container.Find("Button_CheckProviderProfile").gameObject; } if (buttonCheckProviderProfile != null) { buttonCheckProviderProfile.gameObject.SetActive(true); buttonCheckProviderProfile.transform.Find("Title").GetComponent <Text>().text = LanguageController.Instance.GetText("message.proposal.check.proovider.profile"); buttonCheckProviderProfile.GetComponent <Button>().onClick.AddListener(OnCheckProviderProfile); if ((GameObject.FindObjectOfType <ScreenProviderProfileView>() != null) || (m_proposalData.User == UsersController.Instance.CurrentUser.Id)) { buttonCheckProviderProfile.gameObject.SetActive(false); } } m_offerExclusiveContent = m_container.Find("OfferExclusive"); if (m_offerExclusiveContent != null) { // ACCEPTING BUTTONS m_offerExclusiveContent.Find("PriceLabel").GetComponent <Text>().text = LanguageController.Instance.GetText("screen.proposal.offer.price"); if (!m_isDisplayInfo) { m_offerExclusiveContent.Find("PriceValue").GetComponent <InputField>().text = m_proposalData.Price.ToString(); m_offerExclusiveContent.Find("PriceValue").GetComponent <InputField>().onEndEdit.AddListener(OnProposalPrice); } else { m_offerExclusiveContent.Find("PriceValue").GetComponent <Text>().text = m_proposalData.Price.ToString(); } m_offerExclusiveContent.Find("PriceCurrency").GetComponent <Text>().text = RequestsController.Instance.LastRequestConsulted.Currency.ToString(); m_offerExclusiveContent.Find("DeadlineLabel").GetComponent <Text>().text = LanguageController.Instance.GetText("screen.create.request.description.dress"); m_offerExclusiveContent.Find("Button_DeadlineCalendar/Title").GetComponent <Text>().text = DateConverter.TimeStampToDateTimeString(m_proposalData.Deadline); m_offerExclusiveContent.Find("Button_DeadlineCalendar").GetComponent <Button>().onClick.AddListener(OnCalendarClick); if (m_offerExclusiveContent.Find("Button_AcceptKeepLooking") != null) { m_buttonAcceptAndKeepLooking = m_offerExclusiveContent.Find("Button_AcceptKeepLooking").gameObject; } if (m_offerExclusiveContent.Find("Button_AcceptCloseDeal") != null) { m_buttonCloseDeal = m_offerExclusiveContent.Find("Button_AcceptCloseDeal").gameObject; } if (m_buttonAcceptAndKeepLooking != null) { m_buttonAcceptAndKeepLooking.SetActive(false); } if (m_buttonCloseDeal != null) { m_buttonCloseDeal.SetActive(false); } if (m_isDisplayInfo) { bool enableButtonsAccept = false; if (m_proposalData.User != UsersController.Instance.CurrentUser.Id) { if (m_requestData.Customer == UsersController.Instance.CurrentUser.Id) { enableButtonsAccept = true; } } if (m_requestData.Provider == -1) { if (enableButtonsAccept) { if (m_proposalData.Type == ProposalModel.TYPE_OFFER) { switch (m_proposalData.Accepted) { case ProposalModel.STATE_PROPOSAL_ACCEPTED_AND_KEEP_LOOKING: m_buttonCloseDeal.gameObject.SetActive(true); break; case ProposalModel.STATE_PROPOSAL_ACCEPTED_AND_FIXED: m_buttonAcceptAndKeepLooking.gameObject.SetActive(false); m_buttonCloseDeal.gameObject.SetActive(false); break; default: m_buttonAcceptAndKeepLooking.gameObject.SetActive(true); m_buttonCloseDeal.gameObject.SetActive(true); break; } m_buttonAcceptAndKeepLooking.transform.Find("Title").GetComponent <Text>().text = LanguageController.Instance.GetText("message.proposal.accept.and.look"); m_buttonCloseDeal.transform.Find("Title").GetComponent <Text>().text = LanguageController.Instance.GetText("message.proposal.close.deal"); m_buttonAcceptAndKeepLooking.GetComponent <Button>().onClick.AddListener(OnAcceptAndKeepLooking); m_buttonCloseDeal.GetComponent <Button>().onClick.AddListener(OnAcceptAndCloseDeal); if (m_proposalData.Reported.Length > 0) { m_buttonAcceptAndKeepLooking.gameObject.SetActive(false); m_buttonCloseDeal.gameObject.SetActive(false); } } } else { m_buttonAcceptAndKeepLooking.gameObject.SetActive(false); m_buttonCloseDeal.gameObject.SetActive(false); } } else { m_buttonAcceptAndKeepLooking.gameObject.SetActive(false); m_buttonCloseDeal.gameObject.SetActive(false); } } } // OUTDATED OFFER Transform labelOfferToRevalidate = m_container.Find("OfferToRevalidate"); if (labelOfferToRevalidate != null) { labelOfferToRevalidate.gameObject.SetActive(false); if (m_proposalData.Reported.Length > 0) { if (m_buttonAcceptAndKeepLooking != null) { m_buttonAcceptAndKeepLooking.SetActive(false); } if (m_buttonCloseDeal != null) { m_buttonCloseDeal.SetActive(false); } labelOfferToRevalidate.gameObject.SetActive(true); labelOfferToRevalidate.GetComponent <Text>().text = LanguageController.Instance.GetText("message.proposal.you.have.reported.this.offer"); } else { if (!m_proposalData.IsActiveOffer()) { if (m_buttonAcceptAndKeepLooking != null) { m_buttonAcceptAndKeepLooking.SetActive(false); } if (m_buttonCloseDeal != null) { m_buttonCloseDeal.SetActive(false); } if (m_proposalData.User != UsersController.Instance.CurrentUser.Id) { labelOfferToRevalidate.gameObject.SetActive(true); labelOfferToRevalidate.GetComponent <Text>().text = LanguageController.Instance.GetText("screen.proposal.offer.outdated.by.edit"); } } } } m_hasBeenInited = true; SelectTypeMessage(m_proposalData.Type); UIEventController.Instance.UIEvent += new UIEventHandler(OnBasicEvent); }
// ------------------------------------------- /* * 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; } } } } }
// ------------------------------------------- /* * Destroy */ public void Destroy() { m_proposal = null; GameObject.DestroyObject(this.gameObject); }