Пример #1
0
 private void ConnectMES()
 {
     if (L3Session.Opened)
     {
         pbMESStatus.Image = MainResources.button_green.ToBitmap();
     }
     else
     {
         L3Session.ConnectionStr = Properties.Settings.Default.MESServer;
         L3Session.User          = Properties.Settings.Default.Account;
         L3Session.Password      = Properties.Settings.Default.Password;
         pbMESStatus.Image       = MainResources.button_yellow.ToBitmap();
         if (L3Session.Open() != 0)
         {   // Cannot connect to AppServer
             pbMESStatus.Image = MainResources.button_red.ToBitmap();
         }
         else
         {   // Connected to AppServer
             pbMESStatus.Image = MainResources.button_green.ToBitmap();
         }
     }
     try
     {
         AppSvrIF.Command cmdNull = new AppSvrIF.Command();
         cmdNull.Type = (int)AppSvrIF.CommandType.Empty;
         L3Session.Execute(cmdNull);
     }
     catch { }
 }
Пример #2
0
        //预约班别班次
        private void SubscibeShifTeam()
        {
            if (!L3Session.Opened)
                return;

            AppSvrIF.Command cmdNull = new AppSvrIF.Command();
            cmdNull.Type = (int)AppSvrIF.CommandType.Empty;
            L3Session.Execute(cmdNull);
        }
Пример #3
0
        private void WtritReturnLogFromNC(DataSet dt)
        {
            AppSvrIF.Command cmdLog = null;
            int iRet = L3Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "WriteLogFromNC", ref cmdLog);

            if (iRet != 0)
            {
                return;
            }
            cmdLog.set_Parameters(0, dt);
            L3Session.Execute(cmdLog);
        }
Пример #4
0
        private DataSet MesDs(string strHeatID, string strMethod)
        {
            AppSvrIF.Command cmdMaterial = null;
            int iRet = L3Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", strMethod, ref cmdMaterial);

            if (iRet != 0)
            {
                return(null);
            }
            cmdMaterial.set_Parameters(0, strHeatID);
            L3Session.Execute(cmdMaterial);
            if (strMethod == "SendIronQualityJudgeInfor")
            {
                //主表
                DataSet dsMain = cmdMaterial.Return as DataSet;
                if (dsMain == null)
                {
                    return(null);
                }
                if (dsMain.Tables.Count < 1)
                {
                    return(null);
                }
                //从表1
                DataSet dsReturn1 = cmdMaterial.get_Parameters(1) as DataSet;
                if (dsReturn1 == null)
                {
                    return(null);
                }
                if (dsReturn1.Tables.Count < 1)
                {
                    return(null);
                }
                //从表2
                DataSet dsReturn2 = cmdMaterial.get_Parameters(2) as DataSet;
                if (dsReturn2 == null)
                {
                    return(null);
                }
                if (dsReturn2.Tables.Count < 1)
                {
                    return(null);
                }
                DataSet dsM = new DataSet();
                //组织主表记录集
                DataTable tbM = new DataTable();
                tbM           = dsMain.Tables[0].Clone();
                tbM           = dsMain.Tables[0].Copy();
                tbM.TableName = "M";
                dsM.Tables.Add(tbM);
                //组织从表1记录集
                DataTable tbS = new DataTable();
                tbS           = dsReturn1.Tables[0].Clone();
                tbS           = dsReturn1.Tables[0].Copy();
                tbS.TableName = "s1";
                dsM.Tables.Add(tbS);
                //组织从表2记录集
                DataTable tbS1 = new DataTable();
                tbS1           = dsReturn2.Tables[0].Clone();
                tbS1           = dsReturn2.Tables[0].Copy();
                tbS1.TableName = "s2";
                dsM.Tables.Add(tbS1);

                return(dsM);
            }
            else
            {
                //主表
                DataSet dsMain = cmdMaterial.get_Parameters(1) as DataSet;
                if (dsMain == null)
                {
                    return(null);
                }
                if (dsMain.Tables.Count < 1)
                {
                    return(null);
                }
                //从表
                DataSet dsReturn = cmdMaterial.Return as DataSet;
                if (dsReturn == null)
                {
                    return(null);
                }
                if (dsReturn.Tables.Count < 1)
                {
                    return(null);
                }
                DataSet dsM = new DataSet();
                //组织主表记录集
                DataTable tbM = new DataTable();
                tbM           = dsMain.Tables[0].Clone();
                tbM           = dsMain.Tables[0].Copy();
                tbM.TableName = "M";
                dsM.Tables.Add(tbM);
                //组织从表记录集
                DataTable tbS = new DataTable();
                tbS           = dsReturn.Tables[0].Clone();
                tbS           = dsReturn.Tables[0].Copy();
                tbS.TableName = "s1";
                dsM.Tables.Add(tbS);

                return(dsM);
            }
        }
