コード例 #1
0
        public long GetBookmarkIDByUrl(string bookmarkUrl)
        {
            long result = -1;

            try
            {
                using (BookmarksDL _bookmarksDL = new BookmarksDL())
                {
                    Bookmark bkmrk = new Bookmark
                    {
                        Url = bookmarkUrl
                    };

                    DataTable dt = _bookmarksDL.GetChangeColumnList(bkmrk);
                    foreach (DataRow item in dt.Rows)
                    {
                        result = item["ID"].ToLong();
                    }
                }
            }
            catch (Exception ex)
            {
                result = -1;
                LightLogger.LogMethod(ex, "BookmarkManager", "GetBookmarkIDByUrl");
            }
            return(result);
        }
コード例 #2
0
        private List <Browser> GetBrowsers()
        {
            List <Browser> _browsers = new List <Browser>();

            try
            {
                string browserListKey = @"SOFTWARE\Clients\StartMenuInternet";
                using (var clients = Registry.LocalMachine.OpenSubKey(browserListKey))
                {
                    foreach (var client in clients.GetSubKeyNames())
                    {
                        using (var clientKey = clients.OpenSubKey(client))
                        {
                            string name = (string)clientKey.GetValue(string.Empty);
                            using (var commandKey = clientKey.OpenSubKey(@"shell\open\command"))
                            {
                                string exe = (string)commandKey.GetValue(string.Empty);
                                _browsers.Add(new Browser()
                                {
                                    Name = name, Path = exe
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "GetBrowsers");
                _browsers = new List <Browser>();
            }
            return(_browsers);
        }
コード例 #3
0
        public FrmBookmarkList()
        {
            try
            {
                bookMan   = new BookmarkManager();
                exportMan = new ExportManager();
                InitializeComponent();
                rdbtnCreationtime.Checked = true;
                rdbtnStartsWith.Checked   = true;
                IsDateFilteringChecked(false);
                grdVwBookmarks.ColumnHeaderTextList = "ID[i]-Name-Description-Url-Creation Time-Update Time-Table[i]-ChangeSetCount[i]";
                cmbxSearchType.SetItemSource("Name*Name-Url*Url-Description*Description", '-', '*');

                if (cmbxSearchType.Items.Count > 0)
                {
                    cmbxSearchType.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "Ctor");

                MessageUtil.Error("Bookmark List could not be opened.");
            }
        }
コード例 #4
0
        void DeleteObj()
        {
            try
            {
                if (grdBrowsers.SelectedRows.Count > 0)
                {
                    DialogResult dr = MessageUtil.Confirm("External Browser will be deleted. are you sure?");
                    if (dr == System.Windows.Forms.DialogResult.Yes)
                    {
                        int     browserId = grdBrowsers.SelectedRows[0].Cells["Id"].Value.ToInt();
                        Browser br        = new Browser {
                            Id = browserId
                        };
                        br.Delete();
                        UpdateForm();
                    }
                    return;
                }
                return;
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "DeleteObj");

                MessageUtil.Error("Object could not be deleted.");
            }
        }
コード例 #5
0
        public FrmRunWith(string url, bool isRegistered)
        {
            try
            {
                InitializeComponent();
                bookMan       = new BookmarkManager();
                _isRegistered = isRegistered;
                _url          = url;
                List <Browser> browsers = new List <Browser>();

                if (_isRegistered)
                {
                    browsers = GetBrowsers();
                }
                else
                {
                    browsers = bookMan.GetExternalBrowsers();
                }

                cmbxBrowsers.DataSource    = browsers;
                cmbxBrowsers.DisplayMember = "Name";
                cmbxBrowsers.ValueMember   = "Path";
                cmbxBrowsers.SelectedIndex = -1;
                cmbxBrowsers.Refresh();
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "Ctor");

                MessageUtil.Error("Run With Form could not be opened.");
            }
        }
コード例 #6
0
        private void LoadForm()
        {
            try
            {
                _isFormLoaded = false;
                if (_bookmarkId != -1)
                {
                    bookmark = bookMan.GetById(_bookmarkId);
                    if (bookmark != null)
                    {
                        txtName.Text        = bookmark.Name;
                        txtDescription.Text = bookmark.Description;
                        txtUrl.Text         = bookmark.Url;
                    }
                }
                _isFormLoaded = true;
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "FormLoad");

                MessageUtil.Error("Bookmark could not be loaded.");
            }
            finally
            {
                bookmark = new Bookmark();

                if (_bookmarkId != -1)
                {
                    bookmark.ID = _bookmarkId;
                }
            }
        }
コード例 #7
0
        private void BkmrkChanged(Bookmark bkmrk, bool isInsert)
        {
            try
            {
                if (isInsert)
                {
                    bookmarkList.Add(bkmrk);
                }
                else
                {
                    Bookmark bk = bookMan.GetById((int)bkmrk.ID);

                    for (int bookmarkCounter = 0; bookmarkCounter < bookmarkList.Count; bookmarkCounter++)
                    {
                        if (bookmarkList[bookmarkCounter].ID == bkmrk.ID)
                        {
                            bookmarkList[bookmarkCounter].Name        = bk.Name;
                            bookmarkList[bookmarkCounter].Description = bk.Description;
                            bookmarkList[bookmarkCounter].Url         = bk.Url;
                            bookmarkList[bookmarkCounter].UpdateTime  = bk.UpdateTime;
                        }
                    }
                }

                SetDataSourceOfGRid();
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "BkmrkChanged");
            }
        }
コード例 #8
0
        void UpdateForm()
        {
            try
            {
                RefreshSource();
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "UpdateForm");

                MessageUtil.Error("List could not be refreshed.");
            }
        }
