Example #1
0
        public void mCreateJmsSessionAndSendMsg()
        {
            Utils.ToLog("mCreateJmsSessionAndSendMsg");
            string TmpFileName = CreateTmpSpoolMessageFile(Msgtext);


            //Sonic.Jms.Ext.Connection connect = GetJmsConnection();
            JMSCOMCLIENTLib.CJMSQueueConnection connect = SonicCom.GetJmsConnection();
            if (connect != null)
            {
                //  if (SendMsg(Msgtext, connect))
                if (SonicCom.SendMsg(Msgtext, connect))
                {
                    try
                    {
                        File.Delete(TmpFileName);
                        Utils.ToLog("Отправил сообщение и  Удалил временный файл");
                    }
                    catch (Exception e)
                    {
                        Utils.ToLog("[Error] при удалении временного файла " + e.Message);
                    }
                }
                else
                {
                    Utils.ToLog("Не Отправил сообщение ");
                }
                connect.close();
            }
        }
Example #2
0
        public bool TrySendOldJms()
        {
            try
            {
                DirectoryInfo di = new DirectoryInfo(Utils.TmpSpoolFilePath);
                if (!di.Exists)
                {
                    di.Create();
                }
                if (di.GetFiles("*.spl").Length == 0)
                {
                    return(true);
                }

                //  Sonic.Jms.Ext.Connection connect = GetJmsConnection();
                Utils.ToCardLog("JMSCOMCLIENTLib.CJMSQueueConnection connect = SonicCom.GetJmsConnection();");
                JMSCOMCLIENTLib.CJMSQueueConnection connect = SonicCom.GetJmsConnection();
                foreach (FileInfo fi in di.GetFiles("*.spl"))
                {
                    try
                    {
                        if (connect != null)
                        {
                            //if (SendMsg(File.ReadAllText(fi.FullName), connect))
                            if (SonicCom.SendMsg(File.ReadAllText(fi.FullName), connect))
                            {
                                try
                                {
                                    File.Delete(fi.FullName);
                                    Utils.ToLog("Удалил временный файл");
                                }
                                catch (Exception e)
                                {
                                    Utils.ToLog("[Error] при удалении временного файла " + e.Message);
                                }
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    catch (Exception ee)
                    {
                        Utils.ToLog("[Error] TrySendOldJms " + ee.Message);
                        return(true);
                    }
                }
                connect.close();
                return(true);
            }
            catch (Exception e)
            {
                Utils.ToLog("[Error] TrySendOldJms " + e.Message);
                return(true);
            }
        }