Esempio n. 1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            ConnectMES();
            m_AliveMoniter           = new AliveNotifier(L3Session);
            m_AliveMoniter.L3Session = L3Session;
            m_AliveMoniter.Start();

            m_Cfg = new NCDataConfig("NCData.config");
            string strDataDir  = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "DataSent");
            string strDataFail = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "DataFailed");

            Directory.CreateDirectory(strDataDir);
            Directory.CreateDirectory(strDataFail);

            ConnectMES();
            txtMESServer.Text = L3Session.ConnectionStr;
            txtNCServer.Text  = Properties.Settings.Default.NCServer;

            pbNCStatus.Image = MainResources.button_blue.ToBitmap();

            NCDataItemConfig[] datas = m_Cfg.GetDatas();
            foreach (NCDataItemConfig data in datas)
            {
                string   subtgt = data.Subscribe;
                string[] items  = subtgt.Split('.');
                L3Session.Subscribe(items[0], items[1], AppSvrIF.SubscribeType.Change);
                lstTypes.Items.Add(data);
            }
        }
Esempio n. 2
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 { }
 }
Esempio n. 3
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            frmLogin login   = new frmLogin();
            string   account = "Administrator";
            string   pwd     = "";

            if (!login.Login(ref account, ref pwd, LoginFlags.loginNormal))
            {
                return;
            }

            string connstr = string.Format("{0}:{1}", tbAddress.Text, tbPort.Text);

            int iRet = L3Session.Open(connstr, account, pwd);

            if (iRet == 0)
            {
                MessageBox.Show("连接测试成功!");
                L3Session.Close();
            }
            else
            {
                string msg = string.Format("连接测试失败!错误码:0x{0:X}", iRet);
                MessageBox.Show(msg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
        //预约班别班次
        private void SubscibeShifTeam()
        {
            if (!L3Session.Opened)
                return;

            AppSvrIF.Command cmdNull = new AppSvrIF.Command();
            cmdNull.Type = (int)AppSvrIF.CommandType.Empty;
            L3Session.Execute(cmdNull);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (flag != "999")
            {
                Log("2");
            
            L3Session.Close();
            L3Session.Dispose();
            CommDataMag.CommonMethed.FlushMemory();
        }

    }
Esempio n. 7
0
 private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     //if (L3Session.Opened)
     //{
     //    //登录时,记录账号、IP等信息
     //    string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
     //    string strsql = "insert into TS_USER_LOGIN(userid,ip,pcname,flag,version) values ('";
     //    strsql += labelUser.Text + "','" + GetLocalIP() + "','" + GetComputerName() + "','退出','" + version + "')";
     //    exeSql(L3DataAdapter, strsql);
     //}
     L3Session.Close();
     L3Session.Dispose();
     CommDataMag.CommonMethed.FlushMemory();
 }
Esempio n. 8
0
        private void OnLogout(object sender, EventArgs e)
        {
            L3Session.Close();

            labelUser.Text             = "未登录";
            menuLogin.Enabled          = true;
            menuChangePassWord.Enabled = false;
            menuLogout.Enabled         = false;

            l3DataBoxTeamID.Text  = "";
            l3DataBoxShiftID.Text = "";

            L3DataAdapter.ReCheckAccessRights();
        }
Esempio n. 9
0
 private void timer3_Tick(object sender, EventArgs e)
 {
     try
     {
         if (L3Session.Opened)
         {
             if (existms() == "否")
             {
                 timer3.Enabled = false;
                 L3Session.Close();
                 labelUser.Text             = "未登录";
                 menuLogin.Enabled          = true;
                 menuChangePassWord.Enabled = false;
                 menuLogout.Enabled         = false;
                 l3DataBoxTeamID.Text       = "";
                 l3DataBoxShiftID.Text      = "";
                 L3DataAdapter.ReCheckAccessRights();
             }
         }
     }
     catch
     {
     }
 }
Esempio n. 10
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            //frmLogin login = new frmLogin();
            string account = "Administrator";
            string pwd     = "";
            //if (!login.Login(ref account, ref pwd, LoginFlags.loginNormal))
            //    return;

            string connstr = string.Format("{0}:{1}", tbAddress.Text, tbPort.Text);

            connstr = connstr.Replace("1089", "2525");
            int iRet = L3Session.Open(connstr, account, pwd);

            if (iRet == 0)
            {
                MessageBox.Show("连接测试成功!");
                L3Session.Close();
            }
            else
            {
                string msg = string.Format("连接测试失败!错误码:0x{0:X}", iRet);
                if (msg.Contains("A0001400"))
                {
                    msg = "服务器无效或已死机!";
                }
                else if (msg.Contains("A0000402"))
                {
                    msg = "密码错误!";
                }
                else if (msg.Contains("A0000400"))
                {
                    msg = "用户名不存在!";
                }
                MessageBox.Show(msg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 11
0
        private void OnLogin(object sender, EventArgs e)
        {
            ConnectionStringSettings conn = frmConfigConnection.GetCurrentConnection();

            if (conn == null)
            {
                MessageBox.Show("没有配置服务!请先配置服务的连接。");
                return;
            }
            string connstr = conn.ConnectionString;

            connstr = connstr.Replace("1089", "2525");
            frmLogin login   = new frmLogin();
            string   account = ConfigurationManager.AppSettings["LastAccount"];
            string   pwd     = "";

            if (!login.Login(ref account, ref pwd, LoginFlags.loginNormal))
            {
                return;
            }

            int iRet = L3Session.Open(connstr, account, pwd);

            //int iRet = L3Session.Open(connstr, "10910", "xgmes");
            if (iRet != 0)
            {
                string msg = string.Format("连接服务{0}失败!错误代码:{1:X}", conn.Name, iRet);
                if (msg.Contains("A0001400"))
                {
                    msg = "服务器无效或已死机!";
                }
                else if (msg.Contains("A0000402"))
                {
                    msg = "密码错误!";
                }
                else if (msg.Contains("A0000400"))
                {
                    msg = "用户名不存在!";
                }
                MessageBox.Show(msg, "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {
                //
                timer3.Enabled = true;
                timer2.Enabled = true;
                labelUser.Text = account;
                // ConfigurationManager.AppSettings["LastAccount"] = account;
                //获取Configuration对象
                Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                config.AppSettings.Settings["LastAccount"].Value = account;
                config.Save(ConfigurationSaveMode.Modified);


                menuLogout.Enabled         = true;
                menuChangePassWord.Enabled = true;
                menuLogin.Enabled          = false;

                //校对时间
                if (cmdGetServerTime.Execute() >= 0)
                {
                    string strdt = Convert.ToString(cmdGetServerTime.Command.Return);
                    if (strdt != "")
                    {
                        SynchronousTime(strdt);
                    }
                }
                //L3DataAdapter.ReCheckAccessRights();
                //var ubof=L3Session.GetResourceRights("menuBOF");
                //if (ubof == 3)
                //{
                //    UnitMag.PublicResource.bofMenu = true;
                //}

                //var ulf = L3Session.GetResourceRights("menuLF");
                //if (ulf == 3)
                //{
                //    UnitMag.PublicResource.lfMenu = true;
                //}
                //var urh = L3Session.GetResourceRights("menuRH");
                //if (urh == 3)
                //{
                //    UnitMag.PublicResource.rhMenu = true;
                //}
                //var uccm = L3Session.GetResourceRights("menuCCM");
                //if (uccm == 3)
                //{
                //    UnitMag.PublicResource.ccmMenu = true;
                //}
                //var S = L3Session.GetResourceRights("menuBO");

                l3dbxWarning.L3DataAdapter = L3DataAdapter;

                l3dbxWarning.LoadData();

                dsTeamID.L3DataAdapter         = this.L3DataAdapter;
                dsShiftID.L3DataAdapter        = this.L3DataAdapter;
                l3DataBoxTeamID.L3DataAdapter  = null;
                l3DataBoxShiftID.L3DataAdapter = null;

                l3DataBoxTeamID.L3DataAdapter  = this.L3DataAdapter;
                l3DataBoxShiftID.L3DataAdapter = this.L3DataAdapter;

                //登录时,记录账号、IP等信息
                string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                string strsql  = "insert into TS_USER_LOGIN(userid,ip,pcname,flag,version) values ('";
                strsql += account + "','" + GetLocalIP() + "','" + GetComputerName() + "','" + existms() + "','" + version + "')";
                exeSql(L3DataAdapter, strsql);

                if (existms() == "是")
                {
                    toolStripStatusLabel4.Text = "";
                }
                else
                {
                    toolStripStatusLabel4.Text = "未安装MES监控程序,一个小时退出一次";
                }

                //add by hyh 2012-03-30  根据邢钢要求,定时修改密码,否则不应许登陆
                //try
                //{
                //    if (account.Equals("Administrator"))
                //        return;
                //    string strDateSpan = ConfigurationManager.AppSettings["PwdLockCycle"];
                //    string strCurTime = Convert.ToString(cmdGetServerTime.Command.Return);
                //    //获取上次修改密码时间
                //    cmdGetUserLastUpdPwdTime.Parameters[0].ConstantValue = account;
                //    if (pwd == "")
                //        pwd = "null";
                //    cmdGetUserLastUpdPwdTime.Parameters[1].ConstantValue = pwd;
                //    int iret = cmdGetUserLastUpdPwdTime.Execute();
                //    string strLastTime = Convert.ToString(cmdGetUserLastUpdPwdTime.Command.Return);
                //    DateTime dtCur = Convert.ToDateTime(strCurTime);
                //    DateTime dtLastTime = Convert.ToDateTime(strLastTime);
                //    TimeSpan ts = dtCur.Subtract(dtLastTime);
                //    double day = ts.TotalDays;
                //    int ttt = Convert.ToInt32(day);
                //    if (ts.TotalDays > Convert.ToDouble(strDateSpan))
                //    {
                //        MessageBox.Show("密码已过期,请联系管理员,并定期在" + strDateSpan + "天内修改密码!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //        L3Session.Close();
                //    }
                //    else if (ttt > 54)
                //    {
                //        MessageBox.Show("距密码过期还有" + Convert.ToInt32(60 - Convert.ToInt32(day)) + "天,请及时修改密码!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //    }
                //}
                //catch { return; }
                //end
            }
        }
Esempio n. 12
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);
            }
        }
Esempio n. 13
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);
                    }
                }
            }
        }
