Ejemplo n.º 1
0
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            //Check if activity is allowed to run
            ActivityActivationReference.IsAllowed(this, __Context.Web);

            //Resolve tags in string (variables, etc)
            NWWorkflowContext ctx = NWWorkflowContext.GetContext(__Context, new Guid(__ListId), __ListItem.Id, WorkflowInstanceId, this);

            //Activity has begun executing
            base.LogProgressStart(ctx);
            LogHelper.LogInfo(Cat, "NTX PowerShell running at: " + this.__Context.CurrentItemUrl);

            //Determine if a Workflow Constant is being used for authentication
            string runtimeUsername = null;
            string runtimePassword = null;

            if (LoginUserName.Contains("WFConstant") & LoginPassword == "")
            {
                CredentialValue.DetermineRuntimeCredentials(LoginUserName, LoginPassword, out runtimeUsername,
                                                            out runtimePassword, ctx.Context.Web.ID, ctx.Context.Site.ID);
            }
            else
            {
                runtimeUsername = LoginUserName;
                runtimePassword = LoginPassword;
            }


            String script = ctx.AddContextDataToString(PSScript);

            try
            {
                var ps = new PSHelper();
                LogHelper.LogInfo(Cat, "Executing script as " + runtimeUsername + " on " + ComputerName + AppName + ":" + PortNumber + " SSL Enabled: " + SSLEnabled);
                ps.CreatePowerShellRunspace(SSLEnabled, ComputerName, PortNumber, AppName, ShellUri, runtimeUsername, runtimePassword);
                ps.SetRunSpaceVariable("NTXWorkflowContext", __Context);
                ps.SetRunSpaceVariable("NTXListID", new Guid(__ListId));
                ps.SetRunSpaceVariable("NTXWorkflowInstanceID", new Guid(__ListId));
                LogHelper.LogInfo(Cat, "NTX PowerShell RunSpaceVariables loaded");
                ps.AddScriptToPipeLine(script);
                LogHelper.LogInfo(Cat, "NTX PowerShell Script loaded: " + script);
                ps.ConvertPipeContentsToString();
                ResultOutput = ps.ProcessResultsToString(ps.InvokePipeline());

                //Added to ensure runspaces are closed after execution completes. https://msdn.microsoft.com/en-us/library/system.management.automation.runspaces.runspacefactory(v=vs.85).aspx
                ps.DisposePowerShellRunspace();
            }
            catch (Exception e)
            {
                ResultOutput = e.ToString();
                LogHelper.LogException(Cat, e);
            }

            //activity has stopped executing
            base.LogProgressEnd(ctx, executionContext);
            LogHelper.LogInfo(Cat, "NTX PowerShell completed at: " + __Context.CurrentItemUrl);

            return(ActivityExecutionStatus.Closed);
        }
Ejemplo n.º 2
0
        private void Login_btn_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            //Log in to the account
            if (Properties.Settings.Default.FirstTime)
            {
                System.Windows.Forms.MessageBox.Show("No Administration account found in this computer. Please use the 'Create a New Account' button to create a new administration account to start working with this software", "No account found", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
            }
            else
            {
                LoginAccountGrid.Margin = new Thickness(405, 0, 0, 0);

                DoubleAnimation da = new DoubleAnimation();
                da.From           = 0;
                da.To             = 1;
                da.Duration       = TimeSpan.FromSeconds(1);
                da.EasingFunction = new QuinticEase();

                LoginCancelButton.IsEnabled = true;

                LoginUserName.Focus();

                LoginAccountGrid.BeginAnimation(OpacityProperty, da);
            }
        }
Ejemplo n.º 3
0
 public void EnterUserName(string loginUserName)
 {
     LoginUserName.SendKeys(loginUserName);
 }
        private void Login_Click(object sender, EventArgs e)
        {
            string userName = LoginUserName.Text;
            string password = LoginPassword.Text;


            try
            {
                if (Type.Text == "" || Type.Text == null)
                {
                    MessageBox.Show("请选择用户身份");
                }
                else if (LoginUserName.Text == "" || LoginUserName.Text == null || LoginPassword.Text == "" || LoginPassword.Text == "")
                {
                    MessageBox.Show("请输入正确的用户名和密码");
                }
                else if (Type.Text == "管理员")
                {
                    string SelectSQL = "select * from admin where UserName=N'" + userName + "'";

                    DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.Text, SelectSQL);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        //该用户名存在,从数据中获取保存的加盐哈希值,赋值给变量goodhash
                        string goodhash = ds.Tables[0].Rows[0]["Password"].ToString();

                        //判断用户输入的密码是否匹配
                        if (PasswordSecurity.PasswordStorage.VerifyPassword(password, goodhash))
                        {
                            f9 = new Form9();
                            f9.Show();
                            this.Hide();
                        }
                        else
                        {
                            LoginUserName.Clear();
                            LoginPassword.Clear();
                            MessageBox.Show("如果不是管理员,请离开");
                        }
                    }
                    else
                    {
                        LoginUserName.Clear();
                        LoginPassword.Clear();
                        MessageBox.Show("如果不是管理员,请离开");
                    }
                }
                else if (Type.Text == "教师")
                {
                    string SelectSQL = "select * from teacher where UserName=N'" + userName + "'";

                    DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.Text, SelectSQL);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        //该用户名存在,从数据中获取保存的加盐哈希值,赋值给变量goodhash
                        string goodhash = ds.Tables[0].Rows[0]["Password"].ToString();
                        //判断用户输入的密码是否匹配
                        if (PasswordSecurity.PasswordStorage.VerifyPassword(password, goodhash))
                        {
                            f3 = new Form3();
                            f3.Show();
                            this.Hide();
                        }
                        else
                        {
                            LoginUserName.Clear();
                            LoginPassword.Clear();
                            MessageBox.Show("如果不是老师,请选择正确的身份登录");
                        }
                    }
                    else
                    {
                        LoginUserName.Clear();
                        LoginPassword.Clear();
                        MessageBox.Show("如果不是老师,请选择正确的身份登录");
                    }
                }
                else if (Type.Text == "学生")
                {
                    string SelectSQL = "select * from StdInfo where UserName=N'" + userName + "'";

                    DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.Text, SelectSQL);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        string goodhash = ds.Tables[0].Rows[0]["Password"].ToString();
                        if (PasswordSecurity.PasswordStorage.VerifyPassword(password, goodhash))
                        {
                            f2 = new Form2();
                            f2.Show();
                            this.Hide();
                        }
                        else
                        {
                            LoginUserName.Clear();
                            LoginPassword.Clear();
                            MessageBox.Show("用户名或密码错误");
                        }
                    }
                    else
                    {
                        LoginUserName.Clear();
                        LoginPassword.Clear();
                        MessageBox.Show("用户名或密码错误");
                    }
                }
                else
                {
                    MessageBox.Show("用户名或密码错误或身份不匹配");
                }
            }
            catch
            {
                MessageBox.Show("用户名或密码输入错误");
            }
        }
Ejemplo n.º 5
0
 private void LoginClear_MouseClick(object sender, MouseEventArgs e)
 {
     LoginUserName.Text = "";
     LoginPassWord.Text = "";
     LoginUserName.Focus();
 }