Example #1
0
        public PrgState Execute(PrgState p)
        {
            try
            {
                this.Containsp(p);
                StreamReader fs = new StreamReader("read.txt");
                FileData     f  = new FileData(fileName, fs);
                int          id = IDGenerator.GenerateId();
                p.FileTable.Add(id, f);
                IMyDictionary <String, int> st = p.SymTable;
                if (st.ContainsKey(var_file_id))
                {
                    st.Update(var_file_id, id);
                }
                else
                {
                    st.Add(var_file_id, id);
                }
            }

            catch (NullReferenceException e)
            {
                Console.WriteLine(e.StackTrace);
            }
            return(p);
        }
Example #2
0
        public PrgState Execute(PrgState p)
        {
            IMyDictionary <String, int> symbolT = p.SymTable;
            int      id = expFileId.Eval(symbolT);
            FileData fd;

            p.FileTable.TryGetValue(id, out fd);
            StreamReader bf = fd.FileDescriptor;
            String       s  = bf.ReadLine();
            int          number;

            if (s.Equals(""))
            {
                number = 0;
            }
            else
            {
                Int32.TryParse(s, out number);
            }

            if (symbolT.Exists(varName))
            {
                symbolT.Update(varName, number);
            }
            else
            {
                symbolT.Add(varName, number);
            }
            return(p);
        }
 public string RecuringToSend(string mailTo)
 {
     if (_dictionary.HasKey(mailTo))
     {
         _dictionary.Update(mailTo, DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));
         return("this person is already scheduled");
     }
     _dictionary.AddIfKeyNotExist(mailTo, DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));
     // run every 5 minutes
     RecurringJob.AddOrUpdate <ISendMessage>(mailTo, x => x.SendOneMessage(mailTo), "*/5 * * * *");
     return("success");
 }
Example #4
0
        public PrgState Execute(PrgState state)
        {
            IMyDictionary <string, int> sym = state.SymTable;
            IMyStack <IStmt>            stk = state.ExeStack;
            int val = expr.Eval(sym);

            if (sym.Exists(id))
            {
                sym.Update(id, val);
            }
            else
            {
                sym.Add(id, val);
            }
            return(state);
        }