Пример #1
0
        private async Task <LicenseSession> SaveSession(string requestBody)
        {
            var ipString = HttpContext.Connection.RemoteIpAddress.ToString();
            var clientIp =
                await _context.Ips.FirstOrDefaultAsync(ip => ip.Address.Equals(ipString, StringComparison.OrdinalIgnoreCase));

            if (clientIp == null)
            {
                clientIp = new IP {
                    Address = ipString
                };
                await _context.Ips.AddAsync(clientIp);

                await _context.SaveChangesAsync();
            }

            clientIp.RequestCount++;
            _context.Entry(clientIp).State = EntityState.Modified;

            var session = new LicenseSession {
                Address = clientIp, Date = DateTimeHelper.GetCurrentTime(), Query = requestBody
            };

            await _context.AddAsync(session);

            await _context.SaveChangesAsync();

            return(session);
        }
Пример #2
0
        private void tsmiSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (var session = App.CreateSession())
                {
                    if (session.IsValid == false)
                    {
                        LicenseSession.ShowLicenseDialog(session, this);
                        return;
                    }

                    using (new ProgressHelper(this, "Saving ..."))
                    {
                        _SvfDb.Save();
                    }

                    MessageBox.Show(this, @"Save Success!", Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, Text);
            }
        }
Пример #3
0
        public void Check_export_licence()
        {
            var file_path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\Bimcc.BimEngine.lic";

            LicenseInfo licenseInfo = new LicenseInfo();

            if (File.Exists(file_path))
            {
                string LicenseKey = LicenseSession.LoadLicenseKeyFromFile(file_path);

                licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine", LicenseKey);
            }
            else
            {
                licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine");
            }

            if (licenseInfo.IsActivated)
            {
                textBox_company.Enabled = false; textBox_data.Enabled = false;

                textBox_mail.Enabled = false; textbox_HardwareId.Enabled = false;

                textbox_HardwareId.BackColor = Color.MediumSpringGreen;
            }
        }
Пример #4
0
        private void Log_setting_Load(object sender, EventArgs e)
        {
            LicenseInfo licenseInfo = LicenseSession.GetLicenseInfo("BIMCC", "BIMCC.BIMEngine");

            textbox_HardwareId.Text = licenseInfo.HardwareId.ToString();

            Check_export_licence();
        }
Пример #5
0
        public static void Init()
        {
            var config = new Libs.License.Types.LicenseConfig();

            //config.DisableUsbkey = true;
            //config.IssuerKeyId = 123456;
            //config.DisableTrial = true;

            LicenseSession.Init(config);
        }
Пример #6
0
        private void button_export_Click(object sender, EventArgs e)
        {
            openFileDialog.Filter = "授权文件(*.lic)|*.lic|所有文件(*.*)|*.*";

            openFileDialog.FileName = "";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                if (openFileDialog.FileName != null)
                {
                    var path = Path.GetFullPath(openFileDialog.FileName);

                    string LicenseKey = LicenseSession.LoadLicenseKeyFromFile(path);

                    File.WriteAllText(@"C:\Users\Administrator\Desktop\error.txt", LicenseKey);

                    LicenseInfo licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine", LicenseKey);

                    textBox1.Text  = "Bimcc.BimEngine.Revit";
                    textBox2.Text  = licenseInfo.ProductVersion.ToString();
                    textBox3.Text  = licenseInfo.ReleaseDate.ToString();
                    textBox4.Text  = licenseInfo.IsActivated.ToString();
                    textBox5.Text  = licenseInfo.LicenseMode.ToString();
                    textBox6.Text  = licenseInfo.LicenseStatus.ToString();
                    textBox7.Text  = licenseInfo.HardwareId.ToString();
                    textBox8.Text  = licenseInfo.ClientName.ToString();
                    textBox9.Text  = licenseInfo.LicenseExpiration.ToString();
                    textBox10.Text = licenseInfo.SubscriptionExpiration.ToString();

                    if (licenseInfo.IsActivated == false)
                    {
                        textBox4.BackColor  = Color.OrangeRed;
                        textBox5.BackColor  = Color.OrangeRed;
                        textBox6.BackColor  = Color.OrangeRed;
                        textBox3.BackColor  = Color.OrangeRed;
                        textBox9.BackColor  = Color.OrangeRed;
                        textBox10.BackColor = Color.OrangeRed;
                        button_ok.Enabled   = false;
                    }
                    else
                    {
                        button_ok.Enabled   = true;
                        textBox4.BackColor  = Color.MediumSpringGreen;
                        textBox5.BackColor  = Color.MediumSpringGreen;
                        textBox6.BackColor  = Color.MediumSpringGreen;
                        textBox3.BackColor  = Color.WhiteSmoke;
                        textBox9.BackColor  = Color.WhiteSmoke;
                        textBox10.BackColor = Color.WhiteSmoke;
                    }
                }
            }
        }
