123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443 |
- using Oracle.ManagedDataAccess.Client;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Globalization;
- using System.IO;
- using System.Net;
- using System.Runtime.InteropServices;
- using System.Security.Cryptography;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Web.Script.Serialization;
- namespace UMESDLLService
- {
- [Guid("974DEAD2-9D4C-4728-87EA-2407752E300F")]
- [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 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 oCode3, out string oErrMessage);
- bool SetAddressInfo(string iSN, string iMac, string iBT, string iCode1, string iCode2, string iCode3, out string oErrorMessage);
- bool SetTestDetail(string iSN, string iResCode, string[] iClassName, string[] iTestResult, string iMaxValue, string iMinValue, string[] iTestDetail, out string oErrMessage);
- bool GetMEIOrNetCodeRange(string iSN, string iIMEI1, string iNetCode, out string oIMEI1, out string oIMEI2, out string oIMEI3, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oErrMessage);
- bool SetIMEIInfo(string iSN, string iIMEI1, string iIMEI2, string iIMEI3, string iMEID, string iPSN, string iNETCODE, string iID1, string iID2, string iID3, out string oErrMessage);
- bool GetMobileAllInfo(string iSnCode, out string oInfo, 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);
- bool GetInfoByMaterial(string iPCBA, out string oSN, out string oErrMessage);
- bool GetSoftVersion(string iSN, out string oSoftVersion, out string oErrMessage);
- bool GetMakeInfoBySN(string iSN, out string oInfo, out string oErrorMessage);
- bool GetPSN(string iSN, out string oInfo, out string oErrorMessage);
- bool GetMakeInfo(string iSN, out string oInfo, out string oErrorMessage);
- }
- [Guid("5379A8F6-EB38-4A2B-9050-52AD9757E12D")]
- [ComSourceInterfaces(typeof(IMESHelper))]
- [ClassInterface(ClassInterfaceType.None)]
- [ProgId("UMES.DllService.MESHelper")]
- public class MESHelper : IMESHelper
- {
-
- StringBuilder sql = new StringBuilder();
-
- List<string> sqls = new List<string>();
- string Master = "YD_CYZZ";
-
- private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11568)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
-
- private OracleConnection connection;
-
- private OracleCommand command = null;
- public MESHelper()
- {
- connection = new OracleConnection(ConnectionStrings);
- }
- public MESHelper(string IP)
- {
- connection = new OracleConnection("Data Source=" + IP + "/orcl;User ID=N_MES;PassWord=select!#%*(;");
- }
- [Description("获取工单软件版本")]
- public bool GetSoftVersion(string iMakeCode, out string oSoftVersion, out string oErrMessage)
- {
- string oMakeCode = "";
- oErrMessage = "";
- oSoftVersion = "";
-
- if (!CheckExist("Make", "ma_Code='" + iMakeCode + "'"))
- {
- oErrMessage = "工单号" + iMakeCode + "不存在";
- return false;
- }
- oSoftVersion = getFieldDataByCondition("make", "ma_softversion", "ma_code='" + iMakeCode + "'").ToString();
- return true;
- }
- public bool GetInfoByMaterial(string iPCBA, out string oSN, out string oErrMessage)
- {
- oSN = "";
- oErrMessage = "";
- if (iPCBA == "")
- {
- oErrMessage = "主板SN不能为空";
- }
- DataTable dt = (DataTable)ExecuteSql("select ms_firstsn,ms_sncode from CRAFTMATERIAL left join make on cm_makecode=ma_code " +
- "left join makeserial on ms_firstsn=cm_firstsn and cm_makecode=ms_makecode where cm_barcode='" + iPCBA + "' and nvl(cm_status,0)<>-1 order by cm_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- oSN = dt.Rows[0]["ms_sncode"].ToString();
- }
- else
- {
- oErrMessage = "主板SN未查询到关联信息";
- }
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
- {
- return true;
- }
- else
- return false;
- }
-
-
-
-
-
-
-
- [Description("序列号对应工序检测")]
- public bool CheckRoutePassed(string iSN, string iResCode, out string oErrMessage)
- {
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- string SNcode = iSN;
- DataTable dt = (DataTable)ExecuteSql("select ms_sncode from makeserial where ms_sncode='" + iSN + "' or ms_imei1='" + iSN + "' or ms_imei2='" + iSN + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- iSN = dt.Rows[0]["ms_sncode"].ToString();
- }
- if (iSN == "")
- {
- iSN = SNcode;
- }
- 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];
- dt = (DataTable)ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_id=( select max(ms_id) from makeserial where ms_sncode in ( select '" + iSN + "' from dual union select sn from makesnrelation where beforesn='" + iSN + "' and sn<>' ' union select beforesn from makesnrelation where sn='" + iSN + "' and beforesn<>' '))", "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 = "当前序列号" + iSN + "下一工序" + ms_nextstepcode;
- return false;
- }
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || (ms_status == "3" && stepcode == ms_stepcode))
- {
- if (ms_status == "3")
- {
- oErrMessage = "";
- }
- DataTable dt1 = (DataTable)ExecuteSql("select 1 from makebadcount where mbc_sncode='" + iSN + "' and mbc_stepcode='" + stepcode + "' and mbc_status=0", "select");
- int BadCount = dt1.Rows.Count;
-
- if (BadCount == 3)
- {
- oErrMessage = stepcode + "连续三次测试不良,请进行维修";
- return false;
- }
- 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;
- }
- }
-
-
-
-
-
-
-
- [Description("验证身份信息")]
- 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;
- }
-
-
-
-
-
-
-
-
-
-
-
- [Description("分配MAC和BT信息")]
- public bool GetAddressRangeByMO(string iSN, out string oWIFI, out string oBT, out string oCode1, out string oCode2, out string oCode3, out string oErrMessage)
- {
- oWIFI = "";
- oBT = "";
- oCode1 = "";
- oCode2 = "";
- oCode3 = "";
- 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, oCode3, 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].ToString();
- oBT = param[3].ToString();
- oCode1 = param[4].ToString();
- oCode2 = param[5].ToString();
- oCode3 = param[6].ToString();
- oErrMessage = param[7];
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
- return true;
- else
- return false;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [Description("分配IMEI和NetCode信息")]
- public bool GetMEIOrNetCodeRange(string iSN, string iIMEI1, string iNetCode, out string oIMEI1, out string oIMEI2, out string oIMEI3, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oErrMessage)
- {
- oIMEI1 = "";
- oIMEI2 = "";
- oIMEI3 = "";
- oMEID = "";
- oNetCode = "";
- oPSN = "";
- oID1 = "";
- oID2 = "";
- oID3 = "";
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string[] param = new string[] { iSN, "", iIMEI1, iNetCode, oIMEI1, oIMEI2, oIMEI3, 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].ToString();
- oIMEI2 = param[5].ToString();
- oIMEI3 = param[6].ToString();
- oMEID = param[7].ToString();
- oNetCode = param[8].ToString();
- oPSN = param[9].ToString();
- oID1 = param[10].ToString();
- oID2 = param[11].ToString();
- oID3 = param[12].ToString();
- oErrMessage = param[13];
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
- return true;
- else
- return false;
- }
-
-
-
-
-
-
-
- [Description("获取序列号对应工单信息")]
- public bool GetRcardMOInfo(string iSN, out string oMoCode, out string oErrMessage)
- {
-
- oMoCode = "";
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- sql.Clear();
- sql.Append("select max(ms_id) from makeserial where ms_sncode in (select '" + iSN + "' from dual union select sn from ");
- sql.Append("makesnrelation where beforesn='" + iSN + "' and sn<>' ' union select 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;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [Description("查询已分配的信息")]
- public bool GetMobileAllInfo(string iSN, out string oJson, out string oErrMessage)
- {
- JavaScriptSerializer jss = new JavaScriptSerializer();
- Dictionary<string, string> oInfo = new Dictionary<string, string>();
- oErrMessage = "";
- oJson = "";
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- DataTable dt = (DataTable)ExecuteSql("select ms_sncode from makeserial where ms_sncode='" + iSN + "' or ms_firstsn='" + iSN + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- iSN = dt.Rows[0]["ms_sncode"].ToString();
- }
-
- string ms_id = getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode='" + iSN + "' or ms_firstsn='" + iSN + "'").ToString();
- if (ms_id != "")
- {
- 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)
- {
- string Code1 = "";
- string Code2 = "";
- string Code3 = "";
- string Code4 = "";
- string Code5 = "";
- string Code6 = "";
- string Code7 = "";
- string Code8 = "";
- string Code9 = "";
- string Code10 = "";
- string Code11 = "";
- string Code12 = "";
- string Code13 = "";
- string Code14 = "";
- string Code15 = "";
- string Code16 = "";
- string Code17 = "";
- string Code18 = "";
- string Code19 = "";
- string Code20 = "";
- string Code21 = "";
- string Code22 = "";
- string Code23 = "";
- string Code24 = "";
- string Code25 = "";
- string[] param = new string[] { ms_id, Code1, Code2, Code3, Code4, Code5, Code6, Code7, Code8, Code9, Code10, Code11, Code12, Code13, Code14, Code15, Code16, Code17, Code18, Code19, Code20, Code21, Code22, Code23, Code24, Code25 };
- string[] ParamName = new string[] { "v_ms_id", "v_i_code1", "v_i_code2", "v_i_code3", "v_i_code4", "v_i_code5", "v_i_code6", "v_i_code7", "v_i_code8", "v_i_code9", "v_i_code10", "v_i_code11", "v_i_code12", "v_i_code13", "v_i_code14", "v_i_code15", "v_i_code16", "v_i_code17", "v_i_code18", "v_i_code19", "v_i_code20", "v_i_code21", "v_i_code22", "v_i_code23", "v_i_code24", "v_i_code25" };
- CallProcedure("GetMobileAllInfo_NEW_TOOL", ParamName, ref param);
- for (int i = 1; i < param.Length; i++)
- {
-
- if (param[i] != "" && param[i] != "null" && param[i] != null)
- {
- oInfo.Add(param[i].Split('^')[0], param[i].Split('^')[1]);
- }
- }
- oJson = jss.Serialize(oInfo);
- 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");
- }
-
-
-
-
-
-
-
-
-
-
-
- [Description("写入SN的Wifi,BT信息")]
- public bool SetAddressInfo(string iSN, string iMac, string iBT, string iCode1, string iCode2, string iCode3, out string oErrMessage)
- {
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- iSN = getFieldDataByCondition("makeserial", "ms_sncode", "ms_sncode='" + iSN + "' order by ms_id").ToString();
- string[] param = new string[] { iSN, iMac, 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;
- }
- [Description("序列号跳到下一 步")]
- private 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);
- }
-
-
-
-
-
-
-
-
-
-
-
- [Description("设置测试结果,结果必须为NG或者OK")]
- 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; }
- DataTable dt = (DataTable)ExecuteSql("select ms_sncode from makeserial where ms_sncode='" + iTSN + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- iTSN = dt.Rows[0]["ms_sncode"].ToString();
- }
- else
- {
- dt = (DataTable)ExecuteSql("select ms_sncode from makeserial where ms_imei2='" + iTSN + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- iTSN = dt.Rows[0]["ms_sncode"].ToString();
- }
- }
- 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_TOOL", 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_TOOL", ParamName, ref param);
- oErrMessage = param[5];
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
- return true;
- else
- return false;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [Description("设置测试结果")]
- public bool SetTestDetail(string iSN, string iResCode, string[] iClassName, string[] iTestResult, string iMaxValue, string iMinValue, string[] iTestDetail, out string oErrMessage)
- {
- if (iSN == "" || iSN == null)
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string omakeCode = "";
- GetRcardMOInfo(iSN, out omakeCode, out oErrMessage);
- sql.Clear();
- sql.Append("begin ");
- if (iClassName.Length != iTestResult.Length || iTestResult.Length != iTestDetail.Length)
- {
- oErrMessage = "参数项次不对应";
- return false;
- }
- for (int i = 0; i < iTestDetail.Length; i++)
- {
- string sql = "Insert into STEPTESTDETAIL (STD_ID,STD_CLASS,STD_SN,STD_MAKECODE,STD_ACTUALVALUE,STD_TESTRESULT,STD_INDATE,STD_RESCODE,STD_MAXVALUE, STD_MINVALUE)";
- sql += "values(STEPTESTDETAIL_SEQ.nextval,'" + iClassName[i] + "','" + iSN + "','" + omakeCode + "','" + iTestDetail[i] + "','" + iTestResult[i] + "',sysdate,'" + iResCode + "','" + iMaxValue + "','" + iMinValue + "')";
- ExecuteSql(sql.ToString(), "insert");
- }
- return true;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [Description("设置IMEI信息")]
- public bool SetIMEIInfo(string iSN, string iIMEI1, string iIMEI2, string iIMEI3, string iMEID, string iPSN, string iNETCODE, string iID1, string iID2, string iID3, out string oErrMessage)
- {
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- oErrMessage = "";
- string[] param = new string[] { iSN, iIMEI1, iIMEI2, iIMEI3, iMEID, iNETCODE, iPSN, iID1, iID2, iID3, 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;
- }
-
-
-
-
-
-
-
-
-
-
- [Description("设置测试结果")]
- public bool SetPcbaData(string iSN, string iResCode, string iOperator, string iResult, string iErrCode, out string oErrMessage)
- {
- if (iSN == "")
- {
- oErrMessage = "SN不能为空";
- return false;
- }
- string SNcode = iSN;
-
-
-
-
- if (iSN == "")
- {
- iSN = SNcode;
- }
- 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;
- }
-
-
-
-
-
-
-
-
- [Description("序列号归属工单")]
- 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 (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 string GetStepName(string st_code)
- {
- return getFieldDataByCondition("step", "st_name", "st_code='" + st_code + "'").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], OracleDbType.Varchar2, 200, param[i], ParameterDirection.InputOutput));
-
- }
- 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();
- }
- }
-
-
-
-
-
-
- private bool CheckUserLogin(string iUserCode, string iPassWord, string Master, out string oErrorMessage)
- {
- oErrorMessage = "";
- try
- {
- string url = "http://192.168.0.85:8099/mes/mobile/login.action";
- HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url);
- if (webrequest == null)
- {
- return false;
- }
- webrequest.Method = "POST";
- webrequest.Timeout = 1000;
- webrequest.ContentType = "application/x-www-form-urlencoded";
- System.Collections.Hashtable pars = new System.Collections.Hashtable();
- pars.Add("username", iUserCode);
- pars.Add("password", iPassWord);
- pars.Add("master", Master);
- string buffer = "";
-
- if (!(pars == null || pars.Count == 0))
- {
- foreach (string key in pars.Keys)
- {
- buffer = buffer + "&" + key + "=" + pars[key].ToString();
- }
- byte[] data = Encoding.UTF8.GetBytes(buffer);
- using (Stream stream = webrequest.GetRequestStream())
- {
- stream.Write(data, 0, data.Length);
- }
- }
- string[] values = webrequest.Headers.GetValues("Content-Type");
- WebResponse myResponse = webrequest.GetResponse();
- using (Stream resStream = myResponse.GetResponseStream())
- {
- StreamReader newReader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
- string Content = newReader.ReadToEnd();
- Dictionary<string, object> dic = new Dictionary<string, object>();
- dic = ToDictionary(Content);
- if (!dic.ContainsKey("erpaccount"))
- {
- oErrorMessage = dic["reason"].ToString();
- return false;
- }
- newReader.Close();
- }
- }
- catch (Exception ex)
- {
- oErrorMessage = ex.Message.ToString();
- return false;
- }
- return true;
- }
- private Dictionary<string, object> ToDictionary(string JsonData)
- {
- object Data = null;
- Dictionary<string, object> Dic = new Dictionary<string, object>();
- if (JsonData.StartsWith("["))
- {
-
-
- List<Dictionary<string, object>> List = new List<Dictionary<string, object>>();
- MatchCollection ListMatch = Regex.Matches(JsonData, @"{[\s\S]+?}");
- foreach (Match ListItem in ListMatch)
- {
- List.Add(ToDictionary(ListItem.ToString()));
- }
- Data = List;
- Dic.Add("List", Data);
- }
- else
- {
- MatchCollection Match = Regex.Matches(JsonData, @"""(.+?)"": {0,1}(\[[\s\S]+?\]|null|"".+?""|-{0,1}\d*)");
- foreach (Match item in Match)
- {
- try
- {
- if (item.Groups[2].ToString().StartsWith("["))
- {
-
-
- List<Dictionary<string, object>> List = new List<Dictionary<string, object>>();
- MatchCollection ListMatch = Regex.Matches(item.Groups[2].ToString(), @"{[\s\S]+?}");
- foreach (Match ListItem in ListMatch)
- {
- List.Add(ToDictionary(ListItem.ToString()));
- }
- Data = List;
- }
- else if (item.Groups[2].ToString().ToLower() == "null") Data = null;
- else Data = item.Groups[2].ToString();
- Dic.Add(item.Groups[1].ToString(), Data);
- }
- catch { }
- }
- }
- return Dic;
- }
- public bool GetMakeInfoBySN(string iSN, out string oInfo, out string oErrorMessage)
- {
- oInfo = "";
- oErrorMessage = "";
- DataTable rs = (DataTable)ExecuteSql("select ma_remark1,ma_remark2,ma_remark3,ma_remark4,ma_remark5,ma_remark6,ma_remark7,ma_remark8,ma_remark9,ma_remark10,ma_remark11,ma_remark12,ma_remark13,ma_remark14,ma_remark15,ma_remark16,ma_remark17,ma_remark18 from " + Master + ".make " +
- "left join " + Master + ".makeserial on ms_makecode=ma_code where ms_sncode='" + iSN + "' order by ms_id desc", "select");
- if (rs.Rows.Count > 0)
- {
- oInfo += "oMaremark1:" + rs.Rows[0]["ma_remark1"].ToString() + "^";
- oInfo += "oMaremark2:" + rs.Rows[0]["ma_remark2"].ToString() + "^";
- oInfo += "oMaremark3:" + rs.Rows[0]["ma_remark3"].ToString() + "^";
- oInfo += "oMaremark4:" + rs.Rows[0]["ma_remark4"].ToString() + "^";
- oInfo += "oMaremark5:" + rs.Rows[0]["ma_remark5"].ToString() + "^";
- oInfo += "oMaremark6:" + rs.Rows[0]["ma_remark6"].ToString() + "^";
- oInfo += "oMaremark7:" + rs.Rows[0]["ma_remark7"].ToString() + "^";
- oInfo += "oMaremark8:" + rs.Rows[0]["ma_remark8"].ToString() + "^";
- oInfo += "oMaremark9:" + rs.Rows[0]["ma_remark9"].ToString() + "^";
- oInfo += "oMaremark10:" + rs.Rows[0]["ma_remark10"].ToString() + "^";
- oInfo += "oMaremark11:" + rs.Rows[0]["ma_remark11"].ToString() + "^";
- oInfo += "oMaremark12:" + rs.Rows[0]["ma_remark12"].ToString() + "^";
- oInfo += "oMaremark13:" + rs.Rows[0]["ma_remark13"].ToString() + "^";
- oInfo += "oMaremark14:" + rs.Rows[0]["ma_remark14"].ToString() + "^";
- oInfo += "oMaremark15:" + rs.Rows[0]["ma_remark15"].ToString() + "^";
- oInfo += "oMaremark16:" + rs.Rows[0]["ma_remark16"].ToString() + "^";
- oInfo += "oMaremark17:" + rs.Rows[0]["ma_remark17"].ToString() + "^";
- oInfo += "oMaremark18:" + rs.Rows[0]["ma_remark18"].ToString() + "^";
- return true;
- }
- else
- {
- oErrorMessage = "SN未查询到关联信息";
- return false;
- }
- }
- public bool GetMakeInfo(string iSN, out string oInfo, out string oErrorMessage)
- {
- oInfo = "";
- oErrorMessage = "";
- JavaScriptSerializer jss = new JavaScriptSerializer();
- if (iSN == "")
- {
- oErrorMessage = "SN不能为空";
- return false;
- }
- Dictionary<string, string> Info = new Dictionary<string, string>();
- String makecode = getFieldDataByCondition("makeserial", "ms_makecode", "ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')").ToString();
- DataTable rs = (DataTable)ExecuteSql("select mid_item,mid_value from makeitem left join makeitemdetail on mi_id=mid_miid where mi_makecode='" + makecode + "' and mid_item is not null", "select");
- for (int i = 0; i < rs.Rows.Count; i++)
- {
- Info.Add(rs.Rows[i]["mid_item"].ToString(), rs.Rows[i]["mid_value"].ToString());
- }
- oInfo = jss.Serialize(Info);
- return true;
- }
- public bool GetPSN(string iSN, out string oPSN, out string oErrorMessage)
- {
- oPSN = "";
- oErrorMessage = "";
- string iMakecode = getFieldDataByCondition("makeserial", "ms_makecode", "ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')").ToString();
- if (iMakecode == "")
- {
- oErrorMessage = iSN + "无关联工单";
- return false;
- }
- DataTable rs = (DataTable)ExecuteSql("select msl_sncode from makesnlist where msl_beforesn='" + iSN + "'", "select");
- if (rs.Rows.Count > 0)
- {
- oPSN = rs.Rows[0][0].ToString();
- return true;
- }
- rs = (DataTable)ExecuteSql("select msl_sncode,msl_id from makesnlist where msl_makecode='" + iMakecode + "' and msl_type='after' and nvl(msl_status,0)=0 order by msl_sncode", "select");
- if (rs.Rows.Count > 0)
- {
- String msl_id = rs.Rows[0]["msl_id"].ToString();
- String msl_sncode = rs.Rows[0]["msl_sncode"].ToString();
- ExecuteSql("update makesnlist set msl_status=-1,msl_beforesn='" + iSN + "' where msl_id=" + msl_id + " and nvl(msl_status,0)=0", "update");
- oPSN = rs.Rows[0][0].ToString();
- return true;
- }
- else
- {
- oErrorMessage = "无可分配号段";
- return false;
- }
- }
- }
- }
|