public string M59(string sMessage)
        {
            string strRdo = "";

            try
            {
                if (Session["MessagesSession"] == null)
                {
                    MessagesSession msgSession = new MessagesSession();
                    Session["MessagesSession"] = msgSession;
                }

                IRecvMessage msg = null;
                msg         = MessageFactory.GetReceivedMessage(sMessage);
                msg.Session = ((MessagesSession)Session["MessagesSession"]);


                StringCollection sc = msg.Process();

                System.Collections.Specialized.StringEnumerator myEnumerator = sc.GetEnumerator();
                while (myEnumerator.MoveNext())
                {
                    strRdo += myEnumerator.Current + "\n";
                }
            }
            catch (Exception e)
            {
                strRdo = e.ToString();
            }

            return(strRdo);
        }
Exemple #2
0
        //========================================================================================
        //========================================================================================

        private void ReportOutputLines(StringCollection lines)
        {
            if (lines.Count > 0)
            {
                var savecolor = notepad.ForeColor;
                notepad.ForeColor = FontsAndColors.IdentifierForeground;
                notepad.WriteLine(CR + "OUTPUT:" + CR);

                System.Collections.Specialized.StringEnumerator e = lines.GetEnumerator();
                while (e.MoveNext())
                {
                    notepad.Write(e.Current);
                }

                notepad.ForeColor = savecolor;

                messageCount     += lines.Count;
                messagePage.Title = "Messages (" + messageCount + ")";
            }
        }