Пример #7
0
        private void License_Load(object sender, EventArgs e)
        {
            LicenseInfo licenseInfo = new LicenseInfo();

            if (Application.licenseKey.Length == 0)
            {
                Application.licenseKey = Tools.GetLicenseKey();
            }

            licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine", Application.licenseKey);

            Fresh_form(licenseInfo);
        }
Пример #8
0
        public static string GetLicenseKey()
        {
            var filename = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\Bimcc.BimEngine.lic";

            string LicenseKey = string.Empty;

            if (File.Exists(filename))
            {
                LicenseKey = LicenseSession.LoadLicenseKeyFromFile(filename);
            }

            return(LicenseKey);
        }
Пример #9
0
        private void label_platform_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            LicenseInfo licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine", Application.licenseKey);

            if (licenseInfo.IsActivated)
            {
                new Platform_check().ShowDialog();
            }
            else
            {
                Tools.ShowMessageBox("请先对轻量化插件授权");
            }
        }
Пример #10
0
        private void Plugin_manage_FormClosing(object sender, FormClosingEventArgs e)
        {
            Move_file();

            var licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine", Application.licenseKey);

            if (licenseInfo.IsActivated)
            {
                Setting.plugin.Text = "已授权";
            }
            else
            {
                Setting.plugin.Text = "未授权";
            }
        }
Пример #11
0
        private void License_Load(object sender, EventArgs e)
        {
            var filename = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\Bimcc.BimEngine.lic";

            string LicenseKey = string.Empty;

            LicenseInfo licenseInfo = new LicenseInfo();

            if (File.Exists(filename))
            {
                LicenseKey = LicenseSession.LoadLicenseKeyFromFile(filename);
            }

            licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine", LicenseKey);

            Fresh(licenseInfo);
        }
Пример #12
0
        private void button_export_Click(object sender, EventArgs e)
        {
            openFileDialog.Filter = "授权文件(*.lic)|*.lic|所有文件(*.*)|*.*";

            openFileDialog.FileName = "";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                var path_file = Path.GetFullPath(openFileDialog.FileName);

                string LicenseKey = LicenseSession.LoadLicenseKeyFromFile(path_file);

                LicenseInfo licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine", LicenseKey);

                Fresh(licenseInfo);
            }
        }
Пример #13
0
        public static void ShowDialog(IWin32Window parent)
        {
            var info = LicenseSession.GetLicenseInfo(CLIENT_ID, PRODUCT_NAME, LICENSE_KEY);

            LicenseSession.ShowLicenseDialog(CLIENT_ID, PRODUCT_NAME, parent);
        }
Пример #14
0
        public static void ShowDialog(LicenseSession session, IWin32Window parent)
        {
            var info = LicenseSession.GetLicenseInfo(CLIENT_ID, PRODUCT_NAME, LICENSE_KEY);

            LicenseSession.ShowLicenseDialog(session.ClientId, session.AppName, parent);
        }
Пример #15
0
 public static LicenseSession Create()
 {
     LicenseSession.Init();
     return(new LicenseSession(CLIENT_ID, PRODUCT_NAME, LICENSE_KEY));
 }
