예제 #1
0
 /// <param name="subject">Юнит, совершивший действие.</param>
 /// <param name="obj">Юнит, к которому применено действие.</param>
 /// <param name="action">Тип воздействия.</param>
 public ActionResult(IUnit subject, IUnit obj, ActionResultType action)
 {
     Subject = subject;
     Object  = obj;
     Action  = action;
     Message = String.Empty;
 }
예제 #2
0
 /// <summary>
 /// Creates an instance of an ActionResult
 /// </summary>
 /// <param name="msg">the message</param>
 /// <param name="loc">the location</param>
 public ActionResult(string msg, Location loc)
 {
     this.msg  = msg;
     this.loc  = loc;
     type      = ActionResultType.Info;
     this.code = string.Empty;
 }
예제 #3
0
 private void CheckActionResult(ActionResultType result)
 {
     if (result != ActionResultType.OK)
     {
         System.Diagnostics.Debugger.Break();
     }
 }
예제 #4
0
        public static ActionResultType CheckResult(ActionResultType actionResult)
        {
            if (actionResult != ActionResultType.OK)
            {
                Logger.Instance.AddInfoMessage($"{Environment.StackTrace}: {actionResult}");
            }

            return(actionResult);
        }
        public void StartWorkflow()
        {
            System.DateTime startTime = DateTime.Now;

            String originalQueryString = ((!String.IsNullOrWhiteSpace(UrlOriginal)) ? ((UrlOriginal.Split('?').Length > 0) ? UrlOriginal.Split('?')[1] : String.Empty) : String.Empty);


            // CREATE WORKFLOW START REQUEST

            Mercury.Server.Application.WorkflowStartRequest workflowStartRequest = new Server.Application.WorkflowStartRequest();

            workflowStartRequest.Arguments = new System.Collections.Generic.Dictionary <String, Object> ();

            workflowStartRequest.WorkflowId = WorkflowId;

            workflowStartRequest.WorkflowInstanceId = WorkflowInstanceId;

            workflowStartRequest.WorkflowName = WorkflowName;

            // LOAD ARGUMENTS FROM ORIGINAL QUERY STRING

            for (Int32 currentIndex = 0; currentIndex < originalQueryString.Split('&').Length; currentIndex++)
            {
                String parameter = originalQueryString.Split('&')[currentIndex];

                String parameterName = ((parameter.Contains("=")) ? parameter.Split('=')[0] : String.Empty);

                String parameterValue = ((parameter.Contains("=")) ? parameter.Split('=')[1] : String.Empty);

                if (!String.IsNullOrWhiteSpace(parameterName))
                {
                    workflowStartRequest.Arguments.Add(parameterName, parameterValue);
                }
            }


            // CALL WORKFLOW START ON MERCURY SERVER

            workflowResponse = MercuryApplication.WorkflowStart(workflowStartRequest);

            System.Diagnostics.Debug.WriteLine("WorkflowStart: " + DateTime.Now.Subtract(startTime).TotalMilliseconds.ToString());

            WorkflowInstanceId = workflowResponse.WorkflowInstanceId; // ASSIGN NEW WORKFLOW INSTANCE ID FOR FUTURE REFERENCE (CONTINUE AND RESUME)


            startTime = DateTime.Now;

            HandleWorkflowResponse();

            actionResultType = Models.ActionResultType.Control;

            System.Diagnostics.Debug.WriteLine("WorkflowStart_HandleResponse: " + DateTime.Now.Subtract(startTime).TotalMilliseconds.ToString());

            return;
        }
예제 #6
0
        /// <summary>
        /// Конструктор для состояний Ok и Error, то есть для случаев, когда необходимо вывести сообщение.
        /// </summary>
        /// <param name="action">Состояние Ok или Error.</param>
        /// <param name="message">Текст сообщения.</param>
        public ActionResult(ActionResultType action, string message)
        {
            if (action != ActionResultType.Ok && action != ActionResultType.Error)
            {
                throw new ArgumentException("Expected ActionResultType.Ok or ActionResultType.Error", nameof(action));
            }

            Subject = null;
            Object  = null;
            Action  = action;
            Message = message;
        }
