Example #1
0
        //private static void RemoveResults()
        //{
        //    //find root element
        //    var xRoot = DBFactory.GetData().Read(Constants._TYPE, "Root");
        //    var resultId = xRoot.GetAttributeValue(Constants.RESULT);
        //    var results = DBFactory.GetData().GetChildren(resultId);
        //    foreach (var kids in results.Descendants())
        //    {
        //        DBFactory.GetData().Delete(kids.GetAttributeValue(Constants._ID));
        //    }
        //}

        //private static void CleanProject()
        //{
        //    //find root element
        //    var xRoot = DBFactory.GetData().Read(Constants._TYPE, "Root");
        //    var root = DBFactory.GetData().GetChildren(xRoot.GetAttributeValue(Constants._ID));
        //    foreach (var kid in root.Descendants())
        //    {
        //        var id = kid.GetAttributeValue(Constants._ID);
        //        if (id.Equals(xRoot.GetAttributeValue(Constants._ID)))
        //            continue;
        //        foreach (var grandKid in DBFactory.GetData().GetChildren(id).Descendants())
        //        {
        //            DBFactory.GetData().Delete(grandKid.GetAttributeValue(Constants._ID));
        //        }
        //    }
        //}

        private static void TestWorkflow()
        {
            var auto             = new AutoClient();
            var workflowInstance = new WorkflowInstance(Guid.NewGuid().ToString(),
                                                        "7fdcbd7a-b30e-4c36-aa46-58ba74b02401", Configuration.Clone().GetList());
            var xCommand = workflowInstance.GetCommand();

            Console.WriteLine(xCommand.ToString());
            var xResult = auto.Execute(xCommand);

            Console.WriteLine(xResult);
            workflowInstance.SetResult(xResult);
        }
Example #2
0
        private void RunWorkflowById(string workflowId)
        {
            _workflowInstance = new WorkflowInstance(Guid.NewGuid().ToString(), workflowId, _config.GetList())
            {
                ClientId = _config.Get(Constants._ID, Guid.NewGuid().ToString())
            };
            //Mapping between the Object and Line No.

            Log.Debug(_workflowInstance.ToXElement().ToString());
            //do we need to register client at controller debugging? Yes, we need it to maintain the status of this only client
            ClientInstancesManager.GetInstance().Register(_config.SetRegisterBody(XElement.Parse("<Register />")));
            //TODO add visual trace here
            //if workflow is loaded, we can track it.
            //workflowInstance.Tracker.Tracking = this;

            _workflowInstance.Start();

            var debugMode = _config.Get("ModeDebug", "True").Equals("True", StringComparison.CurrentCultureIgnoreCase);

            while (true)
            {
                var xCommand = _workflowInstance.GetCommand();
                if (xCommand == null)
                {
                    break;
                }
                if (debugMode)
                {
                    MessageBox.Show(xCommand.ToString());
                }
                Log.Info(xCommand.ToString());

                var xResult = _autoClient.Execute(xCommand);
                if (debugMode)
                {
                    MessageBox.Show(xResult.ToString());
                }
                Log.Info(xResult.ToString());
                _workflowInstance.SetResult(xResult);
                Thread.Sleep(1000);

                if (_workflowInstance.IsFinished())
                {
                    break;
                }
            }

/*
 *          workflowInstance = null;
 */
        }