コード例 #1
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);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: KCNederland/Glyder.Licensing
        public glyderLicense bindLicense()
        {
            glyderLicense gll = new glyderLicense();

            try
            {
                gll.glyderStateServiceLicense                = new GlyderStateServiceLicense();
                gll.glyderStateServiceLicense.active         = cbSSActive.Checked;
                gll.glyderStateServiceLicense.expirationDate = dpStateService.Value.Date;

                gll.glyderSMILicense                = new GlyderSMILicense();
                gll.glyderSMILicense.active         = cbSMIActive.Checked;
                gll.glyderSMILicense.expirationDate = dpSMI.Value.Date;

                gll.glyderWorkflowLicense                = new GlyderWorkflowLicense();
                gll.glyderWorkflowLicense.active         = cbWorkflowActive.Checked;
                gll.glyderWorkflowLicense.expirationDate = dpWorkflow.Value.Date;

                gll.glyderWorkspaceLicense                = new GlyderWorkspaceLicense();
                gll.glyderWorkspaceLicense.active         = cbWorkspaceActive.Checked;
                gll.glyderWorkspaceLicense.expirationDate = dpWorkspace.Value.Date;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to bind license: " + ex.Message, "GlyderLicensing");
            }
            return(gll);
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: KCNederland/Glyder.Licensing
 public void loadLicense()
 {
     try
     {
         glyderLicense gll = gl.getGlyderLicense();
         cbSSActive.Checked        = gll.glyderStateServiceLicense.active;
         cbSMIActive.Checked       = gll.glyderSMILicense.active;
         cbWorkflowActive.Checked  = gll.glyderWorkflowLicense.active;
         cbWorkspaceActive.Checked = gll.glyderWorkspaceLicense.active;
         if (dpStateService.MinDate > gll.glyderStateServiceLicense.expirationDate.Date)
         {
             dpStateService.MinDate = gll.glyderStateServiceLicense.expirationDate.Date;
         }
         dpStateService.Value = gll.glyderStateServiceLicense.expirationDate;
         if (dpSMI.MinDate > gll.glyderSMILicense.expirationDate.Date)
         {
             dpSMI.MinDate = gll.glyderSMILicense.expirationDate.Date;
         }
         dpSMI.Value = gll.glyderSMILicense.expirationDate;
         if (dpWorkflow.MinDate > gll.glyderWorkflowLicense.expirationDate.Date)
         {
             dpWorkflow.MinDate = gll.glyderWorkflowLicense.expirationDate.Date;
         }
         dpWorkflow.Value = gll.glyderWorkflowLicense.expirationDate;
         if (dpWorkspace.MinDate > gll.glyderWorkspaceLicense.expirationDate.Date)
         {
             dpWorkspace.MinDate = gll.glyderWorkspaceLicense.expirationDate.Date;
         }
         dpWorkspace.Value = gll.glyderWorkspaceLicense.expirationDate;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Laden licentie mislukt: " + ex.ToString());
     }
 }
コード例 #4
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);
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: KCNederland/Glyder.Licensing
        private void btnCreateLicense_Click(object sender, EventArgs e)
        {
            glyderLicense gll       = bindLicense();
            Result        createRes = gl.createNewLicense(gll);

            if (!createRes.success)
            {
                MessageBox.Show(createRes.exception.Message);
            }
            else
            {
                checkIfLicenseExists();
            }
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: KCNederland/Glyder.Licensing
        private void btnUpdateXML_Click(object sender, EventArgs e)
        {
            glyderLicense gll = bindLicense();


            Result updateRes = gl.updateGlyderLicense(gll);

            if (updateRes.success)
            {
                MessageBox.Show("Update succesvol", "GlyderLicensing");
            }
            else
            {
                MessageBox.Show("Update mislukt: " + updateRes.exception.ToString(), "GlyderLicensing");
            }
        }