예제 #1
0
        /*
         * addLicense - adds single license to SoloServer, plus updates UDF and CustomData,
         * returns LicID if assigned, LicPwd and return result
         */
        public static Tuple <string, string, string> addLicense(ListBox lstLicBox, string CustomerID, string OptionID, string qty, string purchased, string expire, string activation, string deactivation, string cores, string notes, string SN, string SNID, string LicName, string CData, string LicType, bool testLic)
        {
            string   LicResult = "";
            string   LicID     = "0";
            string   LicPwd    = "";
            string   udf1      = "";
            string   udf2      = "";
            DateTime thisday   = DateTime.Today;
            DateTime expireday = thisday.AddDays(45);

            // for temp licensed dont indicate purchase date or prev serial number
            // in Licensee Name or UDFs
            if (LicType == "3temp")
            {
                udf1    = "45 Day Temporary License";
                udf2    = "";
                LicName = "45 Day Temp License";
                expire  = expireday.ToString("d");
            }
            else
            {
                udf1 = "Prev Serial Num: " + SN;
                // this function trims time from date
                string[] aryParts = purchased.Split(' ');
                if (aryParts.Length > 1)
                {
                    udf2  = "Originally Purchased: ";
                    udf2 += aryParts[0].Trim();
                }
            }

            //AddSWKLicense(string OptionID, string Qty, string expire, string ActCount, string DeactCount, string cores, string note, string custID, bool test)
            XmlNode resultAdd = ApiAccess.AddSWKLicense(OptionID, qty, expire, activation, deactivation, cores, notes, CustomerID, LicName, testLic);

            // Check to make sure there was a good node of data back
            XmlNode LicNode = resultAdd.SelectSingleNode("ResultCode");

            if (LicNode == null)
            {
                LicResult = "Error - No data returned";
            }
            else if (LicNode.InnerText != "0")
            {
                LicResult = "Error - Insert : " + LicNode.InnerText;
            }
            else

            {
                LicNode = resultAdd.SelectSingleNode("LicenseID");
                // txtLicInfo.Text = "LicenseID: " + LicNode.InnerText + " \n ";
                LicID   = LicNode.InnerText;
                LicNode = resultAdd.SelectSingleNode("ActivationPassword");
                //txtLicInfo.Text += "ActivationPassword: "******"Added";

                // update User Defined fields


                //UpdateSWKLicenseFields(string LicID, string LicPwd, string UDF1, string UDF2, string UDF3)
                XmlNode resultUpdUDF = ApiAccess.UpdateSWKLicenseFields(LicID, LicPwd, udf1, udf2, "");

                //Check results of update
                XmlNode LicUpdUDF = resultUpdUDF.SelectSingleNode("ResultCode");
                if (LicUpdUDF == null)
                {
                    LicResult += " | UDF result: null";
                }
                else if (LicUpdUDF.InnerText != "0")
                {
                    LicResult += " | UDF Error: " + LicUpdUDF.InnerText;
                }
                else
                {
                    LicResult += " | UDF Added";
                }

                // update CustomData
                //UpdateSWKLicenseCData(string LicID, string cdata)

                //build Custom Data
                //string inputCData = "<CustomParameters><IsLease>False</IsLease><IsExecsOverride>True</IsExecsOverride><ExecsAllowed>x</ExecsAllowed><KeyLength>256</KeyLength><Instances>31</Instances><MaxSize>65536</MaxSize><NumProcesses>63</NumProcesses><NumFiles>128</NumFiles><IsGUIsAllowed>True</IsGUIsAllowed><IsCLIAllowed>False</IsCLIAllowed><IsTimeLtd>False</IsTimeLtd></CustomParameters>";

                // make the call to update custom data
                XmlNode resultUpdCData = ApiAccess.UpdateSWKLicenseCData(LicID, CData);

                //Check results of update
                XmlNode LicUpdCData = resultUpdCData.SelectSingleNode("ResultCode");
                if (LicUpdCData == null)
                {
                    LicResult += " | CData result: null";
                }
                else if (LicUpdCData.InnerText != "0")
                {
                    LicResult += " | CData Error: " + LicUpdCData.InnerText;
                }
                else
                {
                    LicResult += " | CData Added";
                }
            }
            return(new Tuple <string, string, string>(LicID, LicPwd, LicResult));
        }
예제 #2
0
        private void btnAddLicense_Click(object sender, EventArgs e)
        {
            //AddSWKLicense(string OptionID, string Qty, string expire, string ActCount, string DeactCount, string cores, string note, string custID, bool test)
            XmlNode resultAdd = ApiAccess.AddSWKLicense("1036", "3", "12/31/2020", "1", "0", "12", "a note goes here", "4400028", "", checkBoxTest.Checked);

            // Check to make sure there was a good node of data back
            XmlNode LicNode = resultAdd.SelectSingleNode("ResultCode");

            if (LicNode == null)
            {
                txtLicInfo.Text = "No data found";
            }
            else if (LicNode.InnerText != "0")
            {
                txtLicInfo.Text = "Insert Error: " + LicNode.InnerText;
            }
            else

            {
                LicNode         = resultAdd.SelectSingleNode("LicenseID");
                txtLicInfo.Text = "LicenseID: " + LicNode.InnerText + " \n ";
                string LicID = LicNode.InnerText;
                LicNode          = resultAdd.SelectSingleNode("ActivationPassword");
                txtLicInfo.Text += "ActivationPassword: "******"Previous Serial Number: 001-204290-001-001-0", "udf2", "udf3");

                //Check results of update
                XmlNode LicUpdUDF = resultUpdUDF.SelectSingleNode("ResultCode");
                if (LicUpdUDF == null)
                {
                    txtLicInfo.Text += " UDF result: null";
                }
                else if (LicUpdUDF.InnerText != "0")
                {
                    txtLicInfo.Text += " UDF Error: " + LicUpdUDF.InnerText;
                }
                else
                {
                    txtLicInfo.Text += " UDF Added";
                }

                // update CustomData
                //UpdateSWKLicenseCData(string LicID, string cdata)

                //build Custom Data
                string inputCData = "<CustomParameters><IsServer>True</IsServer><IsExecsOverride>False</IsExecsOverride><ExecsAllowed>Example String Value</ExecsAllowed><SQLEdition>4</SQLEdition><IsWholeDB>True</IsWholeDB><IsColumn>True</IsColumn><KeyLength>256</KeyLength><IsFolder>True</IsFolder><Instances>31</Instances><SysIdent>True</SysIdent></CustomParameters>";

                // make the call to update custom data
                XmlNode resultUpdCData = ApiAccess.UpdateSWKLicenseCData(LicID, inputCData);

                //Check results of update
                XmlNode LicUpdCData = resultUpdCData.SelectSingleNode("ResultCode");
                if (LicUpdCData == null)
                {
                    txtLicInfo.Text += " CData result: null";
                }
                else if (LicUpdCData.InnerText != "0")
                {
                    txtLicInfo.Text += " CData Error: " + LicUpdCData.InnerText;
                }
                else
                {
                    txtLicInfo.Text += " CData Added";
                }
            }
        }