Ejemplo n.º 1
0
 public void HandleCmd(string cmdStr, ref Context context)
 {
     foreach (AbstractCommand cmd in commandList)
     {
         if (cmd.Process(cmdStr, ref context))
         {
             return;
         }
     }
     throw new EditorException("The command cannot be understood. Use <help> to get help info.");
 }
Ejemplo n.º 2
0
 protected override void Handle(Dictionary<string, string> paramMap, ref Context context)
 {
     string devices = paramMap[DEVICES];
     string where = paramMap[WHERE];
     if (context.Type.Equals(OpenCmd.FAILOVER) || context.Type.Equals(OpenCmd.GOLDCOPY))
     {
         HandleFailover(devices, where, ref context);
     }
     else if (context.Type.Equals(OpenCmd.RDF) || context.Type.Equals(OpenCmd.REPLICA))
     {
         HandleRDF(devices, where, ref context);
     }
 }
Ejemplo n.º 3
0
        public bool Process(string cmdStr, ref Context context)
        {
            if(CanHandle(cmdStr))
            {
                if (context == null
                    && !CMD_NAME.Equals(openCmd.CMD_NAME)
                    && !CMD_NAME.Equals(exitCmd.CMD_NAME)
                    && !CMD_NAME.Equals(helpCmd.CMD_NAME))
                {
                    throw new EditorException("Invalid command, please use open command first.");
                }
                if(cmdStr.Length >= CMD_NAME.Length)
                    cmdStr = cmdStr.Substring(CMD_NAME.Length);
                cmdStr = cmdStr.Trim();

                Dictionary<string, string> paramMap = Parse(cmdStr);

                Handle(paramMap, ref context);
                return true;
            }
            return false;
        }
Ejemplo n.º 4
0
 private void HandleFailover(string devices, string where, ref Context context)
 {
     Dictionary<string, string> devicePairs = deviceParam.ParseFailover(devices);
     Dictionary<string, string> wheres = whereClause.Parse(where);
     CheckKeys(wheres);
     RemoveUnusedFailoverValues(wheres);
     TreeNode copyInfo = context.FindCopyInfo(wheres);
     if (copyInfo == null)
     {
         copyInfo = context.CreateNewCopyInfo(wheres);
         foreach (string key in devicePairs.Keys)
         {
             context.AddToExistingCopyInfo(copyInfo, key, devicePairs[key]);
         }
     }
     else
     {
         foreach (string key in devicePairs.Keys)
         {
             bool sourceContained = context.CopyInfoContainsDeviceSource(copyInfo, key);
             bool targetContained = context.CopyInfoContainsDeviceTarget(copyInfo, devicePairs[key]);
             if (sourceContained && !targetContained)
             {
                 throw new EditorException("The device pair: " + key + "-" + devicePairs[key] + ", its source is already contained.");
             }
             if (!sourceContained && targetContained)
             {
                 throw new EditorException("The device pair: " + key + "-" + devicePairs[key] + ", its target is already contained.");
             }
             if (!sourceContained && !targetContained)
             {
                 context.AddToExistingCopyInfo(copyInfo, key, devicePairs[key]);
             }
         }
     }
 }
Ejemplo n.º 5
0
 private void HandleRDF(string devices, string where, ref Context context)
 {
     HashSet<string> devList = deviceParam.ParseRDF(devices);
     Dictionary<string, string> wheres = whereClause.Parse(where);
 }
Ejemplo n.º 6
0
 protected abstract void Handle(Dictionary<string, string> paramMap, ref Context context);