예제 #7
0
        public ActionResultType <DataTable> DynamicInsertUpdate(ObjectInfoModel model)
        {
            DataTable tbResult = null;
            var       res      = new ActionResultType <DataTable>()
            {
                Data = null, Success = false
            };
            var tableInfo     = GetTableInfo(model.TableName);
            var columnNames   = tableInfo.ColumnInfos.Select(c => c.ColumnName.ToLower());
            var idField       = model.Fields.FirstOrDefault(c => c.FieldName.ToLower() == "id");
            var mappingFields = model.Fields.Where(c => columnNames.Contains(c.FieldName.ToLower()) &&
                                                   string.Compare(c.FieldName, "Id", true) != 0).ToList();

            if (!(idField != null && idField.FieldValue.ToString() != "0"))
            {
                var command       = $"insert into [{model.TableName}] ";
                var insertColumns = new List <string>();
                var valueParams   = new List <string>();
                var paramaters    = new List <SqlParameter>();
                foreach (var field in mappingFields)
                {
                    insertColumns.Add($"[{field.FieldName}]");
                    valueParams.Add($"@{field.FieldName}");
                    paramaters.Add(new SqlParameter($"@{field.FieldName}", field.FieldValue));
                }
                command += "(" + (string.Join(" , ", insertColumns)) + " ) ";
                command += $"values({string.Join(", ", valueParams)})";
                command += "    SELECT CAST(scope_identity() AS int);";
                var newId = context.ExecScalar(command, paramaters);
                tbResult = context.ExecDataTable($"select * from [{model.TableName}] where id=@id", CommandType.Text, new SqlParameter("@id", newId));
            }
            else
            {
                var command       = $"update [{model.TableName}] set ";
                var listSetValues = new List <string>();
                var paramaters    = new List <SqlParameter>();
                foreach (var field in mappingFields)
                {
                    listSetValues.Add($"[{field.FieldName}]=@{field.FieldName}");
                    paramaters.Add(new SqlParameter($"@{field.FieldName}", field.FieldValue));
                }
                paramaters.Add(new SqlParameter("@Id", idField.FieldValue));

                command += (string.Join(" , ", listSetValues));
                command += $" where id=@id";
                context.ExecScalar(command, paramaters);
                tbResult = context.ExecDataTable($"select * from [{model.TableName}] where id=@id", CommandType.Text, new SqlParameter("@id", idField.FieldValue));
            }
            return(new ActionResultType <DataTable>()
            {
                Success = true, Data = tbResult
            });
        }
예제 #8
0
        private IAimpPlaylist CreatePlaylistFromFile(ref ActionResultType result, bool isActive = true)
        {
            var playlistResult = Player.ServicePlaylistManager.CreatePlaylistFromFile(PlaylistPath, isActive);

            this.AreEqual(ActionResultType.OK, playlistResult.ResultType, "playlistResult.ResultType");
            this.NotNull(playlistResult.Result, "playlistResult.Result");

            result = playlistResult.ResultType;

            return(playlistResult.ResultType == ActionResultType.OK
                ? playlistResult.Result
                : default);
예제 #9
0
        protected void CreateNotification(ActionResultType resultType)
        {
            switch (resultType)
            {
            case ActionResultType.Success:
                TempData[resultType.ToString()] = "İşleminiz başarıyla gerçekleşti!";
                break;

            case ActionResultType.Failure:
                TempData[resultType.ToString()] = "İşleminiz gerçekleştirilirken bir hata oluştu";
                break;
            }
        }
예제 #10
0
        public void Sort_OK(PlaylistSort sort)
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType result = ActionResultType.Fail;
                var pl = CreatePlaylistFromFile(ref result);

                if (pl != null)
                {
                    result = pl.Sort(sort).ResultType;
                    this.AreEqual(ActionResultType.OK, result);
                }
            });
        }
예제 #11
0
        public void Delete_IncorrectIndex_IncorrectArgument()
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType result = ActionResultType.Fail;
                var pl = CreatePlaylistFromFile(ref result, false);

                if (pl != null)
                {
                    result = pl.Delete(-1).ResultType;
                    this.AreEqual(ActionResultType.InvalidArguments, result);
                    pl.Close(PlaylistCloseFlag.ForceRemove);
                }
            });
        }
예제 #12
0
    public void generateColor()
    {
        List <object> modifiableUI = new List <object>();

        modifiableUI.Add(sprite);
        modifiableUI.Add(label);
        if (stateMachine.CurrentState.Token == bc.ColorGeneratorFSMStateTokens.GenerateColor)
        {
            ActionResultType result = stateMachine.PerformAction(bc.ColorGeneratorFSMActionTokens.Next, modifiableUI);
            if (result == ActionResultType.Success)
            {
                countDown = waitingTime;
            }
        }
    }
