Пример #1
0
        public xmlResult decryptXML(string xmlString)
        {
            xmlResult xr = new xmlResult();

            try
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(xmlString);

                XmlNode xNode = xDoc.DocumentElement;

                string it = xNode.InnerXml;

                string decrypted = decrypt(it);
                xNode.InnerXml = decrypted;

                xr.success = true;
                xr.xml     = xDoc;
            }
            catch (Exception ex)
            {
                xr.success   = false;
                xr.exception = ex;
            }

            return(xr);
        }
Пример #2
0
        public glyderLicense getGlyderLicense()
        {
            glyderLicense gl = new glyderLicense();

            try
            {
                xmlResult xr = getLicenseXMLFromGlyderDatabase();
                if (xr.success)
                {
                    //XmlDocument glyderLicenseXML = new XmlDocument();
                    //glyderLicenseXML.Load("c:\\Glyder.Licensing\\License.xml");
                    GlyderStateServiceLicense gsl = new GlyderStateServiceLicense();

                    using (XmlReader reader = new XmlNodeReader(xr.xml))
                    {
                        var serializer = new XmlSerializer(typeof(glyderLicense), new XmlRootAttribute("GlyderLicense"));
                        gl = (glyderLicense)serializer.Deserialize(reader);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(gl);
        }
Пример #3
0
        public Result createNewLicense(glyderLicense gl)
        {
            Result createLicenseRes = new Result();

            try
            {
                if (ggc.loaded)
                {
                    xmlResult insertLicenseResult = encryptXML(@"<GlyderLicense>
                      <glyderStateServiceLicense>
                        <applicationID>1</applicationID>
                        <active>" + gl.glyderStateServiceLicense.active.ToString().ToLower() + @"</active>
                        <expirationDate>" + gl.glyderStateServiceLicense.expirationDate.ToString("o") + @"</expirationDate>
                      </glyderStateServiceLicense>
                      <glyderSMILicense>
                        <applicationID>2</applicationID>
                        <active>" + gl.glyderSMILicense.active.ToString().ToLower() + @"</active>
                        <expirationDate>" + gl.glyderSMILicense.expirationDate.ToString("o") + @"</expirationDate>
                      </glyderSMILicense>
                      <glyderWorkflowLicense>
                        <applicationID>3</applicationID>
                        <active>" + gl.glyderWorkflowLicense.active.ToString().ToLower() + @"</active>
                        <expirationDate>" + gl.glyderWorkflowLicense.expirationDate.ToString("o") + @"</expirationDate>
                      </glyderWorkflowLicense>
                      <glyderWorkspaceLicense>
                        <applicationID>4</applicationID>
                        <active>" + gl.glyderWorkspaceLicense.active.ToString().ToLower() + @"</active>
                        <expirationDate>" + gl.glyderWorkspaceLicense.expirationDate.ToString("o") + @"</expirationDate>
                      </glyderWorkspaceLicense>                      
                    </GlyderLicense>");

                    if (insertLicenseResult.success)
                    {
                        string createLicenseQuery = "INSERT INTO tblConfigurations (ApplicationID, Version, [Configuration], CustomerGuid) VALUES(0, 0, '" + insertLicenseResult.xml.OuterXml + "', '" + ggc.customerGuid.ToString() + @"')";

                        using (SqlConnection con = new SqlConnection(glyderConfigurationConnectionstring))
                        {
                            using (SqlCommand com = new SqlCommand(createLicenseQuery, con))
                            {
                                con.Open();
                                createLicenseRes.success = (int)com.ExecuteNonQuery() > 0;
                                con.Close();
                            }
                        }
                    }
                }
                else
                {
                    createLicenseRes.success   = false;
                    createLicenseRes.exception = new Exception("Glyder Global Configuration not found");
                }
            }
            catch (Exception ex)
            {
                createLicenseRes.success   = false;
                createLicenseRes.exception = ex;
            }
            return(createLicenseRes);
        }
Пример #4
0
        public Result updateGlyderLicense(glyderLicense gl)
        {
            Result res = new Result();

            res.success = false;


            try
            {
                using (var sww = new StringWriter())
                {
                    using (XmlWriter writer = XmlWriter.Create(sww))
                    {
                        var serializer = new XmlSerializer(typeof(glyderLicense), new XmlRootAttribute("GlyderLicense"));

                        serializer.Serialize(writer, gl);
                        string    xml = sww.ToString(); // Your XML
                        xmlResult xr  = encryptXML(xml);

                        if (xr.success)
                        {
                            string updateQuery = "UPDATE tblConfigurations SET [Configuration] = @config WHERE ApplicationID = 0 AND Version = 0";
                            using (SqlConnection con = new SqlConnection(glyderConfigurationConnectionstring))
                            {
                                using (SqlCommand cmd = new SqlCommand(updateQuery, con))
                                {
                                    cmd.Parameters.AddWithValue("@config", xr.xml.OuterXml);
                                    con.Open();
                                    if (cmd.ExecuteNonQuery() == 1)
                                    {
                                        res.success = true;
                                    }
                                    con.Close();
                                }
                            }
                        }
                        else
                        {
                            res.exception = xr.exception;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                res.exception = ex;
            }
            return(res);
        }
Пример #5
0
        public xmlResult getLicenseXMLFromGlyderDatabase()
        {
            xmlResult xr = new xmlResult();

            try
            {
                using (SqlConnection con = new SqlConnection(glyderConfigurationConnectionstring))
                {
                    string selectQuery = "SELECT Configuration FROM tblConfigurations WHERE [ApplicationID] = 0 AND [CustomerGuid] = '" + ggc.customerGuid.ToString() + "'";

                    string licenseXMLString = string.Empty;
                    using (SqlCommand com = new SqlCommand(selectQuery, con))
                    {
                        con.Open();
                        var licenseXMLObject = com.ExecuteScalar();
                        con.Close();
                        if (licenseXMLObject != null)
                        {
                            licenseXMLString = licenseXMLObject.ToString();
                        }
                        if (!string.IsNullOrWhiteSpace(licenseXMLString))
                        {
                            xmlResult xmlLicenseResult = decryptXML(licenseXMLString);
                            {
                                if (xmlLicenseResult.success)
                                {
                                    xr.success = true;
                                    xr.xml     = xmlLicenseResult.xml;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                xr.exception = ex;
                xr.success   = false;
            }
            return(xr);
        }