public CodeMaster_cmt_Info GetLastUpdateRecord() { CodeMaster_cmt_Info result = null; try { using (NHibernateTransaction.DBContext db = new NHibernateTransaction.DBContext()) { var data = db.CurrentSession.QueryOver<CodeMaster_cmt_Info>().OrderBy(d => d.cmt_dLastDate).Desc.Take(1).List(); if (data != null && data.Count > 0) { result = data[0]; } } } catch (Exception Ex) { Logger.Error(Ex); //throw Ex; } return result; }
public List<ProjectStopRecord_psrd_Info> GetProjectStopRecords(Guid swlID) { List<ProjectStopRecord_psrd_Info> list = null; try { using (DBContext session = new DBContext()) { string sql = @"select st.* from ProjectStopRecord_psrd st left join PrintProject_ppj pp on pp.[ppj_RecordID] =st.psrd_PPJID and pp.ppj_lActiveRecord='1' left join ScheduleProjList_swl sw on sw.[swl_RecordID] =pp.ppj_SWLID where sw.[swl_RecordID]=? and st.psrd_lSync=0 and st.psrd_dEndTime is not null"; var query = session.CurrentSession.CreateSQLQuery(sql); query.SetParameter(0, swlID.ToString()); query.AddEntity(typeof(ProjectStopRecord_psrd_Info)); list = query.List<ProjectStopRecord_psrd_Info>().ToList(); } } catch (Exception ex) { throw ex; } return list; }
/// <summary> /// 1,同步QC問題主檔 /// </summary> /// <param name="machineID"></param> /// <returns></returns> bool ISync.Download(string machineID) { try { IList<QualityProblemMaster_qpm_Info> sourceList; //加載SERVER品檢質量問題 using (DBContext uow = new DBContext(NHConfigFactory.DBConfig.HBIMSN)) { var query = uow.CurrentSession.QueryOver<QualityProblemMaster_qpm_Info>(); sourceList = query.List<QualityProblemMaster_qpm_Info>(); } using (DBContext uow = DBContext.Begin(NHConfigFactory.DBConfig.PPC)) { uow.CurrentSession.CreateQuery("delete from QualityProblemMaster_qpm_Info").ExecuteUpdate(); //保存SERVERR品檢質量問題到LOCAL foreach (var item in sourceList) { uow.CurrentSession.Save(item); } } return true; } catch (Exception ex) { Common.General.BLLoger.Error(ex); return false; //throw ex; } }
public bool Download(string machineID) { try { ShowMessage("同步物料群組主檔..."); IList<MixMaterialGroup_mmpg_Info> sourceList; //加載SERVER字碼主檔 using (DBContext uow = new DBContext(NHConfigFactory.DBConfig.HBIMSN)) { var query = uow.CurrentSession.QueryOver<MixMaterialGroup_mmpg_Info>(); sourceList = query.List<MixMaterialGroup_mmpg_Info>(); } using (DBContext uow = DBContext.Begin(NHConfigFactory.DBConfig.PPC)) { uow.CurrentSession.CreateQuery("delete from MixMaterialGroup_mmpg_Info").ExecuteUpdate(); //保存SERVER字碼主檔到LOCAL foreach (var item in sourceList) { uow.CurrentSession.Save(item); } } return true; } catch (Exception ex) { Common.General.BLLoger.Error(ex); return false; //throw ex; } }
public static DinnerRecord_dnr_Info CreateDinnerRecord(DinnerRecord_dnr_Info dnr) { try { using (NHibernateTransaction.DBContext db = new NHibernateTransaction.DBContext()) { DateTime dt = DateTime.Now; dnr.dnr_RecordID = Guid.NewGuid(); dnr.dnr_cAdd = "SYS"; dnr.dnr_cLast = "SYS"; dnr.dnr_dAddDate = dt; dnr.dnr_dLastDate = dt; dnr.dnr_dDate = dt.Date; dnr.dnr_lIsAuto = true; dnr.dsm_cProjectStatus = string.Empty; db.CurrentSession.Save(dnr); } } catch (Exception e) { Common.General.BLLoger.Error(e); } return dnr; }
/// <summary> /// 獲取當班空閒記錄 /// </summary> /// <returns></returns> public IList<SpareStatus_sst_Info> Search(Guid shiftInfoID) { using (DBContext uow = new DBContext()) { var query = uow.CurrentSession.QueryOver<SpareStatus_sst_Info>(); query.And(d => d.sst_iSIFOID == shiftInfoID); query = query.OrderBy(d => d.sst_dBeginTime).Desc; return query.List<SpareStatus_sst_Info>(); } }
public List<ShiftProjList_spl_Info> GetShiftProjects(Guid swlID) { string sql = @"SELECT A.* FROM ShiftProjList_spl A LEFT JOIN PrintProject_ppj B ON PPJ_RECORDID=SPL_PPJID LEFT JOIN ScheduleProjList_swl C ON SWL_RECORDID=PPJ_SWLID WHERE C.[swl_RecordID] =? "; using (DBContext t = new DBContext()) { return t.CurrentSession.CreateSQLQuery(sql).SetGuid(0, swlID).List<ShiftProjList_spl_Info>().ToList(); } }
public IList<VacationMaster_vcm_Info> GetAllVacationList() { string sql = @"SELECT * FROM VacationMaster_vcm"; using (DBContext uow =new DBContext()) { ISQLQuery query = uow.CurrentSession.CreateSQLQuery(sql); query.AddEntity(typeof(VacationMaster_vcm_Info)); return query.List<VacationMaster_vcm_Info>(); } }
/// <summary> /// 生產工程合計生產時間 /// </summary> /// <param name="db"></param> /// <param name="ppj"></param> /// <returns></returns> public static int PrintProjectProdTime(DBContext db, PrintProject_ppj_Info ppj) { int total = 0; if (db != null && ppj != null) { var ppjDinnerQuery = db.CurrentSession.QueryOver<DinnerRecord_dnr_Info>(); ppjDinnerQuery.And(d => d.dsm_ppjID == ppj.ppj_RecordID); int splDinnerTime = (int)ppjDinnerQuery.And(d => d.dnr_DSMID != Guid.Empty).List().Sum(d => (d.dnr_dEndTime.Value - d.dnr_dBeginTime.Value).TotalSeconds); total = PrejectRunTime(ppj) - ppj.ppj_iActualPrepairTime - ppj.ppj_iStopTime - splDinnerTime; } return total; }
public bool IsExistRecord(object KeyObject) { MaterialProfile_mlpf_Info obj = KeyObject as MaterialProfile_mlpf_Info; using (DBContext uow =new DBContext()) { string hql = "select m.mlpf_cMaterialCode from MaterialProfile_mlpf_Info m where m.mlpf_cMaterialCode=:mlpf_cMaterialCode"; IList<MaterialProfile_mlpf_Info> list = uow.CurrentSession.CreateQuery(hql).SetString("mlpf_cMaterialCode", obj.mlpf_cMaterialCode).List<MaterialProfile_mlpf_Info>(); if (list.Count > 0) { return true; } return false; } }
public bool IsExistRecord(object KeyObject) { int iRecordID = Convert.ToInt32(KeyObject); using (DBContext uow =new DBContext()) { string hql = "select m.aod_iRecordID from AheadOfOffDuty_aod_Info m where m.aod_iRecordID=:aod_iRecordID"; IList<AheadOfOffDuty_aod_Info> list = uow.CurrentSession.CreateQuery(hql).SetString("aod_iRecordID", iRecordID.ToString()).List<AheadOfOffDuty_aod_Info>(); if (list.Count > 0) { return true; } return false; } }
public bool IsExistRecord(object KeyObject) { int iRecord = Convert.ToInt32(KeyObject); using (DBContext uow = new DBContext()) { string hql = "select m.sim_iRecordID from StaffInfoMaster_sim_Info m where m.sim_iRecordID=:sim_iRecordID"; IList<StaffInfoMaster_sim_Info> list = uow.CurrentSession.CreateQuery(hql).SetString("sim_iRecordID", iRecord.ToString()).List<StaffInfoMaster_sim_Info>(); if (list.Count > 0) { return true; } return false; } }
/// <summary> /// 停機記錄實際停機時間=停機開始時間-停機結束時間-就餐時間 /// </summary> /// <param name="project"></param> /// <returns></returns> public static int ProjectStopRecordActualTime(DBContext db, ProjectStopRecord_psrd_Info stopRecord) { if (stopRecord.psrd_dBeginTime != null && stopRecord.psrd_dEndTime != null) { #region 当前停机记录的就餐时间 var dinnerQuery = db.CurrentSession.QueryOver<DinnerRecord_dnr_Info>().And(d => d.dsm_ppjID == stopRecord.psrd_PPJID); dinnerQuery.And(d => d.dsm_splID == stopRecord.psrd_SPLID); dinnerQuery.And(d => d.dsm_psrdID == stopRecord.psrd_RecordID); int dinnerTime = (int)dinnerQuery.And(d => d.dnr_DSMID != Guid.Empty).List().Sum(d => (d.dnr_dEndTime.Value - d.dnr_dBeginTime.Value).TotalSeconds); #endregion int total = (int)(stopRecord.psrd_dEndTime.Value - stopRecord.psrd_dBeginTime.Value).TotalSeconds - dinnerTime; return total; } return 0; }
bool ISync.Upload(object parentID) { try { ShowMessage("上傳維修要求記錄"); IList<RepairRequestReg_rrr_Info> sourceList; //加載LOCAL維修記錄 using (DBContext uow_loc = new DBContext(NHConfigFactory.DBConfig.PPC)) { var query = uow_loc.CurrentSession.QueryOver<RepairRequestReg_rrr_Info>().And(d => d.rrr_dEndTime != null && d.rrr_lSync == false); sourceList = query.List<RepairRequestReg_rrr_Info>(); } using (DBContext uow_svr = DBContext.Begin(NHConfigFactory.DBConfig.HBIMSN)) { //保存Local維修記錄到SERVER foreach (var item in sourceList) { uow_svr.CurrentSession.Save(item); } } using (DBContext uow_loc = new DBContext(NHConfigFactory.DBConfig.PPC)) { foreach (var item in sourceList) { item.rrr_lSync = true; uow_loc.CurrentSession.Update(item); } } return true; } catch (Exception ex) { Common.General.BLLoger.Error(ex); return false; //throw ex; } }
bool ISync.Download(string machineID) { try { ShowMessage("同步班次類型主檔..."); IList<ShiftTypeMaster_stm_Info> sourceList; //加載SERVER班次類型主檔 using (DBContext uow = new DBContext(NHConfigFactory.DBConfig.HBIMSN)) { var query = uow.CurrentSession.QueryOver<ShiftTypeMaster_stm_Info>(); sourceList = query.List<ShiftTypeMaster_stm_Info>(); } using (DBContext uow = DBContext.Begin(NHConfigFactory.DBConfig.PPC)) { try { uow.CurrentSession.CreateQuery("delete from ShiftTypeMaster_stm_Info").ExecuteUpdate(); //保存SERVER班次類型主檔到LOCAL foreach (var item in sourceList) { uow.CurrentSession.Save(item); } Common.General.BLLoger.Debug("同步更次類型主檔完成。"); } catch (Exception) { uow.CanCommit = false; throw; } } return true; } catch (Exception ex) { Common.General.BLLoger.Error(ex); return false; //throw ex; } }
bool ISync.Download(string machineID) { try { ShowMessage("同步機台主檔..."); IList<MachineMaster_mmt_Info> sourceList; MachineMasterBL mmbl = new MachineMasterBL(); if (!mmbl.CheckNeedUpdate()) { ShowMessage("機台主檔不需要更新。"); return true; } //加載SERVER機台主檔 using (DBContext uow = new DBContext(NHConfigFactory.DBConfig.HBIMSN)) { var query = uow.CurrentSession.QueryOver<MachineMaster_mmt_Info>(); sourceList = query.List<MachineMaster_mmt_Info>(); } using (DBContext uow = DBContext.Begin(NHConfigFactory.DBConfig.PPC)) { uow.CurrentSession.CreateQuery("delete from MachineMaster_mmt_Info").ExecuteUpdate(); //保存SERVER機台主檔到LOCAL foreach (var item in sourceList) { uow.CurrentSession.Save(item); } } ShowMessage("同步機台主檔完成"); return true; } catch (Exception ex) { string message = "同步機台主檔失敗" + ex.Message; ShowMessage(message); Common.General.BLLoger.Error(message); return false; //throw ex; } }
public bool IsExistRecord(object KeyObject) { try { Guid recordID = (Guid)KeyObject; using (DBContext uow = new DBContext()) { string hql = "select m.pjsr_cRecordID from ProjectStopReason_pjsr_Info m where m.pjsr_cRecordID=:pjsr_cRecordID"; IList<ProjectStopReason_pjsr_Info> list = uow.CurrentSession.CreateQuery(hql).SetString("pjsr_cRecordID", recordID.ToString()).List<ProjectStopReason_pjsr_Info>(); if (list.Count > 0) { return true; } return false; } } catch (Exception ex) { throw ex; } }
bool ISync.Download(string machineID) { try { ShowMessage("同步字碼主檔..."); IList<CodeMaster_cmt_Info> sourceList; CodeMasterBL cmbl = new CodeMasterBL(); //if (!cmbl.CheckNeedUpdate()) //{ // ShowMessage("字碼主檔不需要更新。"); // return true; //} //加載SERVER字碼主檔 using (DBContext uow = new DBContext(NHConfigFactory.DBConfig.HBIMSN)) { var query = uow.CurrentSession.QueryOver<CodeMaster_cmt_Info>(); sourceList = query.List<CodeMaster_cmt_Info>(); } using (DBContext uow = DBContext.Begin(NHConfigFactory.DBConfig.PPC)) { //刪除LOCAL字碼主檔 uow.CurrentSession.CreateQuery("delete from CodeMaster_cmt_Info").ExecuteUpdate(); uow.CurrentSession.SessionFactory.Evict(typeof(CodeMaster_cmt_Info)); //保存SERVER字碼主檔到LOCAL foreach (var item in sourceList) { uow.CurrentSession.Save(item); } uow.CurrentSession.Flush(); } return true; } catch (Exception ex) { Common.General.BLLoger.Error(ex); return false; //throw ex; } }
public List<StaffInfoMaster_sim_Info> SearchRecords(Model.IModel.IModelObject searchCondition) { StaffInfoMaster_sim_Info cond = searchCondition as StaffInfoMaster_sim_Info; using (DBContext uow =new DBContext()) { var query = uow.CurrentSession.QueryOver<StaffInfoMaster_sim_Info>().Where(d => d.sim_lIsAtive); if (!String.IsNullOrEmpty(cond.sim_cStaffNo)) { query.And(d => d.sim_cStaffNo.Contains(cond.sim_cStaffNo)); } if (!String.IsNullOrEmpty(cond.sim_cMachineID)) { query.And(d => d.sim_cMachineID == cond.sim_cMachineID); } query.And(d => d.sim_lIsCaptain == cond.sim_lIsCaptain); return (List<StaffInfoMaster_sim_Info>)(query.OrderBy(d => d.sim_cStaffNo).Asc.List()); } }
public static SpareStatus_sst_Info GetCurrentIdle(string machineNO, Guid shiftInfoID) { try { DBContext db = new DBContext(); SpareStatus_sst_Info info = db.CurrentSession.QueryOver<SpareStatus_sst_Info>().And(d => d.sst_cMachineNO == machineNO && d.sst_iSIFOID == shiftInfoID) .And(d => d.sst_dEndTime == null).Take(1).SingleOrDefault(); if (info != null) { return info; } } catch (Exception ex) { Common.General.BLLoger.Error(ex); } return null; }
public List<ShiftProjList_spl_Info> GetLastProjectSPLs(Guid swlID) { List<ShiftProjList_spl_Info> result = null; try { string sql = @"SELECT A.* FROM ShiftProjList_spl A LEFT JOIN PrintProject_ppj B ON PPJ_RECORDID=SPL_PPJID LEFT JOIN ScheduleProjList_swl C ON SWL_RECORDID=PPJ_SWLID WHERE C.[swl_RecordID] =? order by ppj_dProjBeginTime desc limit 0,1"; using (DBContext db = new DBContext()) { result = db.CurrentSession.CreateSQLQuery(sql).AddEntity(typeof(ShiftProjList_spl_Info)).SetString(0, swlID.ToString()).List<ShiftProjList_spl_Info>().ToList(); db.CurrentSession.Clear(); } } catch (Exception) { throw; } return result; }
public List<ProjectQCRecord_pqc_Info> GetLastProjectQCRecord(Guid scheduleProjectID) { List<ProjectQCRecord_pqc_Info> resultList = null; try { using (DBContext uow = new DBContext()) { var query = uow.CurrentSession.GetNamedQuery(NHSqlQueryName.SelectQuery.GetLastProjectQCRecord.ToString()); query.SetParameter(0, scheduleProjectID.ToString()); resultList = query.List<ProjectQCRecord_pqc_Info>().ToList(); } } catch (Exception ex) { //throw ex; Common.General.DALoger.Error(ex); } return resultList; }
bool ISync.Download(string machineID) { try { ShowMessage("同步保養動作..."); IList<MaintainOperationMaster_mom_Info> sourceList; //加載SERVER保養操作主檔 using (DBContext uow = new DBContext(NHConfigFactory.DBConfig.HBIMSN)) { var query = uow.CurrentSession.QueryOver<MaintainOperationMaster_mom_Info>(); sourceList = query.List<MaintainOperationMaster_mom_Info>(); } using (DBContext uow = DBContext.Begin(NHConfigFactory.DBConfig.PPC)) { var query_local = uow.CurrentSession.CreateQuery("delete from MaintainOperationMaster_mom_Info"); query_local.ExecuteUpdate(); //保存SERVER保養操作主檔到LOCAL foreach (var item in sourceList) { uow.CurrentSession.Save(item); } } return true; } catch (Exception ex) { string message = "同步保養動作失敗:" + ex.Message; ShowMessage(message); Common.General.BLLoger.Error(message); return false; //throw ex; } }
public bool DeleteShiftProjectStopRecords(Guid splID) { bool result = false; try { using (DBContext db = new DBContext()) { string sql = @"delete from ProjectStopRecord_psrd where psrd_SPLID=?"; var query = db.CurrentSession.CreateSQLQuery(sql); query.SetParameter(0, splID.ToString()); query.ExecuteUpdate(); } result = true; } catch (Exception ex) { Logger.Error(ex); throw ex; } return result; }
public static bool CheckPPCOnline() { try { Common.General.BLLoger.Info("檢測PPC網絡是否正常"); string address = ConfigUtil.GetAppSetting(Common.DefineConstantValue.DBServerAddress); if (string.IsNullOrEmpty(address)) { using (var dbCtrx = new DBContext(NHConfigFactory.DBConfig.HBIMSN)) { var conn = dbCtrx.CurrentSession.Connection as SqlConnection; address = conn.DataSource; Common.Util.ConfigUtil.SetAppSetting(Common.DefineConstantValue.DBServerAddress, address); } } Common.General.BLLoger.Debug("檢測PPC IP地址:" + address); if (!String.IsNullOrEmpty(address)) { Ping ping = new Ping(); PingReply r = ping.Send(address); if (r.Status == IPStatus.Success) { return true; } else { Common.General.BLLoger.Info("PPC網絡異常"); return false; } } } catch (Exception ex) { Common.General.BLLoger.Info("PPCStatusManage.PPCCheckPPCOnline", ex); } return false; }
/// <summary> /// 開始用餐 /// </summary> /// <returns></returns> public static bool AddDinnerRecord(DinnerRecord_dnr_Info dnr) { bool result = false; try { using (NHibernateTransaction.DBContext db = new NHibernateTransaction.DBContext()) { dnr.dnr_dAddDate = DateTime.Now; dnr.dnr_dLastDate = DateTime.Now; db.CurrentSession.Save(dnr); } } catch (Exception e) { Common.General.BLLoger.Error(e); //throw; } return result; }
bool ISync.Download(string machineID) { try { ShowMessage("同步假期主檔..."); IList<VacationMaster_vcm_Info> sourceList; //加載SERVER假期主檔 using (DBContext uow = new DBContext(NHConfigFactory.DBConfig.HBIMSN)) { var query = uow.CurrentSession.QueryOver<VacationMaster_vcm_Info>(); sourceList = query.List<VacationMaster_vcm_Info>(); } using (DBContext uow = DBContext.Begin(NHConfigFactory.DBConfig.PPC)) { uow.CurrentSession.CreateQuery("delete from VacationMaster_vcm_Info").ExecuteUpdate(); // uow.CurrentSession.SessionFactory.Evict(typeof(VacationMaster_vcm_Info)); //保存SERVER假期主檔到LOCAL foreach (var item in sourceList) { uow.CurrentSession.Save(item); } } return true; } catch (Exception ex) { Common.General.BLLoger.Error(ex); return false; //throw ex; } }
public ProjectStopRecord_psrd_Info GetLastStopRecord(Guid projectID) { try { using (DBContext session = new DBContext()) { var query = session.CurrentSession.QueryOver<ProjectStopRecord_psrd_Info>(); query.And(d => d.psrd_dEndTime == null); query.And(d => d.psrd_PPJID == projectID).OrderBy(d => d.psrd_dBeginTime).Desc.Take(1); IList<ProjectStopRecord_psrd_Info> list = query.List(); if (list != null && list.Count > 0) { return list[0]; } return null; } } catch (Exception ex) { Common.General.DALoger.Error(ex); throw ex; } }
bool ISync.Download(string machineID) { try { ShowMessage("同步工程狀態信號控制主檔..."); IList<SignalLightsStatus_sls_Info> sourceList; //加載SERVER區域主檔 using (DBContext uow = new DBContext(NHConfigFactory.DBConfig.HBIMSN)) { var query = uow.CurrentSession.QueryOver<SignalLightsStatus_sls_Info>(); sourceList = query.List<SignalLightsStatus_sls_Info>(); } using (DBContext uow = DBContext.Begin(NHConfigFactory.DBConfig.PPC)) { uow.CurrentSession.CreateQuery("delete from SignalLightsStatus_sls_Info").ExecuteUpdate(); //保存SERVER區域主檔到LOCAL foreach (var item in sourceList) { uow.CurrentSession.Save(item); } } return true; } catch (Exception ex) { Common.General.BLLoger.Error(ex); return false; } }
bool ISync.Download(string machineID) { try { ShowMessage("同步機器停機原因主檔..."); IList<MachineStopReasonProfile_msrp_Info > sourceList; //加載SERVER停機原因主檔 using (DBContext uow = new DBContext(NHConfigFactory.DBConfig.HBIMSN)) { var query = uow.CurrentSession.QueryOver<MachineStopReasonProfile_msrp_Info>(); sourceList = query.List<MachineStopReasonProfile_msrp_Info>().Where(w=>w.msrp_cMachineID==machineID).ToList(); } using (DBContext uow = DBContext.Begin(NHConfigFactory.DBConfig.PPC)) { uow.CurrentSession.CreateQuery("delete from MachineStopReasonProfile_msrp_Info").ExecuteUpdate(); //保存SERVER停機原因主檔到LOCAL foreach (var item in sourceList) { uow.CurrentSession.Save(item); } } return true; } catch (Exception ex) { Common.General.BLLoger.Error(ex); return false; //throw ex; } }