| | |
| | | { |
| | | public class M141Process_Mysql |
| | | { |
| | | |
| | | string connStrAll = "server=localhost;port=3306;user id=root;password=123456;database=BroDB;charset=utf8"; |
| | | string connStrLocal = "server=localhost;port=3306;user id=root;password=123456;database=BroDB;charset=utf8"; |
| | | |
| | | |
| | | #region 基础操作 |
| | | public void IniDBIP(string IP) |
| | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | public void NewProduct(ProductModel pro) |
| | |
| | | //string destr = "delete from forall where id not in (select id from (select id from forall order BY id desc limit 1000) as subquery)"; |
| | | //Operatoremysql(destr, connStrAll); |
| | | |
| | | if (string.IsNullOrEmpty(netname) /*|| devicestr != "S3" */) |
| | | if (string.IsNullOrEmpty(netname) || devicestr != "S3") |
| | | { |
| | | if (pro.Details != null) |
| | | { |
| | |
| | | item.DefectList.AddRange(defects.Distinct()); |
| | | item.DefectList = item.DefectList.Distinct().ToList(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | Operatoremysql(str2, connStrAll); |
| | | } |
| | | |
| | | string mysqlstr = $"insert into forall (basketcode,device,plcnum,sn,data,time) values('{pro.BasketCode}','{devicestr}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All })}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')"; |
| | | string mysqlstr = $"insert into forall (basketcode,zword,device,plcnum,sn,data,time) values('{pro.BasketCode}','{pro.Zword}','{devicestr}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All })}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')"; |
| | | |
| | | if (Operatoremysql(mysqlstr, connStrAll)) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public List<Netdefectdetail> GetNetdefectdetails(string plcnum) |
| | | { |
| | | try |
| | |
| | | return null; |
| | | } |
| | | |
| | | public string Getbasketcode(string plcnum, out string sn) |
| | | public bool GetS2Result(string plcnum) |
| | | { |
| | | sn = "Noread"; |
| | | try |
| | | { |
| | | string mysqlstr = $"select basketcode,sn from forall where plcnum='{plcnum}' && device='S2' order by id desc limit 1"; |
| | | string mysqlstr = $"select data from forall where plcnum='{plcnum}' && device='S2' order by id desc limit 1"; |
| | | string str = selectmysql(mysqlstr, connStrAll); |
| | | if (string.IsNullOrEmpty(str)) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | ProductModel p = null; |
| | | p = JsonConvert.DeserializeObject<ProductModel>(str, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); |
| | | |
| | | return p.Result == "OK"; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库forlocal获取对象异常 {e.ToString()}"); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public string Getbasketcode(string plcnum, out string sn, out string zword) |
| | | { |
| | | sn = "Noread"; |
| | | zword = "Noread"; |
| | | try |
| | | { |
| | | string mysqlstr = $"select basketcode,sn,zword from forall where plcnum='{plcnum}' && device='S2' order by id desc limit 1"; |
| | | var dt = selectdt(mysqlstr, connStrAll); |
| | | if (dt == null || dt.Rows.Count == 0) |
| | | { |
| | |
| | | else |
| | | { |
| | | sn = dt.Rows[0][1].ToString(); |
| | | zword = dt.Rows[0][2].ToString(); |
| | | return dt.Rows[0][0].ToString(); |
| | | } |
| | | } |
| | |
| | | } |
| | | return "NoRead"; |
| | | } |
| | | |
| | | |
| | | public List<ProductModel> GetProductList(string plcnum) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | public DataTable getBasketCode() |
| | | { |
| | | try |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | public void NewBasketcode(string code) |
| | | { |