コード例 #9
0
 private void Add()
 {
     try
     {
         FrmBookmark bkrmrk = new FrmBookmark();
         bkrmrk.BookmarkChanged += new FrmBookmark.BookmarkChange(this.BkmrkChanged);
         bkrmrk.ShowDialog();
     }
     catch (Exception ex)
     {
         LightLogger.LogMethod(ex, this.Name, "Add");
     }
 }
コード例 #10
0
 void IsStartToggleChanged(object sender, EventArgs e)
 {
     try
     {
         isStartToggle = (sender as RadioButton).Tag.ToInt();
     }
     catch (Exception ex)
     {
         isStartToggle = 0;
         LightLogger.LogMethod(ex, this.Name, "IsStartToggleChanged");
     }
     finally
     {
         Search();
     }
 }
コード例 #11
0
        public FrmBookmark(int bookmarkId)
        {
            try
            {
                InitializeComponent();
                bookmark    = new Bookmark();
                bookMan     = new BookmarkManager();
                _bookmarkId = bookmarkId;
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "FrmBookmark Ctor");

                MessageUtil.Error("Bookmark could not be opened.");
            }
        }
コード例 #12
0
        void Save()
        {
            try
            {
                if (browser.Name.Replace(" ", "").Length == 0)
                {
                    MessageUtil.Message("Browser name can not be empty.");
                    return;
                }

                if (browser.Path.Replace(" ", "").Length == 0)
                {
                    MessageUtil.Message("Browser path can not be empty.");
                    return;
                }

                if (_browserId == -1)
                {
                    browser.Insert();
                    if (ExternalBrowserChanged != null)
                    {
                        ExternalBrowserChanged();
                    }
                }
                else
                {
                    if (browser.ChangeSetCount > 1)
                    {
                        browser.Update();

                        if (ExternalBrowserChanged != null)
                        {
                            ExternalBrowserChanged();
                        }
                    }
                }
                this.Close();
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "Save");

                MessageUtil.Error("Browser could not be saved.");
            }
        }
コード例 #13
0
        public Bookmark GetById(int bookmarkId)
        {
            Bookmark bkmrk = null;

            try
            {
                using (BookmarksDL bkmrksDL = new BookmarksDL())
                {
                    bkmrk = bkmrksDL.GetObjectById <Bookmark>(bookmarkId);
                }
            }
            catch (Exception ex)
            {
                bkmrk = null;
                LightLogger.LogMethod(ex, "BookmarkManager", "GetById");
            }
            return(bkmrk);
        }
コード例 #14
0
        public List <Browser> GetExternalBrowsers()
        {
            List <Browser> _browsers = new List <Browser>();

            try
            {
                using (BookmarksDL bkmrksDL = new BookmarksDL())
                {
                    _browsers = bkmrksDL.GetTableAsList <Browser>();
                }
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, "BookmarkManager", "GetExternalBrowsers");
                _browsers = new List <Browser>();
            }
            return(_browsers);
        }
コード例 #15
0
 private void CreateShortCut(Environment.SpecialFolder flder, string filePath)
 {
     try
     {
         IWshRuntimeLibrary.IWshShortcut shortCut;
         WshShell ws = new WshShell();
         shortCut              = (IWshShortcut)ws.CreateShortcut(Environment.GetFolderPath(flder) + filePath);
         shortCut.TargetPath   = Application.ExecutablePath;
         shortCut.Description  = "This software has been made for managing all bookmarks in one program. Use for good days.\nMade By : Nusty\nPath : " + Application.ExecutablePath;
         shortCut.IconLocation = Application.StartupPath + @"\monitor.ico";
         shortCut.Save();
     }
     catch (Exception ex)
     {
         MessageUtil.Error("Shortcut could not be created.");
         LightLogger.LogMethod(ex, this.Name, "CreateShortCut");
     }
 }
