Exemplo n.º 1
0
        public RESTRequestStatus Post(string appkey,
                                      string sessionid,
                                      string deviceToken,
                                      string platform,
                                      Int64 accountno
                                      )
        {
            RESTRequestStatus response = new RESTRequestStatus(RESTRequestStatusCode.unknown);

            if (AppController.ProceedWithRequest(response, appkey, sessionid, Request) == false)
            {
                return(response);
            }

            string fullpath = Request.Path;
            string op       = fullpath.Substring("/fluid/account/".Length, fullpath.Length - "/fluid/account/".Length);

            switch (op)
            {
            case Constants.device:
                if (DataLayer.AddDeviceToAccount(response, accountno, deviceToken, platform))
                {
                    response.statuscode = RESTRequestStatusCode.success;
                    response.status     = RESTRequestStatusCode.success.ToString( );
                }
                break;
            }

            return(response);
        }
Exemplo n.º 2
0
        public RESTRequestStatus Put(string appkey,
                                     string sessionid,
                                     Int64 cloudid,
                                     string syncitems,
                                     string devicetoken

                                     )
        {
            RESTRequestStatus response = new RESTRequestStatus(RESTRequestStatusCode.unknown);

            Account account   = null;
            Int64   accountNo = 0;

            if (AppController.ProceedWithRequest(response, appkey, sessionid, Request) == false)
            {
                return(response);
            }

            string fullpath = Request.Path;
            string op       = fullpath.Substring("/fluid/sync/".Length, fullpath.Length - "/fluid/sync/".Length);

            switch (op)
            {
            case Constants.basestation:


                //IDictionary<string , string> baseStationSyncItemsDic = JsonConvert.DeserializeObject<Dictionary<string , string>>( syncitems );


                accountNo = DataLayer.GetAccountNoUsingSessionId(sessionid);

                account = DataLayer.GetAccount(accountNo);

                BaseStation baseStation = DataLayer.GetBaseStation(response, cloudid, account);

                if (baseStation.CloudId == cloudid)
                {
                    SyncBaseStation(response, baseStation, syncitems, devicetoken);
                }

                break;

            case Constants.sensor:

                Sensor sensor = DataLayer.GetSensor(response, cloudid);


                if (sensor.CloudId.Equals(cloudid))
                {
                    SyncSensor(response, sensor, syncitems, devicetoken);
                }

                break;
            }

            return(response);
        }
Exemplo n.º 3
0
        public RESTRequestStatus Post(string appkey,
                                      string sessionid,
                                      Int64 cloudId,
                                      Int64 totalTimeStampSync
                                      )
        {
            RESTRequestStatus response = new RESTRequestStatus(RESTRequestStatusCode.unknown);

            Account account   = null;
            Int64   accountNo = 0;


            if (AppController.ProceedWithRequest(response, appkey, sessionid, Request) == false)
            {
                return(response);
            }

            string fullpath = Request.Path;
            string op       = fullpath.Substring("/fluid/sync/".Length, fullpath.Length - "/fluid/sync/".Length);

            switch (op)
            {
            case Constants.basestation:

                accountNo = DataLayer.GetAccountNoUsingSessionId(sessionid);

                account = DataLayer.GetAccount(accountNo);

                BaseStation baseStation = DataLayer.GetBaseStation(response, cloudId, account);

                if (baseStation.CloudId == cloudId)
                {
                    Int64 totalTimeStamps;

                    response.statuscode = RESTRequestStatusCode.success;
                    response.status     = RESTRequestStatusCode.success.ToString( );

                    totalTimeStamps = baseStation.NameTimeStamp +
                                      baseStation.TempUnitTimeStamp +
                                      baseStation.UserDescriptionTimeStamp;

                    if (totalTimeStampSync != totalTimeStamps)
                    {
                        response.response = Constants.needsSyncing;
                    }
                    else
                    {
                        response.response = Constants.synced;
                    }
                }

                break;
            }

            return(response);
        }
Exemplo n.º 4
0
        public RESTRequestStatus Put(string appkey,
                                     string sessionid,
                                     Int64 cloudId,
                                     Int64 totalTimeStampSync,
                                     string baseStationSyncItems

                                     )
        {
            RESTRequestStatus response = new RESTRequestStatus(RESTRequestStatusCode.unknown);

            if (AppController.ProceedWithRequest(response, appkey, sessionid, Request) == false)
            {
                return(response);
            }

            return(response);
        }
Exemplo n.º 5
0
        public RESTRequestStatus Put(string op,
                                     string appkey,
                                     string sessionid,
                                     string macaddress,
                                     string hwtype,
                                     string hwversion,
                                     string fwversion)
        {
            RESTRequestStatus response = new RESTRequestStatus(RESTRequestStatusCode.unknown);

            if (AppController.ProceedWithRequest(response, appkey, sessionid, Request) == false)
            {
                return(response);
            }
            switch (op)
            {
            case Constants.notify:

                Int64 cloudId = DataLayer.GetBaseStationId(response, sessionid, macaddress);

                if (cloudId != 0)
                {
                    response.info.Add(Constants.keyCloudId, cloudId);
                    response.statuscode = RESTRequestStatusCode.ok;
                    response.status     = RESTRequestStatusCode.ok.ToString( );
                }
                else
                {
                    response.statuscode = RESTRequestStatusCode.notfound;
                    response.status     = RESTRequestStatusCode.notfound.ToString( );
                }
                break;
            }

            return(response);
        }
Exemplo n.º 6
0
        public RESTRequestStatus Post(
            string sessionid,
            string appkey,
            string macaddress,
            string status,
            string hwversion,
            string fwversion,
            string name,
            string description,
            string tempunit,
            string devicetoken,

            Int64 cloudId,
            Int64 descriptiontimestamp,
            Int64 nametimestamp,
            Int64 tempunittimestamp

            )

        {
            RESTRequestStatus response = new RESTRequestStatus(RESTRequestStatusCode.unknown);

            BaseStation baseStation = null;
            Account     account     = null;
            Int64       accountNo;

            if (AppController.ProceedWithRequest(response, appkey, sessionid, Request) == false)
            {
                return(response);
            }

            string fullpath = Request.Path;

            string op = fullpath.Substring("/fluid/basestation/".Length, fullpath.Length - "/fluid/basestation/".Length);

            switch (op)
            {
            case Constants.basestations:

                GetBaseStationsForAccount(response, sessionid);

                break;


            case Constants.associateBasestation:


                baseStation = new BaseStation(macaddress,
                                              hwversion,
                                              fwversion,
                                              name,
                                              status,
                                              nametimestamp,
                                              description,
                                              descriptiontimestamp,
                                              tempunit,
                                              tempunittimestamp);

                AssociateBaseStationWithAccount(response, sessionid, baseStation, devicetoken);

                break;

            case Constants.delete:

                accountNo = DataLayer.GetAccountNoUsingSessionId(sessionid);

                account = DataLayer.GetAccount(accountNo);

                baseStation = DataLayer.GetBaseStation(response, cloudId, account);

                baseStation.Status = status;

                DeleteBaseStationFromAccount(response, sessionid, baseStation, devicetoken);

                break;
            }

            DataLayer.CloseConnection( );

            return(response);
        }