Пример #1
0
        public bool RenewMogwareLicense()
        {
            try
            {
                // Post back to either sandbox or live
                string     serverMacAddress = MOG_ControllerSystem.GetComputerMacAddress();
                string     url = "http://www.mogware.net/subscriptions/seat_request.php?phys_address=" + serverMacAddress;
                WebRequest req = HttpWebRequest.Create(url);

                // Set values for the request back
                req.Method        = WebRequestMethods.Http.Post;
                req.ContentType   = "application/x-www-form-urlencoded";
                req.ContentLength = url.Length;

                string strRequest = url;
                req.ContentLength = strRequest.Length;

                // Send the request to PayPal and get the response
                StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), Encoding.ASCII);
                streamOut.Write(strRequest);
                streamOut.Close();
                StreamReader streamIn    = new StreamReader(req.GetResponse().GetResponseStream());
                string       strResponse = streamIn.ReadToEnd();
                streamIn.Close();
                // Get the number of licensed seats
                int licensedSeats = Convert.ToInt32(strResponse);

                // Generate a automatic expiration date
                DateTime expiration = DateTime.Now;
                expiration = expiration.AddDays(30);

                // Generate a new license file based on these parameters
                MOG_LicenseGenerator.Generator.Generate(mFilename, serverMacAddress, expiration, licensedSeats);

                return(true);
            }
            catch
            {
            }

            return(false);
        }