Example #1
0
        public TreeNodeInfo[] GetMenuTreeNodes(CustEnum.System system)
        {
            List<Sys_FormMaster_fom_Info> infos = new List<Sys_FormMaster_fom_Info>();

            List<TreeNodeInfo> treeNodeInfoList = new List<TreeNodeInfo>();
            TreeNodeInfo rootNodeInfo = null;
            TreeNodeInfo[] treeNodeInfos = null;

            TreeNodeInfo itemNodeInfo = null;

            infos = _sysFormMasterDA.GetWinTreeNode(system.ToString());

            foreach (Sys_FormMaster_fom_Info inf in infos)
            {
                Sys_FormMaster_fom_Info info = inf;
                rootNodeInfo = new TreeNodeInfo();
                rootNodeInfo.Text = info.fom_cFormDesc;
                rootNodeInfo.Name = info.fom_cFormNumber;
                rootNodeInfo.Tag = info.fom_cExePath;
                rootNodeInfo.Index = info.fom_iIndex;

                rootNodeInfo.FileName = info.fom_iRecordID.ToString();

                TreeNodeInfo nodeInfo = null;
                info = new Sys_FormMaster_fom_Info();
                info.fom_iParentID = int.Parse(rootNodeInfo.FileName.ToString());
                foreach (var chile in _sysFormMasterDA.SearchRecords(info, "all"))
                {
                    info = chile as Sys_FormMaster_fom_Info;
                    string Name = info.fom_iRecordID.ToString();
                    nodeInfo = null;
                    nodeInfo = LocalGeneralMenu.Instance.InsertTreeNode(rootNodeInfo, info.fom_cFormDesc, info.fom_cExePath, info.fom_cFormNumber, info.fom_iIndex, info.fom_iImageIndex);
                    info = new Sys_FormMaster_fom_Info();
                    info.fom_iParentID = int.Parse(Name.ToString());
                    foreach (var q in _sysFormMasterDA.SearchRecords(info, "all"))
                    {
                        info = q as Sys_FormMaster_fom_Info;

                        if (info.fom_cFormNumber.ToString().ToUpper() == "DEMO")
                        {
                            itemNodeInfo = LocalGeneralMenu.Instance.InsertTreeNode(nodeInfo, info.fom_cFormDesc, info.fom_cExePath, info.fom_cFormNumber, info.fom_iIndex, info.fom_iImageIndex);
                            itemNodeInfo.Remark = "EXE";
                            itemNodeInfo.FileName = "WPFUI\\WPFUI.exe";
                        }
                        else
                            LocalGeneralMenu.Instance.InsertTreeNode(nodeInfo, info.fom_cFormDesc, info.fom_cExePath, info.fom_cFormNumber, info.fom_iIndex, info.fom_iImageIndex);
                    }
                }
                treeNodeInfoList.Add(rootNodeInfo);

            }
            treeNodeInfos = treeNodeInfoList.ToArray();

            return treeNodeInfos;
        }
Example #2
0
        public TreeNodeInfo[] CheckUser(Sys_UserMaster_usm_Info userInfo, CustEnum.System system)
        {
            TreeNodeInfo[] treeNodeInfos = null;
            if (userInfo.usm_cUserLoginID.ToUpper() == "SA")
            {
                treeNodeInfos = GetMenuTreeNodes(system);
            }
            else
            {
                treeNodeInfos = GetMenuTreeNodes(userInfo);
            }

            return treeNodeInfos;
        }
Example #3
0
        public TreeNodeInfo[] GetMenuTreeNodes(CustEnum.System system)
        {
            TreeNodeInfo[] treeNodeInfos = null;

            try
            {
                treeNodeInfos = _systemMenuDA.GetMenuTreeNodes(system);
            }
            catch
            {
                throw;
            }

            return treeNodeInfos;
        }
