<%@ WebHandler Language="C#" Class="ProPlanMana_OrderImport" %>

using System;
using System.Web;
using System.Data;

public class ProPlanMana_OrderImport : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string type = HttpContext.Current.Request["type"];
        string responseText = "";
        switch (type)
        {
            ///机型查询
            case "enginetypeSelect":
                responseText = enginetypeSelect();
                break;
            //工位号查询查询
            case "OpnameSelect":
                responseText = OpnameSelect();
                break;
            //测量范围查询
            case "dataExtentSelect":
                responseText = dataExtentSelect();
                break;
            //测量位置查询
            case "positionSelect":
                responseText = positionSelect();
                break;
            //测量项目查询
            case "projectSelect":
                responseText = projectSelect();
                break;
            //修改
            case "dataExtentUpdate":
                responseText = dataExtentUpdate();
                break;



        }
        context.Response.Write(responseText);
    }
    /// <summary>
    ///测量项目查询
    /// </summary>
    /// <returns></returns>
    private string projectSelect()
    {
        System.Data.DataTable dt = null;
        string opName = HttpContext.Current.Request["opName"];
        string position = HttpContext.Current.Request["position"];
        MES_SPC.QualityData.GetItemName(opName, position, out dt);
        string text = JsonHelper.DataTableToJson(dt);
        return text;
    }


    /// <summary>
    ///测量位置查询
    /// </summary>
    /// <returns></returns>
    private string dataExtentUpdate()
    {
        int keyIndex = Convert.ToInt32(HttpContext.Current.Request["id"]);
        string heoreticalValue = HttpContext.Current.Request["theoreticalvalue"];
        string upLimitValue = HttpContext.Current.Request["upvalue"];
        string downLimitValue = HttpContext.Current.Request["downvalue"];
        bool flag = MES_SPC.QualityData.UpdateMeasureExtent(keyIndex, heoreticalValue, upLimitValue, downLimitValue);
        if (flag)
        {
            return "{\"result\":\"1\"}";
        }
        else
        {
            return "{\"result\":\"0\"}";
        }
    }
    /// <summary>
    ///测量位置查询
    /// </summary>
    /// <returns></returns>
    private string positionSelect()
    {
        System.Data.DataTable dt = null;
        string opName = HttpContext.Current.Request["opName"];
        MES_SPC.QualityData.GetShaftName(opName, out dt);
        string text = JsonHelper.DataTableToJson(dt);
        return text;
    }
    /// <summary>
    ///工位查询
    /// </summary>
    /// <returns></returns>
    private string OpnameSelect()
    {
        System.Data.DataTable dt = null;
        MES_SPC.CraftMana_step.OpnameSelect(out dt);
        string text = JsonHelper.DataTableToJson(dt);
        return text;
    }
    /// <summary>
    ///机型查询
    /// </summary>
    /// <returns></returns>
    private string enginetypeSelect()
    {
        System.Data.DataTable dt = null;
        MES_SPC.CraftMana_step.enginetypeSelect(out dt);
        string text = JsonHelper.DataTableToJson(dt);
        return text;
    }
    /// <summary>
    /// 任务下达，更新计划订单状态为已下达
    /// </summary>
    /// <returns></returns>
    private string dataExtentSelect()
    {
        System.Data.DataTable dt = null;

        string opName = HttpContext.Current.Request["opName"];
        string engineTypeID = HttpContext.Current.Request["engineTypeID"];

        MES_SPC.QualityData.SelectMeasureExtent_simple(engineTypeID, opName, out  dt);

        string text = JsonHelper.CreateJsonParameters(dt, false, 0);//这句话是将json数据对象化，并且返回数据总条数
        return text;
    }


    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}