예제 #13
0
        public void Get_ShouldReadValues(string path)
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType r = ActionResultType.Fail;

                if (path.EndsWith("Float"))
                {
                    var result = Player.ServiceConfig.GetValueAsFloat(path);
                    this.NotNull(() => result);
                    this.AreEqual((float)1.1, () => result.Result);
                    r = result.ResultType;
                }
                else if (path.EndsWith("Int"))
                {
                    var result = Player.ServiceConfig.GetValueAsInt32(path);
                    this.NotNull(() => result);
                    this.AreEqual(1, () => result.Result);
                    r = result.ResultType;
                }
                else if (path.EndsWith("Int64"))
                {
                    var result = Player.ServiceConfig.GetValueAsInt64(path);
                    this.NotNull(() => result);
                    this.AreEqual(2, () => result.Result);
                    r = result.ResultType;
                }
                else if (path.EndsWith("String"))
                {
                    var result = Player.ServiceConfig.GetValueAsString(path);
                    this.NotNull(() => result);
                    this.AreEqual("SomeString", () => result.Result);
                    r = result.ResultType;
                }
                else if (path.EndsWith("Stream"))
                {
                    var result = Player.ServiceConfig.GetValueAsStream(path);
                    this.NotNull(() => result);
                    this.NotNull(() => result.Result);
                    byte[] buf = new byte[result.Result.GetSize()];
                    result.Result.Read(buf, buf.Length);
                    this.AreEqual(3, buf.Length);
                    r = result.ResultType;
                }

                this.AreEqual(ActionResultType.OK, r);
            });
        }
예제 #14
0
        private void Render(ActionResultType actionResultType)
        {
            var errorMessage = _htmlHelper.ViewContext.TempData[actionResultType.ToString()];

            var ulError = new TagBuilder("ul");

            if (errorMessage != null)
            {
                var li = new TagBuilder("li");
                li.SetInnerText(errorMessage.ToString());
                ulError.InnerHtml += li;

                _htmlHelper.RenderPartial("Widget/_Notification"
                                          , new NotificationModel(actionResultType, ulError.ToString()));
            }
        }
예제 #15
0
        public void DeleteAll_OK()
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType result = ActionResultType.Fail;
                var pl = CreatePlaylistFromFile(ref result);

                if (pl != null)
                {
                    result = pl.DeleteAll().ResultType;
                    this.AreEqual(ActionResultType.OK, result, "result");

                    pl.Close(PlaylistCloseFlag.ForceRemove);
                }
            });
        }
예제 #16
0
        public void GetItemCount_ShouldReturnItemCount()
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType result = ActionResultType.Fail;
                var pl = CreatePlaylistFromFile(ref result);

                if (pl != null)
                {
                    var items = pl.GetItemCount();
                    this.AreEqual(4, items);

                    pl.Close(PlaylistCloseFlag.ForceRemove);
                }
            });
        }
예제 #17
0
        /// <summary>
        /// Creates an instance of an ActionResult
        /// </summary>
        /// <param name="type">result type</param>
        /// <param name="line">line number</param>
        /// <param name="column">column</param>
        /// <param name="message">the message</param>
        /// <param name="filename">the filename</param>
        /// <param name="code">The code.</param>
        public ActionResult(ActionResultType type, int line, int column, string message, string filename, string code)
        {
            this.code = code;
            loc       = new Location(line, column, 0, column + 1, filename);
            switch (type)
            {
            case ActionResultType.Error:
                loc.Error = true;
                break;

            case ActionResultType.Warning:
                loc.Warning = true;
                break;
            }
            this.type = type;
            msg       = message;
        }
예제 #18
0
        public void FocusedGroup_ShouldReturnSelectedFocusedGroup()
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType result = ActionResultType.Fail;
                var pl = CreatePlaylistFromFile(ref result);
                if (pl != null)
                {
                    pl.FocusIndex = 0;
                    var item      = pl.FocusedGroup;

                    this.NotNull(item);

                    pl.Close(PlaylistCloseFlag.ForceRemove);
                }
            });
        }
예제 #19
0
        public void Delete_PlayListItem_ShouldReturnOK()
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType result = ActionResultType.Fail;
                var pl            = CreatePlaylistFromFile(ref result, false);
                var getItemResult = pl.GetItem(0);

                this.AreEqual(ActionResultType.OK, getItemResult.ResultType, "Unable to get item from playlist");

                result = pl.Delete(getItemResult.Result).ResultType;

                this.AreEqual(ActionResultType.OK, result, "Unable delete playlist item from playlist");

                pl.Close(PlaylistCloseFlag.ForceRemove);
            });
        }
