public void UpdateErrorCode(string dicstring) { IDictionary <string, object> dic = MapListConverter.JsonToDictionary(dicstring); IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); StringBuilder ofilter = new StringBuilder(); ofilter.Append("ERRORDESC = {0}, "); ofilter.Append("ERRORDESC2 = {1}, "); if (ProConfiguration.GetConfig().DatabaseType == SysModel.DataLinkType.MySql) { ofilter.Append("RECDATE =now() "); } if (ProConfiguration.GetConfig().DatabaseType == SysModel.DataLinkType.Oracle) { ofilter.Append("RECDATE =SYSDATE "); } IDictionary <string, object> modFields = new Dictionary <string, object>(); modFields.Add("ERRORDESC", dic["ERRORDESC"]); modFields.Add("ERRORDESC2", dic["ERRORDESC2"]); string filter = "ERRORCODE = {0}"; IDictionary <string, object> keyVals = new Dictionary <string, object>(); keyVals.Add("ERRORCODE", dic["ERRORCODE"]); dp.UpdateBatchData(table, ofilter.ToString(), modFields, filter, keyVals); }
public string Update_SmtKpMonitor(string woId, string OldMaterId, string NewMasterId, string Machine) { DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); StringBuilder ofilter = new StringBuilder(); ofilter.Append("MASTERID={0},MACHINEID={1}"); IDictionary <string, object> modFields = new Dictionary <string, object>(); modFields.Add("MASTERID", NewMasterId); modFields.Add("MACHINEID", Machine); string filter = "MASTERID={0} AND WOID={1}"; IDictionary <string, object> keyVals = new Dictionary <string, object>(); keyVals.Add("MASTERID1", OldMaterId); keyVals.Add("WOID", woId); dp.UpdateBatchData(tx, "SFCR.T_SMT_KP_MONNITOR", ofilter.ToString(), modFields, filter, keyVals); ofilter = new StringBuilder(); ofilter.Append("MASTERID={0},MACHINEID={1}"); modFields = new Dictionary <string, object>(); modFields.Add("MASTERID", NewMasterId); modFields.Add("MACHINEID", Machine); filter = "MASTERID={0} AND WOID={1}"; keyVals = new Dictionary <string, object>(); keyVals.Add("MASTERID1", OldMaterId); keyVals.Add("WOID", woId); dp.UpdateBatchData(tx, "SFCR.T_SMT_IO", ofilter.ToString(), modFields, filter, keyVals); tx.Commit(); return("OK");// +woId + "--" + OldMaterId + "--" + NewMasterId + "--" + Machine; } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
/// <summary> /// 更改工单表 /// </summary> /// <param name="tWoInFo"></param> /// <param name="Flag"></param> /// <returns></returns> public string UpdateWoInfo(string woId) { try { IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); StringBuilder ofilter = new StringBuilder(); ofilter.Append("inputqty=inputqty-{0}".ToUpper()); IDictionary <string, object> modFields = new Dictionary <string, object>(); modFields.Add("inputqty", 1); string filter = "WOID = {0}"; IDictionary <string, object> keyVals = new Dictionary <string, object>(); keyVals.Add("WOID", woId); dp.UpdateBatchData("SFCR.T_WO_INFO", ofilter.ToString(), modFields, filter, keyVals); return("OK"); } catch (Exception ex) { return(ex.Message); } }
public List <string> GetSnMacImeiForAte(string Esn, string sntype, string woId, int snqty) { List <string> BarcodeList = new List <string>(); string table = "SFCR.T_WO_SNLIST"; string fieldlist = "SNVAL"; int count = 0; DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); IDictionary <string, object> mst = new Dictionary <string, object>(); mst.Add("WOID", woId); mst.Add("SNTYPE", sntype); mst.Add("ESN", Esn); DataSet ds = dp.GetData(table, fieldlist, mst, out count); if (ds.Tables[0].Rows.Count == 0) { mst = new Dictionary <string, object>(); mst.Add("WOID", woId); mst.Add("SNTYPE", sntype); string field = "woId={0} and sntype={1} and status=0 limit " + snqty; DataTable dt = TransactionManager.GetData(table, "ID AS ROWID,SNVAL", field, mst, null, null, out count).Tables[0]; if (dt != null && dt.Rows.Count != 0) { if (dt.Rows.Count == snqty) { IList <IDictionary <string, object> > lsdic = new List <IDictionary <string, object> >(); BarcodeList.Add("OK"); foreach (DataRow dr in dt.Rows) { StringBuilder ofilter = new StringBuilder(); ofilter.Append(" ESN = {0},STATUS = {1}"); IDictionary <string, object> modFields = new Dictionary <string, object>(); modFields.Add("ESN", Esn); modFields.Add("STATUS", 1); string filter = " ID={0} AND STATUS = {1}"; IDictionary <string, object> keyVals = new Dictionary <string, object>(); keyVals.Add("ID", dr["rowid"].ToString()); keyVals.Add("STATUS1", 0); dp.UpdateBatchData(tx, table, ofilter.ToString(), modFields, filter, keyVals); Insert_System_Log(Esn + "-->" + dr["snval"].ToString()); } string msg = "OK"; try { tx.Commit(); // dp.UpdateListData(table, new string[] { "ID", "STATUS" }, lsdic); } catch (Exception ex) { tx.Rollback(); msg = ex.Message; } finally { conn.Close(); conn.Dispose(); } if (msg != "OK") { BarcodeList[0] = "Update DataBase Fall"; return(BarcodeList); } #region 处理并发时避免重复给号,更新完毕后等待300毫秒再读取一次 System.Threading.Thread.Sleep(300); mst = new Dictionary <string, object>(); mst.Add("WOID", woId); mst.Add("SNTYPE", sntype); mst.Add("ESN", Esn); DataSet dss = dp.GetData(table, fieldlist, mst, out count); if (dss.Tables[0].Rows.Count == 0) { BarcodeList[0] = "Get Sn Exception"; return(BarcodeList); } if (dss.Tables[0].Rows.Count != snqty) { BarcodeList[0] = "Get Sn Insufficient Quantity"; return(BarcodeList); } foreach (DataRow dr in dss.Tables[0].Rows) { BarcodeList.Add(dr["snval"].ToString()); Insert_System_Log(Esn + "-->" + dr["snval"].ToString()); } #endregion } else { BarcodeList.Add("Bar code is not enough"); } } else { BarcodeList.Add("FAIL"); } return(BarcodeList); } else { BarcodeList.Add("OK"); foreach (DataRow dr in ds.Tables[0].Rows) { BarcodeList.Add(dr[0].ToString()); } return(BarcodeList); } }