Пример #16
0
 public static void ShowLicenseDialog(IWin32Window parent = null)
 {
     LicenseSession.ShowLicenseDialog(CLIENT_ID, PRODUCT_NAME, parent);
 }
Пример #17
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            using (var session = App.CreateSession())
            {
                if (session.IsValid == false)
                {
                    LicenseSession.ShowLicenseDialog(session, this);
                    return;
                }

                using (new ProgressHelper(this, @"Generating Diff Model ..."))
                {
                    try
                    {
                        var sw = Stopwatch.StartNew();

                        #region setup materials

                        var matUnmodified = new Material
                        {
                            Color        = Vector3D.FromColor(0xffffff), //Darker: Vector3D.FromColor(0x101010)
                            Transparent  = 0.95,
                            Reflectivity = 0
                        };

                        var matAdd = new Material
                        {
                            Color = Vector3D.FromColor(Color.GreenYellow)
                        };

                        var matDelete = new Material
                        {
                            Color = Vector3D.FromColor(Color.Red)
                        };

                        var matModifiedBefore = new Material
                        {
                            Color       = Vector3D.FromColor(Color.Orange),
                            Transparent = 0.5
                        };

                        var matModifiedAfter = new Material
                        {
                            Color = Vector3D.FromColor(Color.Aqua),
                        };

                        #endregion

                        var baseModelPath = txtBaseModel.Text;
                        var incrModelPath = txtIncrementModel.Text;
                        var diffModelPath = txtDiffModel.Text;

                        var svfbase = baseModelPath.EndsWith(@"zip")
                            ? SvfDocument.LoadFromZipFile(baseModelPath)
                            : SvfDocument.LoadFromSvfFile(baseModelPath);

                        var svfincr = incrModelPath.EndsWith(@"zip")
                            ? SvfDocument.LoadFromZipFile(incrModelPath)
                            : SvfDocument.LoadFromSvfFile(incrModelPath);

                        var compareResult = CompareModel(svfbase, svfincr);

                        var svfdiff = new SvfDocument();
                        svfdiff.Model.Name = @"Diff Model";
                        svfdiff.Metadata   = svfbase.Metadata;

                        var nodeUnmodified = svfdiff.Model.Children.CreateNode();
                        nodeUnmodified.Name = @"Unmodified";

                        var nodeAdded = svfdiff.Model.Children.CreateNode();
                        nodeAdded.Name = @"Added";

                        var nodeDeleted = svfdiff.Model.Children.CreateNode();
                        nodeDeleted.Name = @"Deleted";

                        var nodeModifiedBefore = svfdiff.Model.Children.CreateNode();
                        nodeModifiedBefore.Name = @"Modified Before";

                        var nodeModifiedAfter = svfdiff.Model.Children.CreateNode();
                        nodeModifiedAfter.Name = @"Modified After";

                        svfbase.EnumerateNodes(node =>
                        {
                            if (node.Children?.Count == 0 &&
                                node.Fragments?.Count > 0 &&
                                string.IsNullOrEmpty(node.ExternalId) == false)
                            {
                                if (compareResult.Unmodified.Remove(node.ExternalId))
                                {
                                    ImportNodeWithPath(nodeUnmodified, node, svfbase.Model, matUnmodified);
                                }
                                else if (compareResult.Deleted.Remove(node.ExternalId))
                                {
                                    ImportNodeWithPath(nodeDeleted, node, svfbase.Model, matDelete);
                                }
                                else if (compareResult.Modified.Contains(node.ExternalId))
                                {
                                    var targetNode =
                                        ImportNodeWithPath(nodeModifiedBefore, node, svfbase.Model, matModifiedBefore);
                                    targetNode.ExternalId += @"_Before";
                                }
                            }
                        }, svfbase.Model);

                        svfincr.EnumerateNodes(node =>
                        {
                            if (node.Children?.Count == 0 &&
                                node.Fragments?.Count > 0 &&
                                string.IsNullOrEmpty(node.ExternalId) == false)
                            {
                                if (compareResult.Added.Remove(node.ExternalId))
                                {
                                    ImportNodeWithPath(nodeAdded, node, svfincr.Model, matAdd);
                                }
                                else if (compareResult.Modified.Remove(node.ExternalId))
                                {
                                    ImportNodeWithPath(nodeModifiedAfter, node, svfincr.Model, matModifiedAfter);
                                }
                            }
                        }, svfincr.Model);

                        svfdiff.SaveToFolder(diffModelPath, true);
                        svfdiff.Dispose();

                        svfbase.Dispose();
                        svfincr.Dispose();

                        ProgressHelper.Close();
                        var message = $@"Generate Diff Model Success! (duration: {sw.Elapsed})";
                        MessageBox.Show(this, message, Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception ex)
                    {
                        ProgressHelper.Close();
                        MessageBox.Show(this, ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
Пример #18
0
        public static void ShowDialog(IWin32Window parent)
        {
            var info = LicenseSession.GetLicenseInfo(CLIENT_ID, PRODUCT_NAME, GetLicenseKey());

            LicenseSession.ShowLicenseDialog(CLIENT_ID, PRODUCT_NAME, parent, DeployLicenseFileAction);
        }
Пример #19
0
 public static LicenseSession Create()
 {
     LicenseSession.Init();
     return(new LicenseSession(CLIENT_ID, PRODUCT_NAME, GetLicenseKey()));
 }
Пример #20
0
        public static LicenseSession CreateLicenseSession(string licenseKey = null)
        {
            LicenseSession.Init();

            return(new LicenseSession(CLIENT_ID, APP_NAME, licenseKey));
        }
Пример #21
0
 public static void ShowLicenseDialog(LicenseSession session, IWin32Window parent)
 {
     LicenseSession.ShowLicenseDialog(session.ClientId, session.AppName, parent);
 }
Пример #22
0
        private void btnMerge_Click(object sender, EventArgs e)
        {
            var models = new List <SvfModel>();

            foreach (SvfModel item in svfModelBindingSource)
            {
                if (item == null)
                {
                    continue;
                }
                models.Add(item);
            }
            if (models.Count < 1)
            {
                MessageBox.Show(this, @"The source model list is empty!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (string.IsNullOrEmpty(txtOutput.Text))
            {
                MessageBox.Show(this, @"Please Select Output Path!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            using (var session = App.CreateSession())
            {
                if (session.IsValid == false)
                {
                    LicenseSession.ShowLicenseDialog(session, this);
                    return;
                }

                using (new ProgressHelper(this, @"Merging ..."))
                {
                    try
                    {
                        var sw        = Stopwatch.StartNew();
                        var targetDoc = new SvfDocument();
                        var docs      = new List <SvfDocument>();
                        foreach (var model in models)
                        {
                            var doc = model.ModelPath.EndsWith(@"zip")
                                ? SvfDocument.LoadFromZipFile(model.ModelPath)
                                : SvfDocument.LoadFromSvfFile(model.ModelPath);
                            doc.Model.Name = model.ModelTitle;

                            targetDoc.Model.Children.ImportNode(doc.Model);

                            if (targetDoc.Metadata?.DefaultCamera == null)
                            {
                                targetDoc.Metadata = doc.Metadata.Clone();
                            }

                            doc.Reset();
                            docs.Add(doc);
                        }

                        targetDoc.SaveToFolder(txtOutput.Text, true);
                        targetDoc.Dispose();

                        foreach (var doc in docs)
                        {
                            doc.Dispose();
                        }
                        docs.Clear();

                        ProgressHelper.Close();
                        var message = $@"Merge Success! (duration: {sw.Elapsed})";
                        MessageBox.Show(this, message, Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception ex)
                    {
                        ProgressHelper.Close();
                        MessageBox.Show(this, ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
Пример #23
0
 public static void ShowLicenseDialog(IWin32Window parent)
 {
     LicenseSession.ShowLicenseDialog(CLIENT_ID, APP_NAME, parent);
 }
Пример #24
0
        private void License_Load(object sender, EventArgs e)
        {
            var filename = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\Bimcc.BimEngine.lic";

            if (File.Exists(filename))
            {
                LicenseKey = LicenseSession.LoadLicenseKeyFromFile(filename);

                File.WriteAllText(@"C:\Users\Administrator\Desktop\error.txt", LicenseKey);

                LicenseInfo licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine", LicenseKey);

                textBox1.Text  = "Bimcc.BimEngine.Revit";
                textBox2.Text  = licenseInfo.ProductVersion.ToString();
                textBox3.Text  = licenseInfo.ReleaseDate.ToString();
                textBox4.Text  = licenseInfo.IsActivated.ToString();
                textBox5.Text  = licenseInfo.LicenseMode.ToString();
                textBox6.Text  = licenseInfo.LicenseStatus.ToString();
                textBox7.Text  = licenseInfo.HardwareId.ToString();
                textBox8.Text  = licenseInfo.ClientName.ToString();
                textBox9.Text  = licenseInfo.LicenseExpiration.ToString();
                textBox10.Text = licenseInfo.SubscriptionExpiration.ToString();
                if (licenseInfo.IsActivated == false)
                {
                    textBox4.BackColor  = Color.OrangeRed;
                    textBox5.BackColor  = Color.OrangeRed;
                    textBox6.BackColor  = Color.OrangeRed;
                    textBox3.BackColor  = Color.OrangeRed;
                    textBox9.BackColor  = Color.OrangeRed;
                    textBox10.BackColor = Color.OrangeRed;
                    button_ok.Enabled   = false;
                }
                else
                {
                    button_ok.Enabled   = true;
                    textBox4.BackColor  = Color.MediumSpringGreen;
                    textBox5.BackColor  = Color.MediumSpringGreen;
                    textBox6.BackColor  = Color.MediumSpringGreen;
                    textBox3.BackColor  = Color.WhiteSmoke;
                    textBox9.BackColor  = Color.WhiteSmoke;
                    textBox10.BackColor = Color.WhiteSmoke;
                }
            }
            else
            {
                LicenseInfo licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine");

                textBox1.Text  = "Bimcc.BimEngine.Revit";
                textBox2.Text  = licenseInfo.ProductVersion.ToString();
                textBox3.Text  = licenseInfo.ReleaseDate.ToString();
                textBox4.Text  = licenseInfo.IsActivated.ToString();
                textBox5.Text  = licenseInfo.LicenseMode.ToString();
                textBox6.Text  = licenseInfo.LicenseStatus.ToString();
                textBox7.Text  = licenseInfo.HardwareId.ToString();
                textBox8.Text  = licenseInfo.ClientName.ToString();
                textBox9.Text  = licenseInfo.LicenseExpiration.ToString();
                textBox10.Text = licenseInfo.SubscriptionExpiration.ToString();
                if (licenseInfo.IsActivated == false)
                {
                    textBox4.BackColor  = Color.OrangeRed;
                    textBox5.BackColor  = Color.OrangeRed;
                    textBox6.BackColor  = Color.OrangeRed;
                    textBox3.BackColor  = Color.OrangeRed;
                    textBox9.BackColor  = Color.OrangeRed;
                    textBox10.BackColor = Color.OrangeRed;
                    button_ok.Enabled   = false;
                }
                else
                {
                    button_ok.Enabled   = true;
                    textBox4.BackColor  = Color.MediumSpringGreen;
                    textBox5.BackColor  = Color.MediumSpringGreen;
                    textBox6.BackColor  = Color.MediumSpringGreen;
                    textBox3.BackColor  = Color.WhiteSmoke;
                    textBox9.BackColor  = Color.WhiteSmoke;
                    textBox10.BackColor = Color.WhiteSmoke;
                }
            }
        }
Пример #25
0
 public LicenseInfo Check_export_licence()
 {
     return(LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine", Application.licenseKey));
 }
Пример #26
0
 public static void ShowLicenseDialog(IWin32Window parent = null)
 {
     LicenseSession.ShowLicenseDialog(GetClientId(), PRODUCT_NAME, parent);
 }