Example #1
0
        /// <summary>
        /// �x�s��ƶi�JExecution table
        /// </summary>
        /// <param name="sender"></param>
        public void saveExecution(string rspId, int evenId, ExecutionObj sender, bool isUserChange)
        {
            try
            {
                //�x�s"�����p���s��","�ƥ�o�ͮɶ�","�Ƶ�","�B�z���A"
                InsertCommand cmd;
                if (!isUserChange)
                {
                    cmd = Command.GetInsertCmd.setRSPExecutionCmd(sender);
                    com.insert(cmd);
                }

                //�x�s�B�z�����
                if (!isUserChange && com.Select(string.Format("Select * from {0}.{1} where INC_ID = '{2}';", RSPGlobal.GlobaSchema, DBConnect.DB2TableName.tblIIPService, rspId)).Rows.Count == 0)
                {   //�ϥΪ̤w�]�w���s
                    foreach (LiaiseUnit unit in sender.Units)
                    {
                        if (unit == null) break;
                        if (isUserChange)
                        {//�Y�����D�{���϶�
                            if (com.select(DataType.Unit, Command.GetSelectCmd.getExeUnitData(rspId, exeObj.AlarmClass)) != null)
                                com.insert(Command.GetInsertCmd.setIIPServiceCmd(rspId, unit.subServiceID, unit.memo));
                            else
                                com.update(Command.GetUpdateCmd.setIIPServiceCmd(rspId, unit.subServiceID, unit.memo, DateTime.Now));
                        }//
                        else
                        {
                            cmd = Command.GetInsertCmd.setIIPServiceCmd(rspId, unit.subServiceID, unit.memo);
                            com.insert(cmd);
                        }
                    }
                }

                //�x�sWIS���
                if (sender.WISOutputData != null)
                {
                    foreach (System.Collections.DictionaryEntry de in sender.WISOutputData)
                    {
                        if (de.Value == null) break;
                        RemoteInterface.HC.CMSOutputData output = (RemoteInterface.HC.CMSOutputData)de.Value;
                        if (isUserChange)
                        {
                            if (com.select(DataType.OutputData, Command.GetSelectCmd.getOutputData(rspId, (string)de.Key)) != null)
                            {
                                com.update(Command.GetUpdateCmd.setRSPExecutionOutputDataCmd(evenId, (string)de.Key, 0, output));
                            }
                            else
                            {
                                cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.WIS, output, isUserChange);
                                com.insert(cmd);
                            }
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage2(rspId, (string)de.Key, 2, DeviceType.WIS.ToString(), output.g_code_id, output.icon_id, 0, output.mesg));
                        }
                        else
                        {
                            cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.WIS, output, isUserChange);
                            com.insert(cmd);
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage1(rspId, (string)de.Key, 2, DeviceType.WIS.ToString(), output.g_code_id, output.icon_id, 0, output.mesg));
                        }
                    }
                }

                //�x�sFS���
                if (sender.FSOutputData != null)
                {
                    foreach (System.Collections.DictionaryEntry de in sender.FSOutputData)
                    {
                        if (de.Value == null) break;
                        RemoteInterface.HC.FSOutputData output = (RemoteInterface.HC.FSOutputData)de.Value;
                        string display = EasyClient.getFSDisplay(output.type);
                        if (isUserChange)
                        {
                            if (com.select(DataType.OutputData, Command.GetSelectCmd.getOutputData(rspId, (string)de.Key)) != null)
                            {
                                com.update(Command.GetUpdateCmd.setRSPExecutionOutputDataCmd(evenId, (string)de.Key, 0, output));
                            }
                            else
                            {
                                cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.FS, de.Value, isUserChange);
                                com.insert(cmd);
                            }
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage2(rspId, (string)de.Key, 2, DeviceType.FS.ToString(), 0, 0, 0, display));
                        }
                        else
                        {
                            cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.FS, de.Value, isUserChange);
                            com.insert(cmd);
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage1(rspId, (string)de.Key, 2, DeviceType.FS.ToString(), 0, 0, 0, display));
                        }
                    }
                }

                //�x�sCSLS���
                if (sender.CSLSOutputData != null)
                {
                    foreach (System.Collections.DictionaryEntry de in sender.CSLSOutputData)
                    {
                        if (de.Value == null) break;
                        RemoteInterface.HC.CSLSOutputData output = (RemoteInterface.HC.CSLSOutputData)((List<object>)de.Value)[1];
                        if (isUserChange)
                        {
                            if (com.select(DataType.OutputData, Command.GetSelectCmd.getOutputData(rspId, (string)de.Key)) != null)
                            {
                                com.update(Command.GetUpdateCmd.setRSPExecutionOutputDataCmd(evenId, (string)de.Key, (int)((List<object>)de.Value)[0], output));
                            }
                            else
                            {
                                cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.CSLS, de.Value, isUserChange);
                                com.insert(cmd);
                            }
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage2(rspId, (string)de.Key, 2, DeviceType.CSLS.ToString(), 0, 0, 0, output.dataset.Tables[0].Rows[0]["speed"].ToString()));
                        }
                        else
                        {
                            cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.CSLS, de.Value, isUserChange);
                            com.insert(cmd);
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage1(rspId, (string)de.Key, 2, DeviceType.CSLS.ToString(), 0, 0, 0, output.dataset.Tables[0].Rows[0]["speed"].ToString()));
                        }
                    }
                }

                //�x�sRGS���
                if (sender.RGSOutputData != null)
                {
                    foreach (System.Collections.DictionaryEntry de in sender.RGSOutputData)
                    {
                        if (de.Value == null) break;
                        RemoteInterface.MFCC.RGS_GenericDisplay_Data output = (RemoteInterface.MFCC.RGS_GenericDisplay_Data)((List<object>)de.Value)[1];
                        byte icon1 = 0;
                        byte icon2 = 0;
                        byte graph_code_id = 0;
                        string meg = "";
                        EasyClient.getRGSDisplay(output, ref  graph_code_id, ref  icon1, ref  icon2, ref  meg);

                        if (isUserChange)
                        {
                            if (com.select(DataType.OutputData, Command.GetSelectCmd.getOutputData(rspId, (string)de.Key)) != null)
                            {
                                com.update(Command.GetUpdateCmd.setRSPExecutionOutputDataCmd(evenId, (string)de.Key, (int)((List<object>)de.Value)[0], output));
                            }
                            else
                            {
                                cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.RGS, de.Value, isUserChange);
                                com.insert(cmd);
                            }
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage2(rspId, (string)de.Key, 2, DeviceType.RGS.ToString(), graph_code_id, icon1, icon2, meg));
                        }
                        else
                        {
                            cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.RGS, de.Value, isUserChange);
                            com.insert(cmd);
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage1(rspId, (string)de.Key, 2, DeviceType.RGS.ToString(), graph_code_id, icon1, icon2, meg));
                        }
                    }
                }

                //�x�sCMS���
                if (sender.CMSOutputData != null)
                {
                    foreach (System.Collections.DictionaryEntry de in sender.CMSOutputData)
                    {
                        if (de.Value == null) break;
                        RemoteInterface.HC.CMSOutputData output = (RemoteInterface.HC.CMSOutputData)((List<object>)de.Value)[1];

                        if (isUserChange)
                        {
                            if (com.select(DataType.OutputData, Command.GetSelectCmd.getOutputData(rspId, (string)de.Key)) != null)
                            {
                                com.update(Command.GetUpdateCmd.setRSPExecutionOutputDataCmd(evenId, (string)de.Key, (int)((List<object>)de.Value)[0], output));
                            }
                            else
                            {
                                cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.CMS, de.Value, isUserChange);
                                com.insert(cmd);
                            }
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage2(rspId, (string)de.Key, 2, DeviceType.CMS.ToString(), output.g_code_id, output.icon_id, 0, output.mesg));
                        }
                        else
                        {
                            cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.CMS, de.Value, isUserChange);
                            com.insert(cmd);
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage1(rspId, (string)de.Key, 2, DeviceType.CMS.ToString(), output.g_code_id, output.icon_id, 0, output.mesg));
                        }
                    }
                }

                //�x�sLCS���
                if (sender.LCSOutputData != null)
                {
                    foreach (System.Collections.DictionaryEntry de in sender.LCSOutputData)
                    {
                        if (de.Value == null) break;
                        RemoteInterface.HC.LCSOutputData output = (RemoteInterface.HC.LCSOutputData)((List<object>)de.Value)[1];
                        if (isUserChange)
                        {
                            if (com.select(DataType.OutputData, Command.GetSelectCmd.getOutputData(rspId, (string)de.Key)) != null)
                            {
                                com.update(Command.GetUpdateCmd.setRSPExecutionOutputDataCmd(evenId, (string)de.Key, (int)((List<object>)de.Value)[0], output));
                            }
                            else
                            {
                                cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.LCS, de.Value, isUserChange);
                                com.insert(cmd);
                            }
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage2(rspId, (string)de.Key, 0, DeviceType.LCS.ToString(), 0, 0, 0, getLCSDisplay(output)));
                        }
                        else
                        {
                            cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.LCS, de.Value, isUserChange);
                            com.insert(cmd);
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage1(rspId, (string)de.Key, 0, DeviceType.LCS.ToString(), 0, 0, 0, getLCSDisplay(output)));
                        }
                    }
                }

                //�x�sRMS���
                if (sender.RMSOutputData != null)
                {
                    foreach (System.Collections.DictionaryEntry de in sender.RMSOutputData)
                    {
                        if (de.Value == null) break;
                        RemoteInterface.HC.RMSOutputData output = (RemoteInterface.HC.RMSOutputData)((List<object>)de.Value)[1];
                        if (isUserChange)
                        {
                            if (com.select(DataType.OutputData, Command.GetSelectCmd.getOutputData(rspId, (string)de.Key)) != null)
                            {
                                com.update(Command.GetUpdateCmd.setRSPExecutionOutputDataCmd(evenId, (string)de.Key, (int)((List<object>)de.Value)[0], output));
                            }
                            else
                            {
                                cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.RMS, de.Value, isUserChange);
                                com.insert(cmd);
                            }
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage2(rspId, (string)de.Key, 2, DeviceType.RMS.ToString(), 0, 0, 0, EasyClient.getRMSDisplay(output)));
                        }
                        else
                        {
                            cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.RMS, de.Value, isUserChange);
                            com.insert(cmd);
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage1(rspId, (string)de.Key, 2, DeviceType.RMS.ToString(), 0, 0, 0, EasyClient.getRMSDisplay(output)));
                        }
                    }
                }

                if (sender.MASOutputData != null)
                {
                    foreach (System.Collections.DictionaryEntry de in sender.MASOutputData)
                    {
                        if (de.Value == null) break;
                        if (!isUserChange)
                        {
                            RemoteInterface.HC.MASOutputData output = (RemoteInterface.HC.MASOutputData)de.Value;
                            cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.MAS, de.Value, isUserChange);
                            com.insert(cmd);
                            com.update(Command.GetUpdateCmd.setRSPExecutionMessage1(rspId, (string)de.Key, 2, DeviceType.MAS.ToString(), 0, 0, 0, EasyClient.getMASDisplay(output)));
                        }
                    }
                }

                //�x�sCCTV���
                if (sender.CCTVOutputData != null)
                {
                    foreach (System.Collections.DictionaryEntry de in sender.CCTVOutputData)
                    {
                        cmd = Command.GetInsertCmd.setRSPExecutionOutputDataCmd(rspId, evenId, (string)de.Key, DeviceType.CCTV, de.Value, false);
                        com.insert(cmd);
                        //serMeg.setAlarmMeg("�x�sRMS���(������)");
                    }
                }

                //serMeg.setServerMeg("�[�J�@���ƥ��tblRSPExecution");
            }
            catch (System.Exception ex)
            {
                //serMeg.setAlarmMeg("�[�J�@���ƥ��tblRSPExecution���~!!");
                throw ex;
            }
        }
