Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            string      uuid         = context.Request["uuid"];
            string      clientid     = context.Request["clientid"];
            string      appid        = context.Request["appid"];
            string      websiteOwner = bllApp.WebsiteOwner;
            UserInfo    user         = bllApp.GetCurrentUserInfo();
            WebsiteInfo website      = bllApp.GetWebsiteInfoModelFromDataBase();

            AppPushClient uClient = bllApp.GetAppPushClient(websiteOwner, clientid, appid, uuid, "");

            if (uClient != null)
            {
                if (user != null)
                {
                    uClient.UserID = user.UserID;
                    apiResp.status = bllApp.Update(uClient);
                }
                else
                {
                    apiResp.status = true;
                }
                apiResp.code = apiResp.status ? (int)APIErrCode.IsSuccess : (int)APIErrCode.OperateFail;
                bllApp.ContextResponse(context, apiResp);
                return;
            }
            if (!string.IsNullOrWhiteSpace(clientid))
            {
                uClient = bllApp.GetAppPushClient(websiteOwner, "", "", uuid, "");
            }
            if (uClient != null)
            {
                if (user != null)
                {
                    uClient.UserID = user.UserID;
                }
                uClient.PushClientId = clientid;
                uClient.PushAppId    = appid;
                if (!string.IsNullOrWhiteSpace(uClient.PushAppId) && uClient.PushAppId != website.AppPushAppId)
                {
                    apiResp.status = false;
                    apiResp.code   = (int)APIErrCode.OperateFail;
                    bllApp.ContextResponse(context, apiResp);
                    return;
                }
                apiResp.status = bllApp.Update(uClient);
                apiResp.code   = apiResp.status? (int)APIErrCode.IsSuccess:(int)APIErrCode.OperateFail;
                bllApp.ContextResponse(context, apiResp);
                return;
            }
            uClient = new AppPushClient();
            uClient.WebsiteOwner = websiteOwner;
            uClient.UUId         = uuid;
            uClient.PushClientId = clientid;
            uClient.PushAppId    = appid;
            if (user != null)
            {
                uClient.UserID = user.UserID;
            }
            uClient.InsertDate = DateTime.Now;

            if (!string.IsNullOrWhiteSpace(uClient.PushAppId) && uClient.PushAppId != website.AppPushAppId)
            {
                apiResp.status = false;
                apiResp.code   = (int)APIErrCode.OperateFail;
                bllApp.ContextResponse(context, apiResp);
                return;
            }
            apiResp.status = bllApp.Add(uClient);
            apiResp.code   = apiResp.status ? (int)APIErrCode.IsSuccess : (int)APIErrCode.OperateFail;
            bllApp.ContextResponse(context, apiResp);
        }
Ejemplo n.º 2
0
        public bool ExistsAppPushClient(string websiteOwner, string clientId, string appId, string uuId, string userId)
        {
            AppPushClient uClient = GetAppPushClient(websiteOwner, clientId, appId, uuId, userId);

            return(uClient != null);
        }