コード例 #16
0
        private void FormLoad(object sender, EventArgs e)
        {
            try
            {
                using (BookmarksDL bookmrksDL = new BookmarksDL())
                {
                    bookmarkList = bookmrksDL.GetTableAsList <Bookmark>();

                    SetDataSourceOfGRid();
                }
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "FormLoad");

                MessageUtil.Error("Bookmark List could not be loaded.");
            }
        }
コード例 #17
0
 private void ExportToExcel()
 {
     try
     {
         DataTable dt2Export = new DataTable();
         using (BookmarksDL bkmrkDL = new BookmarksDL())
         {
             dt2Export = bkmrkDL.GetTable(new Bookmark {
             });
         }
         exportMan.Export2Excel(dt2Export, "Bookmarks", "D:/Bookmarks.xls");
     }
     catch (Exception ex)
     {
         LightLogger.LogMethod(ex, this.Name, "ExportToExcel");
         MessageUtil.Error("Export Operation failed");
     }
 }
コード例 #18
0
        private void UpdateObj()
        {
            try
            {
                if (grdVwBookmarks.SelectedRows.Count > 0)
                {
                    int         bkmrkId = grdVwBookmarks.SelectedRows[0].Cells["ID"].Value.ToInt();
                    FrmBookmark bkrmrk  = new FrmBookmark(bkmrkId);
                    bkrmrk.BookmarkChanged += new FrmBookmark.BookmarkChange(this.BkmrkChanged);
                    bkrmrk.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "Update");

                MessageUtil.Error("Object could not be updated");
            }
        }
コード例 #19
0
        private void ExportToExcelSearch()
        {
            try
            {
                DataTable dt2Export = new DataTable();
                int       rowCount  = grdVwBookmarks.Rows.Count;
                if (rowCount > 0)
                {
                    int colCount = grdVwBookmarks.ColumnCount;
                    for (int colCounter = 0; colCounter < colCount; colCounter++)
                    {
                        if (object.ReferenceEquals(typeof(Bookmark).GetProperty(grdVwBookmarks.Columns[colCounter].Name).PropertyType, typeof(DateTime)) == false &&
                            grdVwBookmarks.Columns[colCounter].Visible == true)
                        {
                            dt2Export.Columns.Add(grdVwBookmarks.Columns[colCounter].Name, typeof(string));
                        }
                    }
                    colCount = dt2Export.Columns.Count;
                    DataRow row;
                    for (int rowCounter = 0; rowCounter < rowCount; rowCounter++)
                    {
                        row = null;
                        row = dt2Export.NewRow();

                        for (int colcounter = 0; colcounter < colCount; colcounter++)
                        {
                            row[dt2Export.Columns[colcounter].ColumnName] = grdVwBookmarks.Rows[rowCounter].Cells[dt2Export.Columns[colcounter].ColumnName].Value.ToStr();
                        }

                        dt2Export.Rows.Add(row);
                    }
                }

                exportMan.Export2Excel(dt2Export, "Bookmarks", "D:/Bookmarks.xls");
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "ExportToExcel");
                MessageUtil.Error("Export Operation failed");
            }
        }
コード例 #20
0
 private void grdVwBookmarks_SelectionChanged(object sender, EventArgs e)
 {
     try
     {
         txtDetails.Text = string.Empty;
         if (grdVwBookmarks.SelectedRows.Count > 0)
         {
             StringBuilder strBuilder = new StringBuilder();
             strBuilder.AppendLine(string.Format("{0} : {1}", "İsim", grdVwBookmarks.SelectedRows[0].Cells["Name"].Value.ToStr()));
             strBuilder.AppendLine("-------------------");
             strBuilder.AppendLine(string.Format("{0} : {1}", "Açıklama", grdVwBookmarks.SelectedRows[0].Cells["Description"].Value.ToStr()));
             strBuilder.AppendLine("-------------------");
             strBuilder.AppendLine(string.Format("{0} : {1}", "Adres", grdVwBookmarks.SelectedRows[0].Cells["Url"].Value.ToStr()));
             txtDetails.Text = strBuilder.ToString();
         }
     }
     catch (Exception ex)
     {
         LightLogger.LogMethod(ex, this.Name, "grdVwBookmarks_SelectionChanged");
     }
 }
