Exemplo n.º 1
0
 /// <summary>
 /// 獲取機台及工程運行所需要的基本資料,如果存在返回一個對象,否則返回一個NULL值。
 /// </summary>
 /// <returns></returns>
 public override BaseData GetBaseData()
 {
     try
     {
         BaseData data = new BaseData();
         data.Machine = m_ProfileDataBLL.GetMachineBaseData();
         data.Project = m_ProfileDataBLL.GetProjectBaseData();
         return data;
     }
     catch (Exception ex)
     {
         OnException("BaseDataSynchronismManager", "GetBaseData", ex.Message);
         return null;
     }
 }
 /// <summary>
 /// 基本資料更新事件通知控制中心,由模塊調用通知控制中心
 /// </summary>
 /// <param name="baseData"></param>
 public void OnDataBaseUpdate(BaseData baseData)
 {
     if (this.DataBaseUpdateEvent != null)
     {
         EventBaseInfo<BaseData> eventInfo = new EventBaseInfo<BaseData>();
         eventInfo.ObjectInformation = baseData;
         this.DataBaseUpdateEvent(this, eventInfo);
     }
 }
        public override void SaveBaseData(BaseData baseData)
        {
            if (baseData == null)
            {
                return;
            }

            //保存機台基本資料
            if (this.m_MQ_MachineBaseData != null && baseData.Machine != null)
            {
                Message msgSave = new Message();
                msgSave.Label = "MachineBaseData" + DateTime.Now.ToString(mc_strTimeFormat);
                try
                {
                    msgSave.Body = baseData.Machine;

                    MessageQueueTransaction transaction = new MessageQueueTransaction();
                    transaction.Begin();
                    this.m_MQ_MachineBaseData.Send(msgSave, transaction);
                    transaction.Commit();

                    //清理消息隊列至單條記錄
                    SetMQToSingleRec(this.m_MQ_MachineBaseData);
                }
                catch (Exception ex)
                {
                    base.OnException(mc_strControllerName, "SaveBaseData_Machine", ex.Message);
                }
            }

            //保存工程基本資料
            if (this.m_MQ_ProjectBaseData != null && baseData.Project != null)
            {
                Message msgSave = new Message();
                msgSave.Label = "ProjectBaseData" + DateTime.Now.ToString(mc_strTimeFormat);
                msgSave.Body = baseData.Project;
                try
                {
                    MessageQueueTransaction transaction = new MessageQueueTransaction();
                    transaction.Begin();
                    this.m_MQ_ProjectBaseData.Send(msgSave, transaction);
                    transaction.Commit();

                    //清理消息隊列至單條記錄
                    SetMQToSingleRec(this.m_MQ_ProjectBaseData);
                }
                catch (Exception ex)
                {
                    base.OnException(mc_strControllerName, "SaveBaseData_Project", ex.Message);
                }
            }
        }
        public override BaseData GetBaseData()
        {
            BaseData rtEntity = null;
            MachineBaseData macData = null;
            ProjectBaseData projData = null;

            if (this.m_MQ_MachineBaseData != null)
            {
                try
                {
                    Message[] arrMsgs = this.m_MQ_MachineBaseData.GetAllMessages();
                    if (arrMsgs != null && arrMsgs.Length > 0)
                    {
                        Message msgRec = this.m_MQ_MachineBaseData.Peek();
                        if (msgRec != null)
                        {
                            msgRec.Formatter = new XmlMessageFormatter(new Type[] { typeof(MachineBaseData) });
                            macData = msgRec.Body as MachineBaseData;
                        }
                    }
                }
                catch (Exception ex)
                {
                    base.OnException(mc_strControllerName, "GetBaseData_Machine", ex.Message);
                }
            }

            if (this.m_MQ_ProjectBaseData != null)
            {
                try
                {
                    Message[] arrMsgs = this.m_MQ_ProjectBaseData.GetAllMessages();
                    if (arrMsgs != null && arrMsgs.Length > 0)
                    {
                        Message msgRec = this.m_MQ_ProjectBaseData.Peek();
                        if (msgRec != null)
                        {
                            msgRec.Formatter = new XmlMessageFormatter(new Type[] { typeof(ProjectBaseData) });
                            projData = msgRec.Body as ProjectBaseData;
                        }
                    }
                }
                catch (Exception ex)
                {
                    base.OnException(mc_strControllerName, "GetBaseData_Project", ex.Message);
                }
            }

            if (macData != null || projData != null)
            {
                rtEntity = new BaseData();
                rtEntity.Machine = macData;
                rtEntity.Project = projData;
            }

            return rtEntity;
        }
 /// <summary>
 /// 備份機台所需的基本資料
 /// </summary>
 /// <param name="baseData">基本資料對象</param>
 public abstract void SaveBaseData(BaseData baseData);