using RFrameGenerate.BLL;
using RFrameGenerate.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace jiouosdp.Areas.Distribution.Controllers
{
    public class DistributionSetController : Controller
    {
        //
        // GET: /Distribution/DistributionSet/

        [PF(PCode.DistributionManage.DistributionSet)]
        public ActionResult Index()
        {
            return View();
        }
        public JsonResult UpdateParameterSetting(string parameterName, string parameterValue)
        {
            Result result = new Result(false);
            var names = parameterName.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            var values = parameterValue.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            using (var tran = new RFramework.SQLServer.SqlRTransaction())
            {
                for (var i = 0; i < names.Length; i++)
                {
                    string name = names[i];
                    string value = values[i];
                    result = ParameterManage.UpdateParam(name, value);
                    if (result.State != true)
                    {
                        break;
                    }
                }
            }
            if (result.State == true)
                return Json(new { Result = "OK" });
            else
                return Json(new { Result = "OK", Msg = result.Msg });

        }
    }
}
