public static TMain ReadSysBaseData <TMain>(this DBCtrl db, eSysID configgroup) where TMain : iSysData <eSysID>, new() { TMain vpara = new TMain(); vpara.sysid = configgroup; vpara.tablename = nameof(SYSBASEDATA <eSysID, eBaseDataType>); vpara.prefix = "BASE"; SqlScript sql; if (!typeof(TMain).Name.Contains("Model")) { sql = new SqlScript($@" SELECT * FROM SYSBASEDATA WHERE MODELNAME='*' AND SYSID='{configgroup.ToString()}' AND BASEDATATYPE='{typeof(TMain).Name}'"); } else { sql = new SqlScript($@" SELECT * FROM SYSBASEDATA A JOIN SYSBASEDATA B ON B.SYSID='Main' AND B.BASEDATATYPE='SystemParameter' AND B.BASEDATAID='CurrentSelectModeName' AND A.MODELNAME=B.BASEDATAVALUE WHERE A.SYSID='{configgroup.ToString()}' AND A.BASEDATATYPE='{typeof(TMain).Name}'"); } IEnumerable <SYSBASEDATA <eSysID, eBaseDataType> > data = db.Read <SYSBASEDATA <eSysID, eBaseDataType> >(sql); if (data.Count() == 0) { return(vpara); } data.Read <TMain, eSysID, eBaseDataType>(ref vpara); return(vpara); }
public static List <SqlScript> UpdateHWSETTING(this DBCtrl db, IEnumerable <HWSETTING> settings) { List <SqlScript> sqls = new List <SqlScript>(); foreach (var item in settings) { sqls.AddRange(db.Update(eInsertUpdateType.Replace, item)); } return(sqls); }
public static TMain ReadSysTrxData <TMain>(this DBCtrl db, eSysID sysid, string modelname = "*") where TMain : SysData <eSysID>, new() { TMain vpara = new TMain(); vpara.sysid = sysid; vpara.tablename = nameof(SYSTRXDATA <eSysID, eTrxDataType>); vpara.prefix = "TRX"; db.ReadSystrxdatas().Where(x => x.MODELNAME == modelname).Read <TMain, eSysID, eTrxDataType>(ref vpara); return(vpara); }
public static List <SqlScript> DeleteHWSETTING(this DBCtrl db, PK_HWSETTING pk) { List <SqlScript> sqls = new List <SqlScript>(); // sqls.AddRange(db.Delete(pk)); sqls.Add(new SqlScript() { sql = $"DELETE FROM HW_SETTING WHERE SYSTEM='{pk.SYSTEM}' AND MODULE='{pk.MODULE}' AND CUSTNAME='{pk.CUSTNAME}'" }); return(sqls); // return db.Delete(pk); }
public static List <SqlScript> DeleteMODEL(this DBCtrl db, PK_MODEL pk) { List <SqlScript> sqls = new List <SqlScript>(); sqls.AddRange(db.Delete(pk)); sqls.Add(new SqlScript() { sql = $"DELETE FROM MODELINPUT WHERE MODELNAME='{pk.MODELNAME}'" }); sqls.Add(new SqlScript() { sql = $"DELETE FROM SYSBASEDATA WHERE MODELNAME='{pk.MODELNAME}'" }); return(sqls); }
public static List <SqlScript> UpdateParameter <T>(this DBCtrl db, T Main, eSysID sysid, eBaseDataType dataType) { List <SqlScript> sqls = new List <SqlScript>(); foreach (PropertyInfo item in Main.GetType().GetProperties().Where(x => x.GetCustomAttribute <ConfigAttribute>() != null && x.GetCustomAttribute <ConfigAttribute>().IsSettingColumn)) { SYSBASEDATA <eSysID, eBaseDataType> data = new SYSBASEDATA <eSysID, eBaseDataType>(); // 將設定值寫入DB data.SYSID = sysid; data.MODELNAME = "*"; data.BASEDATATYPE = dataType; data.BASEDATAID = item.Name; data.BASEDATAVALUE = item.PropertyType.IsArray ? data.BASEDATAVALUE = item.GetValue(Main).ToArrayString() : data.BASEDATAVALUE = item.GetValue(Main).ToString(); sqls.AddRange(db.UpdateSysBaseData(data)); } return(sqls); }
public static List <MODEL> MODELs(this DBCtrl db) { return(db.Read <MODEL>().ToList()); }
public static List <SqlScript> CreateMODEL(this DBCtrl db, MODEL pk) { return(db.Create <MODEL>(eInsertUpdateType.Replace, pk)); }
public static List <SqlScript> CreatePART(this DBCtrl db, PART part) { return(db.Create(eInsertUpdateType.Normal, part)); }
public static List <SqlScript> UpdatePART(this DBCtrl db, PART part) { return(db.Update(part)); }
public static List <PART> parts(this DBCtrl db) { return(db.Read <PART>().ToList()); }
public static PART ReadPART(this DBCtrl db, string partname) { return(db.parts().Where(x => x.PARTNAME == partname).FirstOrDefault()); }
public static List <SqlScript> CreateHWSETTING(this DBCtrl db, HWSETTING pk) { return(db.Create(eInsertUpdateType.Replace, pk)); }
public static IEnumerable <SqlScript> UpdateSysBaseData(this DBCtrl db, SYSBASEDATA <eSysID, eBaseDataType> data) { return(db.Update(eInsertUpdateType.Replace, data)); }
public static List <SqlScript> UpdateSystrxdatas(this DBCtrl db, SYSTRXDATA <eSysID, eTrxDataType> data) { return(db.Update(eInsertUpdateType.Replace, data)); }
public static List <SqlScript> UpdateHWSETTING(this DBCtrl db, HWSETTING HWSetting) { return(db.Update(eInsertUpdateType.Replace, HWSetting)); }
public static IEnumerable <SYSTRXDATA <eSysID, eTrxDataType> > ReadSystrxdatas(this DBCtrl db, string model = null) { if (model == null) { return(db.Read <SYSTRXDATA <eSysID, eTrxDataType> >()); } else { return(db.Read <SYSTRXDATA <eSysID, eTrxDataType> >(new SqlScript() { sql = $"SELECT * FROM SYSTRXDATA WHERE MODELNAME IN ('*','{model}')" })); } }
public static List <HWSETTING> ReadHWSETTING(this DBCtrl db) { return(db.Read <HWSETTING>().ToList()); }
public static Dictionary <eSysID, List <eBaseDataType> > dicSysIDBaseDataType(this DBCtrl db) { Dictionary <eSysID, List <eBaseDataType> > _dicSysIDBaseDataType = new Dictionary <eSysID, List <eBaseDataType> >(); foreach (eSysID enumType in Enum.GetValues(typeof(eSysID))) { _dicSysIDBaseDataType.Add(enumType, new List <eBaseDataType>()); Array ary = Enum.GetValues(typeof(eBaseDataType)); Array.Sort(ary); foreach (eBaseDataType item in ary) { if (db.Read <SYSBASEDATA <eSysID, eBaseDataType> >() .Where(x => x.SYSID.Equals(enumType)) .Where(x => x.BASEDATATYPE.Equals(item)).Count() > 0) { _dicSysIDBaseDataType[enumType].Add(item); } } _dicSysIDBaseDataType[enumType].Sort( (eBaseDataType x, eBaseDataType y) => { return(string.Compare(x.ToString(), y.ToString(), true)); }); } return(_dicSysIDBaseDataType); }