예제 #1
0
 /// <summary>
 /// CTOR
 /// </summary>
 /// <param name="isOfflineTask"></param>
 public CommonCommandProcessorStrategy(bool isOfflineTask)
 {
     if (isOfflineTask)
     {
         taskService = LocalCommandsProcessor.GetInstance();
     }
     else
     {
         taskService = RemoteCommandsProcessor.GetInstance();
     }
 }
예제 #2
0
        /// <summary>
        ///   loads a new table start the table parsing process
        ///   delete any old instances of the same table (even if they other unique ids
        /// </summary>
        protected internal void LoadTable(String tableUId)
        {
            CommandsProcessorBase server = RemoteCommandsProcessor.GetInstance();

            // the table must exist in the hashTable at this stage else it is an error
            if (TableExists(tableUId))
            {
                //get the table
                var current = (TableCache)_tables[tableUId];
                try
                {
                    byte[] residentTableContent = server.GetContent(tableUId, true);
                    try
                    {
                        String residentTableContentStr = Encoding.UTF8.GetString(residentTableContent, 0,
                                                                                 residentTableContent.Length);
                        ClientManager.Instance.RuntimeCtx.Parser.loadTableCacheData(residentTableContentStr);
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException(
                                  "Unable to parse resident table " + tableUId + ", due to unsupported encoding.", ex);
                    }
                }
                catch (Exception ex)
                {
                    Misc.WriteStackTrace(ex, Console.Error);
                }

                //start parsing
                current.FillData();

                //delete old tables
                var         deletedUids = new List <String>();
                IEnumerator enm         = _tables.Values.GetEnumerator();
                while (enm.MoveNext())
                {
                    var    tbl       = (TableCache)enm.Current;
                    String currIdent = tbl.GetTableCommonIdentifier();
                    if (currIdent.Equals(current.GetTableCommonIdentifier()) && (tbl.GetTableUniqueId() != tableUId))
                    {
                        deletedUids.Add(tbl.GetTableUniqueId());
                    }
                }
                //delete
                for (int i = 0; i < deletedUids.Count; i++)
                {
                    _tables.Remove(deletedUids[i]);
                }
            }
        }