Beispiel #1
0
        /// <summary>
        /// Creates contract from DTO contract.
        /// Saves remote community.
        /// Creates unique id for community.
        /// Replies with UID.
        /// </summary>
        /// <param name="ao_comdata"></param>
        /// <returns></returns>
        public static CommunityData RecieveContract(CommunityData ao_comdata)
        {
            string ls_authtoken = Guid.NewGuid().ToString();
            Community ao_com = new Community();
            ao_com.name = ao_comdata.name;
            ao_com.home = false;
            ao_com.domain = ao_comdata.domain;
            ao_com.challengesEndpoint = ao_comdata.challengesEndpoint;
            ao_com.authtoken = ls_authtoken;

            db.Communities.Add(ao_com);
            db.SaveChanges();

            //Find home community to send back information.
            IQueryable<Community> lo_homecomquery = from coms in db.Communities
                                                    where coms.home == true
                                                    select coms;

            Community lo_homecom = lo_homecomquery.First();

            CommunityData ao_responsedata = new CommunityData();
            ao_responsedata.authtoken = ls_authtoken;
            ao_responsedata.domain = lo_homecom.domain;
            ao_responsedata.challengesEndpoint = lo_homecom.challengesEndpoint;
            ao_responsedata.name = lo_homecom.name;

            return ao_responsedata;
        }
Beispiel #2
0
        /// <summary>
        /// Sends contract to remote community.
        /// </summary>
        /// <param name="ao_community"></param>
        /// <returns></returns>
        public Community RequestContract(Community ao_community)
        {
            try {
                if (ao_community.home) return ao_community;

                GoAberChallengeWSConsumer lo_challengeconsumer = GoAberChallengeWSConsumer.GetInstance();
                return lo_challengeconsumer.RequestContract(ao_community);
            } catch (Exception e)
            {
                return null;
            }
        }
Beispiel #3
0
 public IEnumerable<Team> GetTeamsByCommunity(Community currentCommunity)
 {
     return db.Teams.Where(t => t.communityId == currentCommunity.Id)
                    .Include(t => t.community)
                    .OrderBy(t => t.name);
 }
        public Community RequestContract(Community ao_community)
        {
            //Find home community, we need to send this informatiopn for foreign community.
            IQueryable<Community> lo_homecomquery = from coms in db.Communities
                                                    where coms.home == true
                                                    select coms;

            Community lo_homecom = lo_homecomquery.First();

            RemoteChallengeWS.CommunityData ao_comdata = new RemoteChallengeWS.CommunityData();
            ao_comdata.name = lo_homecom.name;
            ao_comdata.domain = lo_homecom.domain;
            ao_comdata.challengesEndpoint = lo_homecom.challengesEndpoint;
            RemoteChallengeWS.CommunityData lo_responsedata = GetSOAPClient(ao_community).RecieveCommunityContract(ao_comdata);

            ao_community.authtoken = lo_responsedata.authtoken;
            return ao_community;
        }
 public GoAberChallengesWSSoapClient GetSOAPClient(Community ao_com)
 {
     Uri lo_host = new Uri(ao_com.domain);
     Uri lo_endpoint = new Uri(lo_host, ao_com.challengesEndpoint);
     GoAberChallengesWSSoapClient lo_service = new GoAberChallengesWSSoapClient("GoAberChallengesWSSoap", lo_endpoint.AbsoluteUri);
     return lo_service;
 }
        public Result SendResult(Result ao_res, Community ao_sendto)
        {
            try {
                RemoteChallengeWS.ResultData lo_resdata = new RemoteChallengeWS.ResultData();
                lo_resdata.categoryUnitId = ao_res.categoryUnitId;
                lo_resdata.authtoken = ao_sendto.authtoken;
                lo_resdata.value = ao_res.value.Value;
                lo_resdata.challengeId = ao_res.challengeId;

                GoAberChallengesWSSoapClient lo_service = GetSOAPClient(ao_sendto);

                RemoteChallengeWS.ResultData lo_responsedata = lo_service.RecieveResult(lo_resdata);

                Result lo_response = new Result();
                lo_response.categoryUnitId = lo_responsedata.categoryUnitId;
                lo_response.challengeId = lo_responsedata.challengeId;

                string ls_authtoken = lo_responsedata.authtoken;
                IQueryable<Community> lo_comquery = from c in db.Communities
                                                    where c.authtoken == ls_authtoken
                                                    select c;
                Community lo_community = lo_comquery.First();

                lo_response.communityId = lo_community.Id;
                lo_response.value = lo_responsedata.value;

                return lo_response;
            } catch (Exception e)
            {
                Debug.Write(e.StackTrace);
                return null;
            }
        }