// This function builds a request line from the class properties. protected virtual void BuildRequestLine() { if (Command == null || User == null || DeviceID == null || DeviceType == null) { throw new InvalidDataException("ASCommandRequest not initialized."); } if (UseEncodedRequestLine == true) { // Use the EncodedRequest class to generate // an encoded request line EncodedRequest encodedRequest = new EncodedRequest(); encodedRequest.ProtocolVersion = Convert.ToByte(Convert.ToSingle(ProtocolVersion) * 10); encodedRequest.SetCommandCode(Command); encodedRequest.SetLocale("en-us"); encodedRequest.DeviceId = DeviceID; encodedRequest.DeviceType = DeviceType; encodedRequest.PolicyKey = PolicyKey; // Add the User parameter to the request line encodedRequest.AddCommandParameter("User", user); // Add any command-specific parameters if (CommandParameters != null) { for (int i = 0; i < parameters.Length; i++) { encodedRequest.AddCommandParameter(CommandParameters[i].Parameter, CommandParameters[i].Value); } } // Generate the request line RequestLine = encodedRequest.GetBase64EncodedString(); } else { // Generate a plain-text request line. RequestLine = string.Format("Cmd={0}&User={1}&DeviceId={2}&DeviceType={3}", Command, User, DeviceID, DeviceType); if (CommandParameters != null) { for (int i = 0; i < parameters.Length; i++) { RequestLine = string.Format("{0}&{1}={2}", RequestLine, CommandParameters[i].Parameter, CommandParameters[i].Value); } } } }
// This function builds a request line from the class properties. protected virtual void BuildRequestLine() { if (Command == null || User == null || DeviceID == null || DeviceType == null) throw new InvalidDataException("ASCommandRequest not initialized."); if (UseEncodedRequestLine == true) { // Use the EncodedRequest class to generate // an encoded request line EncodedRequest encodedRequest = new EncodedRequest(); encodedRequest.ProtocolVersion = Convert.ToByte(Convert.ToSingle(ProtocolVersion) * 10); encodedRequest.SetCommandCode(Command); encodedRequest.SetLocale("en-us"); encodedRequest.DeviceId = DeviceID; encodedRequest.DeviceType = DeviceType; encodedRequest.PolicyKey = PolicyKey; // Add the User parameter to the request line encodedRequest.AddCommandParameter("User", user); // Add any command-specific parameters if (CommandParameters != null) { for (int i = 0; i < parameters.Length; i++) { encodedRequest.AddCommandParameter(CommandParameters[i].Parameter, CommandParameters[i].Value); } } // Generate the request line RequestLine = encodedRequest.GetBase64EncodedString(); } else { // Generate a plain-text request line. RequestLine = string.Format("Cmd={0}&User={1}&DeviceId={2}&DeviceType={3}", Command, User, DeviceID, DeviceType); if (CommandParameters != null) { for (int i = 0; i < parameters.Length; i++) { RequestLine = string.Format("{0}&{1}={2}", RequestLine, CommandParameters[i].Parameter, CommandParameters[i].Value); } } } }