• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ServiceResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ServiceResponse的典型用法代码示例。如果您正苦于以下问题:C# ServiceResponse类的具体用法?C# ServiceResponse怎么用?C# ServiceResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServiceResponse类属于命名空间,在下文中一共展示了ServiceResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateVolunteerTask

        public HttpResponseMessage CreateVolunteerTask(VolunteerTaskInfo task)
        {
            try
            {
                var timeStamp = DateTime.Now;

                task.CreatedByDate = timeStamp;
                task.CreatedByUserId = UserInfo.UserID;
                task.LastUpdatedByDate = timeStamp;
                task.LastUpdatedByUserId = UserInfo.UserID;

                VolunteerTaskDataAccess.CreateItem(task);

                var savedTask =
                    VolunteerTaskDataAccess.GetItems(task.VolunteerId)
                        .OrderByDescending(t => t.CreatedByDate)
                        .FirstOrDefault();

                var response = new ServiceResponse<VolunteerTaskInfo> { Content = savedTask };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:28,代码来源:VolunteerTaskController.cs


示例2: using

        ServiceResponse<IList<BudgetReceipt>> ISearchEngine.FindBudgetItemDescriptions(ServiceRequest<BudgetReceipt> searchRequest)
        {
            var output = new ServiceResponse<IList<BudgetReceipt>>();

            using (var unitOfWork = RepositoryManager<BudgetReceipt>.Instance.CreateWorkUnit())
            {
                try
                {
                    var repo = new Repository<BudgetReceipt>(unitOfWork.Session);
                    var result = repo.FilterBy(x => (x.Subscriber.Id == _subscriber.Id && x.Description.StartsWith(searchRequest.Data.Description))).ToList();
                    unitOfWork.Commit();

                    output.Data = result.Distinct(new BudgetReceipt.DescriptionCompare()).ToList();
                    output.Result = Result.Successful;

                }
                catch (GenericADOException e)
                {
                    output.Message = MessageFactory.CreateGenerator(RepositoryType.Postgres).GenerateErrorMessage(e);
                    _logger.Critical(output.Message, e);
                    output.Result = Result.Failure;
                }
                catch (Exception e)
                {
                    _logger.Critical(e.Message, e);
                }
            }

            return output;
        }
开发者ID:RabidDog,项目名称:myfinfriend,代码行数:30,代码来源:DefaultSearchEngine.cs


示例3: BookTableReservation

        /// <summary>
        /// Book the table reservation
        /// </summary>
        /// <param name="bookingDetail">Booking detais</param>
        /// <returns></returns>
        public ServiceResponse<bool> BookTableReservation(BookingDetail bookingDetail)
        {
            // Add business rules

            var serviceResponse = new ServiceResponse<bool>();

            try
            {
                var result = reservationRepository.BookTableReservation(bookingDetail);
                serviceResponse.Result = result;

                if (result == true)
                {
                    serviceResponse.OperationSuccess = true;
                    serviceResponse.ServiceMessage = "Booking successful";
                }
                else
                {
                    serviceResponse.OperationSuccess = false;
                    serviceResponse.ServiceMessage = "Unable to book the reservation";
                }
            }
            catch (Exception ex)
            {
                serviceResponse.ErrorMessage = ex.Message;
            }

            return serviceResponse;
        }
开发者ID:balachandarj,项目名称:theranos,代码行数:34,代码来源:ReservationBL.cs


示例4: GetResultFormatsAsync

        public Task<ServiceResponse<IEnumerable<ResultFormatInformation>>> GetResultFormatsAsync()
        {
            var format = new ResultFormatInformation { DisplayName = "Excel", FileExtension = ".xlsx" };
            var response = new ServiceResponse<IEnumerable<ResultFormatInformation>>(new[] { format });

            return Task.FromResult(response);
        }
开发者ID:chlowell,项目名称:dotnet-apiport,代码行数:7,代码来源:FileOutputApiPortService.cs


示例5: AssignRoomToTrack

        public HttpResponseMessage AssignRoomToTrack(int roomId, int trackId, int codeCampId)
        {
            try
            {
                var track = TrackDataAccess.GetItem(trackId, codeCampId);

                if (track != null)
                {
                    track.RoomId = roomId;
                    track.LastUpdatedByDate = DateTime.Now;
                    track.LastUpdatedByUserId = UserInfo.UserID;

                    TrackDataAccess.UpdateItem(track);
                }

                var response = new ServiceResponse<string> { Content = SUCCESS_MESSAGE };

                if (track == null)
                {
                    ServiceResponseHelper<string>.AddNoneFoundError("track", ref response);
                }

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:30,代码来源:TrackController.cs


示例6: GetResponseAsync

        public async Task<ServiceResponse<string>> GetResponseAsync(GoogleMapsParameters parameters)
        {
            var result = new ServiceResponse<string>()
            {
                Success = false,
                Message = "Failed to get a response from service"
            };

            var uri = GetUri(parameters);

            using (var client = new HttpClient())
            {
                try
                {
                    result.Value = await client.GetStringAsync(uri);
                    result.Success = true;
                    result.Message = "Ok";
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return result;
        }
开发者ID:ChenKKaminsky,项目名称:Route-Planner,代码行数:25,代码来源:GoogleMapsApi.cs


示例7: GetAddressInfoAsync

        public async Task<ServiceResponse<int>> GetAddressInfoAsync(DistanceMatrixParameters parameters, InfoType info)
        {
            var result = new ServiceResponse<int>()
            {
                Success = false,
                Message = "Failed to get Buration data from service"
            };

            var response = await GetResponseAsync(parameters);

            if (response.Success)
            {
                var json = JsonConvert.DeserializeObject<DistanceMatrixResponse>(response.Value);

                var elem = json.Rows[0].Elements[0];

                var propName = Enum.GetName(typeof(InfoType), (int)info);

                var item = elem.GetType().GetProperty(propName).GetValue(elem);

                var value = item.GetType().GetProperty("Value").GetValue(item);

                result.Value = (int)value;
                result.Success = true;
                result.Message = "";
            }
            else
            {
                throw new Exception(response.Message, new Exception(response.Value));
            }

            return result;
        }
开发者ID:ChenKKaminsky,项目名称:Route-Planner,代码行数:33,代码来源:DistanceMatrixApi.cs


示例8: AddContact

        public JsonResult AddContact(string firstName, string middleName, string lastName, string email, string phone,
                                     int contactGroupId)
        {
            var result = new ServiceResponse<Object>();

            var contact = new Contact
                {
                    FirstName = firstName,
                    MiddleName = middleName,
                    LastName = lastName,
                    Email = email,
                    Phone = phone,
                    ContactGroupId = contactGroupId
                };

            try
            {
                _contactService.AddContact(contact);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("AddContact: " + ex.Message);

                result.Message = ex.Message;
            }

            result.Result = GetAllGroupsResponse();

            return JsonResponse(result);
        }
开发者ID:programulya,项目名称:Contacts,代码行数:30,代码来源:HomeController.cs


示例9: SaveActivity

        public async Task<string> SaveActivity(string activity)
        {
            WCFProxy.AuthorisationManagerServiceClient authorisationManagerServiceClient = null;

            try
            {
                authorisationManagerServiceClient
                    = new WCFProxy.AuthorisationManagerServiceClient(new WSHttpBinding(),
                        new EndpointAddress(endpointAddress));

                var result = await authorisationManagerServiceClient.SaveActivityAsync(activity).ConfigureAwait(false);

                authorisationManagerServiceClient.Close();

                return result;
            }
            catch (Exception ex)
            {
                if (authorisationManagerServiceClient != null)
                {
                    authorisationManagerServiceClient.Abort();
                }

                var serviceResponse = new ServiceResponse(ex.Message, true);
                var response = Serializer.SerializeToJson(serviceResponse);
                return response;
            }
        }
开发者ID:grantcolley,项目名称:authorisationmanager,代码行数:28,代码来源:AuthorisationManagerWCFClient.cs


示例10: AssignSessionToTimeSlot

        public HttpResponseMessage AssignSessionToTimeSlot(int sessionId, int timeSlotId, int codeCampId)
        {
            try
            {
                var session = SessionDataAccess.GetItem(sessionId, codeCampId);

                if (session != null)
                {
                    session.TimeSlotId = timeSlotId;
                    session.LastUpdatedByDate = DateTime.Now;
                    session.LastUpdatedByUserId = UserInfo.UserID;

                    SessionDataAccess.UpdateItem(session);
                }

                var response = new ServiceResponse<string> { Content = SUCCESS_MESSAGE };

                if (session == null)
                {
                    ServiceResponseHelper<string>.AddNoneFoundError("session", ref response);
                }

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:30,代码来源:TimeSlotController.cs


示例11: CreateMember

 public ServiceResponse CreateMember(Member member, string originalPassword)
 {
     var result = new ServiceResponse();
     member.PasswordSalt = CreateSalt();
     member.HashedPassword = _formsAuth.HashPasswordForStoringInConfigFile(originalPassword + member.PasswordSalt, "sha1");
     _memberRepo.Save(member);
     return result;
 }
开发者ID:chrcar01,项目名称:SimpleTasks,代码行数:8,代码来源:SecurityService.cs


示例12: GetEvent

        public ServiceResponse<CodeCampInfo> GetEvent(int itemId)
        {
            var result = new ServiceResponse<CodeCampInfo>();

            result = ServiceHelper.GetRequest<ServiceResponse<CodeCampInfo>>(fullApiUri + "GetEvent?itemId=" + itemId);

            return result;
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:8,代码来源:ServiceProxy.cs


示例13: DeleteEvent

        public ServiceResponse<string> DeleteEvent(int itemId)
        {
            var result = new ServiceResponse<string>();

            result = ServiceHelper.DeleteRequest<ServiceResponse<string>>(fullApiUri + "DeleteEvent?itemId=" + itemId, string.Empty);

            return result;
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:8,代码来源:ServiceProxy.cs


示例14: CreateEvent

        public ServiceResponse<string> CreateEvent(CodeCampInfo codeCamp)
        {
            var result = new ServiceResponse<string>();

            result = ServiceHelper.PostRequest<ServiceResponse<string>>(fullApiUri + "CreateEvent", codeCamp.ObjectToJson());

            return result;
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:8,代码来源:ServiceProxy.cs


示例15: Login

 public ServiceResponse<LoginResult> Login(string email, string password)
 {
     var result = new ServiceResponse<LoginResult>();
     var member = GetMember(email, password);
     var loginResult = new LoginResult();
     loginResult.LoginFailed = member == null;
     loginResult.Member = member;
     result.Data = loginResult;
     return result;
 }
开发者ID:chrcar01,项目名称:SimpleTasks,代码行数:10,代码来源:SecurityService.cs


示例16: ClientObjectRelationTypeGet

		private void ClientObjectRelationTypeGet(ServiceResponse<PagedResult<ObjectRelationType>> response, object token)
		{
			if (response.Error != null)
			{
				ServiceFailed(this, new DataEventArgs<Exception>(response.Error));
				return;
			}

			foreach (var objectRelationType in response.Body.Results)
				_objectRelationTypes.Add(objectRelationType);
		}
开发者ID:CHAOS-Community,项目名称:CHAOS.Portal.Client-.NET,代码行数:11,代码来源:MCMTypesManager.cs


示例17: Deserialize

        public static ServiceResponse Deserialize(XmlReader reader, ServiceResponse serviceResponse)
        {
            if (reader.IsStartElement(DTD.Response.TagServiceResponse))
            {
                if (serviceResponse == null)
                {
                    serviceResponse = new ServiceResponse();
                }

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    do
                    {
                        #region <ERROR>
                        if (reader.IsStartElement(DTD.Response.ServiceResponse.TagError))
                        {
                            if(int.Parse(reader.GetAttribute(DTD.Error.TagNumber))!=0)
                            {
                                throw XMLErrorSerializer.Deserialize(reader.ReadSubtree());
                            }
                            else
                            {
                                reader.Skip();
                            }
                        }
                        #endregion <ERROR>

                        #region <OID>
                        if (reader.IsStartElement(DTD.TagOID))
                        {
                            serviceResponse.Oid = XMLAdaptorOIDSerializer.Deserialize(reader.ReadSubtree());
                        }
                        #endregion <OID>

                        #region <Arguments>
                        if (reader.IsStartElement(DTD.Response.ServiceResponse.TagArguments))
                        {
                            serviceResponse.Arguments = XMLArgumentsSerializer.Deserialize(reader.ReadSubtree());
                        }
                        #endregion <Arguments>
                    } while (reader.Read());
                }
                else
                {
                    reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the Service.Response in Start Element.", "XmlReader reader");
            }
            return serviceResponse;
        }
开发者ID:sgon1853,项目名称:UPM_MDD_Thesis,代码行数:54,代码来源:Service.Response.Serializer.cs


示例18: ClientLanguageGetCompleted

		private void ClientLanguageGetCompleted(ServiceResponse<PagedResult<Language>> response, object token)
		{
			if(response.Error != null)
			{
				ServiceFailed(this, new DataEventArgs<Exception>(response.Error));
				return;
			}

			foreach (var language in response.Body.Results)
				_languages.Add(language);

			Loaded(this, EventArgs.Empty);
		}
开发者ID:CHAOS-Community,项目名称:CHAOS.Portal.Client-.NET,代码行数:13,代码来源:LanguageManager.cs


示例19: AddRoleToUser

 public string AddRoleToUser(string userId, string roleId)
 {
     try
     {
         return authorisationManagerServer.AddRoleToUser(userId, roleId);
     }
     catch (Exception ex)
     {
         var serviceResponse = new ServiceResponse(ex.Message, ex);
         var response = Serializer.SerializeToJson(serviceResponse);
         return response;
     }
 }
开发者ID:grantcolley,项目名称:authorisationmanager,代码行数:13,代码来源:AuthorisationManagerTestService.cs


示例20: AddActivityToRole

 public string AddActivityToRole(string roleId, string activityId)
 {
     try
     {
         return authorisationManagerServer.AddActivityToRole(roleId, activityId);
     }
     catch (Exception ex)
     {
         var serviceResponse = new ServiceResponse(ex.Message, ex);
         var response = Serializer.SerializeToJson(serviceResponse);
         return response;
     }
 }
开发者ID:grantcolley,项目名称:authorisationmanager,代码行数:13,代码来源:AuthorisationManagerTestService.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ServiceResult类代码示例发布时间:2022-05-24
下一篇:
C# ServiceReference1.Service1Client类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap