コード例 #1
0
        //Login to Session
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //initialize SDK
            shiftPlanning = new ShiftPlanning(txtAPIKey.Text);
            if (shiftPlanning.getLoginStatus())
            {
            }

            try
            {
                //log
                txtLog.AppendText("\r\n\r\nMethod: doLogin");

                //login to session
                //preparing list of request field
                RequestFields login_details = new RequestFields();
                login_details.Add("username", txtUsername.Text);
                login_details.Add("password", txtPassword.Text);
                //calling method
                response = shiftPlanning.doLogin(login_details);

                //checking response
                if (response.Status.Code == "1")
                {//if login success
                    //get the current session
                    session = shiftPlanning.getSession();
                    //update log
                    txtLog.AppendText("\r\nLogin " + response.Status.Text +
                                      "\r\nWelcome " + response.Data["employee"].Item["name"].Value +
                                      "\r\nBusiness Name: " + response.Data["business"].Item["name"].Value +
                                      "\r\nToken: " + response.Status.Token);
                    btnLogout.Enabled = true;
                }
                else
                {
                    //update log
                    txtLog.AppendText("\r\n\r\nLogin " + response.Status.Text +
                                      "\r\nError: " + response.Status.Error);
                }
            }
            catch (Exception ex)
            {
                txtLog.AppendText("\r\n\r\nException: " + ex.Message);
            }
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: HughJeffner/cs-sdk
        //Login to Session
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //initialize SDK
            shiftPlanning = new ShiftPlanning(txtAPIKey.Text);
            if (shiftPlanning.getLoginStatus())
            {
            }

            try
            {
                //log
                txtLog.AppendText("\r\n\r\nMethod: doLogin");

                //login to session
                //preparing list of request field
                RequestFields login_details = new RequestFields();
                login_details.Add("username", txtUsername.Text);
                login_details.Add("password", txtPassword.Text);
                //calling method
                response = shiftPlanning.doLogin(login_details);

                //checking response
                if (response.Status.Code == "1")
                {//if login success
                    //get the current session 
                    session = shiftPlanning.getSession();
                    //update log
                    txtLog.AppendText("\r\nLogin " + response.Status.Text +
                        "\r\nWelcome " + response.Data["employee"].Item["name"].Value +
                        "\r\nBusiness Name: " + response.Data["business"].Item["name"].Value +
                        "\r\nToken: " + response.Status.Token);
                    btnLogout.Enabled = true;
                }
                else
                {
                    //update log
                    txtLog.AppendText("\r\n\r\nLogin " + response.Status.Text +
                           "\r\nError: " + response.Status.Error);
                }
            }
            catch (Exception ex)
            {
                txtLog.AppendText("\r\n\r\nException: " + ex.Message);
            }
        }