Beispiel #1
0
        private void buttonActivate_Click(object sender, EventArgs e)
        {
            string originalKey = null;

            try
            {
                string serialNum = txtSerialNumber.Text != null?txtSerialNumber.Text.Trim() : "";

                Guid serialNumber = new Guid(serialNum);
            }
            catch
            {
                MessageBox.Show("Invalid Serial Number");
                return;
            }

            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\EntitySpaces 2012", true);

            if (key != null)
            {
                originalKey = (string)key.GetValue("Profiler_Number");
                key.SetValue("Profiler_Number", txtSerialNumber.Text.Trim());
            }

            try
            {
                Licensing licensing = new Licensing();
                licensing.ReplaceMeLater("profiler", "2012.1.0000.0", "Profiler_Number", "Profiler_Number2", "Interop.ADODB64X.dll", proxySettings);

                MessageBox.Show("You must close the Profiler and restart it for the activation to take effect.");
            }
            catch (Exception)
            {
                MessageBox.Show("Unable to Validate License");

                if (originalKey != null && originalKey.Length > 0)
                {
                    key.SetValue("Profiler_Number", originalKey);
                }
            }
        }
Beispiel #2
0
        public ProfilerWindow()
        {
            InitializeComponent();

            InitSkinGallery();

            bool canRunOffline = false;
            int  result;

            if (!DesignMode)
            {
                proxySettings.Load();

#if !PROFILER_TRIAL
                RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\EntitySpaces 2012", true);

                Crypto crypto = new Crypto();

                string id           = licensing.getUniqueID("C");
                string serialNumber = ""; // b69e3783-9f56-47a7-82e0-6eee6d0779bf

                if (key != null)
                {
                    try
                    {
                        serialNumber = (string)key.GetValue("Profiler_Number");
                    }
                    catch { }
                }


                string offlinePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                offlinePath += @"\EntitySpaces\ES2012\Interop.ADODB64X.dll";

                // See if we have registered our license
                result = licensing.ValidateLicense("profiler", serialNumber, System.Environment.MachineName, id, version, proxySettings);

                switch (result)
                {
                case 0:

                    // Try Registering it ...
                    int newResult = licensing.RegisterLicense("profiler", serialNumber, System.Environment.MachineName, id, version, proxySettings);

                    if (newResult == 1)
                    {
                        licensing.CreateSerialNumber2Key(key, "Profiler_Number2", id, false);
                        result = 1;
                    }
                    else
                    {
                        result = 0;
                    }
                    break;

                case 1:

                    licensing.CreateSerialNumber2Key(key, "Profiler_Number2", id, false);
                    try
                    {
                        File.Delete(offlinePath);
                    }
                    catch { }

                    break;

                case -1:

                    bool     isOffLine   = false;
                    DateTime offLineDate = DateTime.MinValue;
                    if (licensing.ReadSerialNumber2Key(key, "Profiler_Number2", id, out isOffLine, out offLineDate))
                    {
                        if (isOffLine)
                        {
                            if (File.Exists(offlinePath))
                            {
                                DateTime fileDate = licensing.OpenOfflineFile(offlinePath);

                                if (DateTime.Now > offLineDate)
                                {
                                    TimeSpan ts = DateTime.Now.Subtract(offLineDate);
                                    if (ts.Days < licensing.DaysTheyCanRunOffline)
                                    {
                                        if (fileDate < DateTime.Now)
                                        {
                                            canRunOffline = true;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            licensing.CreateSerialNumber2Key(key, "Profiler_Number2", id, true);
                            licensing.CreateOfflineFile(offlinePath);
                            canRunOffline = true;
                        }
                    }
                    break;
                }
#else
                Licensing license = new Licensing();
                string    id      = license.getUniqueID("C");

                result = licensing.ValidateLicense("trial", "b69e3783-9f56-47a7-82e0-6eee6d0779bf", System.Environment.MachineName, id, version, proxySettings);

                if (1 != result)
                {
                    result = licensing.RegisterLicense("trial", "b69e3783-9f56-47a7-82e0-6eee6d0779bf", System.Environment.MachineName, id, version, proxySettings);
                }
#endif

                if (result == 1 || (canRunOffline && result == -1))
                {
                    // creates an instance of the IXDListener object using the given implementation
                    listener = XDListener.CreateListener(XDTransportMode.IOStream);
                    listener.MessageReceived += new XDListener.XDMessageHandler(OnMessageReceived);

                    listener.RegisterChannel(Channels.Channel_1);
                    listener.RegisterChannel(Channels.Channel_2);
                    listener.RegisterChannel(Channels.Channel_3);
                    listener.RegisterChannel(Channels.Channel_4);
                    listener.RegisterChannel(Channels.Channel_5);
                    listener.RegisterChannel(Channels.Channel_6);
                    listener.RegisterChannel(Channels.Channel_7);
                    listener.RegisterChannel(Channels.Channel_8);
                    listener.RegisterChannel(Channels.Channel_9);
                    listener.RegisterChannel(Channels.Channel_10);

                    navChannel1.Tag  = channel_1;
                    navChannel2.Tag  = channel_2;
                    navChannel3.Tag  = channel_3;
                    navChannel4.Tag  = channel_4;
                    navChannel5.Tag  = channel_5;
                    navChannel6.Tag  = channel_6;
                    navChannel7.Tag  = channel_7;
                    navChannel8.Tag  = channel_8;
                    navChannel9.Tag  = channel_9;
                    navChannel10.Tag = channel_10;

                    channel_1.NavBarItem  = navChannel1;
                    channel_2.NavBarItem  = navChannel2;
                    channel_3.NavBarItem  = navChannel3;
                    channel_4.NavBarItem  = navChannel4;
                    channel_5.NavBarItem  = navChannel5;
                    channel_6.NavBarItem  = navChannel6;
                    channel_7.NavBarItem  = navChannel7;
                    channel_8.NavBarItem  = navChannel8;
                    channel_9.NavBarItem  = navChannel9;
                    channel_10.NavBarItem = navChannel10;

                    currentChannel = channel_1;
                    this.Text      = "EntitySpaces Profiler - " + currentChannel.Name;
                    esTracePacketBindingSource.DataSource = currentChannel.ChannelData;

                    clock = new System.Threading.Timer(TimerCallback, null, 2000, 1500);

                    //define color of user customized token
                    lzbasetype.gFmtOpt.HighlightingElements[(int)TLzHighlightingElement.sfkUserCustomized].SetForegroundInRGB("#FF00FF");

                    foreach (var obj in lzbasetype.gFmtOpt.HighlightingElements)
                    {
                        if (obj.Foreground.ToString().ToLower() == "12632256")
                        {
                            obj.SetForegroundInRGB("#000000");
                        }
                    }
                    lzbasetype.gFmtOpt.AlignAliasInSelectList = false;
                }


                //this.gridView1.BestFitColumns();
            }
        }
Beispiel #3
0
        private void OnMessageReceived(object sender, XDMessageEventArgs e)
        {
#if PROFILER_TRIAL
            if (++mod % 1000 == 0)
            {
                Licensing license = new Licensing();
                string    id      = license.getUniqueID("C");

                int result = licensing.ValidateLicense("trial", "b69e3783-9f56-47a7-82e0-6eee6d0779bf", System.Environment.MachineName, id, version, proxySettings);

                if (1 != result)
                {
                    result = licensing.RegisterLicense("trial", "b69e3783-9f56-47a7-82e0-6eee6d0779bf", System.Environment.MachineName, id, version, proxySettings);
                }

                if (result != 1)
                {
                    listener.UnRegisterChannel(Channels.Channel_1);
                    listener.UnRegisterChannel(Channels.Channel_2);
                    listener.UnRegisterChannel(Channels.Channel_3);
                    listener.UnRegisterChannel(Channels.Channel_4);
                    listener.UnRegisterChannel(Channels.Channel_5);
                    listener.UnRegisterChannel(Channels.Channel_6);
                    listener.UnRegisterChannel(Channels.Channel_7);
                    listener.UnRegisterChannel(Channels.Channel_8);
                    listener.UnRegisterChannel(Channels.Channel_9);
                    listener.UnRegisterChannel(Channels.Channel_10);
                    return;
                }
            }
#endif

            try
            {
                esTracePacket entry = new esTracePacket();

                string[] fields = e.DataGram.Message.Split('±');

                if (fields[0].Length > 0)
                {
                    entry.TransactionId = Convert.ToInt32(fields[0]);
                }

                if (fields[1].Length > 0)
                {
                    entry.ObjectType = fields[1];
                }

                entry.CallStack       = fields[2];
                entry.ApplicationName = fields[3];
                entry.TraceChannel    = fields[4];
                entry.ThreadId        = Convert.ToInt32(fields[5]);
                entry.Sql             = fields[6];
                entry.Duration        = Convert.ToInt64(fields[7]);
                entry.Ticks           = Convert.ToInt64(fields[8]);
                entry.PacketOrder     = Convert.ToInt64(fields[9]);
                entry.Action          = fields[10];
                entry.Syntax          = fields[11];
                entry.Exception       = fields[12];

                if (fields[13].Length > 0)
                {
                    // Parse Parameters
                    string[] parameters = fields[13].Split('«');

                    esParameter param = null;
                    for (int i = 0; i < parameters.Length; i += 5)
                    {
                        if (param == null)
                        {
                            param = new esParameter();
                        }

                        param.Name      = parameters[i];
                        param.Direction = parameters[i + 1];
                        param.ParamType = parameters[i + 2];

                        if (parameters[i + 3] != "null")
                        {
                            param.BeforeValue = parameters[i + 3];
                        }

                        if (parameters[i + 4] != "null")
                        {
                            param.AfterValue = parameters[i + 4];
                        }

                        entry.SqlParameters.Add(param);
                        param = null;
                    }
                }

                switch (entry.TraceChannel)
                {
                case Channels.Channel_1: AddEntryToList(channel_1, entry); break;

                case Channels.Channel_2: AddEntryToList(channel_2, entry); break;

                case Channels.Channel_3: AddEntryToList(channel_3, entry); break;

                case Channels.Channel_4: AddEntryToList(channel_4, entry); break;

                case Channels.Channel_5: AddEntryToList(channel_5, entry); break;

                case Channels.Channel_6: AddEntryToList(channel_6, entry); break;

                case Channels.Channel_7: AddEntryToList(channel_7, entry); break;

                case Channels.Channel_8: AddEntryToList(channel_8, entry); break;

                case Channels.Channel_9: AddEntryToList(channel_9, entry); break;

                case Channels.Channel_10: AddEntryToList(channel_10, entry); break;
                }
            }
            catch { }
        }