Exemple #3
0
        //write brain file to disc
        protected void writeBrainFile(StringCollection memoryBuffer)
        {
            if (fullPathName != "")
            {
                writeBrainFile(memoryBuffer, fullPathName);
                return;
            }
            File.Delete(filePath);
            FileStream   fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);

            sw.BaseStream.Seek(0, SeekOrigin.End);
            System.Collections.Specialized.StringEnumerator ii = memoryBuffer.GetEnumerator();
            while (ii.MoveNext())
            {
                string dat = ii.Current;
                sw.WriteLine(dat);
            }
            sw.Flush();
            sw.Close();
            fs.Close();
        }
        public string M3(string sMessage)
        {
            string strRdo = "";

            try
            {
                IRecvMessage msg = null;
                msg = MessageFactory.GetReceivedMessage(sMessage);
                StringCollection sc = msg.Process();

                System.Collections.Specialized.StringEnumerator myEnumerator = sc.GetEnumerator();
                while (myEnumerator.MoveNext())
                {
                    strRdo += myEnumerator.Current + "\n";
                }
            }
            catch (Exception e)
            {
                strRdo = e.ToString();
            }

            return(strRdo);
        }
 public StringCollectionReader(StringCollection stringCollection, string newLine)
 {
     stringEnumerator = stringCollection.GetEnumerator();
     this.newLine = newLine ?? Environment.NewLine;
     GetNextLine();
 }
        public string Message(string sMessage)
        {
            string strRdo = "";

            try
            {
                if (_logger == null)
                {
                    System.Configuration.AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();

                    // *** TODO
                    _logger = new Logger(MethodBase.GetCurrentMethod().DeclaringType);
                    //               _logger = new FileLogger(LoggerSeverities.Debug, (string)appSettings.GetValue("ServiceLog", typeof(string)));
                    //OPS.Comm.Messaging.CommMain.Logger.AddLogMessage += new AddLogMessageHandler(Logger_AddLogMessage);
                    //OPS.Comm.Messaging.CommMain.Logger.AddLogException += new AddLogExceptionHandler(Logger_AddLogException);
                    DatabaseFactory.Logger = _logger;
                }

                Logger_AddLogMessage(string.Format("Message.LogMsgDB: Empty unit. xml={0}", "Hello"), LoggerSeverities.Error);

                if (Session["MessagesSession"] == null)
                {
                    MessagesSession msgSession = new MessagesSession();
                    Session["MessagesSession"] = msgSession;
                }

                IRecvMessage msg = null;
                msg = MessageFactory.GetReceivedMessage(sMessage);

                msg.Session = ((MessagesSession)Session["MessagesSession"]);

                StringCollection sc = msg.Process();

                System.Collections.Specialized.StringEnumerator myEnumerator = sc.GetEnumerator();
                while (myEnumerator.MoveNext())
                {
                    strRdo += myEnumerator.Current + "\n";
                }

                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(sMessage);
                    int iUnitId = GetUnitIdForLogging(doc);

                    if (iUnitId != -1)
                    {
                        System.Configuration.AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
                        string CCunitId = (string)appSettings.GetValue("UnitID", typeof(string));
                        LogMsgDB(iUnitId, int.Parse(CCunitId), doc.DocumentElement.Name, sMessage, strRdo.Replace("\n", ""));
                    }
                    else
                    {
                        Logger_AddLogMessage(string.Format("Message.LogMsgDB: Empty unit. xml={0}", sMessage), LoggerSeverities.Error);
                    }
                }
                catch (Exception e)
                {
                    Logger_AddLogException(e);
                }
            }
            catch (Exception e)
            {
                strRdo = e.ToString();
            }

            return(strRdo);
        }
        // bool indicates if StringEnumerator hasMoreLines? to parse
        private bool SkipBlanks(StringEnumerator strings)
        {
            while(strings.MoveNext())
            {
                if(strings.Current != "") return true;
            }

            return false;
        }
        private int FindLogMessageSize(StringEnumerator strings)
        {
            bool hasMoreLines = SkipBlanks(strings);
            if (!hasMoreLines) return 0;

            int size = int.Parse(strings.Current);
            return size;
        }
        private void FindTimestamp(StringEnumerator strings)
        {
            bool hasMoreLines = SkipBlanks(strings);
            if (!hasMoreLines) return;

            string[] parts = strings.Current.Split();
            _timestamp = DateTime.ParseExact(parts[0], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
            _timestamp = _timestamp.Add(TimeSpan.Parse(parts[1]));
        }
        private void FindLogMessage(StringEnumerator strings)
        {
            bool hasMoreLines = SkipBlanks(strings);
            if (!hasMoreLines) return;

            System.Text.StringBuilder buffer = new System.Text.StringBuilder();
            do
            {
                buffer.Append(strings.Current);
                buffer.Append(Environment.NewLine);
            } while(strings.MoveNext());

            _message = buffer.ToString().TrimEnd();
        }
        private void FindChanges(StringEnumerator changes)
        {
            do
            {
                string line = changes.Current.Trim();
                if(line == "") continue;
                int separatorPos = line.IndexOf(' ');
                string changeType = line.Substring(0, separatorPos);
                string path = line.Substring(separatorPos).TrimStart();

                switch(changeType)
                {
                    case "A":
                        _added.Add(path);
                        break;
                    case "U":
                        _modified.Add(path);
                        break;
                    case "D":
                        _deleted.Add(path);
                        break;
                    case "_U":
                    case "UU":
                        _propertyChanges.Add(path);
                        break;
                    default:
                        log.Warn("Unable to parse: " + line);
                        break;
                }

            } while(changes.MoveNext());
        }
        private void FindAuthor(StringEnumerator strings)
        {
            bool hasMoreLines = SkipBlanks(strings);
            if (!hasMoreLines) return;

            _author = strings.Current;
        }
 private void FillDiffCollection(StringEnumerator strings)
 {
     do
     {
         DiffLine dl = DiffLine.Parse(strings.Current);
         _diffLines.Add(dl);
     } while(strings.MoveNext());
 }
Exemple #14
0
        public bool Message(byte [] msgIn, out byte [] msgOut)
        {
            bool bRdo = false;

            msgOut = null;

            try
            {
                if (_logger == null)
                {
                    System.Configuration.AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
                    _logger = new Logger(MethodBase.GetCurrentMethod().DeclaringType);
                    DatabaseFactory.Logger = _logger;

                    // *** TODO
                    //               _logger = new FileLogger(LoggerSeverities.Debug, ((string)appSettings.GetValue("ServiceLog", typeof(string))).Replace(".log","BB.log"));
                    //OPS.Comm.Messaging.CommMain.Logger.AddLogMessage += new AddLogMessageHandler(Logger_AddLogMessage);
                    //OPS.Comm.Messaging.CommMain.Logger.AddLogException += new AddLogExceptionHandler(Logger_AddLogException);
                    //DatabaseFactory.Logger=_logger;
                }

                if (Session["MessagesSession"] == null)
                {
                    MessagesSession msgSession = new MessagesSession();
                    Session["MessagesSession"] = msgSession;
                }

                string  strMsgIn  = DecryptMsg(msgIn);
                char [] charsTrim = new char[1];
                charsTrim[0] = '\0';
                strMsgIn     = strMsgIn.Trim(charsTrim);
                string       strMsgOut = "";
                IRecvMessage msg       = null;
                Logger_AddLogMessage("Msg In: " + strMsgIn.Replace("\n", ""), LoggerSeverities.Info);

                msg = MessageFactory.GetReceivedMessage(strMsgIn);

                msg.Session = ((MessagesSession)Session["MessagesSession"]);

                StringCollection sc = msg.Process();



                System.Collections.Specialized.StringEnumerator myEnumerator = sc.GetEnumerator();
                while (myEnumerator.MoveNext())
                {
                    strMsgOut += myEnumerator.Current;
                }

                if (strMsgOut != "")
                {
                    msgOut = EncryptMsg(strMsgOut);
                    Logger_AddLogMessage("Msg Out: " + strMsgOut, LoggerSeverities.Info);
                    string strIP = Context.Request.UserHostAddress;
                    LogMsgDB(strMsgIn, strMsgOut, strIP);
                    bRdo = true;
                }
            }
            catch (Exception e)
            {
                bRdo = false;
            }

            return(bRdo);
        }