Exemplo n.º 1
0
    public override void Command(Icommand command)
    {
        switch (command.GetUnitCommand())
        {
        case (UnitCommands.Move):
            if (IsMoveable())
            {
                MoveCommand(command);
            }
            break;

        case (UnitCommands.Hold):
            if (IsMoveable())
            {
                HoldCommand();
            }
            break;

        case (UnitCommands.Build):
            if (this.unitType == UnitType.Worker)
            {
                BuildCommand(command);
            }
            break;
        }
    }
        protected void bottonClickAction(object sender, EventArgs e)
        {
            Button button     = sender as Button;
            string buttonName = button.ID;

            Icommand      command = CommandFactory.CreateCommand(buttonName);
            CommandArg    cmdArg  = new CommandArg();
            CommandResult results = null;

            cmdArg.Value   = txtNameValuePair.Text;
            cmdArg.ListBox = ListBox1;
            if (command != null)
            {
                results = command.Execute(cmdArg);
                if (results.ErrorMessage == "")
                {
                    ListBox1.DataSource = results.NvCollection;
                    ListBox1.DataBind();
                    errorLabel.Text = "";
                }
                else
                {
                    errorLabel.Text      = results.ErrorMessage;
                    errorLabel.ForeColor = System.Drawing.Color.Red;
                    errorLabel.Font.Size = FontUnit.Larger;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Execute a command in the undo sequence. Used for Redo
        /// </summary>
        /// <param name="slot">Which command</param>
        /// <param name="arg1">First argument to be passed</param>
        /// <param name="arg2">Second argument to be passed</param>
        public void executeCommand(int slot, object arg1, object arg2)
        {
            Icommand c = (Icommand)commands[slot];

            c.execute();
            lastExecuted = c;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Undo the last command.
 /// </summary>
 /// <returns></returns>
 public bool undo()
 {
     if (lastExecuted == null)
     {
         return(false);
     }
     lastExecuted.undo();
     lastExecuted = null;
     return(true);
 }
Exemplo n.º 5
0
        public bool CreateAllVitalProcedures(ddl worker)
        {
            bool   success = true;
            Module mod     = this.GetType().Module;

            Type[]          types    = mod.GetTypes();
            List <Icommand> unsorted = new List <Icommand>();

            foreach (Type ty in types)
            {
                if (!ty.IsAbstract)
                {
                    Type[] ifs = ty.GetInterfaces();
                    if (TypeArrayContains(ifs, typeof(Icommand)))
                    {
                        /* cue with others on error */
                        if (ty.GetCustomAttributes(typeof(VitalAttribute), true).Length > 0)
                        {
                            if (ty.GetConstructor(new Type[] { ((Iddl)worker).GetType() }) != null) /* [dlatikay 20110525] additional fuse */
                            {
                                try
                                {
                                    Icommand Proc = (Icommand)Activator.CreateInstance(ty, (Iddl)worker); /* passing the constructor argument */
                                    unsorted.Add(Proc);
                                }
                                catch
                                {
                                    if (Debugger.IsAttached)
                                    {
                                        Debugger.Break();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            var sorted = unsorted.OrderBy(p => p.GetType().Name);

            foreach (Icommand proc in sorted)
            {
                if (!CreateProcedure(worker, proc, true))
                {
                    success = false;
                }
            }
            /* complete */
            return(success);
        }
Exemplo n.º 6
0
    void BuildCommand(Icommand command)
    {
        bool atDestination = true;

        this.command = command;
        if (transform.position != command.GetPoint())
        {
            atDestination = false;
            GetComponent <Movement>().MoveUnit(command.GetPoint());
            StartCoroutine(AtBuildingPlacement(command.GetPoint(), atDestination));
        }
        else
        {
            CmdBuildBuilding();
        }
    }
Exemplo n.º 7
0
        private void CheckedForLookedAtOBjectObjects()
        {
            RaycastHit raycastHit;

            if (Physics.Raycast(transform.position, transform.forward, out raycastHit,
                                maxDistanceToActivateObjects, layerActivatableObjectsAreOn))
            {
                //if our ray hits something, we go into this code block
                objectLookedAt = raycastHit.collider.gameObject.GetComponent <IActivatable>();
                userInput      = raycastHit.collider.gameObject.GetComponent <Icommand>();

                if (objectLookedAt == null)
                {
                    // attack();
                    throw new System.Exception(raycastHit.collider.gameObject.name +
                                               " MUST have a script that implements IActivatable script attached to it.");
                }

                string objectName = raycastHit.collider.gameObject.name;
                //Debug.Log("Object Looked at " + objectName);

                if (Input.GetButton("xButton"))
                {
                    if (gameObject.tag == "Items")
                    {
                        raycastHit.collider.gameObject.SetActive(false);

                        Debug.Log("The user is looking at an activatable Object, and now has clicked.");
                        objectLookedAt.DoActivate();
                        userInput.DoCommand();
                    }
                    userInput.DoCommand();
                }
            }
            else
            {
                objectLookedAt = null;
                userInput      = null;
            }

            Vector3 endPoint = transform.position + maxDistanceToActivateObjects * transform.forward;

            Debug.DrawLine(transform.position, endPoint, Color.red);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Executes a command by name and adds it to the undo queue.
        /// </summary>
        /// <param name="whichCommand">Name of the command</param>
        public void executeCommand(string whichCommand)
        {
            int      f;
            Icommand c;

            if (whichCommand == null)             // command without undo
            {
                lastExecuted = null;
                return;
            }
            for (f = 0; f < commands.Count; f++)
            {
                c = (Icommand)commands[f];
                if (c.getName().Equals(whichCommand))
                {
                    c.execute();
                    lastExecuted = c;
                    return;
                }
            }
        }
Exemplo n.º 9
0
 public bool CreateProcedure(ddl worker, Icommand proc, bool continueonerror)
 {
     try
     {
         return(worker.CreateProcedure(proc));
     }
     catch (Exception ex)
     {
         var list = from x in Assembly.GetExecutingAssembly().GetTypes() where x.Name.StartsWith("pr") && x.Name.Contains("02") && x.Name.Length > 30 select x;
         foreach (var name in list)
         {
             Debug.WriteLine(name);
         }
         if (continueonerror)
         {
             Tracing.WarningDAL("Failed to create stored procedure \"{0}\": {1}", proc.GetType().Name, ex.ToString());
             return(false);
         }
         else
         {
             throw new DALException(String.Format("Failed to create stored procedure \"{0}\": {1}", proc.GetType().Name, ex.Message), ex);
         }
     }
 }
Exemplo n.º 10
0
        public ActionResult SignIn(Login_table user)
        {
            LoginManager manager = new LoginManager(user);
            Invoker      invoker = new Invoker();
            Icommand     command = null;

            //++++++++++++++++++++++++adding login +++++++++++++++++++++

            username = user.EmailAddress;
            pwd      = user.Password;
            ProvideMemberShip p = new ProvideMemberShip();

            bool valid = p.ValidateUser(username, pwd);

            if (valid == true)
            {
                FormsAuthentication.SetAuthCookie(username, false);
                Stopwatch sw = Stopwatch.StartNew();
                command = new SaveLog(manager);
                invoker.Commands.Add(command);
                command = new ConfirmationLogin(manager);
                invoker.Commands.Add(command);

                invoker.Execute();
                sw.Stop();

                Console.WriteLine(sw.Elapsed.Milliseconds);

                return(RedirectToAction("Index", "Login_table"));
            }
            else
            {
                TempData["Msg"] = "Login Failed  ";
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Executes command and adds it to the undo queue.
 /// </summary>
 /// <param name="c"></param>
 public void executeCommand(Icommand c)
 {
     c.execute();
     this.lastExecuted = c;
 }
Exemplo n.º 12
0
 public abstract void Command(Icommand command);
Exemplo n.º 13
0
 void MoveCommand(Icommand command)
 {
     GetComponent <Movement>().MoveUnit(command.GetPoint());
 }
Exemplo n.º 14
0
 /// <summary>
 /// the constructor we are passing our commands using dependency injection
 /// </summary>
 /// <param name="turnOffCommand"></param>
 /// <param name="turnOnCommand"></param>
 public RemoteInvoker(TurnOffCommand turnOffCommand, TurnOnCommand turnOnCommand)
 {
     this._turnOffCommand = turnOffCommand;
     this._turnOnCommand  = turnOnCommand;
 }
Exemplo n.º 15
0
 public override void SetCommand(Icommand command)
 {
     base.SetCommand(command);
     StartCoroutine(waitandExecute());
 }
Exemplo n.º 16
0
 public void SetCommand(Icommand newCommand)
 {
     command = newCommand;
 }
Exemplo n.º 17
0
        public bool CreateAllProcedures(ddl worker, bool continueonerror)
        {
            bool success = true;
            /* 1. create the explicit stored procedures */
            Module mod = this.GetType().Module;

            Type[]          types    = mod.GetTypes();
            List <Icommand> unsorted = new List <Icommand>();

            foreach (Type ty in types)
            {
                if (!ty.IsAbstract)
                {
                    Type[] ifs = ty.GetInterfaces();
                    if (TypeArrayContains(ifs, typeof(Icommand)))
                    {
                        /* cue with others on error */
                        if (!(ty.Equals(typeof(commandadhoc)))) /* [dlatikay 20110525] added these constructorless exceptions (previously threw on db_core_create) */
                        {
                            if (!(ty.Equals(typeof(commanddynamic))))
                            {
                                if (!(ty.Equals(typeof(commandpassthrough))))                               /* added [dlatikay 20110525] was missing; explanation [dlatikay 20140716] some of them are hardwiredly parametrized, so they're in fact potentially ad hoc! */
                                {
                                    if (ty.GetConstructor(new Type[] { ((Iddl)worker).GetType() }) != null) /* [dlatikay 20110525] additional fuse */
                                    {
                                        try
                                        {
                                            Icommand Proc = (Icommand)Activator.CreateInstance(ty, (Iddl)worker); /* passing the constructor argument */
                                            unsorted.Add(Proc);
                                        }
                                        catch
                                        {
                                            if (Debugger.IsAttached)
                                            {
                                                Debugger.Break();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            /* carry out creation, [dlatikay 20120628] sorting by vitals first */
            var sorted = unsorted.OrderBy(p => String.Format("{0}.{1}", p.IsVital ? "1" : "2", p.GetType().Name));

            foreach (Icommand proc in sorted)
            {
                if (!(proc is commandadhoc))
                {
                    if (!(proc is commanddynamic))
                    {
                        if (!(proc is commandpassthrough)) /* added [dlatikay 20110525] was missing */
                        {
                            if (!(proc is autoincrementertemplate))
                            {
                                if (!(proc is prdoc02FT)) /* -!- support this somehow, it is special */
                                //if (!(proc is prdoc02FT_MSSQL)) /* [dlatikay 20120703] now supported also when FT service is not installed on MSSQL (support this somehow, it is special (fails if FT catalog is not present at the time the proc is created)) */
                                //if (!(proc is prdoc02FTCacheLookup)) /* -!- support this somehow, it is special [dlatikay 20091201]; reinstated [dlatikay 20120611] this should be creatable */
                                {
                                    if (!CreateProcedure(worker, proc, continueonerror))
                                    {
                                        success = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            /* 2. [dlatikay 20110926] create the implied CRUD procedures for the declarative tables */
            var tables = ListAllSchemaTables();

            tables.Sort((t1, t2) => String.CompareOrdinal(t1.Name, t2.Name));
            foreach (var table in tables)
            {
                var Tab = (ITable)Activator.CreateInstance(table); /* passing the constructor argument */
                /* 1a. inserts */
                if (!CreateProceduresCRUD(worker, Tab))
                {
                    success = false;
                }
            }
            /* complete */
            return(success);
        }
Exemplo n.º 18
0
 public ApplicationClass(DatabaseFactory databaseFactory)
 {
     _databaseFactory = databaseFactory;
     _connection      = databaseFactory.CreateConnection();
     _command         = databaseFactory.CreateCommand();
 }
Exemplo n.º 19
0
 public virtual void SetCommand(Icommand command)
 {
     commandToExecute = command;
 }
Exemplo n.º 20
0
 /// <summary>Constructs the command list</summary>
 public Command()
 {
     commands     = new ArrayList();
     lastExecuted = null;
 }
Exemplo n.º 21
0
 /// <summary>
 /// Load a Command object into the undo list
 /// </summary>
 /// <param name="c"></param>
 /// <returns></returns>
 public int loadCommand(Icommand c)
 {
     return(commands.Add(c));
 }
Exemplo n.º 22
0
 public void eraseCommand()
 {
     commandToExecute = null;
 }
Exemplo n.º 23
0
 public void AddComponent(Icommand command)
 {
     commandBuffer.Add(command);
 }
Exemplo n.º 24
0
 public ReadUserControl(Icommand command, int imageLength, AppParams appParams)
 {
     InitializeComponent();
Exemplo n.º 25
0
 public override void SetCommand(Icommand command)
 {
     base.SetCommand(command);
 }