예제 #20
0
        public void Get_NotExist_ShouldReturnDefault(string path)
        {
            ExecuteInMainThread(
                () =>
            {
                ActionResultType r = ActionResultType.Fail;

                if (path.EndsWith("Float"))
                {
                    var result = Player.ServiceConfig.GetValueAsFloat(path);
                    this.NotNull(() => result);
                    this.AreEqual(default(float), () => result.Result);
                    r = result.ResultType;
                }
                else if (path.EndsWith("Int"))
                {
                    var result = Player.ServiceConfig.GetValueAsInt32(path);
                    this.NotNull(() => result);
                    this.AreEqual(default(int), () => result.Result);
                    r = result.ResultType;
                }
                else if (path.EndsWith("Int64"))
                {
                    var result = Player.ServiceConfig.GetValueAsInt64(path);
                    this.NotNull(() => result);
                    this.AreEqual(default(Int64), () => result.Result);
                    r = result.ResultType;
                }
                else if (path.EndsWith("String"))
                {
                    var result = Player.ServiceConfig.GetValueAsString(path);
                    this.NotNull(() => result);
                    this.Null(() => result.Result);
                    r = result.ResultType;
                }
                else if (path.EndsWith("Stream"))
                {
                    var result = Player.ServiceConfig.GetValueAsStream(path);
                    this.NotNull(() => result);
                    this.Null(() => result.Result);
                }

                this.AreEqual(ActionResultType.Fail, r);
            });
        }
예제 #21
0
        public void ContinueWorkflow(System.Collections.Specialized.NameValueCollection form)
        {
            System.DateTime startTime = DateTime.Now;

            Mercury.Server.Application.WorkflowUserInteractionResponseBase userInteractionResponse = null;


            // COMING BACK IN FROM A POSTBACK (AJAX REQUEST)

            // USE THE SELECTED WORKFLOW CONTROL TO RESTORE STATE AND VALIDATE

            System.Diagnostics.Debug.WriteLine("Workflow Control - Continue Workflow: " + workflowControl);


            // AT THIS POINT, THE WORKFLOW CONTROL HAS BEEN REBUILT AND UPDATED FROM THE CLIENT

            if (workflowControl.Contains("ContactEntity"))
            {
                userInteractionResponse = HandleUserInteraction_ContactEntity(form);
            }

            // IF USER INTERACTION RESPONSE AVAILABLE, CONTINUE WORKFLOW, OR REBUILD EXISTING PAGE

            if (userInteractionResponse != null)
            {
                WorkflowControl = String.Empty;

                workflowResponse = MercuryApplication.WorkflowContinue(WorkflowName, WorkflowInstanceId, userInteractionResponse);

                HandleWorkflowResponse();

                actionResultType = Models.ActionResultType.Control;
            }

            else
            {
                actionResultType = Models.ActionResultType.View;
            }


            System.Diagnostics.Debug.WriteLine("WorkflowContinue_HandleResponse: " + DateTime.Now.Subtract(startTime).TotalMilliseconds.ToString());

            return;
        }
예제 #22
0
        public void GetFiles_All_ShouldAllFiles()
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType result = ActionResultType.Fail;
                var pl = CreatePlaylistFromFile(ref result);

                if (pl != null)
                {
                    var getFilesResult = pl.GetFiles(PlaylistGetFilesFlag.All);
                    result             = getFilesResult.ResultType;
                    this.AreEqual(ActionResultType.OK, getFilesResult.ResultType, "result.ResultType");
                    this.NotNull(getFilesResult.Result);
                    this.AreEqual(4, getFilesResult.Result.Count);

                    pl.Close(PlaylistCloseFlag.ForceRemove);
                }
            });
        }
예제 #23
0
        private void Render(ActionResultType actionResultType)
        {
            var modelStates = _htmlHelper.ViewData.ModelState
                              .Where(x => x.Key == actionResultType.ToString()).ToList();

            var ul = new TagBuilder("ul");

            if (modelStates.Any())
            {
                foreach (var modelState in modelStates)
                {
                    var li = new TagBuilder("li");
                    li.SetInnerText(modelState.Value.Errors.FirstOrDefault().ErrorMessage);
                    ul.InnerHtml += li;
                }
                _htmlHelper.RenderPartial("Widget/_Notification"
                                          , new NotificationModel(actionResultType, ul.ToString()));
            }
        }
예제 #24
0
        public void Group_Select_ShouldToggleSelect()
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType result = ActionResultType.Fail;
                var pl = CreatePlaylistFromFile(ref result);
                if (pl != null)
                {
                    var getGroupResult = pl.GetGroup(0);

                    this.AreEqual(ActionResultType.OK, getGroupResult.ResultType);
                    this.NotNull(getGroupResult.Result);

                    this.IsFalse(getGroupResult.Result.Selected);
                    getGroupResult.Result.Selected = true;
                    this.IsTrue(getGroupResult.Result.Selected);

                    pl.Close(PlaylistCloseFlag.ForceRemove);
                }
            });
        }
