Exemplo n.º 1
0
        private void btn_read_Click(object sender, RoutedEventArgs e)
        {
            checkLicense();
            Lic lobj = new Lic();

            lobj.getLicDetails(@"R:\Dropbox\GitHub\ZSharpLicense\ReleasePackage\Lic\License.XML");
        }
Exemplo n.º 2
0
 private void btnLicence_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtLicence.Text != "")
         {
             LicenceManager licMG = new LicenceManager();
             Lic            lic   = licMG.GetAll().FirstOrDefault(l => l.Lic1 == txtLicence.Text);
             if (lic != null)
             {
                 File.Create(@"C:\Windows\lic.txt");
                 licMG.Delete(lic);
                 Users.FRM_Login login = new  Users.FRM_Login();
                 this.Hide();
                 login.ShowDialog();
                 Application.Exit();
             }
             else
             {
                 MessageBox.Show("عفواّ رقم الترخيص غير صحيح");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            if (args.Any(a => a == "--generate"))
            {
                GenerateNewKeyPair();
            }

            var dto = new Lic()
            {
                ValidUntil = DateTime.Now.AddDays(7)
            };

            var fileName = string.Join("", DateTime.Now.ToString().Where(c => char.IsDigit(c)));

            new LicenceGenerator().CreateLicenseFile(dto, fileName + ".ftb_licence");
        }
Exemplo n.º 4
0
 private static void ApplyLicense(this LicenceType License, string licensePath, bool ThrowExIfExpired, CodeToApplyLicense ApplyLicenseCode)
 {
     try
     {
         using (Lic lic = new Lic(License, licensePath))
         {
             if (lic != null)
             {
                 if (lic.CanApply)
                 {
                     if (ApplyLicenseCode != null)
                     {
                         ApplyLicenseCode(lic.LicenseStream);
                     }
                     else
                     {
                         throw new Exception("Delegate ApplyLicenseCode of type CodeToApplyLicense is null");
                     }
                 }
             }
         }
     }
     catch (InvalidOperationException IoEx)
     {
         if (IoEx.Message.ToLowerInvariant().Contains("expired"))
         {
             if (ThrowExIfExpired)
             {
                 throw new Exception("The Aspose license has expired.", IoEx);
             }
         }
         else
         {
             throw new Exception("InvalidOperationException on applying Aspose license!", IoEx);
         }
     }
     catch (System.Exception ex)
     {
         throw new Exception("Generic Exception on applying Aspose license!", ex);
     }
 }
Exemplo n.º 5
0
        public static List <object> checkLicense()
        {
            List <object> li = new List <object>();

            try
            {
                Lic    lobj     = new Lic();
                string ss       = lobj.GetMACAddress().ToString();
                string app_path = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
                GV.licStatus = lobj.ApplicationStatus(@"R:\Dropbox\GitHub\ZSharpLicense\ReleasePackage\Lic\License.XML");
                GV.licMess   = lobj.getAppmessage();

                li.Add(GV.licStatus);
                li.Add(GV.licMess);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return(li);
        }
Exemplo n.º 6
0
        public void CreateLicenseFile(Lic dto, string fileName)
        {
            var ms = new MemoryStream();

            new XmlSerializer(typeof(Lic)).Serialize(ms, dto);
            // Create a new CspParameters object to specify
            // a key container.
            // Create a new RSA signing key and save it in the container.
            RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider();

            rsaKey.FromXmlString(PrivateKey);
            // Create a new XML document.
            XmlDocument xmlDoc = new XmlDocument();

            // Load an XML file into the XmlDocument object.
            xmlDoc.PreserveWhitespace = true;
            ms.Seek(0, SeekOrigin.Begin);
            xmlDoc.Load(ms);
            // Sign the XML document.
            SignXml(xmlDoc, rsaKey);
            // Save the document.
            xmlDoc.Save(fileName);
        }
Exemplo n.º 7
0
        private void Window_Activated(object sender, EventArgs e)
        {

            var n = new Lic(); ;
            this.licBox.Text = n.GetPay();
        }
Exemplo n.º 8
0
        string FormBlock(string f)
        {
            var ret = new StringBuilder("");
            var e   = qstr.ExtractExt(f);

            if (Data.C($"Lic {f}") == "")
            {
                Console.BackgroundColor = ConsoleColor.DarkMagenta;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("License block not yet known");
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.Gray;
                var mx = 0;
                for (int i = 0; Lic.ContainsKey(i); i++)
                {
                    mx = i;
                    Console.WriteLine($" {i + 1} = {Lic[i]}");
                }
                int keuze = -1;
                do
                {
                    Console.Write("Please make your choice: ");
                    keuze = qstr.ToInt(Console.ReadLine()) - 1;
                } while (!Lic.ContainsKey(keuze));
                Data.D($"Lic {f}", Lic[keuze]);
                Data.SaveSource(GINIFile);
            }
            if (qstr.Prefixed(Data.C($"Lic {f}").ToUpper(), "LIC/"))
            {
                Error("Invalid License Value -- Fixing!");
                Data.D($"Lic {f}", qstr.StripDir(Data.C($"Lic {f}"))); // Result of an early bug, but it haunts the rest of my debugging sessions!
            }

            var mlic  = Data.C($"Lic {f}");
            var cyear = Data.C($"IYEAR {f}");

            if (cyear == "" && Data.C($"CYEAR {f}") != "")
            {
                Console.Beep();
                Console.WriteLine($"Correcting database ===> {f}");
                Data.D($"IYEAR {f}", Data.C($"CYEAR"));
            }
            Ask($"IYEAR {f}", ThisYear, "Intial year of this project: ");
            if (cyear == "")
            {
                cyear = Data.C($"IYEAR {f}").Trim();
            }
            else if (!qstr.Suffixed(cyear, ThisYear))
            {
                Console.WriteLine($"{cyear} not suffixed as {ThisYear}, so adding that!   ({qstr.Right(cyear, ThisYear.Length)})");
                cyear += $", {ThisYear}";
                Data.D($"IYEAR {f}", cyear);
                Data.SaveSource(GINIFile);
            }

            foreach (string fld in License.Fields(mlic))
            {
                Ask($"Licfield - {f} - {mlic} - {fld}", License.Get(mlic).C($"DEFAULT[{fld}]"), fld + ": ");
            }

            var ldata = License.Get(mlic);
            var edata = Extension.Get(e);

            if (edata.C("START") == "" || edata.C("END") == "")
            {
                throw new Exception($"Language '{e}' has is not complete!");
            }
            ret.Append($"{edata.C("START")}\n");
            foreach (string licline in ldata.List("License"))
            {
                string tl = licline.Replace("<\\n>", "\n");
                tl = tl.Replace("[\\n]", "\n");
                tl = tl.Replace("[$thisfile]", f);
                tl = tl.Replace("<$thisfile>", f);
                tl = tl.Replace("[$years]", Data.C($"IYEAR {f}"));
                tl = tl.Replace("<$years>", Data.C($"IYEAR {f}"));
                tl = tl.Replace("[$version]", CrVersion);
                tl = tl.Replace("<$version>", CrVersion);
                foreach (string fld in License.Fields(Data.C($"Lic {f}")))
                {
                    tl = tl.Replace($"[{fld}]", Data.C($"Licfield - {f} - {mlic} - {fld}"));
                    tl = tl.Replace($"<{fld}>", Data.C($"Licfield - {f} - {mlic} - {fld}"));
                }
                if (edata.C("PREF") != "")
                {
                    tl = $"{edata.C("PREF")} {tl}";
                }
                ret.Append($"{tl}\n");
            }
            ret.Append($"{edata.C("END")}");
            return(ret.ToString());
        }