コード例 #21
0
        public void RunWithForm(bool isRegistered)
        {
            try
            {
                string url = string.Empty;
                if (grdVwBookmarks.SelectedRows.Count > 0)
                {
                    url = grdVwBookmarks.SelectedRows[0].Cells["Url"].Value.ToStr();
                }
                if (url.IsNullOrSpace() == false)
                {
                    FrmRunWith frw = new FrmRunWith(url, isRegistered);
                    frw.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "RunWithForm");

                MessageUtil.Error("Object could not be runned.");
            }
        }
コード例 #22
0
        void FormLoad()
        {
            try
            {
                isFormLoaded = false;
                if (_browserId != -1)
                {
                    if (dtBrowserList != null)
                    {
                        for (int rowCounter = 0; rowCounter < dtBrowserList.Rows.Count; rowCounter++)
                        {
                            if (dtBrowserList.Rows[rowCounter]["Id"].ToInt() == _browserId)
                            {
                                txtName.Text = dtBrowserList.Rows[rowCounter]["Name"].ToStr();
                                txtPath.Text = dtBrowserList.Rows[rowCounter]["Path"].ToStr();
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "FormLoad");

                MessageUtil.Error("Browser List could not be loaded.");
            }
            finally
            {
                isFormLoaded = true;

                browser = new Browser();
                if (_browserId != -1)
                {
                    browser.Id = _browserId;
                }
            }
        }
コード例 #23
0
        private void RunWith()
        {
            try
            {
                if (_url.IsNullOrSpace())
                {
                    MessageUtil.Message("Url can not be null!..");
                    return;
                }
                if (cmbxBrowsers.SelectedIndex == -1)
                {
                    MessageUtil.Message("Select Browser!..");
                    return;
                }
                if (cmbxBrowsers.SelectedValue == null)
                {
                    MessageUtil.Message("Select Browser!..");
                    return;
                }

                using (Process p = new Process())
                {
                    p.StartInfo.UseShellExecute = true;
                    p.StartInfo.FileName        = cmbxBrowsers.SelectedValue.ToString();
                    p.StartInfo.Arguments       = "\"" + _url + "\"";
                    p.Start();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, MethodBase.GetCurrentMethod().Name); // "RunWith"

                MessageUtil.Error("Object could not be runned.");
            }
        }
コード例 #24
0
        private void Delete()
        {
            try
            {
                if (grdVwBookmarks.SelectedRows.Count > 0)
                {
                    if (MessageUtil.Confirm("Bookmark will be deleted. Are you sure?") == System.Windows.Forms.DialogResult.Yes)
                    {
                        int      bkmrkId = grdVwBookmarks.SelectedRows[0].Cells["ID"].Value.ToInt();
                        Bookmark bkmrk   = null;
                        for (int bookmarkCounter = 0; bookmarkCounter < bookmarkList.Count; bookmarkCounter++)
                        {
                            if (bkmrkId == bookmarkList[bookmarkCounter].ID)
                            {
                                bkmrk = bookmarkList[bookmarkCounter];
                                break;
                            }
                        }

                        if (bkmrk != null)
                        {
                            bkmrk.Delete();
                            bookmarkList.Remove(bkmrk);
                            SetDataSourceOfGRid();
                            MessageUtil.Message("Bookmark deleted successfully.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "Delete");

                MessageUtil.Error("Object could not be deleted.");
            }
        }
コード例 #25
0
        private void Save()
        {
            try
            {
                if (txtUrl.Text.IsNullOrSpace())
                {
                    MessageUtil.Warn("Url can not be empty.");
                    return;
                }

                if (txtName.Text.IsNullOrSpace())
                {
                    MessageUtil.Warn("Name can not be empty.");
                    return;
                }
                long id = bookMan.GetBookmarkIDByName(bookmark.Name);
                if (id != -1 && id != _bookmarkId)
                {
                    MessageUtil.Warn("Bookmark is exist with given name.");
                    return;
                }

                id = bookMan.GetBookmarkIDByUrl(bookmark.Url);
                if (id != -1 && id != _bookmarkId)
                {
                    MessageUtil.Warn("Bookmark is exist with given Url.");
                    return;
                }

                if (_bookmarkId == -1)
                {
                    bookmark.CreationTime = DateTime.Now;
                    bookmark.ID           = bookmark.InsertAndGetId();
                    if (BookmarkChanged != null)
                    {
                        BookmarkChanged(bookmark, true);
                    }

                    txtName.ResetText();
                    txtDescription.ResetText();
                    txtUrl.ResetText();

                    bookmark = new Bookmark();
                }
                else
                {
                    if (bookmark.ChangeSetCount > 1)
                    {
                        bookmark.UpdateTime = DateTime.Now;
                        bookmark.Update();
                        isUpdated = true;
                        if (BookmarkChanged != null)
                        {
                            BookmarkChanged(bookmark, false);
                        }

                        btnSave.Enabled = false;
                        btnCancel.Text  = "Close";
                    }
                }
                MessageUtil.Message("Boomark Saved.");
            }
            catch (Exception ex)
            {
                LightLogger.LogMethod(ex, this.Name, "Save");
            }
        }
コード例 #26
0
        private void Search(string strSearch, string searchColumn,
                            bool isDateFiltering, int isCreationTime, int dateFilterSelection)
        {
            try
            {
                List <Bookmark> searchList = new List <Bookmark>();
                searchList = bookmarkList;
                if (searchList != null)
                {
                    try
                    {
                        if (strSearch.IsNullOrSpace() == false)
                        {
                            switch (searchColumn)
                            {
                            case "Name":
                                searchList = searchList.AsQueryable <Bookmark>().Where <Bookmark>(b => b.Name.Contains(strSearch)).ToList <Bookmark>();
                                break;

                            case "Description":
                                searchList = searchList.AsQueryable <Bookmark>().Where <Bookmark>(b => b.Description.Contains(strSearch)).ToList <Bookmark>();
                                break;

                            case "Url":
                                searchList = searchList.AsQueryable <Bookmark>().Where <Bookmark>(b => b.Url.Contains(strSearch)).ToList <Bookmark>();
                                break;

                            default:
                                break;
                            }
                        }

                        if (isDateFiltering)
                        {
                            DateTime dtStart = new DateTime(dtpStartDate.Value.Year,
                                                            dtpStartDate.Value.Month,
                                                            dtpStartDate.Value.Day,
                                                            dtpStartTime.Value.Hour,
                                                            dtpStartTime.Value.Minute,
                                                            dtpStartTime.Value.Second);

                            DateTime dtEnd = new DateTime(dtpEndDate.Value.Year,
                                                          dtpEndDate.Value.Month,
                                                          dtpEndDate.Value.Day,
                                                          dtpEndTime.Value.Hour,
                                                          dtpEndTime.Value.Minute,
                                                          dtpEndTime.Value.Second);

                            switch (isCreationTime)
                            {
                            case 1:
                                switch (dateFilterSelection)
                                {
                                case 1:
                                    searchList = searchList.AsQueryable <Bookmark>().Where <Bookmark>(b => b.CreationTime >= dtStart).ToList <Bookmark>();
                                    break;

                                case 2:
                                    searchList = searchList.AsQueryable <Bookmark>().Where <Bookmark>(b => b.CreationTime >= dtStart && b.CreationTime <= dtEnd).ToList <Bookmark>();
                                    break;

                                case 3:
                                    searchList = searchList.AsQueryable <Bookmark>().Where <Bookmark>(b => b.CreationTime <= dtEnd).ToList <Bookmark>();
                                    break;

                                default:
                                    break;
                                }
                                break;

                            case 2:
                                switch (dateFilterSelection)
                                {
                                case 1:
                                    searchList = searchList.AsQueryable <Bookmark>().Where <Bookmark>(b => b.UpdateTime >= dtStart).ToList <Bookmark>();
                                    break;

                                case 2:
                                    searchList = searchList.AsQueryable <Bookmark>().Where <Bookmark>(b => b.UpdateTime >= dtStart && b.UpdateTime <= dtEnd).ToList <Bookmark>();
                                    break;

                                case 3:
                                    searchList = searchList.AsQueryable <Bookmark>().Where <Bookmark>(b => b.UpdateTime <= dtEnd).ToList <Bookmark>();
                                    break;

                                default:
                                    break;
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    catch (Exception exInner)
                    {
                        searchList = new List <Bookmark>();
                        LightLogger.LogMethod(exInner, this.Name, "Search_Inner");
                    }
                }

                SetDataSourceOfGRid(searchList);
            }
            catch (Exception exOuter)
            {
                LightLogger.LogMethod(exOuter, this.Name, "Search_Outer");
            }
        }
コード例 #27
0
 /// <summary>
 /// Enable or disable logging
 /// </summary>
 /// <param name="logger"></param>
 /// <returns></returns>
 public static ILogger Enable(this ILogger logger, bool enable)
 {
     LightLogger.EnableLogging(enable);
     return(logger);
 }