예제 #25
0
        public void Group_GetItem()
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType result = ActionResultType.Fail;
                var pl = CreatePlaylistFromFile(ref result);

                if (pl != null)
                {
                    var group = GetGroup(pl, 0, ref result);

                    if (group != null)
                    {
                        var getItemResult = group.GetItem(0);
                        this.AreEqual(ActionResultType.OK, getItemResult.ResultType);
                        this.NotNull(getItemResult.Result);
                    }

                    pl.Close(PlaylistCloseFlag.ForceRemove);
                }
            });
        }
예제 #26
0
        public void Group_Expanded_ShouldToggleGroup()
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType result = ActionResultType.Fail;
                var pl = CreatePlaylistFromFile(ref result);

                if (pl != null)
                {
                    var group = GetGroup(pl, 0, ref result);

                    if (group != null)
                    {
                        this.IsTrue(group.Expanded);
                        group.Expanded = !group.Expanded;
                        this.IsFalse(group.Expanded);
                    }

                    pl.Close(PlaylistCloseFlag.ForceRemove);
                }
            });
        }
예제 #27
0
        public void GetGroup_ShouldReturnGroup()
        {
            ExecuteInMainThread(() =>
            {
                ActionResultType result = ActionResultType.Fail;
                var pl = CreatePlaylistFromFile(ref result);
                if (pl != null)
                {
                    var group = GetGroup(pl, 0, ref result);

                    if (group != null)
                    {
                        this.IsTrue(group.Name.EndsWith(@"Plugins\AimpTestRunner\resources"));
                        this.AreEqual(0, group.Index);
                        this.AreEqual(4, group.Count);
                        this.IsFalse(group.Selected);
                        this.IsTrue(group.Expanded);
                    }

                    pl.Close(PlaylistCloseFlag.ForceRemove);
                }
            });
        }
예제 #28
0
        public void Delete_ByFilter_ShouldExecuteCallback()
        {
            ExecuteInMainThread(() =>
            {
                var executed = false;

                ActionResultType result = ActionResultType.Fail;
                var pl = CreatePlaylistFromFile(ref result);

                if (pl != null)
                {
                    result = pl.Delete(PlaylistDeleteFlags.None, "track", (item, o) =>
                    {
                        executed = true;
                        return(false);
                    }).ResultType;

                    this.IsTrue(executed);

                    pl.Close(PlaylistCloseFlag.ForceRemove);
                }
            });
        }
예제 #29
0
        /// <summary>
        /// Handles the exception.
        /// </summary>
        /// <param name="ex">The ex.</param>
        /// <param name="resultType">Type of the result.</param>
        /// <param name="operationName">Name of the operation.</param>
        /// <param name="sourceFilePath">The source file path.</param>
        /// <param name="sourceLineNumber">The source line number.</param>
        /// <returns></returns>
        protected virtual ActionResult HandleException(Exception ex, ActionResultType resultType = ActionResultType.PartialView,
                                                       [CallerMemberName] string operationName   = null,
                                                       [CallerFilePath] string sourceFilePath    = null,
                                                       [CallerLineNumber] int sourceLineNumber   = 0)
        {
            var          exception = ex?.Handle(new { routeData = ControllerContext.RequestContext.RouteData.ToJson() }, operationName: operationName, sourceFilePath: sourceFilePath, sourceLineNumber: sourceLineNumber);
            ActionResult result    = null;

            if (exception != null)
            {
                if (exception.Code.Major == ExceptionCode.MajorCode.OperationFailure)
                {
                    Framework.ApiTracking?.LogException(exception.ToExceptionInfo());
                }

                switch (resultType)
                {
                case ActionResultType.PartialView:
                    result = PartialView(defaultErrorPartialView, exception.ToSimpleExceptionInfo());
                    break;

                case ActionResultType.View:
                    result = View(defaultErrorView, exception.ToSimpleExceptionInfo());
                    break;

                case ActionResultType.Default:
                case ActionResultType.Json:
                default:
                    this.PackageResponse(null, exception);
                    result = null;
                    break;
                }
            }

            return(result);
        }
예제 #30
0
        public static string GetNotificationTypeClassName(this HtmlHelper htmlHelper, ActionResultType notificationType)
        {
            switch (notificationType)
            {
            case ActionResultType.Success:
                return("success");

            case ActionResultType.Failure:
                return("danger");

            default:
                return(string.Empty);
            }
        }