Пример #1
0
        public ActivityResponse DeleteActivityConvert( )
        {
            var response = new ActivityResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                response.Message = ActivityDao.DeleteActivityConvert();
                if (!string.IsNullOrEmpty(response.Message))
                {
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                return(response);
            }
            catch (SqlException sqlException)
            {
                response.Acknowledge = AcknowledgeType.Failure;
                response.Message     = sqlException.Message;
                return(response);
            }
            catch (Exception ex)
            {
                response.Acknowledge = AcknowledgeType.Failure;
                response.Message     = ex.Message;
                return(response);
            }
        }
        public static async Task <ActivityResponse> SetLeagueEmailAddressCommandHandlerActivity(
            [ActivityTrigger] DurableActivityContext context,
            ILogger log)
        {
            ActivityResponse ret = new ActivityResponse()
            {
                FunctionName = "SetLeagueEmailAddressCommandHandlerActivity"
            };

            try
            {
                CommandRequest <Set_Email_Address_Definition> cmdRequest = context.GetInput <CommandRequest <Set_Email_Address_Definition> >();

                if (null != cmdRequest)
                {
                    await HandleSetLeagueEmailAddressCommand(cmdRequest.CommandUniqueIdentifier.ToString(), log,
                                                             new WriteContext(ret.FunctionName, context.InstanceId ));

                    ret.Message = $"Command processed {cmdRequest.CommandName} : {cmdRequest.CommandUniqueIdentifier}";
                }
                else
                {
                    ret.FatalError = true;
                    ret.Message    = $"Unable to read command request from {context.InstanceId }";
                }
            }
            catch (Exception ex)
            {
                ret.FatalError = true;
                ret.Message    = ex.Message;
            }

            return(ret);
        }
Пример #3
0
 public static ActivityResponseDTO Create(ActivityResponse activityResponseType)
 {
     return(new ActivityResponseDTO()
     {
         Type = activityResponseType.ToString()
     });
 }