Example #2
0
        /// <summary>
        ///  ���o�����p��
        /// </summary>
        /// <param name="rspId">�����p���s��</param>
        /// <returns>�����p��</returns>
        public ExecutionObj getExecutionObj(string rspId)
        {
            exeObj = new ExecutionObj();
            exeObj.Units = new List<LiaiseUnit>();
            exeObj.CCTVOutputData = new System.Collections.Hashtable();
            exeObj.CMSOutputData = new System.Collections.Hashtable();
            exeObj.CSLSOutputData = new System.Collections.Hashtable();
            exeObj.FSOutputData = new System.Collections.Hashtable();
            exeObj.RGSOutputData = new System.Collections.Hashtable();
            exeObj.RMSOutputData = new System.Collections.Hashtable();
            exeObj.WISOutputData = new System.Collections.Hashtable();
            exeObj.LCSOutputData = new System.Collections.Hashtable();
            exeObj.MASOutputData = new System.Collections.Hashtable();
            //try
            //{
                //���oĵ�i�s��
                com.select(DataType.IIPEvent, Command.GetSelectCmd.getIIPEventCmd(rspId, false));
                //���o"�����p���s��","�ƥ�o�ͮɶ�","�Ƶ�","�B�z���A"
                com.select(DataType.Execution, Command.GetSelectCmd.getRspExecution(rspId));
                //���o"�B�z�����"
                com.select(DataType.Unit, Command.GetSelectCmd.getExeUnitData(rspId, exeObj.AlarmClass));
                //���o"�]�ƿ�X���"
                com.select(DataType.OutputData, Command.GetSelectCmd.getOutputData(rspId));

                com.GetReaderData -= new DBConnect.GetReaderDataHandler(com_GetReaderData);
                return exeObj;
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }