1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.OracleClient;
- using System.Runtime.InteropServices;
- using System.Text;
- namespace BenQGuru.eMES.DLLService
- {
- [Guid("99D0E96E-1058-415D-9874-D34537625284")]
- [InterfaceType(ComInterfaceType.InterfaceIsDual)]
- public interface IMESHelper
- {
- [DispId(12)]
- bool CheckRoutePassed(string iSN, string iResCode, out string oErrMessage);
- bool GetRcardMOInfo(string iSN, out string oMoCode, out string oErrMessage);
- bool GetMaster(out string Master);
- bool SetMaster(string Master);
- bool CheckUserAndResourcePassed(string iUserCode, string iResCode, string iPassWord, out string oErrMessage);
- bool GetAddressRangeByMO(string iSN, out string oWIFI, out string oBT, out string oCode1, out string oCode2, out string oCdoe3, out string oErrMessage);
- bool SetAddressInfo(string iSN, string iWIFI, string iBT, string iCode1, string iCode2, string iCode3, out string oErrorMessage);
- bool SetTestDetail(string iSN, string iTestResult, string iResCode, ref string[] iTestDetail, out string oErrMessage);
- bool GetMEIOrNetCodeRange(string iSnCode, string iIMEI1, string iNetCode, out string oIMEI1, out string oIMEI2, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oID4, out string oID5, out string oErrMessage);
- bool SetIMEIInfo(string iSnCode, string iIMEI1, out string oErrMessage);
- bool GetMobileAllInfo(string iSnCode, out string oWIFI, out string oBT, out string oCode1, out string oCode2, out string oCode3, out string oIMEI1, out string oIMEI2, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oID4, out string oID5, out string oErrorMessage);
- bool SetMobileData(string iTSN, string iSN, string iSourceCode, string iOperator, string iResult, string iErrCode, string flag, out string oErrorMessage);
- bool SetPcbaData(string iSN, string iResCode, string iOperator, string iResult, string iErrCode, out string oErrMessage);
- bool GoMo(string iMO, string iSN, string iResCode, out string oErrMessage);
- }
- [Guid("41EAB546-6EF4-464A-895A-9C34013A5D8C")]
- [ComSourceInterfaces(typeof(IMESHelper))]
- [ClassInterface(ClassInterfaceType.None)]
- [ProgId("DllService.MESHelper")]
- public class MESHelper : IMESHelper
- {
-
- StringBuilder sql = new StringBuilder();
-
- List<string> sqls = new List<string>();
-
- private string ConnectionStrings = "Data Source=192.168.230.200/orcl;User ID=MES;PassWord=select!#%*(;";
-
- private OracleConnection connection;
-
- private OracleCommand command = null;
- DataTable MasterDB;
- public MESHelper()
- {
- connection = new OracleConnection(ConnectionStrings);
- }
-
-
-
-
-
-
-
- public bool CheckRoutePassed(string iSN, string iResCode, out string oErrMessage)
- {
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string[] param = new string[] { "", iResCode, iSN, "", "", "", oErrMessage };
- string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
- CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
- oErrMessage = param[6];
- DataTable dt = (DataTable)ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')", "select");
- string ms_status = "";
- string ms_stepcode = "";
- string ms_nextstepcode = "";
- if (dt.Rows.Count > 0)
- {
- ms_status = dt.Rows[0]["ms_status"].ToString();
- ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
- ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
- }
- string stepcode = GetStepCodeBySource(iResCode);
- if (ms_nextstepcode != "" && ms_nextstepcode != stepcode)
- {
- oErrMessage = "当前序列号下一工序" + ms_nextstepcode;
- return false;
- }
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || (ms_status == "3" && ms_stepcode == stepcode))
- {
- if (ms_status == "3")
- {
- oErrMessage = "";
- }
- return true;
- }
- else
- return false;
- }
-
-
-
-
-
-
- private bool CheckUserLogin(string iUserCode, string iPassWord, out string oErrorMessage)
- {
- oErrorMessage = "";
- string SQL = "select em_code from employee where em_code=:UserName and em_password =:PassWord";
- DataTable dt;
- dt = (DataTable)ExecuteSql(SQL, "select", iUserCode, iPassWord);
- if (dt.Rows.Count > 0)
- return true;
- else
- {
- oErrorMessage = "用户名或者密码不正确!";
- return false;
- }
- }
-
-
-
-
-
-
-
- public bool CheckUserAndResourcePassed(string iUserCode, string iResCode, string iPassWord, out string oErrMessage)
- {
- oErrMessage = "";
- if (iUserCode == "" || iPassWord == "" || iResCode == "")
- {
- oErrMessage = "用户名,密码,岗位资源必须填写";
- return false;
- }
- if (CheckUserLogin(iUserCode, iPassWord, out oErrMessage))
- {
- string SQL = "select em_code,em_type,em_name from employee where em_code=:UserName ";
- DataTable dt;
- dt = (DataTable)ExecuteSql(SQL, "select", iUserCode);
- if (dt.Rows.Count > 0)
- {
- string em_name = dt.Rows[0]["em_name"].ToString();
- string em_type = dt.Rows[0]["em_type"].ToString();
- if (iResCode == "")
- {
- oErrMessage = "岗位资源不允许为空";
- return false;
- }
- if (em_type == "admin")
- {
- if (CheckExist("Source", "sc_code='" + iResCode + "' and sc_statuscode='AUDITED'"))
- {
- return true;
- }
- else
- {
- oErrMessage = "岗位资源编号错误或者未审核!";
- return false;
- }
- }
- else
- {
- dt = getFieldsDatasByCondition("cs$empgroup left join cs$userresource on ur_groupcode=eg_groupcode left join source on ur_resourcecode=sc_code", new string[] { "ur_resourcecode" }, "eg_emcode = '" + iUserCode + "' and sc_statuscode='AUDITED'");
-
- if (dt.Rows.Count > 0)
- {
-
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i]["ur_resourcecode"].ToString() == iResCode)
- return true;
- }
- oErrMessage = "用户不处于当前资源所属分组!";
- }
- else
- oErrMessage = "岗位资源编号错误或者未审核!";
- }
- }
- else
- oErrMessage = "用户不存在!";
- }
- return false;
- }
-
-
-
-
-
-
-
-
-
-
-
- public bool GetAddressRangeByMO(string iSN, out string oWIFI, out string oBT, out string oCode1, out string oCode2, out string oCdoe3, out string oErrMessage)
- {
- oWIFI = "";
- oBT = "";
- oCode1 = "";
- oCode2 = "";
- oCdoe3 = "";
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string omakeCode = "";
- GetRcardMOInfo(iSN, out omakeCode, out oErrMessage);
- string[] param = new string[] { iSN, omakeCode, oWIFI, oBT, oCode1, oCode2, oCdoe3, oErrMessage };
- string[] ParamName = new string[] { "v_i_sncode", "v_i_macode", "v_o_mac", "v_o_bt", "v_o_code1", "v_o_code2", "v_o_code3", "v_o_errmsg" };
- CallProcedure("CS_GETADDRESSBYMAKECODE", ParamName, ref param);
- oWIFI = param[2];
- oBT = param[3];
- oCode1 = param[4];
- oCode2 = param[5];
- oCdoe3 = param[6];
- oErrMessage = param[7];
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
- return true;
- else
- return false;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public bool GetMEIOrNetCodeRange(string iSN, string iIMEI1, string iNetCode, out string oIMEI1, out string oIMEI2, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oID4, out string oID5, out string oErrMessage)
- {
- oIMEI1 = "";
- oIMEI2 = "";
- oMEID = "";
- oNetCode = "";
- oPSN = "";
- oID1 = "";
- oID2 = "";
- oID3 = "";
- oID4 = "";
- oID5 = "";
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string[] param = new string[] { iSN, "", iIMEI1, iNetCode, oIMEI1, oIMEI2, "", oMEID, oNetCode, oPSN, oID1, oID2, oID3, oErrMessage };
- string[] ParamName = new string[] { "v_i_sncode", "v_i_macode", "v_i_imei", "v_i_netcode", "v_o_imei1", "v_o_imei2", "v_o_imei3", "v_o_meid", "v_o_netcode", "v_o_psn", "v_o_id1", "v_o_id2", "v_o_id3", "v_o_errmsg" };
- CallProcedure("CS_GETIMEIORNETCODERANGE", ParamName, ref param);
- oIMEI1 = param[4];
- oIMEI2 = param[5];
- oMEID = param[7];
- oNetCode = param[8];
- oPSN = param[9];
- oID1 = param[10];
- oID2 = param[11];
- oID3 = param[12];
- oErrMessage = param[13];
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
- return true;
- else
- return false;
- }
-
-
-
-
-
-
-
- public bool GetRcardMOInfo(string iSN, out string oMoCode, out string oErrMessage)
- {
-
- oMoCode = "";
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- sql.Length = 0;
- sql.Append("select max(ms_id) from makeserial where ms_sncode in (select '" + iSN + "' from dual union select ");
- sql.Append("beforesn from makesnrelation where sn='" + iSN + "' and beforesn<>' ')");
- DataTable dt = (DataTable)ExecuteSql(sql.ToString(), "select");
- string ms_id = dt.Rows[0][0].ToString();
- oMoCode = getFieldDataByCondition("MakeSerial", "ms_makecode", "ms_id='" + ms_id + "'").ToString();
- if (oMoCode != "")
- return true;
- else
- {
- oErrMessage = "序列号:" + iSN + " 未归属工单";
- return false;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public bool GetMobileAllInfo(string iSN, out string oWIFI, out string oBT, out string oCode1, out string oCode2, out string oCode3, out string oIMEI1, out string oIMEI2, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oID4, out string oID5, out string oErrMessage)
- {
- oBT = "";
- oMEID = "";
- oWIFI = "";
- oPSN = "";
- oNetCode = "";
- oIMEI1 = "";
- oIMEI2 = "";
- oCode1 = "";
- oCode2 = "";
- oCode3 = "";
- oID1 = "";
- oID2 = "";
- oID3 = "";
- oID4 = "";
- oID5 = "";
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
-
- string ms_id = getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode='" + iSN + "'").ToString();
- if (ms_id != "")
- {
- DataTable dt = getFieldsDataByCondition("MakeSerial", new string[] { "ms_id", "ms_mac", "ms_bt", "ms_meid", "ms_netcode", "ms_psn", "ms_imei1", "ms_imei2", "ms_imei3", "ms_othcode1", "ms_othcode2", "ms_othcode3", "ms_othid1", "ms_othid2", "ms_othid3" }, "ms_id='" + ms_id + "'");
- if (dt.Rows.Count > 0)
- {
- oWIFI = dt.Rows[0]["ms_mac"].ToString();
- oBT = dt.Rows[0]["ms_bt"].ToString();
- oPSN = dt.Rows[0]["ms_psn"].ToString();
- oNetCode = dt.Rows[0]["ms_netcode"].ToString();
- oMEID = dt.Rows[0]["ms_meid"].ToString();
- oIMEI1 = dt.Rows[0]["ms_imei1"].ToString();
- oIMEI2 = dt.Rows[0]["ms_imei2"].ToString();
- oCode1 = dt.Rows[0]["ms_othcode1"].ToString();
- oCode2 = dt.Rows[0]["ms_othcode2"].ToString();
- oCode3 = dt.Rows[0]["ms_othcode3"].ToString();
- oID1 = dt.Rows[0]["ms_othid3"].ToString();
- oID2 = dt.Rows[0]["ms_othid3"].ToString();
- oID3 = dt.Rows[0]["ms_othid3"].ToString();
- oErrMessage = "";
- return true;
- }
- else
- {
- oErrMessage = "序列号" + iSN + "不存在";
- return false;
- }
- }
- else
- {
- oErrMessage = "序列号" + iSN + "不存在";
- return false;
- }
- }
-
-
-
-
-
-
-
-
- private void InsertMakeProcess(string iSnCode, string iMakeCode, string iSourceCode, string iMPKind, string result, string iUserCode)
- {
- string CurrentStep = "";
- string LineCode = "";
- string CurrentStepName = "";
- GetStepCodeAndNameAndLineBySource(iSourceCode, ref CurrentStep, ref CurrentStepName, ref LineCode);
- sql.Length = 0;
- sql.Append("insert into MakeProcess(mp_id,mp_makecode,mp_maid, mp_mscode,mp_sncode,mp_stepcode,mp_stepname,");
- sql.Append("mp_craftcode,mp_craftname,mp_kind,mp_result,mp_indate,mp_inman,mp_wccode,mp_linecode,mp_sourcecode,mp_snstatus,mp_sncheckno,mp_snoutboxcode)");
- sql.Append("select MakeProcess_seq.nextval, ma_code,ma_id,ms_code,ms_sncode,'" + CurrentStep + "','" + CurrentStepName + "',");
- sql.Append("ma_craftcode,ma_craftname,'" + iMPKind + "','" + result + "',sysdate,'" + iUserCode + "',ma_wccode,'" + LineCode + "','" + iSourceCode + "',");
- sql.Append("ms_status,ms_checkno,ms_outboxcode from make left join makeserial on ms_makecode=ma_code left join step on st_code=ms_stepcode ");
- sql.Append("where ms_sncode='" + iSnCode + "' and ma_code='" + iMakeCode + "' and st_code='" + CurrentStep + "'");
- ExecuteSql(sql.ToString(), "insert");
- }
-
-
-
-
-
-
-
-
-
-
-
- public bool SetAddressInfo(string iSN, string iWIFI, string iBT, string iCode1, string iCode2, string iCode3, out string oErrMessage)
- {
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string[] param = new string[] { iSN, iWIFI, iBT, iCode1, iCode2, iCode3, oErrMessage };
- string[] ParamName = new string[] { "v_i_sncode", "v_i_mac", "v_i_bt", "v_i_code1", "v_i_code2", "v_i_code3", "v_o_errmsg" };
- CallProcedure("CS_SETADDRESSINFO", ParamName, ref param);
- oErrMessage = param[6];
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
- return true;
- else
- return false;
- }
- public bool SetStepFinish(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, string iErrCode, out string oErrMessage)
- {
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string StepCode = getFieldDataByCondition("Makeserial", "ms_stepcode", "ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'").ToString();
- string CurrentStep = GetStepCodeBySource(iSourceCode);
- string BgCode = getFieldDataByCondition("step", "st_badgroupcode", "st_code='" + CurrentStep + "'").ToString();
- switch (iResult)
- {
- case "OK":
- break;
- case "NG":
- if (iErrCode == "")
- {
- oErrMessage = "测试结果为NG时必须传递不良代码";
- return false;
- }
- else
- {
- UpdateByCondition("makebad", "mb_status=-1", "mb_sncode='" + iSN + "' and mb_makecode='" + iMakeCode + "' and mb_stepcode='" + CurrentStep + "' and mb_status=0");
- string[] BadCode = iErrCode.Split(',');
- sql.Length = 0;
- sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
- sql.Append(",mb_sourcecode,mb_badcode,mb_badtable,mb_bgcode,mb_soncode,mb_status) select makebad_seq.nextval");
- sql.Append(",ma_code,ms_code,ms_sncode,'" + iUserCode + "',sysdate,'" + CurrentStep + "','" + iSourceCode + "',:bc_code,'',");
- sql.Append("'" + BgCode + "',sp_soncode,'0' from make left join makeSerial on ms_makecode=ma_code left join stepProduct on ");
- sql.Append("sp_mothercode=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'");
- List<string> InsertSQL = new List<string>();
- for (int i = 0; i < BadCode.Length; i++)
- {
- InsertSQL.Add(sql.ToString().Replace(":bc_code", "'" + BadCode[i] + "'"));
- }
- ExecuteSQLTran(InsertSQL.ToArray());
-
- ExecuteSql("update makeserial set ms_status='3' where ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'", "update");
- }
- break;
- default:
- oErrMessage = "测试结果必须为NG或者OK";
- return false;
- }
-
- if (StepCode == CurrentStep && iResult == "OK")
- {
- DataTable dt = getFieldsDataByCondition("makeserial", new string[] { "ms_status", "ms_craftcode", "ms_prodcode" }, "ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'");
- if (dt.Rows.Count > 0)
- {
- string ms_status = dt.Rows[0]["ms_status"].ToString();
- string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
- string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
- if (ms_status == "3")
- {
- string nextstepcode = getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid ", "cd_nextstepcode", "cr_code='" + ms_craftcode + "' and cr_prodcode='" + ms_prodcode + "' and cd_stepcode='" + CurrentStep + "'").ToString();
- UpdateByCondition("makeserial", "ms_status=1,ms_nextstepcode='" + nextstepcode + "'", "ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'");
- UpdateByCondition("makebad", "mb_status=-1", "mb_sncode='" + iSN + "' and mb_makecode='" + iMakeCode + "'");
- }
- }
- }
- return CS_SetFinish(iMakeCode, iSourceCode, iSN, iUserCode, iResult, out oErrMessage);
- }
-
-
-
-
-
-
-
-
-
-
-
- public bool SetMobileData(string iTSN, string iSN, string iSourceCode, string iOperater, string iResult, string iErrCode, string flag, out string oErrorMessage)
- {
- oErrorMessage = "";
- if (iTSN == "") { oErrorMessage = "TSN不能为空"; return false; }
- if (iSN == "") { oErrorMessage = "SN不能为空"; return false; }
- string[] param = new string[] { iTSN, iSN, iSourceCode, iOperater, iResult, iErrCode, oErrorMessage };
- string[] ParamName = new string[] { "v_i_tsn", "v_i_sncode", "v_i_sourcecode", "v_i_usercode", "v_i_result", "v_i_errcode", "v_o_errmsg" };
- CallProcedure("CS_DLLSNCHANGE", ParamName, ref param);
- oErrorMessage = param[6];
- if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
- return true;
- else
- return false;
- }
- private bool CS_SetFinish(string iMakeCode, string iSourceCode, string iSN, string iUserCode, string iResult, out string oErrMessage)
- {
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, iResult, oErrMessage };
- string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_i_result", "v_o_errmsg" };
- CallProcedure("CS_SETSTEPRESULT", ParamName, ref param);
- oErrMessage = param[5];
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
- return true;
- else
- return false;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public bool SetTestDetail(string iSN, string iTestResult, string iResCode, ref string[] iTestDetail, out string oErrMessage)
- {
- if (iSN == "" || iSN == null)
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string omakeCode;
- GetRcardMOInfo(iSN, out omakeCode, out oErrMessage);
- sql.Length = 0;
- sql.Append("begin ");
- for (int i = 0; i < iTestDetail.Length; i++)
- {
- sql.Append("Insert into STEPTESTDETAIL (STD_ID,STD_CLASS,STD_SN,STD_MAKECODE,STD_ACTUALVALUE,STD_TESTRESULT,STD_INDATE,STD_RESCODE)");
- sql.Append("values(STEPTESTDETAIL_SEQ.nextval,'ITEM" + i + "','" + iSN + "','" + omakeCode + "','" + iTestDetail[i] + "','" + iTestResult + "',sysdate,'" + iResCode + "');");
- }
- sql.Append("end;");
- ExecuteSql(sql.ToString(), "insert");
- return true;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public bool SetIMEIInfo(string iSN, string iIMEI1, out string oErrMessage)
- {
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string[] param = new string[] { iSN, iIMEI1, "", "", "", "", "", "", "", "", oErrMessage };
- string[] ParamName = new string[] { "v_i_sncode", "v_i_imei1", "v_i_imei2", "v_i_imei3", "v_i_meid", "v_i_netcode", "v_i_psn", "v_i_id1", "v_i_id2", "v_i_id3", "v_o_errmsg" };
- CallProcedure("CS_SETIMEIINFO", ParamName, ref param);
- oErrMessage = param[10];
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
- return true;
- else
- return false;
- }
-
-
-
-
-
-
-
-
-
-
- public bool SetPcbaData(string iSN, string iResCode, string iOperator, string iResult, string iErrCode, out string oErrMessage)
- {
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string oMakeCode = "";
- GetRcardMOInfo(iSN, out oMakeCode, out oErrMessage);
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
- return SetStepFinish(oMakeCode, iResCode, iSN, "", iResult, iOperator, iErrCode, out oErrMessage);
- else
- return false;
- }
- public bool GoMo(string iMO, string iSN, string iResCode, out string oErrMessage)
- {
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string[] param = new string[] { iMO, iResCode, iSN, "", "", "", oErrMessage };
- string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
- CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
- oErrMessage = param[6];
- DataTable dt = (DataTable)ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')", "select");
- string ms_status = "";
- string ms_stepcode = "";
- string ms_nextstepcode = "";
- if (dt.Rows.Count > 0)
- {
- ms_status = dt.Rows[0]["ms_status"].ToString();
- ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
- ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
- }
- string stepcode = GetStepCodeBySource(iResCode);
- if (ms_nextstepcode != "" && ms_nextstepcode != stepcode)
- {
- oErrMessage = "当前序列号下一工序" + ms_nextstepcode;
- return false;
- }
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || (ms_status == "3" && ms_stepcode == stepcode))
- {
- if (ms_status == "3")
- {
- oErrMessage = "";
- }
- return true;
- }
- else
- return false;
- }
-
-
-
-
-
-
-
- private void GetStepCodeAndNameAndLineBySource(string Source, ref string StepCode, ref string StepName, ref string LineCode)
- {
- DataTable dt = getFieldsDataByCondition("source", new string[] { "sc_stepcode", "sc_stepname", "sc_linecode" }, "sc_code='" + Source + "'");
- if (dt.Rows.Count > 0)
- {
- StepCode = dt.Rows[0]["sc_stepcode"].ToString();
- StepName = dt.Rows[0]["sc_stepname"].ToString();
- LineCode = dt.Rows[0]["sc_linecode"].ToString();
- }
- }
-
-
-
-
-
-
- private void GetStepCodeAndNameBySource(string Source, ref string StepCode, ref string StepName)
- {
- DataTable dt = getFieldsDataByCondition("source", new string[] { "sc_stepcode", "sc_stepname", "sc_linecode" }, "sc_code='" + Source + "'");
- if (dt.Rows.Count > 0)
- {
- StepCode = dt.Rows[0]["sc_stepcode"].ToString();
- StepName = dt.Rows[0]["sc_stepname"].ToString();
- }
- }
-
-
-
-
-
- private string GetStepCodeBySource(string Source)
- {
- return getFieldDataByCondition("source", "sc_stepcode", "sc_code='" + Source + "'").ToString();
- }
-
-
-
- private object getFieldDataByCondition(string TableName, string Field, string Condition)
- {
- DataTable dt = new DataTable();
- string sql = "select " + Field + " from " + TableName + " where " + Condition;
- command = new OracleCommand(sql, connection);
- Reconnect(command);
- OracleDataAdapter ad = new OracleDataAdapter();
- ad.SelectCommand = command;
- try
- {
- ad.Fill(dt);
- }
- catch (Exception)
- {
- connection = new OracleConnection(ConnectionStrings);
- connection.Open();
- command = new OracleCommand(sql, connection);
- ad = new OracleDataAdapter();
- ad.SelectCommand = command;
- ad.Fill(dt);
- }
- ad.Dispose();
- command.Dispose();
- if (dt.Rows.Count > 0)
- {
- return dt.Rows[0][0];
- }
- else
- {
- return "";
- }
- }
-
-
-
- private DataTable getFieldsDataByCondition(string TableName, string[] Fields, string Condition)
- {
- DataTable dt = new DataTable();
- string sql = "select ";
- sql += AddField(Fields);
- sql += " from " + TableName + " where " + Condition + " and rownum=1";
- command = new OracleCommand(sql, connection);
- Reconnect(command);
- OracleDataAdapter ad = new OracleDataAdapter(command);
- try
- {
- ad.Fill(dt);
- }
- catch (Exception)
- {
- connection = new OracleConnection(ConnectionStrings);
- connection.Open();
- command = new OracleCommand(sql, connection);
- ad = new OracleDataAdapter();
- ad.SelectCommand = command;
- ad.Fill(dt);
- }
- ad.Dispose();
- command.Dispose();
- return dt;
- }
-
-
-
- private DataTable getFieldsDatasByCondition(string TableName, string[] Fields, string Condition)
- {
- DataTable dt = new DataTable();
- string sql = "select ";
- sql += AddField(Fields);
- sql += " from " + TableName + " where " + Condition;
- command = new OracleCommand(sql, connection);
- Reconnect(command);
- OracleDataAdapter ad = new OracleDataAdapter(command);
- try
- {
- ad.Fill(dt);
- }
- catch (Exception)
- {
- connection = new OracleConnection(ConnectionStrings);
- connection.Open();
- command = new OracleCommand(sql, connection);
- ad = new OracleDataAdapter();
- ad.SelectCommand = command;
- ad.Fill(dt);
- }
- ad.Dispose();
- command.Dispose();
- return dt;
- }
-
-
-
- private DataTable getFieldsDatas(string TableName, string Fields)
- {
- DataTable dt = new DataTable();
- string sql = "select ";
- sql += Fields;
- sql += " from " + TableName;
- command = new OracleCommand(sql, connection);
- Reconnect(command);
- OracleDataAdapter ad = new OracleDataAdapter(command);
- ad.SelectCommand = command;
- try
- {
- ad.Fill(dt);
- }
- catch (Exception)
- {
- connection = new OracleConnection(ConnectionStrings);
- connection.Open();
- command = new OracleCommand(sql, connection);
- ad = new OracleDataAdapter();
- ad.SelectCommand = command;
- ad.Fill(dt);
- }
- ad.Dispose();
- command.Dispose();
- return dt;
- }
-
-
-
-
-
-
- private bool CheckExist(string TableName, string Condition)
- {
- string sql = "select count(1) from " + TableName + " where " + Condition;
- command = new OracleCommand(sql, connection);
- Reconnect(command);
- OracleDataAdapter ad = new OracleDataAdapter(command);
- DataTable dt = new DataTable();
- ad.Fill(dt);
- ad.Dispose();
- command.Dispose();
- return int.Parse(dt.Rows[0][0].ToString()) > 0;
- }
-
-
-
-
-
-
- private object ExecuteSql(string SQL, string Type, params object[] names)
- {
- object result = null;
- command = new OracleCommand(SQL, connection);
- Reconnect(command);
-
- if (names.Length > 0)
- {
- string[] par = SQL.Split(':');
-
- StringBuilder[] addpar = new StringBuilder[par.Length - 1];
- for (int i = 0; i < par.Length - 1; i++)
- {
-
- char[] c = par[i + 1].ToCharArray();
- addpar[i] = new StringBuilder();
- for (int j = 0; j < c.Length; j++)
- {
- if (c[j] != ' ' && c[j] != ',' && c[j] != ')')
- {
- addpar[i].Append(c[j]);
- }
- else
- {
- break;
- }
- }
- }
- for (int i = 0; i < addpar.Length; i++)
- {
- command.Parameters.Add(new OracleParameter(addpar[i].ToString(), names[i]));
- }
- }
- switch (Type.ToUpper())
- {
- case "SELECT":
- OracleDataAdapter ad = new OracleDataAdapter(command);
- result = new DataTable();
- try
- {
- ad.Fill((DataTable)result);
- }
- catch (Exception)
- {
- connection = new OracleConnection(ConnectionStrings);
- connection.Open();
- command = new OracleCommand(SQL, connection);
- ad = new OracleDataAdapter();
- ad.SelectCommand = command;
- ad.Fill((DataTable)result);
- }
- break;
- case "DELETE":
- try
- {
- result = command.ExecuteNonQuery();
- }
- catch (Exception)
- {
- command.Connection = new OracleConnection(ConnectionStrings);
- command.Connection.Open();
- result = command.ExecuteNonQuery();
- }
- break;
- case "UPDATE":
- try
- {
- result = command.ExecuteNonQuery();
- }
- catch (Exception)
- {
- command.Connection = new OracleConnection(ConnectionStrings);
- command.Connection.Open();
- result = command.ExecuteNonQuery();
- }
- break;
- case "INSERT":
- try
- {
- result = command.ExecuteNonQuery();
- }
- catch (Exception)
- {
- command.Connection = new OracleConnection(ConnectionStrings);
- command.Connection.Open();
- result = command.ExecuteNonQuery();
- }
- break;
- }
- command.Dispose();
- return result;
- }
-
-
-
-
- private void ExecuteSQLTran(params string[] SQL)
- {
- command = new OracleCommand();
- command.Connection = new OracleConnection(ConnectionStrings);
- command.Connection.Open();
- Reconnect(command);
- OracleTransaction tx = command.Connection.BeginTransaction(IsolationLevel.ReadCommitted);
- command.Transaction = tx;
- try
- {
- foreach (string sql in SQL)
- {
- if (!string.IsNullOrEmpty(sql))
- {
- command.CommandText = sql;
- command.ExecuteNonQuery();
- }
- }
- tx.Commit();
- }
- catch (OracleException E)
- {
- tx.Rollback();
- throw new Exception(E.Message);
- }
- command.Dispose();
- }
- private string UpdateByCondition(string TableName, string update, string condition)
- {
- string sql = "update " + TableName + " set " + update + " where " + condition;
- command = new OracleCommand(sql, connection);
- Reconnect(command);
- try
- {
- command.ExecuteNonQuery();
- }
- catch (Exception)
- {
- command.Connection = new OracleConnection(ConnectionStrings);
- command.Connection.Open();
- command.ExecuteNonQuery();
- }
- command.Dispose();
- return sql;
- }
- private void CallProcedure(string ProcedureName, string[] ParamName, ref string[] param)
- {
- command = new OracleCommand(ProcedureName);
- command.Connection = connection;
- Reconnect(command);
- command.CommandText = ProcedureName;
- command.CommandType = CommandType.StoredProcedure;
- for (int i = 0; i < param.Length; i++)
- {
- command.Parameters.Add(new OracleParameter(ParamName[i], OracleType.VarChar, 200, ParameterDirection.InputOutput, "", DataRowVersion.Default, true, param[i]));
- }
- try
- {
- command.ExecuteNonQuery();
- }
- catch (Exception)
- {
- command.Connection = new OracleConnection(ConnectionStrings);
- command.Connection.Open();
- command.ExecuteNonQuery();
- }
- for (int i = 0; i < command.Parameters.Count; i++)
- param[i] = command.Parameters[i].Value.ToString();
- command.Dispose();
- }
- private string AddField(string[] Fields)
- {
- string sql = " ";
- foreach (string field in Fields)
- {
- sql += field + ",";
- }
- return sql.Substring(0, sql.Length - 1);
- }
- private string[] GetField(string field)
- {
- string[] fields = field.Split(',');
- for (int i = 0; i < fields.Length; i++)
- {
- fields[i] = fields[i].Substring(fields[i].LastIndexOf("as") + 2, fields[i].Length - fields[i].LastIndexOf("as") - 2).Trim();
- }
- return fields;
- }
- private void Reconnect(OracleCommand cmd)
- {
- if (cmd.Connection.State == ConnectionState.Closed)
- {
- cmd.Connection.Open();
- }
- }
- public bool GetMaster(out string oMaster)
- {
- MasterDB = (DataTable)ExecuteSql("select ms_pwd,ma_user,ma_inneraddress from master", "select");
- oMaster = "";
- for (int i = 0; i < MasterDB.Rows.Count; i++)
- {
- if (i != MasterDB.Rows.Count - 1)
- oMaster += MasterDB.Rows[i]["ma_user"].ToString() + "|";
- else
- oMaster += MasterDB.Rows[i]["ma_user"].ToString();
- }
- return true;
- }
- public bool SetMaster(string iMaster)
- {
- DataTable dt = (DataTable)ExecuteSql("select ms_pwd,ma_user,ma_inneraddress from master where ma_user='" + iMaster + "'", "select");
- if (dt.Rows.Count > 0)
- {
- ConnectionStrings = "Data Source=" + dt.Rows[0]["ma_inneraddress"].ToString() + "/orcl;User ID=" + iMaster + ";PassWord=" + dt.Rows[0]["ms_pwd"].ToString() + ";";
- try
- {
- connection = new OracleConnection(ConnectionStrings);
- }
- catch (Exception)
- {
- return false;
- }
- return true;
- }
- return false;
- }
- }
- }
|