예제 #1
0
        // -------------------------------------------

        /*
         * 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();
                    }
                }
            }
        }