/// <summary> /// Send a login command to the KCD. /// </summary> private void SendLoginCommand() { AnpMsg msg = m_kws.NewKcdCmd(KAnp.KANP_CMD_KWS_CONNECT_KWS); // Add the delete workspace flag. if (m_kws.Kcd.MinorVersion >= 4) { msg.AddUInt32(Convert.ToUInt32(m_kws.Cd.CurrentTask == KwsTask.DeleteRemotely)); } // Add the last event information. AnpMsg lastEvent = m_kws.GetLastKAnpEventInDb(); if (lastEvent == null) { msg.AddUInt64(0); msg.AddUInt64(0); } else { msg.AddUInt64(lastEvent.ID); msg.AddUInt64(lastEvent.Elements[1].UInt64); } // Add the credential information. msg.AddUInt32(m_kws.Cd.Credentials.UserID); msg.AddString(m_kws.Cd.Credentials.UserName); msg.AddString(m_kws.Cd.Credentials.UserEmailAddress); msg.AddString(m_kws.Cd.Credentials.EmailID); // Send a ticket only if we're at the cached or ticket steps. byte[] ticket = null; if (m_currentStep != KwsLoginStep.Pwd) { ticket = m_kws.Cd.Credentials.Ticket; } msg.AddBin(ticket); // Send a password only if we're at the cached or password steps. String pwd = ""; if (m_currentStep != KwsLoginStep.Ticket) { pwd = m_kws.Cd.Credentials.Pwd; } msg.AddString(pwd); // Post the login query. m_kws.PostKcdCmd(msg, HandleConnectKwsReply); }