当前位置: 首页>>代码示例>>C#>>正文


C# BaseMessage.setData方法代码示例

本文整理汇总了C#中CmsWeb.MobileAPI.BaseMessage.setData方法的典型用法代码示例。如果您正苦于以下问题:C# BaseMessage.setData方法的具体用法?C# BaseMessage.setData怎么用?C# BaseMessage.setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CmsWeb.MobileAPI.BaseMessage的用法示例。


在下文中一共展示了BaseMessage.setData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FetchImage

        public ActionResult FetchImage(string data)
        {
            // Authenticate first
            var authError = Authenticate();
            if (authError != null) return authError;

            // Check to see if type matches
            BaseMessage dataIn = BaseMessage.createFromString(data);
            if (dataIn.type != BaseMessage.API_TYPE_PERSON_IMAGE_REFRESH)
                return BaseMessage.createTypeErrorReturn();

            // Everything is in order, start the return
            MobilePostFetchImage mpfi = JsonConvert.DeserializeObject<MobilePostFetchImage>(dataIn.data);

            BaseMessage br = new BaseMessage();
            if (mpfi.id == 0) return br.setData("The ID for the person cannot be set to zero");

            br.data = "The picture was not found.";
            br.type = BaseMessage.API_TYPE_PERSON_IMAGE_REFRESH;

            var person = DbUtil.Db.People.SingleOrDefault(pp => pp.PeopleId == mpfi.id);

            if (person.PictureId != null)
            {
                ImageData.Image image = null;

                switch (mpfi.size)
                {
                    case 0: // 50 x 50
                        image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.ThumbId);
                        break;

                    case 1: // 120 x 120
                        image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.SmallId);
                        break;

                    case 2: // 320 x 400
                        image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.MediumId);
                        break;

                    case 3: // 570 x 800
                        image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.LargeId);
                        break;

                }

                if (image != null)
                {
                    br.data = Convert.ToBase64String(image.Bits);
                    br.count = 1;
                    br.error = 0;
                }
            }

            return br;
        }
开发者ID:vs06,项目名称:bvcms,代码行数:56,代码来源:MobileAPIController.cs

示例2: FetchImage

        public ActionResult FetchImage(string data)
        {
            // Authenticate first
            var result = AuthenticateUser();
            if (!result.IsValid) return AuthorizationError(result);

            BaseMessage dataIn = BaseMessage.createFromString(data);
            MobilePostFetchImage mpfi = JsonConvert.DeserializeObject<MobilePostFetchImage>(dataIn.data);

            BaseMessage br = new BaseMessage();
            if (mpfi.id == 0) return br.setData("The ID for the person cannot be set to zero");

            br.data = "The picture was not found.";

            var person = DbUtil.Db.People.SingleOrDefault(pp => pp.PeopleId == mpfi.id);

            if (person.PictureId != null)
            {
                Image image = null;

                switch (mpfi.size)
                {
                    case 0: // 50 x 50
                        image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.ThumbId);
                        break;

                    case 1: // 120 x 120
                        image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.SmallId);
                        break;

                    case 2: // 320 x 400
                        image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.MediumId);
                        break;

                    case 3: // 570 x 800
                        image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.LargeId);
                        break;

                }

                if (image != null)
                {
                    br.data = Convert.ToBase64String(image.Bits);
                    br.count = 1;
                    br.setNoError();
                }
            }

            return br;
        }
开发者ID:vanutama,项目名称:bvcms,代码行数:50,代码来源:MobileAPIController.cs

示例3: FetchImage

        public ActionResult FetchImage(string data)
        {
            // Authenticate first
            if (!Auth())
                return BaseMessage.createErrorReturn("Authentication failed, please try again", BaseMessage.API_ERROR_INVALID_CREDENTIALS);

            BaseMessage dataIn = BaseMessage.createFromString(data);
            CheckInFetchImage cifi = JsonConvert.DeserializeObject<CheckInFetchImage>(dataIn.data);

            BaseMessage br = new BaseMessage();
            if (cifi.id == 0) return br.setData("The ID for the person cannot be set to zero");

            br.data = "The picture was not found.";

            var person = DbUtil.Db.People.SingleOrDefault(pp => pp.PeopleId == cifi.id);

            if (person.PictureId != null)
            {
                ImageData.Image image = null;

                switch (cifi.size)
                {
                    case 0: // 50 x 50
                    image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.ThumbId);
                    break;

                    case 1: // 120 x 120
                    image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.SmallId);
                    break;

                    case 2: // 320 x 400
                    image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.MediumId);
                    break;

                    case 3: // 570 x 800
                    image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == person.Picture.LargeId);
                    break;

                }

                if (image != null)
                {
                    br.data = Convert.ToBase64String(image.Bits);
                    br.count = 1;
                    br.setNoError();
                }
            }

            return br;
        }
开发者ID:clearfunction,项目名称:bvcms,代码行数:50,代码来源:CheckInAPIController.cs


注:本文中的CmsWeb.MobileAPI.BaseMessage.setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。