public void Previous(int sessionID, StepCollectRequest request)
        {
            //ExecutionStepElement currentInstacnceElement = parentInstance.Configuration.ExecutionSteps[currentInstance.Configuration.Name];

            //int currentStepIndex = parentInstance.Configuration.ExecutionSteps.IndexOf(currentInstacnceElement);
            ServiceInstance previousStep;
            ServiceInstance currentStep;

            if (request.StepName != StepInstances[sessionID].Configuration.Name)
            {
                throw new Exception("Step name is not matching current step!");
            }
            currentStep = StepInstances[sessionID];
            ExecutionStepElement currentStepElement = currentStep.ParentInstance.Configuration.ExecutionSteps[currentStep.Configuration.Name];

            int currentStepIndex = currentStep.ParentInstance.Configuration.ExecutionSteps.IndexOf(currentStepElement);
        }
        public StepCollectResponse Collect(int sessionID, StepCollectRequest request)
        {
            StepCollectResponse response = null;
            StepCollectResponse tempResponse;

            try
            {
                // make sure request.StepName matches StepInstances[sessionID].Configuration.Name(client is in the right step)
                if (request.StepName != StepInstances[sessionID].Configuration.Name)
                {
                    throw new Exception("Step name is not matching current step!");
                }
                //connect to the  collector
                using (ServiceClient <IStepCollector> client = new ServiceClient <IStepCollector>("Test", String.Format("net.tcp://*****:*****@"UPDATE Wizards_Sessions_Data 
																			SET 
																			CurrentStepName=@CurrentStepName:NvarChar,
																			WizardStatus=@WizardStatus:Int
																			WHERE SessionID=@SessionID:Int 
																			AND ServiceInstanceID=@ServiceInstanceID:BigInt"                                                                            ))
                                {
                                    sqlCommand.Parameters["@CurrentStepName"].Value   = nextStep.Name;
                                    sqlCommand.Parameters["@SessionID"].Value         = sessionID;
                                    sqlCommand.Parameters["@WizardStatus"].Value      = WizardStatus.Collect;
                                    sqlCommand.Parameters["@ServiceInstanceID"].Value = parentInstance.ParentInstance.InstanceID;
                                    sqlCommand.ExecuteNonQuery();
                                }
                            }
                            //create succesful response with the collected details
                            response = new StepCollectResponse()
                            {
                                Errors = null, Result = StepResult.Next, NextStep = new StepConfiguration()
                                {
                                    StepName = nextStep.Name
                                }
                            };
                        }
                        else //the last step of the collectors
                        {
                            //Change Status and current Step
                            using (DataManager.Current.OpenConnection())
                            {
                                using (SqlCommand sqlCommand = DataManager.CreateCommand(@"UPDATE Wizards_Sessions_Data 
																			SET 
																			CurrentStepName=@CurrentStepName:NvarChar,
																			WizardStatus=@WizardStatus:Int
																			WHERE SessionID=@SessionID:Int 
																			AND ServiceInstanceID=@ServiceInstanceID:BigInt"                                                                            ))
                                {
                                    sqlCommand.Parameters["@CurrentStepName"].Value   = string.Empty;
                                    sqlCommand.Parameters["@SessionID"].Value         = sessionID;
                                    sqlCommand.Parameters["@WizardStatus"].Value      = WizardStatus.Execute;
                                    sqlCommand.Parameters["@ServiceInstanceID"].Value = parentInstance.ParentInstance.InstanceID;
                                    sqlCommand.ExecuteNonQuery();
                                }
                            }
                            response = new StepCollectResponse()
                            {
                                Errors = null, Result = StepResult.Done
                            };
                        }
                    }
                    else //error
                    {
                        response = new StepCollectResponse()
                        {
                            Result = StepResult.HasErrors, Errors = tempResponse.Errors
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write("Service not Started yet: ", ex);
                throw new WebFaultException <string>("Service not Started yet: " + ex.Message, HttpStatusCode.ServiceUnavailable);
            }
            return(response);
        }