Пример #5
0
        private void Adapter_OnObjectPropChanged(string strObj, string strProp, object newVal, object oldVal)
        {
            //取出入库时需要上传的炉次号并反写标志
            AppSvrIF.Command cmdInstore        = null;
            AppSvrIF.Command cmdInstoreComfirm = null;
            int iRet = L3Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "GetInStore", ref cmdInstore);

            if (iRet != 0)
            {
                return;
            }
            iRet = L3Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "ConfirmInStore", ref cmdInstoreComfirm);
            if (iRet != 0)
            {
                return;
            }
            L3Session.Execute(cmdInstore);
            DataSet dsInstore = cmdInstore.Return as DataSet;

            if (dsInstore != null)
            {
                if (dsInstore.Tables.Count > 0)
                {
                    DataTable tbData2 = dsInstore.Tables[0];
                    if (tbData2.Rows.Count > 0)
                    {
                        foreach (DataRow tbrow in tbData2.Rows)
                        {
                            tbrow["NC_Confirm_Flag"] = "1";
                        }
                        InStoredt.Merge(tbData2);
                        cmdInstoreComfirm.set_Parameters(0, dsInstore);
                        L3Session.Execute(cmdInstoreComfirm);
                    }
                }
            }

            //取出铁水需要上传的炉次号并反写标志
            AppSvrIF.Command cmdIron        = null;
            AppSvrIF.Command cmdIronComfirm = null;
            iRet = L3Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "GetIron", ref cmdIron);
            if (iRet != 0)
            {
                return;
            }
            iRet = L3Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "ConfirmIron", ref cmdIronComfirm);
            if (iRet != 0)
            {
                return;
            }
            L3Session.Execute(cmdIron);
            DataSet dsIron = cmdIron.Return as DataSet;

            if (dsIron != null)
            {
                if (dsIron.Tables.Count > 0)
                {
                    DataTable tbData = dsIron.Tables[0];
                    if (tbData.Rows.Count > 0)
                    {
                        Irondt.Merge(tbData);
                        cmdIronComfirm.set_Parameters(0, dsIron);
                        L3Session.Execute(cmdIronComfirm);
                    }
                }
            }

            //取出库内改判炉号并反写标志
            AppSvrIF.Command cmdQuality        = null;
            AppSvrIF.Command cmdQualityComfirm = null;
            iRet = L3Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "GetInStoreQuality", ref cmdQuality);
            if (iRet != 0)
            {
                return;
            }
            iRet = L3Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "ConfirmInStoreQuality", ref cmdQualityComfirm);
            if (iRet != 0)
            {
                return;
            }
            L3Session.Execute(cmdQuality);
            DataSet dsQuality = cmdQuality.Return as DataSet;

            if (dsQuality != null)
            {
                if (dsQuality.Tables.Count > 0)
                {
                    DataTable tbData1 = dsQuality.Tables[0];
                    if (tbData1.Rows.Count > 0)
                    {
                        foreach (DataRow tbrow in tbData1.Rows)
                        {
                            tbrow["NC_Confirm_Flag"] = "1";
                        }
                        Qualitydt.Merge(tbData1);
                        cmdQualityComfirm.set_Parameters(0, dsQuality);
                        L3Session.Execute(cmdQualityComfirm);
                    }
                }
            }

            //取出全回炉时需要上传的炉次号并反写标志
            AppSvrIF.Command cmdAll        = null;
            AppSvrIF.Command cmdAllComfirm = null;
            iRet = L3Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "GetAllReturn", ref cmdAll);
            if (iRet != 0)
            {
                return;
            }
            iRet = L3Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "ConfirmAllReturn", ref cmdAllComfirm);
            if (iRet != 0)
            {
                return;
            }
            L3Session.Execute(cmdAll);
            DataSet dsAll = cmdAll.Return as DataSet;

            if (dsAll != null)
            {
                if (dsAll.Tables.Count > 0)
                {
                    DataTable tbData3 = dsAll.Tables[0];
                    if (tbData3.Rows.Count > 0)
                    {
                        foreach (DataRow tbrow in tbData3.Rows)
                        {
                            tbrow["NC_Confirm_Flag"] = "1";
                        }
                        Allreturndt.Merge(tbData3);
                        cmdAllComfirm.set_Parameters(0, dsAll);
                        L3Session.Execute(cmdAllComfirm);
                    }
                }
            }
        }
