public HttpResponseMessage QuoteRequestEdit(QuoteRequestUpdateRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } bool isSuccessful = _QuoteRequestService.UpdateQuoteRequest(model); var qrUserId = UserService.GetCurrentUserId(); var userProfile = _AdminService.ProfileGetByUserId(qrUserId); var qrCompanyId = userProfile.CompanyId; ActivityService activityService = new ActivityService(); ActivityRequest activity = new ActivityRequest(); activity.UserId = qrUserId; activity.CompanyId = qrCompanyId; activity.PrimaryId = model.QrId.ToString(); activity.ActivityType = ActivityType.QuoteRequest; activity.ActionType = ActionType.Updated; activity.Name = model.Name; activityService.ActivityInsert(activity); ItemResponse <bool> response = new ItemResponse <bool> { Item = isSuccessful }; return(Request.CreateResponse(HttpStatusCode.OK, response)); }
/// <summary> /// Change Activity informations. /// </summary> /// <param name="request">activity request.</param> /// <returns>Activity message.</returns> public ActivityMessage UpdateActivity(ActivityRequest request) { ActivityMessage message = new ActivityMessage(); try { request.FindActivityDto = FindActivityDto.ActivityId; ActivityResponsePivot response = _serviceActivity.FindActivities(request.ToPivot()); if (response?.ActivityPivot != null) { _serviceActivity.UpdateActivity(request.ToPivot()); message.OperationSuccess = true; } else { message.ErrorMessage = ActivityMessageResource.NotFoundActivity; message.ErrorType = ErrorType.FunctionalError; message.OperationSuccess = false; } } catch (Exception e) { message.ErrorType = ErrorType.TechnicalError; message.ErrorMessage = e.Message; } return(message); }
/// <summary> /// 查询培育任务 /// </summary> /// <param name="logcallrequest"></param> /// <returns></returns> public async Task <QueryResult <CrmEntity> > GetActivityList(ActivityRequest activityrequest) { try { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); var ProxyUserId = userInfo != null ? userInfo.systemuserid : null; var fetchString = _onlyLeadRepository.GetActivityList(activityrequest); var fetchXdoc = XDocument.Parse(fetchString); var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage() { EntityName = "mcs_activity", FetchXml = fetchXdoc, ProxyUserId = ProxyUserId }; var fetchResponse = await _crmService.Execute(fetchRequest); var fetchResponseResult = fetchResponse as CrmRetrieveMultipleFetchResponseMessage; var queryResult = new QueryResult <CrmEntity>(); queryResult.Results = fetchResponseResult.Value.Results; queryResult.CurrentPage = activityrequest.PageIndex; queryResult.TotalCount = fetchResponseResult.Value.Count; return(queryResult); } catch (Exception ex) { throw ex; } }
} // end of PossibleChangeWard #endregion //-------------------------------------------------------------------------------------------------- // Custom Methods //-------------------------------------------------------------------------------------------------- #region ChooseDoctor private EntityDoctor ChooseDoctor(EntityPatient patient, ActivityRequest request) { IReadOnlyList <EntityDoctor> doctors = ControlledDoctors; foreach (EntityDoctor doctor in doctors) { if ((doctor.IsWaiting() || doctor.IsInOnlyActivity("ActivityInpatientDoctorOrganizationalWork")) && !doctor.BlockedForDispatching) { return(doctor); } } // end foreach if (request is RequestInpatientActivity && ((RequestInpatientActivity)request).Activity == "ActivityInpatientEmergencyTreatment") { foreach (EntityDoctor doctor in doctors) { if (doctor.IsWaitingOrPreEmptable()) { return(doctor); } } // end foreach } // end if return(null); } // end of ChooseDoctor
/// <summary> /// 列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <QueryResult <CrmEntity> > getlist(ActivityRequest request) { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); try { var fetchXdoc = _Repository.GetListFetchXml(request); var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage() { EntityName = "mcs_activity", FetchXml = fetchXdoc.Result, ProxyUserId = userInfo?.systemuserid }; var fetchResponse = await _crmService.Execute(fetchRequest); var fetchResponseResult = fetchResponse as CrmRetrieveMultipleFetchResponseMessage; var queryResult = new QueryResult <CrmEntity>(); queryResult.Results = fetchResponseResult.Value.Results; queryResult.CurrentPage = request.PageSize; queryResult.TotalCount = 0; return(queryResult); } catch (Exception ex) { throw ex; } }
/// <summary> /// From Activity Request to Activity Request pivot. /// </summary> /// <param name="request">the request to assemble.</param> /// <returns>Activity Request pivot result.</returns> public static ActivityRequestPivot ToPivot(this ActivityRequest request) { return(new ActivityRequestPivot { FindActivityPivot = Utility.EnumToEnum <FindActivityDto, FindActivityPivot>(request.FindActivityDto), ActivityPivot = request.ActivityDto.ToPivot() }); }
public static Activity ToActivity(this ActivityRequest activityRequest) { return(new Activity { LeadId = activityRequest.LeadId, Type = ParseEnum <ActivityType>(activityRequest.Type), }); }
public virtual async Task <HttpResponseMessage> Post([FromBody] Microsoft.Bot.Connector.Activity activity) { try { if (activity != null && activity.GetActivityType() == ActivityTypes.Message) { // Get and process IMessageActivity message = activity.AsMessageActivity(); ActivityRequest request = new ActivityRequest( recipient: message.Recipient.Name, text: message.Text, from: message.From.Name, fromId: message.From.Id, channelId: message.ChannelId, conversationId: message.Conversation.Id, isGroup: message.Conversation.IsGroup, attachments: message.Attachments?.Select( attachment => new AttachmentRequest(attachment.ContentUrl, attachment.ContentType) )); ActivityResponse response = await this.ActivityProcessor.ProcessActivityAsync(this.Store, request).ConfigureAwait(false); // Reply (on a new network connection) back. Microsoft.Bot.Connector.Activity reply = activity.CreateReply(); reply.Text = response.Text; foreach (AttachmentResponse attachment in response.Attachments) { reply.Attachments.Add(new Attachment(attachment.ContentType, attachment.ContentUrl, null, attachment.Name)); } // Send it either as a group message or individually, depending on how we received the message, using (ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl))) { if (message.Conversation.IsGroup.HasValue && message.Conversation.IsGroup.Value) { await connector.Conversations.SendToConversationAsync(reply); } else { await connector.Conversations.ReplyToActivityAsync(reply); } } } } catch (Exception ex) { using (ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl))) { Microsoft.Bot.Connector.Activity reply = activity.CreateReply(); reply.Text = ex.Message + " " + ex.StackTrace; await connector.Conversations.ReplyToActivityAsync(reply); } } // We always accept the message and send the response using the bot framework on another channel. return(new HttpResponseMessage(HttpStatusCode.Accepted)); }
public async Task <List <extension.Activities> > GetActivities(ActivityRequest req, int selfId) { //TODO: Проект убрать после отладки var workItems = await _azureDevOpsService.GetChildWorkItems(req.Project ?? "ShtormDemoProject(Agile)", selfId); int[] wiIds = workItems.Select(x => x.Id).Where(x => x != null).Cast <int>().ToArray(); var timesheets = await _timesheetRepository.GetTimesheets(wiIds); return(timesheets.GroupingActivitiesDuration().ToList()); }
private void RequestSuggestion_Impl(ActivityRequest activityRequest) { SuggestedMetric_Metadata result = this.owner.ChooseExperimentOption(activityRequest); if (result.Content != null) { this.Suggestion = result.Content; this.owner.UpdateStatus(); } }
public IActionResult Create([FromBody] ActivityRequest request) { var activity = Mapper.Map <Activity>(request); activityRepository.CreateActivity(activity); var response = Mapper.Map <ActivityResponse>(activity); return(Ok(response)); }
public SuggestedMetric_Metadata ChooseExperimentOption(ActivityRequest activityRequest) { SuggestedMetric_Metadata result = this.activityRecommender.ChooseExperimentOption(activityRequest, this.Suggestions); if (result.Error != "") { this.UpdateStatus(result.Error); } return(result); }
public IActionResult Update(Guid id, [FromBody] ActivityRequest request) { var activity = activityRepository.GetActivity(id); Mapper.Map(request, activity); activityRepository.UpdateActivity(activity); var response = Mapper.Map <ActivityResponse>(activity); return(Ok(response)); }
public IActionResult Post([FromHeader] string eventId, [FromBody] ActivityRequest activity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _activityService.Create(activity, eventId); return(Ok()); }
public async Task <IActionResult> AddActivity([FromBody] ActivityRequest request) { try { var activity = await _activityService.Create(request.ToActivity()); return(Created(nameof(GetActivity), activity.ToActivityResponse())); } catch (Exception e) { return(BadRequest(new ErrorPayload(1, e.Message))); } }
public void Test_ActivityRequest() { // Ensures that we can serialize and deserialize activity request messages. ActivityRequest message; using (var stream = new MemoryStream()) { // Empty message. message = new ActivityRequest(); stream.SetLength(0); stream.Write(message.SerializeAsBytes(ignoreTypeCode: true)); stream.Seek(0, SeekOrigin.Begin); message = ProxyMessage.Deserialize <ActivityRequest>(stream, ignoreTypeCode: true); Assert.NotNull(message); Assert.Equal(0, message.ClientId); Assert.Equal(0, message.RequestId); Assert.Equal(0, message.ContextId); // Round-trip message.ClientId = 444; message.RequestId = 555; message.ContextId = 666; Assert.Equal(444, message.ClientId); Assert.Equal(555, message.RequestId); Assert.Equal(666, message.ContextId); stream.SetLength(0); stream.Write(message.SerializeAsBytes(ignoreTypeCode: true)); stream.Seek(0, SeekOrigin.Begin); message = ProxyMessage.Deserialize <ActivityRequest>(stream, ignoreTypeCode: true); Assert.NotNull(message); Assert.Equal(444, message.ClientId); Assert.Equal(555, message.RequestId); Assert.Equal(666, message.ContextId); // Clone() message = (ActivityRequest)message.Clone(); Assert.NotNull(message); Assert.Equal(444, message.ClientId); Assert.Equal(555, message.RequestId); Assert.Equal(666, message.ContextId); } }
public async Task <NewtonsoftJsonActionResult <QueryResult <CrmEntity> > > GetMyActivityList(string seachkey = "", string systemuserid = "", int pageSize = 10, int page = 1, string sort = "", int mcs_activitystatus = -1) { var request = new ActivityRequest() { SearchKey = seachkey, PageIndex = page, PageSize = pageSize, mcs_activitystatus = mcs_activitystatus, UserId = systemuserid }; var list = await app.GetActivityList(request); return(list); }
public async Task <ActionResult> Edit(string id, ActivityRequest activityRequest) { try { await _eventManagerApi.UpdateActivityOfAnEventAsync(TempData.Peek("EventId").ToString(), id, activityRequest); return(RedirectToAction(nameof(Index), "Activity", new { id = TempData.Peek("EventId").ToString() })); } catch { await CreateStageDropDown(); await CreateSpeakerDropDown(); return(View()); } }
/// <summary> /// Create new Activity /// </summary> /// <param name="request">activity request.</param> /// <returns>Activity message.</returns> public ActivityMessage CreateActivity(ActivityRequest request) { ActivityMessage message = new ActivityMessage(); try { message = _serviceActivity.CreateActivity(request.ToPivot()).ToMessage(); message.OperationSuccess = true; } catch (Exception e) { message.ErrorType = ErrorType.TechnicalError; message.ErrorMessage = e.Message; } return(message); }
private void Suggest(ActivityRequestOptimizationProperty optimizationProperty) { ActivityRequest activityRequest = new ActivityRequest(this.categoryBox.Activity, this.atLeastAsFunAs_activity, DateTime.Now, optimizationProperty); activityRequest.NumOptionsRequested = this.numChoicesPerSuggestion; if (this.atLeastAsFunAs_activity != null) { DateTime startDate = activityRequest.Date; DateTime hypotheticalEndDate = this.engine.GuessParticipationEndDate(this.atLeastAsFunAs_activity, startDate); Participation hypotheticalParticipation = new Participation(startDate, hypotheticalEndDate, activityRequest.ActivityToBeat); hypotheticalParticipation.Hypothetical = true; Rating userPredictedRating = this.specify_AtLeastAsFunAs_Layout.EstimatedRating_Box.GetRelativeRating(this.engine, hypotheticalParticipation); activityRequest.UserPredictedRating = userPredictedRating; } this.RequestSuggestion.Invoke(activityRequest); }
public async Task <ActivityResult> GetResidentActivity(ActivityRequest activityRequest) { LoginRequest loginRequest = new LoginRequest() { userName = _configuration.GetSection("ApplicationSettings")["UserName"], password = _configuration.GetSection("ApplicationSettings")["Password"] }; LoginResponse loginResponse = await _authenticationService.Login(loginRequest); //var result = await _apiManager.PostExternalAsync<ActivityResult>("report", "GetResidentActivity", activityRequest, loginResponse.token); var response = await Task.Run(async() => { var result = await PostAsync(activityRequest, loginResponse.token); return(result); }); return(response); }
public void Create(ActivityRequest element, string eventId) { Activity activity = new Activity { ActivityId = Guid.NewGuid().ToString(), StartDate = element.StartDate, EndDate = element.EndDate, Description = element.Description, EventId = eventId, Name = element.Name, SpeakerId = element.SpeakerId, StageId = element.StageId }; _botEventManagementContext.Activity.Add(activity); _botEventManagementContext.SaveChanges(); }
public async Task <ApiResponse> Create(ActivityRequest model) { var activity = new Activity(model.Name.ToLower(), model.Description, model.Location, model.Open, model.Close); try { await _bookingDbContext.Activities.AddAsync(activity); await _bookingDbContext.SaveChangesAsync(); } catch (Exception e) { return(new ApiResponse(400, "Could not create activity")); } return(new ApiResponse(201, "Activity Created")); }
public void UpdateActivity(ActivityRequest request) { var activity = GetActivities().First(a => a.Id == request.Id); activity.Name = request.Name; activity.ProcessId = request.ProcessId; activity.Units = request.Units; activity.SafeProductivityRate = request.SafeProductivityRate; activity.AggressiveProductivityRate = request.AggressiveProductivityRate; activity.DurationFunction = request.DurationFunction; activity.UnitDelta = request.UnitDelta; activity.StartToFinish = request.StartToFinish; activity.Dependencies = request.Dependencies; activity.Duration = request.Duration; activity.AggressiveDuration = request.AggressiveDuration; activity.inputProdRate = request.InputProdRate; activity.Section = request.Section; _repository.UpdateActivity(activity); }
public void AddActivity(ActivityRequest request) { _repository.AddActivity(new Activity { Name = request.Name, ProcessId = request.ProcessId, Units = request.Units, SafeProductivityRate = request.SafeProductivityRate, AggressiveProductivityRate = request.AggressiveProductivityRate, DurationFunction = request.DurationFunction, UnitDelta = request.UnitDelta, StartToFinish = request.StartToFinish, Dependencies = request.Dependencies, Duration = request.Duration, AggressiveDuration = request.AggressiveDuration, inputProdRate = request.InputProdRate, Section = request.Section }); }
/// <inheritdoc /> public async Task <ActivityResponse> ProcessActivityAsync(IStore store, ActivityRequest request) { ConversationResponse <T> response; if (!(await store.ExistsAsync(this.SubContainer, request.ConversationId))) { response = await this.StartConversationAsync(store, request).ConfigureAwait(false); } else { T priorConversation = await store.GetAsync <T>(this.SubContainer, request.ConversationId).ConfigureAwait(false); response = await this.ContinueConversationAsync(store, request, priorConversation).ConfigureAwait(false); } await store.CreateOrUpdateAsync(this.SubContainer, request.ConversationId, response.ConversationContext).ConfigureAwait(false); return(response.SpecificResponse); }
/// <summary> /// 列表获取 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <XDocument> GetListFetchXml(ActivityRequest request) { return(await Task <XDocument> .Run(() => { var filterStr = ""; if (!string.IsNullOrEmpty(request.SearchKey)) { filterStr += $@" <filter type='or'> <condition attribute='mcs_name' operator='like' value='%{request.SearchKey}%' /> <condition attribute='mcs_activitystatus' operator='eq' value='{request.mcs_activitystatus}' /> </filter>/> "; } var fetchXml = $@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' count='{request.PageSize}' page='{request.PageIndex}'> <entity name='mcs_activity'> <attribute name='mcs_name' /> <attribute name='createdon' /> <attribute name='mcs_importantlevel' /> <attribute name='mcs_endtime' /> <attribute name='mcs_activitystatus' /> <attribute name='ownerid' /> <attribute name='mcs_nextfollowuptime' /> <attribute name='mcs_nextfollowupcontent' /> <attribute name='mcs_thisfollowupcontent' /> <attribute name='mcs_onlyleadid' /> <attribute name='mcs_activityid' /> <order attribute='createdon' descending='true' /> <filter type='and'> <condition attribute='statecode' operator='eq' value='0' /> {filterStr} </filter> <link-entity name='mcs_onlylead' from='mcs_onlyleadid' to='mcs_onlyleadid' visible='false' link-type='outer' > <attribute name='mcs_mobilephone' alias='mobilephone'/> <attribute name='mcs_name' alias='onlyleadname'/> </link-entity> </entity> </fetch>"; return XDocument.Parse(fetchXml); })); }
public HttpResponseMessage QuoteRequestInsert(QuoteRequestInsertRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } //QuoteRequestInsertRequest newQuoteRequest = new QuoteRequestInsertRequest(); model.UserId = UserService.GetCurrentUserId(); var userProfile = _AdminService.ProfileGetByUserId(model.UserId); model.CompanyId = userProfile.CompanyId; int quoteId = _QuoteRequestService.InsertQuoteRequest(model); ActivityService activityService = new ActivityService(); ActivityRequest activity = new ActivityRequest(); activity.UserId = model.UserId; activity.CompanyId = model.CompanyId; activity.PrimaryId = quoteId.ToString(); activity.ActivityType = ActivityType.QuoteRequest; activity.ActionType = ActionType.Created; activity.Name = model.Name; activityService.ActivityInsert(activity); ItemResponse <int> response = new ItemResponse <int> { Item = quoteId }; return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public void Update(ActivityRequest element, string eventId) { var activity = _botEventManagementContext.Activity.Where(x => x.ActivityId == element.ActivityId && x.EventId == eventId).FirstOrDefault(); if (element.StartDate != DateTime.MinValue && element.StartDate != activity.StartDate) { activity.StartDate = element.StartDate; } if (element.EndDate != DateTime.MinValue && element.EndDate != activity.EndDate) { activity.EndDate = element.EndDate; } if (element.Description != activity.Description) { activity.Description = element.Description; } if (element.Name != activity.Name) { activity.Name = element.Name; } if (element.SpeakerId != activity.SpeakerId) { activity.SpeakerId = element.SpeakerId; } if (element.StageId != activity.StageId) { activity.StageId = element.StageId; } _botEventManagementContext.Entry(activity).State = EntityState.Modified; _botEventManagementContext.SaveChanges(); }
public async Task <ActionResult <ActivityResult> > GetResidentActivity(ActivityRequest activityRequest) { var result = await _reportingService.GetResidentActivity(activityRequest); return(result); }