Example #4
0
        /// <summary>
        /// 删除指定工序的指定日期前的待同步保养记录
        /// </summary>
        /// <param name="dtDeadline">指定日期,精确到日</param>
        /// <returns></returns>
        public bool DeleteMaintainRecordsToMaximo(CustEnum.ProdProcess processType, DateTime dtDeadline)
        {
            bool resRtn = false;

            dtDeadline = dtDeadline.Date;

            string strSqlConn = string.Empty;

            try
            {
                strSqlConn = DbHelperSQL.GetProcessSQLConnString(processType);

                if (!string.IsNullOrEmpty(strSqlConn))
                {
                    using (SqlConnection conn = new SqlConnection(strSqlConn))
                    {
                        SqlTransaction transaction = null;
                        conn.Open(); //開啟連接
                        transaction = conn.BeginTransaction(); //開啟事務

                        try
                        {
                            resRtn = this.m_TransformToMaximoDAL.DeleteMaintainRecordsToMaximo(dtDeadline, transaction);
                        }
                        catch (Exception exTran)
                        {
                            resRtn = false;
                            throw exTran;
                        }
                        finally
                        {
                            if (resRtn)
                                transaction.Commit();
                            else
                                transaction.Rollback();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                resRtn = false;
                throw ex;
            }

            return resRtn;
        }
Example #5
0
        /// <summary>
        /// 返回字碼主檔
        /// add by justinleung
        /// </summary>
        /// <param name="system">系統名稱</param>
        /// <param name="key1">模塊1</param>
        /// <param name="key2">模塊2</param>
        /// <returns></returns>
        public IList<CodeMaster_cmt_Info> GetCodeMasters(CustEnum.System system, CustEnum.KEY1 key1, CustEnum.KEY2 key2)
        {
            IList<CodeMaster_cmt_Info> infos = null;
            if (CustEnum.System.HBManager == system)
            {
                try
                {
                    this._codeMasterDA = SQLDAFactory.GetDAL<ICodeMasterDA>(SQLDAFactory.CodeMaster_cmt);
                    //Dictionary<string, object> param = new Dictionary<string, object>();
                    //param.Add("cmt_cKey1", Enum.GetName(key1.GetType(), key1));
                    //param.Add("cmt_cKey2", Enum.GetName(key2.GetType(), key2));
                    CodeMaster_cmt_Info info = new CodeMaster_cmt_Info();
                    info.cmt_cKey1 = Enum.GetName(key1.GetType(), key1);
                    info.cmt_cKey2 = Enum.GetName(key2.GetType(), key2);
                    infos = this._codeMasterDA.SearchRecords(info);
                }
                catch
                {
                    throw new Exception(Resource.B0002);
                }

            }
            //else if (CustEnum.System.PPC == system)
            //{
            //    try
            //    {
            //        this._codeMasterDA = SQLiteDAFacotry.CodeMasterDAInstance;
            //        Dictionary<string, object> param = new Dictionary<string, object>();
            //        param.Add("cmt_cKey1", Enum.GetName(key1.GetType(), key1));
            //        param.Add("cmt_cKey2", Enum.GetName(key2.GetType(), key2));
            //        infos = this._codeMasterDA.GetEntities<CodeMaster_cmt_Info>(param).OrderBy(d=>d.cmt_cValue).ToList();
            //    }
            //    catch (Exception ex)
            //    {
            //        throw new Exception(Resource.B0001 + ex.Message);
            //    }
            //}

            return infos;
        }
Example #6
0
        //public ReturnValueInfo DeleteRecord_Sqlite(ProjectQCRecord_pqc_Info model)
        //{
        //    using (DBContext uow = DBContext.Begin())
        //    {
        //        try
        //        {
        //            ReturnValueInfo rvInfo = new ReturnValueInfo();
        //            //ReturnValueInfo rvInfoRecord = new ReturnValueInfo();
        //            if (model.ListProblemRecords != null)
        //            {
        //                foreach (ProjectQCProblem_pqcp_Info problemItem in model.ListProblemRecords)
        //                {
        //                    uow.CurrentSession.Delete(problemItem);
        //                }
        //            }
        //            //rvInfoRecord = this._IProjectQCRecordDA_Sqlite.Delete(model);
        //            //if (!rvInfoRecord.boolValue || rvInfoRecord.isError)
        //            //{
        //            //    return rvInfoRecord;
        //            //}
        //            rvInfo.boolValue = true;
        //            return rvInfo;
        //        }
        //        catch (Exception ex)
        //        {
        //            throw ex;
        //        }
        //    }
        //}
        public bool AddQCBlankRecord(ProjectQCRecord_pqc_Info pqcRecord, CustEnum.RecordType recordType)
        {
            try
            {
                using (DBContext uow = DBContext.Begin())
                {
                    int maxRecord = 0;
                    QCPloblemView_qcpv_Info lastRec = uow.CurrentSession.QueryOver<QCPloblemView_qcpv_Info>().And(d => d.pqc_SPLID == pqcRecord.pqc_SPLID).OrderBy(d => d.pqc_iQCTimes).Desc.Take(1).SingleOrDefault();
                    if (lastRec != null)
                    {
                        maxRecord = lastRec.pqc_iQCTimes;
                    }

                    ProjectQCRecord_pqc_Info pqc = new ProjectQCRecord_pqc_Info();
                    pqc.pqc_RecordID = Guid.NewGuid();
                    pqc.pqc_iQCQTY = 0;
                    pqc.pqc_iProdQTY = pqcRecord.pqc_iProdQTY;
                    pqc.pqc_iQCTimes = maxRecord + 1;
                    pqc.pqc_cMode = CustEnum.RecordMode.MANUAL.ToString();
                    pqc.pqc_cType = recordType.ToString();
                    pqc.pqc_dAddDate = DateTime.Now;
                    pqc.pqc_SPLID = pqcRecord.pqc_SPLID;
                    uow.CurrentSession.Save(pqc);

                    uow.CurrentSession.CreateQuery("update ShiftProjList_spl_Info set spl_iQCTimes=:spl_iQCTimes where spl_RecordID=:spl_RecordID").SetInt32("spl_iQCTimes", pqc.pqc_iQCTimes).SetGuid("spl_RecordID", pqcRecord.pqc_SPLID).ExecuteUpdate();

                    uow.CurrentSession.Flush();
                    return true;
                }

            }
            catch (Exception ex)
            {

                return false;
                throw ex;
            }
        }
 /// <summary>
 /// 設置信息燈狀態
 /// </summary>
 /// <param name="projectStatus">工程狀態</param>
 public abstract void SetSignalStatus(CustEnum.ProjectStatus projectStatus);
Example #8
0
        /// <summary>
        /// 返回字碼主檔VALUE對應TEXT
        /// add by justinleung
        /// </summary>
        /// <param name="system">系統名稱</param>
        /// <param name="key1">模塊1</param>
        /// <param name="key2">模塊2</param>
        /// <param name="value">鍵值</param>
        /// <returns>鍵值對應字符</returns>
        public CodeMaster_cmt_Info GetText(CustEnum.System system, CustEnum.KEY1 key1, CustEnum.KEY2 key2, string value)
        {
            CodeMaster_cmt_Info info = null;
            if (CustEnum.System.HBManager == system)
            {
                try
                {
                    this._codeMasterDA = SQLDAFactory.GetDAL<ICodeMasterDA>(SQLDAFactory.CodeMaster_cmt);
                }
                catch
                {
                    throw new Exception(Resource.B0002);
                }

            }
            //else if (CustEnum.System.PPC == system)
            //{
            //    try
            //    {
            //        this._codeMasterDA = SQLiteDAFacotry.CodeMasterDAInstance;
            //        Dictionary<string, object> param = new Dictionary<string, object>();
            //        param.Add("cmt_cKey1", Enum.GetName(key1.GetType(), key1));
            //        param.Add("cmt_cKey2", Enum.GetName(key2.GetType(), key2));
            //        param.Add("cmt_cValue", value);
            //        info = this._codeMasterDA.GetEntity<CodeMaster_cmt_Info>(param);
            //    }
            //    catch
            //    {
            //        throw new Exception(Resource.B0001);
            //    }
            //}

            return info;
        }
        /// <summary>
        /// 功能權限設置
        /// </summary>
        /// <param name="status">工程狀態</param>
        void FunctionEnableSetting(CustEnum.ProjectStatus status)
        {
            CommonDefine.ProjectStatusFunctionEnable functionEnable = new CommonDefine.ProjectStatusFunctionEnable();
            switch (status)
            {
                case CustEnum.ProjectStatus.PREPARE:
                    functionEnable.ClearQty = false;
                    functionEnable.CorrectQty = false;
                    functionEnable.Stop = false;
                    functionEnable.ProjectEnd = false;
                    functionEnable.More = true;
                    functionEnable.Setting = true;
                    functionEnable.Reset = true;
                    functionEnable.SetPerQty = true;

                    break;
                case CustEnum.ProjectStatus.PROD_IN:

                    functionEnable.ClearQty = true;
                    functionEnable.CorrectQty = true;
                    functionEnable.More = true;
                    functionEnable.Stop = false;
                    functionEnable.ProjectEnd = false;
                    functionEnable.Setting = true;
                    functionEnable.Reset = true;
                    functionEnable.SetPerQty = true;

                    break;
                case CustEnum.ProjectStatus.PROD_STOP:
                    functionEnable.ClearQty = true;
                    functionEnable.CorrectQty = true;
                    functionEnable.Stop = true;
                    functionEnable.ProjectEnd = true;
                    functionEnable.More = true;
                    functionEnable.Setting = true;
                    functionEnable.Reset = true;
                    functionEnable.SetPerQty = true;

                    break;
                case CustEnum.ProjectStatus.INITIAL:
                    functionEnable.ClearQty = false;
                    functionEnable.CorrectQty = false;
                    functionEnable.Stop = false;
                    functionEnable.ProjectEnd = false;
                    functionEnable.More = false;
                    functionEnable.Setting = false;
                    functionEnable.Reset = false;
                    functionEnable.SetPerQty = false;

                    break;
                default:
                    functionEnable.ClearQty = false;
                    functionEnable.CorrectQty = false;
                    functionEnable.Stop = false;
                    functionEnable.ProjectEnd = false;
                    functionEnable.More = false;
                    functionEnable.Setting = false;
                    functionEnable.Reset = false;
                    functionEnable.SetPerQty = false;

                    break;
            }

            this.OnProjectStatusFunctionEnable(functionEnable);
        }
        /// <summary>
        /// 生產工程狀態設置
        /// </summary>
        /// <param name="projectStatus">工程狀態</param>
        public override void ProductionProjectStatusSetting(CustEnum.ProjectStatus projectStatus)
        {
            if (this._currentProjectStatus != projectStatus)
            {
                if (projectStatus != CustEnum.ProjectStatus.INITIAL)
                {
                    this._currentProjectStatus = projectStatus;
                }

                this.SetSingnalLightStatus(projectStatus);

                this.OnMachineProductionStatusChange(projectStatus);
            }
        }
Example #11
0
        /// <summary>
        /// 根據KEY批量刪除數據
        /// </summary>
        /// <param name="p_strKey1"></param>
        /// <param name="p_strKey2"></param>
        /// <returns></returns>
        /// <remarks>(NO:0005078) 現時只用於刪除從Maximo系統同步過來的機台部件  Add By Leothlik TonyWu On 18/07/2014</remarks>
        public bool RemoveByKey(CustEnum.KEY1 key1)
        {
            bool isSuccess = false;
            try
            {
                using (MainDBDataContext db = new MainDBDataContext())
                {
                    string l_strKey1 = Enum.GetName(key1.GetType(), key1);

                    var l_lisOldData = db.CodeMaster_cmt.Where(p => p.cmt_cKey1 == l_strKey1.Trim()).ToList();

                    if (l_lisOldData.Count > 0)
                    {
                        db.CodeMaster_cmt.DeleteAllOnSubmit(l_lisOldData);
                        db.SubmitChanges();
                        isSuccess = true;
                    }
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            return isSuccess;
        }
Example #12
0
        /// <summary>
        /// 分析工程生產狀態
        /// </summary>
        /// <param name="machineStatus"></param>
        /// <param name="oldStatus"></param>
        /// <param name="schProj"></param>
        /// <returns></returns>
        private CustEnum.ProductionStatus AnalysisProdStatus(DBContext uow, CustEnum.MachineStatus machineStatus, CustEnum.ProductionStatus oldStatus, ScheduleProjList_swl_Info project, PrintProject_ppj_Info ppj, ShiftProjList_spl_Info spl)
        {
            CustEnum.ProductionStatus newStatus = CustEnum.ProductionStatus.STOP;
            if (project != null && (project.swl_cProjStatus == CustEnum.ProjectStatus.PREPARE.ToString() || project.swl_cProjStatus == CustEnum.ProjectStatus.PREPARE_OT.ToString()))
            {
                if (machineStatus == CustEnum.MachineStatus.MACHINE_PRODUCTION)//開始生產
                {
                    newStatus = CustEnum.ProductionStatus.PROD_BEGIN;
                }
                else if (machineStatus == CustEnum.MachineStatus.MACHINE_SHUTDOWN)
                {
                    newStatus = CustEnum.ProductionStatus.PRO_PREPARE;
                }
            }
            else if (project != null
                && (project.swl_cProjStatus == CustEnum.ProjectStatus.PROD_IN.ToString()
                || project.swl_cProjStatus == CustEnum.ProjectStatus.PROD_SLOW.ToString()
                || project.swl_cProjStatus == CustEnum.ProjectStatus.PROD_STOP.ToString()
                || project.swl_cProjStatus == CustEnum.ProjectStatus.PROD_STOP_OT.ToString()))
            {
                if (machineStatus == CustEnum.MachineStatus.MACHINE_PRODUCTION)//開機
                {

                    if (oldStatus == CustEnum.ProductionStatus.PROD_STOP)
                    {
                        newStatus = CustEnum.ProductionStatus.PROD_RESART;//生產繼續
                    }
                    else
                    {
                        newStatus = CustEnum.ProductionStatus.PROD_IN;//生產中
                    }
                }
                else if (machineStatus == CustEnum.MachineStatus.MACHINE_SHUTDOWN)//停機
                {

                    if (oldStatus == CustEnum.ProductionStatus.PROD_IN || project.swl_cProjStatus == CustEnum.ProjectStatus.PROD_SLOW.ToString())
                    {

                        int totalTimes = (int)(DateTime.Now - project.PROD_STOP_Datetime.Value).TotalSeconds;//已經停機的時間

                        #region 停機期間是否存在用餐記錄
                        var dinnerQuery = uow.CurrentSession.QueryOver<DinnerRecord_dnr_Info>().And(d => d.dsm_swlID == project.swl_RecordID);
                        dinnerQuery.And(d => d.dsm_ppjID == ppj.ppj_RecordID);
                        dinnerQuery.And(d => d.dsm_splID == spl.spl_RecordID);
                        dinnerQuery.And(d => d.dnr_dEndTime > project.PROD_STOP_Datetime);//停機在就餐結束前發生
                        dinnerQuery.And(d => d.dsm_cProjectStatus == CustEnum.ProjectStatus.PROD_IN.ToString());
                        dinnerQuery.And(d => d.dnr_DSMID != Guid.Empty);

                        var piDinnerRecord = dinnerQuery.List();
                        if (piDinnerRecord.Count > 0)
                        {
                            DinnerRecord_dnr_Info dnr = piDinnerRecord[0];
                            mLog.Debug("--------當前機台停機,就餐中,就餐時間=" + (int)(dnr.dnr_dEndTime.Value - dnr.dnr_dBeginTime.Value).TotalSeconds);
                            totalTimes -= (int)(dnr.dnr_dEndTime.Value - dnr.dnr_dBeginTime.Value).TotalSeconds;
                        }

                        #endregion

                        mLog.Debug("檢查到當前PLC 機台狀態是停機狀態,持續時間" + totalTimes.ToString());

                        if (totalTimes > project.PROD_STOP_COND * 60) //超出最長停機時間
                        {
                            newStatus = CustEnum.ProductionStatus.PROD_STOP;//生產中停機
                        }
                        else
                        {
                            newStatus = oldStatus;
                        }

                    }
                    else if (oldStatus == CustEnum.ProductionStatus.PROD_STOP || project.swl_cProjStatus == CustEnum.ProjectStatus.PROD_STOP_OT.ToString())
                    {
                        newStatus = oldStatus;
                    }

                }
            }

            mLog.Debug("當前工程狀態=" + newStatus.ToString());
            return newStatus;
        }
Example #13
0
        public CustEnum.ProductionStatus SaveData(CustEnum.ProductionStatus prodStatus, ScheduleProjList_swl_Info schProj, PrintProject_ppj_Info printProj, ShiftProjList_spl_Info shiftProject, PLCData_pda_Info data, int savetoDBInterval)
        {
            DateTime start = DateTime.Now;

            ///工程生產狀態
            CustEnum.ProductionStatus status;
            try
            {
                //暫時關閉這項功能,由於可能存在性能問題
                //IPLCDataDA plcda = SQLiteDAFacotry.GetDAL<IPLCDataDA>(SQLiteDAFacotry.PLCDataDAL);
                //if (data != null && data.SaveToDB)
                //{
                //    //選擇工程後開始記錄機台PLC數據
                //    plcda.Insert(data);
                //}

                ///根據PLC返回數據,分析判斷機台狀態
                CustEnum.MachineStatus mstatus = AnalysisStatus(schProj, data);

                using (DBContext uow = DBContext.Begin())
                {
                    // 根據印刷工程狀態 與 機台狀態,得出印刷工程生產狀態
                    status = AnalysisProdStatus(uow, mstatus, prodStatus, schProj, printProj, shiftProject);
                    //Common.General.BLLoger.Debug("工程生產狀態--->" + status.ToString());
                    #region

                    //生產開始
                    switch (status)
                    {
                        case CustEnum.ProductionStatus.PRO_PREPARE:

                            //#region 更新印刷工程信息
                            //if (printProj.ppj_iPredictPrepairTime > 0)
                            //{
                            //    if (printProj.ppj_iActualPrepairTime > printProj.ppj_iPredictPrepairTime)
                            //    {
                            //        schProj.swl_cProjStatus = CustEnum.ProjectStatus.PREPARE_OT.ToString();
                            //        schProj.swl_dStatusChange = DateTime.Now;
                            //        schProj.swl_dLastDate = DateTime.Now;
                            //        uow.CurrentSession.Update(uow.CurrentSession.Merge(schProj));
                            //    }
                            //}
                            //#endregion

                            break;
                        case CustEnum.ProductionStatus.PROD_BEGIN:
                            if (status != prodStatus) //狀態改變
                            {

                                ProduceBegin(uow, schProj, printProj, shiftProject, data);
                            }
                            break;

                        //生產中
                        case CustEnum.ProductionStatus.PROD_IN:

                            Producing(uow, schProj, printProj, shiftProject, data, savetoDBInterval);

                            break;

                        //生產中停機
                        case CustEnum.ProductionStatus.PROD_STOP:

                            #region 記錄生產中停機信息
                            if (prodStatus != status) //狀態改變
                            {
                                ProduceStop(uow, schProj, printProj, shiftProject, data);
                            }
                            else
                            {
                                //判斷是否停機超時
                                IList<ProjectStopRecord_psrd_Info> psrd = uow.CurrentSession.QueryOver<ProjectStopRecord_psrd_Info>().And(d => d.psrd_PPJID == printProj.ppj_RecordID).And(d => d.psrd_dEndTime == null).OrderBy(d => d.psrd_dBeginTime).Desc.List();

                                if (psrd.Count > 0 && psrd[0].psrd_iPredictStopTime > 0)
                                {

                                    ProduceStop2Long(uow, schProj, printProj, shiftProject, psrd[0]);

                                    for (int index = 1; index < psrd.Count; index++)
                                    {
                                        psrd[index].psrd_dEndTime = DateTime.Now;
                                        uow.CurrentSession.Update(psrd[index]);
                                    }

                                }
                            }
                            #endregion

                            break;

                        //生產繼續
                        case CustEnum.ProductionStatus.PROD_RESART:

                            ProduceRestart(uow, schProj, printProj, shiftProject, data);

                            break;

                        default:
                            break;
                    }

                    #endregion

                }
            }
            catch (Exception ex)
            {

                Common.General.BLLoger.Debug(ex);
                throw new Exception(Resource.B0022);
            }
            DateTime end = DateTime.Now;

            if (savetoDBInterval == 0)
            {
                mLog.Debug("保存工程數據到數據庫,耗時" + (end - start).Milliseconds.ToString());
            }
            else
            {
                //mLog.Debug("不保存工程數據到數據庫,耗時" + (end - start).Milliseconds.ToString());
            }
            return status;
        }
Example #14
0
        public bool Remove(CustEnum.System system, CodeMaster_cmt_Info info)
        {
            if (CustEnum.System.HBManager == system)
            {
                try
                {
                    throw new NotImplementedException();
                }
                catch
                {

                    throw new Exception(Resource.B0006);
                }
            }
            //else if (CustEnum.System.PPC == system)
            //{
            //    try
            //    {
            //        this._codeMasterDA = SQLiteDAFacotry.CodeMasterDAInstance;
            //        this._codeMasterDA.Delete(info);

            //    }
            //    catch
            //    {
            //        throw new Exception(Resource.B0007);
            //    }
            //}
            return true;
        }
Example #15
0
        /// <summary>
        /// 設置信息燈狀態
        /// </summary>
        /// <param name="projectStatus">工程狀態</param>
        public override void SetSignalStatus(CustEnum.ProjectStatus projectStatus)
        {
            try
            {
                if (base.SignalLightsStatusInfos != null && base.SignalLightsStatusInfos.Count > 0)
                {
                    SignalLightsStatusInfo currentStatusInfo = base.SignalLightsStatusInfos.FirstOrDefault(x => x.Status == projectStatus.ToString());//匹配指定狀態的信號燈配置記錄

                    if (currentStatusInfo != null)
                    {
                        this.m_currentProjStatus = currentStatusInfo;
                    }
                    else
                    {
                        this.m_currentProjStatus = CreateInitialStatusInfo();
                    }
                }
            }
            catch (Exception)
            {

            }
        }
Example #16
0
        /// <summary>
        /// 同步指定工序的機台保養記錄到Maximo系統
        /// </summary>
        /// <returns></returns>
        public ReturnValueInfo SyncMacMaintainRecordsToMaximo(CustEnum.ProdProcess processType)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();

            if (this.m_MaximoServiceWS == null)
            {
                rvInfo.isError = true;
                rvInfo.messageText = "WebService未被初始化。";
                return rvInfo;
            }

            try
            {
                //獲取所有未上傳的保養待同步記錄
                List<MaintainRecordToMaximoRecord> listMaintainToMaximo = this.m_TransformToMaximoDAL.GetAllUnsyncMaintainRecordToMaximoRecord(processType);
                //轉換數據格式
                List<MaintainOperation> listMaintainOperation = ExchangeMaintainRecordsForService(listMaintainToMaximo);

                if (listMaintainOperation != null && listMaintainOperation.Count > 0)
                {
                    string strSqlConn = DbHelperSQL.GetProcessSQLConnString(processType);

                    //按保養記錄ID分組
                    IEnumerable<IGrouping<Guid, MaintainOperation>> groupMaintain = listMaintainOperation.GroupBy(x => x.MtrId);
                    foreach (IGrouping<Guid, MaintainOperation> itemGroup in groupMaintain)
                    {
                        Guid cMtrID = itemGroup.Key;
                        List<MaintainOperation> listMaintainOperationItems = itemGroup.ToList();
                        if (listMaintainOperationItems != null)
                        {
                            int iRtn = this.m_MaximoServiceWS.SaveMaintainList(cMtrID, listMaintainOperationItems.ToArray());

                            if (iRtn > 0)
                            {
                                using (SqlConnection conn = new SqlConnection(strSqlConn))
                                {
                                    SqlTransaction transaction = null;
                                    conn.Open(); //開啟連接
                                    transaction = conn.BeginTransaction(); //開啟事務

                                    bool res = false;
                                    try
                                    {
                                        foreach (MaintainOperation item in listMaintainOperationItems)
                                        {
                                            bool resUpdate = this.m_TransformToMaximoDAL.UpdateSynchronized_MaintainRecordToMaximo(item.RecordId, transaction);
                                        }
                                        res = true;
                                    }
                                    catch (Exception exUpdate)
                                    {
                                        throw exUpdate;
                                    }
                                    finally
                                    {
                                        if (res)
                                            transaction.Commit();
                                        else
                                            transaction.Rollback();
                                    }
                                }

                                rvInfo.messageText = "Sucess";
                                rvInfo.boolValue = true;
                            }
                            else
                            {
                                rvInfo.messageText = "上傳保養記錄失敗。";
                            }
                        }
                    }
                }
                else
                {
                    if (listMaintainToMaximo != null && listMaintainToMaximo.Count == 0)
                    {
                        rvInfo.boolValue = true;
                    }
                    else
                    {
                        rvInfo.messageText = "轉換保養記錄格式時出現異常。";
                    }
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }

            return rvInfo;
        }
        /// <summary>
        /// 檢查要“抽起”或“結束”的工程生產數據是否完整,如果不完整則返回一個殘缺數據的類型。
        /// </summary>
        /// <param name="departmentCode">機台所屬科組編號</param>
        /// <param name="operationType">操作類型“抽起”或“結束”</param>
        /// <param name="shiftInfo">當前班次信息</param>
        /// <param name="projectData">當前工程生產數據</param>
        /// <returns>返回一個殘缺的數據類型</returns>
        public override CommonDefine.ProjectDataType CheckProjectProductionDataFull(string departmentCode, CustEnum.ProjectStatus operationType, MachineShiftData shiftInfo, ProjectProductionData projectData)
        {
            try
            {
                CommonDefine.ProjectDataType l_enumDataFull = CommonDefine.ProjectDataType.DataFull;

                //■■■檢查“工程更多資料”是否缺少數據,如果缺少時返回一個“工程更多資料”類型,
                //需要根據不同科組來進行不同的檢查,並退出方法

                ReturnValueInfo projectAdditionalResult = this.CheckProjectAdditionalDataFull(departmentCode, projectData.ProjectMProductionData.AdditionalInformation);

                if (projectAdditionalResult != null)
                {
                    if (!projectAdditionalResult.boolValue)
                    {
                        return CommonDefine.ProjectDataType.ProjectAdditionalInformation;
                    }
                }

                //■■■檢查“停機記錄”列表中是否存在沒有 選擇停機原因的記錄,如果存在則返回一個“停機記錄”類型,並退出方法
                foreach (var item in projectData.ShiftProjectData.MachineHaltRecords)
                {
                    if (item.StopReasons == null || item.StopReasons.Count == 0)
                        return  CommonDefine.ProjectDataType.MachineHaltRecord;
                }

                //■■■檢查“檢品記錄”列表中是否存在沒有進行品檢的記錄,如果存在則返回一個“檢品記錄”類型,並退出方法
                foreach (var item in projectData.ShiftProjectData.QCRecords)
                {
                    if (item.pqc_dQCEndTime.HasValue==false)
                        return CommonDefine.ProjectDataType.ProjectQC;
                }

                //■■■檢查“班次人員”列表中 是否已選擇了班次人員,如果 沒有選擇則返回一個“班次人員”類型,並退出方法
                bool isSelectedStaff= false;

                if (shiftInfo.StaffInfos != null && shiftInfo.StaffInfos.Count > 0)
                {
                    isSelectedStaff = true;
                }

                if (shiftInfo.sifo_DutyCaptainID != null && shiftInfo.sifo_DutyCaptainID!=Guid.Empty)
                {
                    isSelectedStaff = true;
                }

                if (!isSelectedStaff)
                {
                    return CommonDefine.ProjectDataType.ShiftStaff;
                }

                //■■■數據都完整,返回一個完整的類型
                return l_enumDataFull;
            }
            catch (Exception ex) { throw ex; }
        }
Example #18
0
        public bool Update(CustEnum.System system, CodeMaster_cmt_Info info)
        {
            if (CustEnum.System.HBManager == system)
            {
                try
                {
                    this._codeMasterDA.UpdateRecord(info);

                }
                catch
                {

                    throw new Exception(Resource.B0006);
                }
            }
            //else if (CustEnum.System.PPC == system)
            //{
            //    try
            //    {
            //        this._codeMasterDA_Sqlite = SQLiteDAFacotry.CodeMasterDAInstance;
            //        this._codeMasterDA_Sqlite.Update(info);

            //    }
            //    catch
            //    {
            //        throw new Exception(Resource.B0007);
            //    }
            //}
            return true;
        }
Example #19
0
 /// <summary>
 /// 根據KEY批量刪除數據
 /// </summary>
 /// <param name="key1"></param>
 /// <returns></returns>
 /// <remarks>(NO:0005078) 現時只用於刪除從Maximo系統同步過來的機台部件  Add By Leothlik TonyWu On 18/07/2014</remarks>
 public bool RemoveByKey(CustEnum.KEY1 key1)
 {
     return _codeMasterDA.RemoveByKey(key1);
 }
 /// <summary>
 /// 檢查要“抽起”或“結束”的工程生產數據是否完整,如果不完整則返回一個殘缺數據的類型
 /// </summary>
 /// <param name="departmentCode">機台所屬科組編號</param>
 /// <param name="operationType">操作類型“抽起”或“結束”</param>
 /// <param name="shiftInfo">當前班次信息</param>
 /// <param name="projectData">當前工程生產數據</param>
 /// <returns>返回一個殘缺的數據類型</returns>
 public abstract CommonDefine.ProjectDataType CheckProjectProductionDataFull(string departmentCode, CustEnum.ProjectStatus operationType, MachineShiftData shiftInfo, ProjectProductionData projectData);
Example #21
0
        /// <summary>
        /// 設置IP狀態
        /// </summary>
        /// <param name="offLineList"></param>
        /// <returns></returns>
        public bool SetLineIP(List<SysMonitoring> offLineList, CustEnum.SystemStatus status)
        {
            DateTime dt = System.DateTime.Now;

            try
            {
                for (int index = 0; index < offLineList.Count; index++)
                {
                    offLineList[index].sym_iStatus = (Int32)status;
                    offLineList[index].sym_dLastTime = dt;
                    _ISysMonitoringBL.Update(offLineList[index]);
                }
                return true;
            }
            catch
            {
                return false;
            }
        }