Пример #6
0
        private void MesAllReturnSendToNC()
        {
            string    strXslt = "";
            string    Method  = "";
            DataTable dt      = new DataTable();

            dt = Allreturndt.Copy();
            Allreturndt.Clear();
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string strHeatID = dt.Rows[i]["HeatID"].ToString();
                    string strType   = "1";
                    //订单
                    strXslt = @"MillPlanToNC.xslt";
                    AppSvrIF.Command cmdPlanOrder = null;
                    int iRet = L3Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "SendPlanInfor", ref cmdPlanOrder);
                    if (iRet != 0)
                    {
                        continue;
                    }
                    cmdPlanOrder.set_Parameters(0, strHeatID);
                    L3Session.Execute(cmdPlanOrder);

                    DataSet dsPlanOrder = cmdPlanOrder.Return as DataSet;
                    if (dsPlanOrder != null && dsPlanOrder.Tables.Count > 0 && dsPlanOrder.Tables[0].Rows.Count > 0)
                    {
                        string strXML = TranslateDataSetToNC(strXslt, dsPlanOrder);
                        TransferXML(strXML, strHeatID, strType, strXslt);
                    }
                    else
                    {
                        dsLog.Clear();
                        DataRow row = dsLog.Tables[0].NewRow();
                        row["HeatID"]   = strHeatID;
                        row["BillType"] = strXslt;
                        row["Other1"]   = strType;
                        row["Flag"]     = "1";
                        row["Remark"]   = "在MES中没有查询出相应的数据";
                        dsLog.Tables[0].Rows.Add(row);
                        WtritReturnLogFromNC(dsLog);
                    }
                    //投料
                    strXslt = @"BOFAddMaterialsInforToNC.xslt";
                    Method  = "SendAddMaterialsInfor";
                    DataSet dsM = new DataSet();
                    dsM = MesDs(strHeatID, Method);
                    if (dsM != null)
                    {
                        string strXML = TranslateDataSetToNC(strXslt, dsM);
                        TransferXML(strXML, strHeatID, strType, strXslt);
                    }
                    else
                    {
                        dsLog.Clear();
                        DataRow row = dsLog.Tables[0].NewRow();
                        row["HeatID"]   = strHeatID;
                        row["BillType"] = strXslt;
                        row["Other1"]   = strType;
                        row["Flag"]     = "1";
                        row["Remark"]   = "在MES中没有查询出相应的数据";
                        dsLog.Tables[0].Rows.Add(row);
                        WtritReturnLogFromNC(dsLog);
                    }

                    //完工
                    strXslt = @"BloomInfor.xslt";
                    Method  = "SendBloomInfor";
                    DataSet dsB = new DataSet();
                    dsB = MesDs(strHeatID, Method);
                    if (dsB != null)
                    {
                        string strXML = TranslateDataSetToNC(strXslt, dsB);
                        TransferXML(strXML, strHeatID, strType, strXslt);
                    }
                    else
                    {
                        dsLog.Clear();
                        DataRow row = dsLog.Tables[0].NewRow();
                        row["HeatID"]   = strHeatID;
                        row["BillType"] = strXslt;
                        row["Other1"]   = strType;
                        row["Flag"]     = "1";
                        row["Remark"]   = "在MES中没有查询出相应的数据";
                        dsLog.Tables[0].Rows.Add(row);
                        WtritReturnLogFromNC(dsLog);
                    }

                    //入库
                    strXslt = @"BloomInStoreInfor.xslt";
                    Method  = "SendBloomInStoreInfor";
                    DataSet dsI = new DataSet();
                    dsI = MesDs(strHeatID, Method);
                    if (dsI != null)
                    {
                        string strXML = TranslateDataSetToNC(strXslt, dsI);
                        TransferXML(strXML, strHeatID, strType, strXslt);
                    }
                    else
                    {
                        dsLog.Clear();
                        DataRow row = dsLog.Tables[0].NewRow();
                        row["HeatID"]   = strHeatID;
                        row["BillType"] = strXslt;
                        row["Other1"]   = strType;
                        row["Flag"]     = "1";
                        row["Remark"]   = "在MES中没有查询出相应的数据";
                        dsLog.Tables[0].Rows.Add(row);
                        WtritReturnLogFromNC(dsLog);
                    }
                }
            }
        }