コード例 #1
0
        private void ReorderScale(HttpContext context)
        {
            string xPath = context.Request.Params["XPath"];

            // Get the source string from the http request's parameters.
            string source = context.Request.Params["Source"];

            DefinitionObject score = new DefinitionObject(Global.Core, source, xPath);

            int order = int.Parse(context.Request.Params["Order"]);

            int oldOrder = int.Parse(score.GetValue("Order").ToString());

            score.SetValue("Order", order);
            score.Save();

            DefinitionObject[] scores = score.GetParent().GetChilds();
            foreach (DefinitionObject _score in scores)
            {
                int _order = int.Parse(_score.GetValue("Order").ToString());

                if (_order < order)
                {
                    continue;
                }

                if (_order >= oldOrder)
                {
                    continue;
                }

                if (_score.GetValue("Id") == score.GetValue("Id"))
                {
                    continue;
                }

                _score.SetValue(
                    "Order",
                    (_order + 1)
                    );

                _score.Save();
            }

            ReOrderScores(scores.OrderBy(x => int.Parse(x.GetValue("Order").ToString())).ToArray());
        }