Пример #4
0
        public ActionResult CreateCustomList(CustomList customList)
        {
            var acResponse = new ActivityResponse();

            try
            {
                if (string.IsNullOrEmpty(customList.CustomListName))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please provide custom List Name";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                _customListService.Insert(customList);
                _unitOfWork.SaveChanges();

                acResponse.Code       = 5;
                acResponse.ResponseId = customList.CustomListId;
                acResponse.Message    = "Custom List was successfully Created";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                acResponse.Code    = -1;
                acResponse.Message = "An unknown error was encountered. Please try again.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
        }
Пример #5
0
        public override Task <ActivityResponse> GetActivity(GetProductRequest request, Grpc.Core.ServerCallContext context)
        {
            this.logger.LogInformation($"Received query for product activity for SKU {request.SKU}");
            var response = new ActivityResponse();

            try
            {
                var activities = this.repository.GetActivity(request.SKU);
                foreach (var activity in activities)
                {
                    response.Activities.Add(new Activity
                    {
                        SKU          = activity.SKU,
                        ActivityID   = activity.ActivityId,
                        Timestamp    = (ulong)activity.CreatedOn,
                        OrderID      = activity.OrderId,
                        Quantity     = (uint)activity.Quantity,
                        ActivityType = ToProtoActivityType(activity.ActivityType)
                    });
                }
                return(Task.FromResult(response));
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex, "Failed to retrieve activity for SKU : {}", request.SKU);
                return((Task <ActivityResponse>)Task.FromException(ex));
            }
        }
        public ActionResult EditCustomFieldType(CustomFieldType customFieldType)
        {
            var acResponse = new ActivityResponse();

            try
            {
                if (customFieldType.TableId < 1 || string.IsNullOrEmpty(customFieldType.FieldTypeId))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "An unknown error was encountered. Please try again.";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                if (string.IsNullOrEmpty(customFieldType.FieldTypeName))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please provide customFieldType Name";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                _customFieldTypeService.Update(customFieldType);
                _unitOfWork.SaveChanges();

                acResponse.Code    = 5;
                acResponse.Message = "Custom Field Type was successfully updated";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                acResponse.Code    = -1;
                acResponse.Message = "An unknown error was encountered. Please try again.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult DeleteCustomListDataList(List <string> customListDataIds)
        {
            var acResponse = new ActivityResponse();

            try
            {
                if (!customListDataIds.Any())
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Invalid operation.";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }
                customListDataIds.ForEach(i =>
                {
                    var datasToDelete = _customListDataService.Query(o => o.CustomListDataId == i).Select().ToList();
                    if (datasToDelete.Any())
                    {
                        var tt = datasToDelete[0];
                        _customListDataService.Delete(tt);
                        _unitOfWork.SaveChanges();
                    }
                });

                acResponse.Code    = 5;
                acResponse.Message = "Selected Item(s) were successfully deleted.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                acResponse.Code    = -1;
                acResponse.Message = "An unknown error was encountered. Please try again.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult DeleteProjectCustomListDatas(List <int> projectCustomListDataTableIds)
        {
            var acResponse = new ActivityResponse();

            try
            {
                if (!projectCustomListDataTableIds.Any())
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Invalid operation.";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }
                projectCustomListDataTableIds.ForEach(i =>
                {
                    _customListDataService.Delete(i);
                    _unitOfWork.SaveChanges();
                });

                acResponse.Code    = 5;
                acResponse.Message = "Selected Item(s) were successfully deleted.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                acResponse.Code    = -1;
                acResponse.Message = "An unknown error was encountered. Please try again.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
        }
Пример #9
0
        public ActionResult AddAppSetting(AppSetting appSetting)
        {
            var acResponse = new ActivityResponse();

            if (appSetting.SynchronisationTime.TimeOfDay.Hours < 1)
            {
                acResponse.Code    = -1;
                acResponse.Message = "Please provide Synchronization time.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
            if (appSetting.SynchFrequency < 1)
            {
                acResponse.Code    = -1;
                acResponse.Message = "Please provide Synchronization Frequency.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }

            if (string.IsNullOrEmpty(appSetting.Id))
            {
                appSetting.Id = EntityIdGenerator.GenerateEntityId();
                _appSettingService.Insert(appSetting);
                _unitOfWork.SaveChanges();
            }
            else
            {
                _appSettingService.Update(appSetting);
                _unitOfWork.SaveChanges();
            }

            acResponse.Code         = 5;
            acResponse.EnrollmentId = appSetting.Id;
            acResponse.Message      = "Process completed successfully";
            return(Json(acResponse, JsonRequestBehavior.AllowGet));
        }
        public static async Task <ActivityResponse> RunWebHookNotificationActivity(
            [ActivityTrigger] DurableActivityContext context,
            Binder outputBinder,
            ILogger log)
        {
            ActivityResponse response = new ActivityResponse()
            {
                FunctionName = "RunWebHookNotificationActivity"
            };

            Command_Notification_Request notifyRequest = context.GetInput <Command_Notification_Request>();

            if (null != notifyRequest)
            {
                var payloadAsJSON = new StringContent(JsonConvert.SerializeObject(notifyRequest));

                // Use the binder to bind to an HTTP client to send the results to
                using (var client = new HttpClient())
                {
                    HttpResponseMessage msgResp = await client.PostAsync(notifyRequest.HookAddress, payloadAsJSON);

                    if (null != msgResp)
                    {
                        response.Message = $"Output sent - {msgResp.ReasonPhrase}";
                    }
                }
            }
            else
            {
                response.StepFailure = true;
                response.Message     = "Unable to read command notification request from context";
            }

            return(response);
        }
Пример #11
0
        public string SelectByTour(ActivitySearch valFilter)
        {
            string          vResult      = string.Empty;
            DataTable       vDatainTable = new DataTable();
            SQLToolsLibrary vSqlTools    = new SQLToolsLibrary();

            try {
                if (valFilter.DateStart == DateTime.MinValue)
                {
                    valFilter.DateStart = new DateTime(1753, 1, 1);
                }
                List <SqlParameter> vParameterList = new List <SqlParameter> {
                    new SqlParameter("@IdLanguage", valFilter.IdLanguage.ToString()),
                    new SqlParameter("@IdTour", valFilter.IdTour.ToString()),
                    new SqlParameter("@IdCurrency", valFilter.IdCurrency.ToString()),
                    new SqlParameter("@DateStart", valFilter.DateStart),
                    new SqlParameter("@MinimumPeople", valFilter.MinimumPeople),
                    new SqlParameter("@RowsPerPage", valFilter.RowsPerPage),
                    new SqlParameter("@PageNumber", valFilter.PageNumber)
                };
                ActivityResponse vModel = new ActivityResponse();
                vDatainTable = vSqlTools.ExcecuteSelectWithStoreProcedure(vParameterList, "sp_Select_Activity_Filter", vConnection);
                List <Activity> vData = DataTableToListFilter(vDatainTable);
                vModel.Activities = vData;
                vModel.TotalRows  = GetTotalRowsFilter(valFilter);
                if (vModel.Activities != null & vModel.Activities.Count > 0)
                {
                    vResult = JsonConvert.SerializeObject(vModel, Formatting.Indented);
                }
            } catch (Exception vEx) {
                string vMessage = vEx.Message;
                vResult = string.Empty;
            }
            return(vResult);
        }
Пример #12
0
        public ActionResult CreateCustomField(CustomField customField)
        {
            var acResponse = new ActivityResponse();

            try
            {
                if (string.IsNullOrEmpty(customField.CustomFieldName))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please provide custom Field Name";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                if (string.IsNullOrEmpty(customField.CustomGroupId))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please select custom Group";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                if (string.IsNullOrEmpty(customField.FieldTypeId))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please select custom Field Type";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                //if (string.IsNullOrEmpty(customField.CustomListId))
                //{
                //    acResponse.Code = -1;
                //    acResponse.Message = "Please select custom List";
                //    return Json(acResponse, JsonRequestBehavior.AllowGet);
                //}

                //todo : try implement the commented code below for live environment
                //if (customField.FieldTypeId != "List" || customField.FieldTypeId != "Date")
                //{
                //    if (string.IsNullOrEmpty(customField.CustomFieldSize))
                //    {
                //        acResponse.Code = -1;
                //        acResponse.Message = "Please provide Custom Field Size";
                //        return Json(acResponse, JsonRequestBehavior.AllowGet);
                //    }
                //}

                _customFieldService.Insert(customField);
                _unitOfWork.SaveChanges();

                acResponse.Code       = 5;
                acResponse.ResponseId = customField.CustomFieldId;
                acResponse.Message    = "Custom Field was successfully Created";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                acResponse.Code    = -1;
                acResponse.Message = "An unknown error was encountered. Please try again.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
        }
        public static async Task <ActivityResponse> GetLeagueSummaryQueryProjectionRequestActivity(
            [ActivityTrigger] DurableActivityContext context,
            ILogger log)
        {
            ActivityResponse ret = new ActivityResponse()
            {
                FunctionName = "GetLeagueSummaryQueryProjectionRequestActivity"
            };

            try
            {
                QueryRequest <Get_League_Summary_Definition> queryRequest = context.GetInput <QueryRequest <Get_League_Summary_Definition> >();

                if (null != log)
                {
                    log.LogInformation($"GetLeagueSummaryQueryProjectionRequestActivity called for query : {queryRequest.QueryUniqueIdentifier}");
                }


                await RequestProjectionsGetLeagueSummaryQuery(queryRequest.QueryName,
                                                              queryRequest.QueryUniqueIdentifier.ToString(),
                                                              log);

                ret.Message = $"Requested projections : { queryRequest.QueryUniqueIdentifier.ToString() } ";
            }
            catch (Exception ex)
            {
                ret.Message    = ex.Message;
                ret.FatalError = true;
            }
            return(ret);
        }
Пример #14
0
        public ActivityResponse UpdateActivity(ActivityEntity Activity)
        {
            var response = new ActivityResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                if (!Activity.Validate())
                {
                    foreach (string error in Activity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                response.Message = ActivityDao.UpdateActivity(Activity);
                if (!string.IsNullOrEmpty(response.Message))
                {
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                response.ActivityId = Activity.ActivityId;
                return(response);
            }
            catch (Exception ex)
            {
                response.Acknowledge = AcknowledgeType.Failure;
                response.Message     = ex.Message;
                return(response);
            }
        }
Пример #15
0
        public ActionResult DeleteCustomField(int customFieldTableId)
        {
            var acResponse = new ActivityResponse();

            try
            {
                if (customFieldTableId < 1)
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Invalid selection.";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                _customFieldService.Delete(customFieldTableId);
                _unitOfWork.SaveChanges();

                acResponse.Code    = 5;
                acResponse.Message = "Custom Field was successfully deleted.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                acResponse.Code    = -1;
                acResponse.Message = "An unknown error was encountered. Please try again.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult CreateProjectCustomGroup(ProjectCustomGroup projectCustomGroup)
        {
            var acResponse = new ActivityResponse();

            try
            {
                if (string.IsNullOrEmpty(projectCustomGroup.CustomGroupId))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please select at least one custom Group";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                if (string.IsNullOrEmpty(projectCustomGroup.ProjectCode))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please provide Project Code";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                _projectCustomGroupService.Insert(projectCustomGroup);
                _unitOfWork.SaveChanges();

                acResponse.Code    = 5;
                acResponse.Message = "Project Custom Group was successfully Created";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                acResponse.Code    = -1;
                acResponse.Message = "An unknown error was encountered. Please try again.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
        }
        public static async Task <ActivityResponse> CommandNotificationOrchestrator(
            [OrchestrationTrigger] DurableOrchestrationContext context,
            Microsoft.Extensions.Logging.ILogger log)
        {
            ActivityResponse <Command_Notification_Response> response = new ActivityResponse <Command_Notification_Response>()
            {
                FunctionName = "CommandNotificationOrchestrator"
            };

            Command_Notification_Request request = context.GetInput <Command_Notification_Request>();

            if (null != request)
            {
                Guid UniqueIdentifierGuid;
                if (Guid.TryParse(request.CommandUniqueIdentifier, out UniqueIdentifierGuid))
                {
                    // run the [Command_Notifications_Projection]..
                    response = await context.CallActivityAsync <ActivityResponse <Command_Notification_Response> >("CommandNotificationActivity", request);
                }
                else
                {
                    response.FatalError = true;
                    response.Message    = $"Unable to get command unique identifier for {request.CommandName} {request.CommandUniqueIdentifier } as a GUID ";
                }
            }

            return(response);
        }
        public ActionResult CreateCustomListData(CustomListData customListData)
        {
            var acResponse = new ActivityResponse();

            try
            {
                if (string.IsNullOrEmpty(customListData.ListDataName))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please provide custom List Data Name";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                if (string.IsNullOrEmpty(customListData.CustomListDataId))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please select custom List";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                customListData.CustomListDataId = Guid.NewGuid().ToString();
                _customListDataService.Insert(customListData);
                _unitOfWork.SaveChanges();

                acResponse.Code    = 5;
                acResponse.Message = "Custom List Data was successfully Created";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                acResponse.Code    = -1;
                acResponse.Message = "An unknown error was encountered. Please try again.";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
        }
        private void ActivityProcess(MessageReceivedEventArgs message)
        {
            var activityRequest = _serializerService.Deserialize <ActivityReq>(message.Message);

            var activityNotification = new ActivityNotification
            {
                Sender    = activityRequest.Login,
                IsWriting = activityRequest.IsWriting
            };

            KeyValuePair <User, UserDetails> activeUser =
                _currentUsers.SingleOrDefault(u => u.Key.Login == activityRequest.Recipient);

            if (activeUser.Key != null)
            {
                activeUser.Value.TopicList.ToList()
                .ForEach(
                    topic => QueueServerService.SendData(topic, ConfigurationService.ExchangeName, activityNotification));
            }

            QueueServerService.SendData(activityRequest.Recipient, ConfigurationService.ExchangeName,
                                        activityNotification);

            var activityResponse = new ActivityResponse();

            QueueServerService.SendData(message.TopicSender, ConfigurationService.ExchangeName, activityResponse);
        }
        public static async Task <ActivityResponse <Command_Notification_Response> > GetCommandNotificationsActivity([ActivityTrigger] DurableActivityContext context,
                                                                                                                     ILogger log)
        {
            ActivityResponse <Command_Notification_Response> response = new ActivityResponse <Command_Notification_Response>()
            {
                FunctionName = "CommandNotificationActivity",
                ReturnedData = new Command_Notification_Response()
            };

            Command_Get_Notifications_Request payload = context.GetInput <Command_Get_Notifications_Request>();

            if (null != payload)
            {
                // run the projection to send the notifications..
                Projection getCommandNotifications = new Projection(Constants.Domain_Command,
                                                                    payload.CommandName,
                                                                    payload.CommandUniqueIdentifier,
                                                                    nameof(Command_Notifications_Projection));

                Command_Notifications_Projection cmdProjection = new Command_Notifications_Projection(log);

                await getCommandNotifications.Process(cmdProjection);

                if ((cmdProjection.CurrentSequenceNumber > 0) || (cmdProjection.ProjectionValuesChanged()))
                {
                    // Send the completed notification if the command is complete
                    if (cmdProjection.Completed)
                    {
                        // make it an "all completed" notification
                        response.ReturnedData.Completed = true;
                    }
                    else if (cmdProjection.InError)
                    {
                        // make it an "all completed" notification
                        response.ReturnedData.InError = true;
                    }
                    else
                    {
                        // otherwise send each step notification
                        foreach (CommandStepCompleted stepCompleted in cmdProjection.StepsCompleted)
                        {
                            // make it a "steps completed" notification
                        }
                    }

                    if (null != cmdProjection.ImpactedEntities)
                    {
                        response.ReturnedData.ImpactedEntities = cmdProjection.ImpactedEntities;
                    }

                    if (null != cmdProjection.NotificationTargetHooks)
                    {
                        response.ReturnedData.NotificationTargetHooks = cmdProjection.NotificationTargetHooks;
                    }
                }
            }

            return(response);
        }
Пример #21
0
        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));
        }
Пример #22
0
        public ActionResult CreateProject(Project project)
        {
            var acResponse = new ActivityResponse();

            try
            {
                if (string.IsNullOrEmpty(project.ProjectName))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please provide project Name";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                if (string.IsNullOrEmpty(project.ProjectDescription))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please provide Project Description";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }


                if (string.IsNullOrEmpty(project.ProjectCode))
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please provide Project Code";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }

                if (project.LicenseExpiryDate.Year <= 1)
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "Please provide a valid Project Expiry Date";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }
                var similarProjects = _projectService.Query(p => p.ProjectCode.ToLower() == project.ProjectCode.ToLower() || p.ProjectName.ToLower() == project.ProjectName.ToLower()).Select().ToList();
                if (similarProjects.Any())
                {
                    acResponse.Code    = -1;
                    acResponse.Message = "A Project with Similar Project Code or Name already exists.";
                    return(Json(acResponse, JsonRequestBehavior.AllowGet));
                }
                project.DateCreated = DateTime.Now;
                _projectService.Insert(project);
                _unitOfWork.SaveChanges();

                acResponse.Code    = 5;
                acResponse.Message = "Project was successfully Created";
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                acResponse.Code    = -1;
                acResponse.Message = "An unknown error was encountered. Please try again.";
                ErrorLogger.LogError(e.StackTrace, e.Source, e.Message);
                return(Json(acResponse, JsonRequestBehavior.AllowGet));
            }
        }
Пример #23
0
        public static void ActivityResponseReceived(ActivityDO activityDo, ActivityResponse responseType)
        {
            var handler = EventActivityResponseReceived;

            if (handler != null)
            {
                handler(activityDo, responseType);
            }
        }
Пример #24
0
        public static async Task <ActivityResponse> QueryLogOutputTargetActivity(
            [ActivityTrigger] DurableActivityContext context,
            ILogger log)
        {
            ActivityResponse ret = new ActivityResponse()
            {
                FunctionName = "QueryLogOutputTargetActivity"
            };

            #region Logging
            if (null != log)
            {
                log.LogDebug($"Logging query output  in {ret.FunctionName} ");
            }
            #endregion

            QueryRequest <object> queryRequest = context.GetInput <QueryRequest <object> >();
            if (null != queryRequest)
            {
                EventStream queryEvents = new EventStream(Constants.Domain_Query,
                                                          queryRequest.QueryName,
                                                          queryRequest.QueryUniqueIdentifier.ToString());

                if (null != queryEvents)
                {
                    // Set the context for the events to be written using
                    queryEvents.SetContext(new WriteContext(ret.FunctionName, context.InstanceId));

                    if (null != queryRequest.ResponseTargets)
                    {
                        foreach (var responseTarget in queryRequest.ResponseTargets)
                        {
                            // set the parameter(s)
                            await queryEvents.AppendEvent(new TheLongRun.Common.Events.Query.OutputLocationSet
                                                              (responseTarget.ReturnPath, responseTarget.ReturnTarget));

                            #region Logging
                            if (null != log)
                            {
                                // Unable to get the request details from the orchestration
                                log.LogInformation($"{ret.FunctionName } : Set output path {responseTarget.ReturnPath} : {responseTarget.ReturnTarget} ");
                            }
                            #endregion
                        }
                    }
                }
                else
                {
                    ret.Message    = $"Unable to get the event stream for {queryRequest.QueryName} : {queryRequest.QueryUniqueIdentifier }";
                    ret.FatalError = true;
                }
            }

            return(ret);
        }
Пример #25
0
        /**********************************************************************************/

        protected void SetResponse(ActivityResponse response, string message = null, object details = null)
        {
            OperationalState.CurrentActivityResponse = ActivityResponseDTO.Create(response);

            if (!string.IsNullOrWhiteSpace(message) || details != null)
            {
                OperationalState.CurrentActivityResponse.AddResponseMessageDTO(new ResponseMessageDTO()
                {
                    Message = message, Details = details
                });
            }
        }
Пример #26
0
        private ActivityResponse FlattenResult(ActivityList resultList)
        {
            ActivityResponse result = new ActivityResponse();

            result.runActivities           = Mapper.Map <List <RunActivity>, List <RunResponse> >(resultList.runActivities);
            result.bikeActivities          = Mapper.Map <List <BikeActivity>, List <BikeResponse> >(resultList.bikeActivities);
            result.freePlayActivities      = Mapper.Map <List <FreePlayActivity>, List <FreePlayResponse> >(resultList.freePlayActivities);
            result.golfActivities          = Mapper.Map <List <GolfActivity>, List <GolfResponse> >(resultList.golfActivities);
            result.guidedWorkoutActivities = Mapper.Map <List <GuidedWorkoutActivity>, List <GuidedWorkoutResponse> >(resultList.guidedWorkoutActivities);
            result.sleepActivities         = Mapper.Map <List <SleepActivity>, List <SleepResponse> >(resultList.sleepActivities);
            return(result);
        }
Пример #27
0
        public static async Task <ActivityResponse> QueryOutputToEventGridActivity(
            [ActivityTrigger] DurableActivityContext context,
            Binder outputBinder,
            ILogger log)
        {
            ActivityResponse ret = new ActivityResponse()
            {
                FunctionName = "QueryOutputToEventGridActivity"
            };

            #region Logging
            if (null != log)
            {
                log.LogDebug($"Output  in {ret.FunctionName} ");
            }
            #endregion

            // Read the results
            QueryOutputRecord <object> results = context.GetInput <QueryOutputRecord <object> >();
            if (null != results)
            {
                EventGridAttribute egAttribute = EventGridAttributeFromTarget(results.Target, results.QueryName, results.QueryUniqueIdentifier);

                if (null != egAttribute)
                {
                    // split the target string into an event grid attribute

                    Microsoft.Azure.EventGrid.Models.EventGridEvent eventGridEvent = new Microsoft.Azure.EventGrid.Models.EventGridEvent()
                    {
                        Subject = results.QueryUniqueIdentifier.ToString(),
                        Data    = results.Results
                    };

                    IAsyncCollector <EventGridEvent> eventCollector = outputBinder.Bind <IAsyncCollector <EventGridEvent> >(egAttribute);
                    if (null != eventCollector)
                    {
                        await eventCollector.AddAsync(eventGridEvent);

                        await eventCollector.FlushAsync();
                    }
                }
                else
                {
                    ret.Message = $"Unable to determine the event grid target from {results.Target}";
                }
            }
            else
            {
                ret.Message = $"Unable to get query output record to send to event grid";
            }

            return(ret);
        }
Пример #28
0
        private void FillListModel(ActivityResponse newActivityResponse, bool loadImageData)
        {
            view.Model.Statuses.Clear();

            foreach (ActivityData newActivityData in newActivityResponse.arActivityDatas)
            {
                StatusUpdatesListViewItem newStatusUpdateListViewItem = new StatusUpdatesListViewItem();

                #region установка группы

                newStatusUpdateListViewItem.Group = string.Empty;

                if (newActivityData.adTime.Date == DateTime.Now.Date)
                {
                    newStatusUpdateListViewItem.Group = Resources.StatusUpdatesList_Controller_Group_Today;
                }
                else if (newActivityData.adTime.Date == DateTime.Now.AddDays(-1).Date)
                {
                    newStatusUpdateListViewItem.Group = Resources.StatusUpdatesList_Controller_Group_Yesterday;
                }
                else
                {
                    newStatusUpdateListViewItem.Group = newActivityData.adTime.Date.ToString("d MMMM");
                }

                #endregion

                newStatusUpdateListViewItem.Uid           = newActivityData.adStatusID.ToString();
                newStatusUpdateListViewItem.UserID        = newActivityData.adDataSender.psUserID.ToString();
                newStatusUpdateListViewItem.UserName      = newActivityData.adDataSender.psUserName;
                newStatusUpdateListViewItem.UserStatus    = newActivityData.adText;
                newStatusUpdateListViewItem.StatusSetDate = newActivityData.adTime;
                //newStatusUpdateListViewItem.UserPhoto = SystemConfiguration.AppInstallPath + @"\Cache\Files\Thumb\" + HttpUtility.GetMd5Hash(newActivityData.adDataSender.psUserPhotoURL);

                //bool result;

                //if (loadImageData)
                //{
                //    result = Globals.BaseLogic.ICommunicationLogic.LoadImage(newActivityData.adDataSender.psUserPhotoURL, @"Thumb\" + HttpUtility.GetMd5Hash(newActivityData.adDataSender.psUserPhotoURL), false, _afterLoadImageEventHandler, UISettings.CalcPix(50), newActivityData.adTime, "DateTime");
                //}
                //else
                //{
                //    result = false;
                //}

                //newStatusUpdateListViewItem.IsUserPhotoLoaded = result;

                view.Model.Statuses.Add(newStatusUpdateListViewItem);
            }

            view.Model.Statuses.Sort();
        }
Пример #29
0
        public static async Task <ActivityResponse> GetLeagueSummaryQueryProjectionProcessActivity(
            [ActivityTrigger] DurableActivityContext context,
            ILogger log)
        {
            ActivityResponse ret = new ActivityResponse()
            {
                FunctionName = "GetLeagueSummaryQueryProjectionRequestActivity"
            };

            ret.Message = "Obsolete: this function has been replaced by the generic projection processor";

            return(await Task <ActivityResponse> .FromResult(ret));
        }
Пример #30
0
        public Task <ActivityResponse> GetActivityAsync()
        {
            var activity = new ActivityResponse
            {
                TraceId  = _activityContextAccessor.TraceId,
                ParentId = _activityContextAccessor.ParentId,
                RootId   = _activityContextAccessor.CorrelationId,
                Baggage  = GetBaggage(),
                TenantId = GetTenant()
            };

            return(Task.FromResult(activity));
        }