Esempio n. 1
0
        /// <summary>
        /// Called when the KMOD ticket query results are available.
        /// </summary>
        private void OnKmodTicketResult(WmLoginTicketQuery query)
        {
            if (m_kmodQuery != query)
            {
                return;
            }
            m_kmodQuery = null;
            Debug.Assert(m_step == OpStep.TicketReply);

            try
            {
                // Update the registry information.
                query.UpdateRegistry();

                // Generic failure.
                if (query.Res != WmLoginTicketQueryRes.OK)
                {
                    throw new Exception(query.OutDesc);
                }

                // We cannot create a workspace.
                if (!KwmCfg.Cur.CanCreateKws())
                {
                    throw new EAnpExInvalidKpsConfig();
                }

                // Update the credentials.
                Creds.Ticket           = query.Ticket.BinaryTicket;
                Creds.UserName         = query.Ticket.AnpTicket.Elements[0].String;
                Creds.UserEmailAddress = query.Ticket.AnpTicket.Elements[1].String;

                // Set the KCD address.
                if (KwmCfg.Cur.CustomKcdFlag)
                {
                    Creds.KcdAddress = KwmCfg.Cur.CustomKcdAddress;
                }
                else
                {
                    Creds.KcdAddress = KwmCfg.Cur.KpsKcdAddr;
                }
                if (Creds.KcdAddress == "")
                {
                    throw new Exception("invalid KCD address");
                }

                // Create the workspace object.
                Kws = Wm.CreateWorkspace(Creds);
                RegisterToKws();

                // Start the spawn operation and wait for the connection.
                m_step = OpStep.Connecting;
                Kws.Sm.RequestTaskSwitch(KwsTask.Spawn);
                SendCreateKwsCmdIfNeeded();
            }

            catch (Exception ex)
            {
                HandleFailure(ex);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Import or join a workspace that does not exist in the KWM.
        /// </summary>
        private static void ImportNewKws(KwsCredentials creds)
        {
            KLogging.Log("Importing new workspace " + creds.KwsName + ".");

            // Create the workspace.
            Workspace kws = Wm.CreateWorkspace(creds);

            // Set its main status.
            kws.Cd.MainStatus = KwsMainStatus.Good;

            // Make the workspace work online.
            kws.Sm.RequestTaskSwitch(KwsTask.WorkOnline);
        }