Esempio n. 14
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);
                    }
                }
            }
        }
Esempio n. 15
0
        private void OnLogin(object sender, EventArgs e)
        {
            ConnectionStringSettings conn = frmConfigConnection.GetCurrentConnection();
            if (conn == null)
            {
                MessageBox.Show("没有配置服务!请先配置服务的连接。");
                return;
            }
            string connstr = conn.ConnectionString;

            frmLogin login = new frmLogin();
            string account = ConfigurationManager.AppSettings["LastAccount"];
            string pwd = "";
            if (!login.Login(ref account, ref pwd, LoginFlags.loginNormal))
                return;

            int iRet = L3Session.Open(connstr, account, pwd);
            //int iRet = L3Session.Open(connstr, "10910", "xgmes");
            if (iRet != 0)
            {
                string msg = string.Format("连接服务{0}失败!错误代码:{1:X}", conn.Name, iRet);
                MessageBox.Show(msg, "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {

                labelUser.Text = account;
                ConfigurationManager.AppSettings["LastAccount"] = account;
                menuLogout.Enabled = true;
                menuChangePassWord.Enabled = true;
                menuLogin.Enabled = false;

                //校对时间
                if (cmdGetServerTime.Execute() >= 0)
                {
                    string strdt = Convert.ToString(cmdGetServerTime.Command.Return);
                    if (strdt != "")
                        SynchronousTime(strdt);
                }
                L3DataAdapter.ReCheckAccessRights();

                l3dbxWarning.L3DataAdapter = L3DataAdapter;
                l3dbxWarning.LoadData();

                dsTeamID.L3DataAdapter = this.L3DataAdapter;
                dsShiftID.L3DataAdapter = this.L3DataAdapter;

                l3DataBoxTeamID.L3DataAdapter = null;
                l3DataBoxShiftID.L3DataAdapter = null;

                l3DataBoxTeamID.L3DataAdapter = this.L3DataAdapter;
                l3DataBoxShiftID.L3DataAdapter = this.L3DataAdapter;

                //add by hyh 2012-03-30  根据邢钢要求,定时修改密码,否则不应许登陆
                //try
                //{
                //    if (account.Equals("Administrator"))
                //        return;
                //    string strDateSpan = ConfigurationManager.AppSettings["PwdLockCycle"];
                //    string strCurTime = Convert.ToString(cmdGetServerTime.Command.Return);
                //    //获取上次修改密码时间
                //    cmdGetUserLastUpdPwdTime.Parameters[0].ConstantValue = account;
                //    if (pwd == "")
                //        pwd = "null";
                //    cmdGetUserLastUpdPwdTime.Parameters[1].ConstantValue = pwd;
                //    int iret = cmdGetUserLastUpdPwdTime.Execute();
                //    string strLastTime = Convert.ToString(cmdGetUserLastUpdPwdTime.Command.Return);
                //    DateTime dtCur = Convert.ToDateTime(strCurTime);
                //    DateTime dtLastTime = Convert.ToDateTime(strLastTime);
                //    TimeSpan ts = dtCur.Subtract(dtLastTime);
                //    double day = ts.TotalDays;
                //    int ttt = Convert.ToInt32(day);
                //    if (ts.TotalDays > Convert.ToDouble(strDateSpan))
                //    {
                //        MessageBox.Show("密码已过期,请联系管理员,并定期在" + strDateSpan + "天内修改密码!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //        L3Session.Close();
                //    }
                //    else if (ttt > 54)
                //    {
                //        MessageBox.Show("距密码过期还有" + Convert.ToInt32(60 - Convert.ToInt32(day)) + "天,请及时修改密码!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //    }
                //}
                //catch { return; }
                //end
            }
        }