Exemplo n.º 1
0
        public static void Add(List <string> threadIDList)
        {
            try
            {
                DBProvider.SQLite sqliteProvider = new DBProvider.SQLite("core.db", GlobalVar.THREAD_DATA_CREATE_SQLITE);

                foreach (string i in threadIDList)
                {
                    sqliteProvider.ExecuteQuery("INSERT OR IGNORE INTO ThreadIDStored ( id ) VALUES ( " + i + " )");
                }

                sqliteProvider.Close( );
            }
            catch (SQLiteException ex)
            {
                Utility.WriteErrorLog("SQLiteException - " + ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(null, "오류", "죄송합니다, 데이터를 정의하지 못했습니다, SQLite 오류입니다.\n\n" + ex.Message + " (0x" + (ex.ErrorCode > 0 ? ex.ErrorCode : 0) + ")", NotifyBoxType.OK, NotifyBoxIcon.Error);
            }
            catch (IOException ex)
            {
                Utility.WriteErrorLog("IOException - " + ex.Message, Utility.LogSeverity.EXCEPTION);
            }
            catch (Exception ex)
            {
                Utility.WriteErrorLog(ex.Message, Utility.LogSeverity.EXCEPTION);
            }
        }
Exemplo n.º 2
0
        public static bool RemoveAll( )
        {
            try
            {
                DBProvider.SQLite sqliteProvider = new DBProvider.SQLite("core.db", GlobalVar.NOTIFY_ARTICLE_CREATE_SQLITE);

                sqliteProvider.ExecuteQuery("DELETE FROM ArticleNotification");

                sqliteProvider.Close( );

                return(true);
            }
            catch (System.Data.SQLite.SQLiteException ex)
            {
                Utility.WriteErrorLog("SQLiteException - " + ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(null, "오류", "죄송합니다, 데이터를 삭제하지 못했습니다, SQLite 오류가 발생했습니다.\n\n" + ex.Message + " (0x" + (ex.ErrorCode > 0 ? ex.ErrorCode : 0) + ")", NotifyBoxType.OK, NotifyBoxIcon.Error);

                return(false);
            }
            catch (Exception ex)
            {
                Utility.WriteErrorLog(ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(null, "오류", "죄송합니다, 데이터를 삭제하지 못했습니다, 알 수 없는 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);

                return(false);
            }
        }
Exemplo n.º 3
0
        public static void Save( )
        {
            Main mainForm = Utility.GetMainForm( );

            if (mainForm != null)
            {
                mainForm.MaskShow( );
            }

            try
            {
                DBProvider.SQLite sqliteProvider = new DBProvider.SQLite("core.db", GlobalVar.NOTIFY_ARTICLE_CREATE_SQLITE);

                sqliteProvider.ExecuteQuery("DELETE FROM ArticleNotification");

                foreach (NotifyData i in LISTS)
                {
                    sqliteProvider.ExecuteQuery(
                        string.Format("INSERT INTO ArticleNotification VALUES ( {0}, '{1}', '{2}', '{3}', '{4}', {5}, {6}, '{7}', '{8}', '{9}' )",
                                      i.threadID,
                                      i.threadTitle.Replace("'", "''"),
                                      i.threadAuthor,
                                      i.threadURL,
                                      i.threadTime,
                                      i.threadHit,
                                      i.focused == true ? 1 : 0,
                                      i.personaconURL,
                                      i.articleName,
                                      i.authorRank
                                      )
                        );


                    Application.DoEvents( );
                }

                sqliteProvider.Close( );
            }
            catch (System.Data.SQLite.SQLiteException ex)
            {
                Utility.WriteErrorLog("SQLiteException - " + ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(null, "오류", "죄송합니다, 데이터를 저장하지 못했습니다, SQLite 오류가 발생했습니다.\n\n" + ex.Message + " (0x" + (ex.ErrorCode > 0 ? ex.ErrorCode : 0) + ")", NotifyBoxType.OK, NotifyBoxIcon.Error);
            }
            catch (Exception ex)
            {
                Utility.WriteErrorLog(ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(null, "오류", "죄송합니다, 데이터를 저장하지 못했습니다, 알 수 없는 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
            }
            finally
            {
                if (mainForm != null)
                {
                    mainForm.MaskClose( );
                }
            }
        }
Exemplo n.º 4
0
        public static void Initialize(bool force = true)
        {
            try
            {
                if (!Directory.Exists(GlobalVar.DATA_DIR))
                {
                    Directory.CreateDirectory(GlobalVar.DATA_DIR);
                }

                Notify.Initialize( );

                if (force)                   // 데이터 파일이 없을 시
                {
                    NaverRequest.New("http://cafe.naver.com/ArticleList.nhn?search.clubid=" + GlobalVar.CAFE_ID + "&search.boardtype=L&userDisplay=15", NaverRequest.RequestMethod.GET, Encoding.Default, (value) =>
                    {
                        DBProvider.SQLite sqliteProvider = new DBProvider.SQLite("core.db", GlobalVar.THREAD_DATA_CREATE_SQLITE);

                        List <TableDataTable> dataTable = Parse.TotalArticlePageCrawling(value);

                        foreach (TableDataTable i in dataTable)
                        {
                            sqliteProvider.ExecuteQuery("INSERT OR IGNORE INTO ThreadIDStored ( id ) VALUES ( " + i.number + " )");
                        }

                        sqliteProvider.Close( );

                        TopProgressMessage.End( );
                    }, ( Exception ex ) =>
                    {
                        NotifyBox.Show(null, "오류", "죄송합니다, 데이터를 불러오지 못했습니다.\n\n" + ex.Message + " (0x" + (ex.HResult > 0 ? ex.HResult : 0) + ")", NotifyBoxType.OK, NotifyBoxIcon.Error);
                    });
                }
            }
            catch (SQLiteException ex)
            {
                Utility.WriteErrorLog("SQLiteException - " + ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(null, "오류", "죄송합니다, 데이터를 불러오지 못했습니다, SQLite 오류입니다.\n\n" + ex.Message + " (0x" + (ex.ErrorCode > 0 ? ex.ErrorCode : 0) + ")", NotifyBoxType.OK, NotifyBoxIcon.Error);
            }
            catch (IOException ex)
            {
                Utility.WriteErrorLog("IOException - " + ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(null, "오류", "죄송합니다, 데이터를 불러오지 못했습니다, 파일 접근 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
            }
            catch (Exception ex)
            {
                Utility.WriteErrorLog(ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(null, "오류", "죄송합니다, 데이터를 불러오지 못했습니다, 알 수 없는 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
            }
        }
Exemplo n.º 5
0
        public static string[] Get( )
        {
            try
            {
                DBProvider.SQLite sqliteProvider = new DBProvider.SQLite("core.db", GlobalVar.THREAD_DATA_CREATE_SQLITE);
                List <string>     array          = new List <string>( );

                sqliteProvider.ExecuteDataReader("SELECT * FROM ThreadIDStored", ( SQLiteDataReader reader ) =>                  // order by 추가바람
                {
                    array.Add(reader["id"].ToString( ));
                    return(true);
                });

                sqliteProvider.Close( );

                return(array.ToArray( ));
            }
            catch (SQLiteException ex)
            {
                Utility.WriteErrorLog("SQLiteException - " + ex.Message, Utility.LogSeverity.EXCEPTION);
                return(new string[] { });
            }
            catch (Exception ex)
            {
                Utility.WriteErrorLog(ex.Message, Utility.LogSeverity.EXCEPTION);
                return(new string[] { });
            }

            //JsonArrayCollection collection = ( JsonArrayCollection ) new JsonTextParser( ).Parse( File.ReadAllText( DATA_FILE_LOCATION ) );
            //string[ ] dataTable = new string[ collection.Count ];
            //int count = 0;

            //foreach ( JsonStringValue i in collection )
            //{
            //	dataTable[ count ] = i.Value;
            //	count++;
            //}

            //return dataTable;
            //}
            //catch { return new string[ ] { }; }
        }
Exemplo n.º 6
0
        public static void Initialize( )
        {
            try
            {
                DBProvider.SQLite sqliteProvider = new DBProvider.SQLite("core.db", GlobalVar.NOTIFY_ARTICLE_CREATE_SQLITE);

                sqliteProvider.ExecuteDataReader("SELECT * FROM ArticleNotification ORDER BY threadID DESC", (System.Data.SQLite.SQLiteDataReader reader) =>
                {
                    LISTS.Add(new NotifyData( )
                    {
                        threadID      = reader["threadID"].ToString( ),
                        threadTitle   = HttpUtility.HtmlDecode(reader["threadTitle"].ToString( )),
                        threadURL     = reader["threadURL"].ToString( ),
                        threadHit     = int.Parse(reader["threadHit"].ToString( )),
                        threadTime    = reader["threadTime"].ToString( ),
                        threadAuthor  = HttpUtility.HtmlDecode(reader["threadAuthor"].ToString( )),
                        personaconURL = reader["personaconURL"].ToString( ),
                        articleName   = reader["articleName"].ToString( ),
                        authorRank    = reader["authorRank"].ToString( ),
                        focused       = reader["focused"].ToString( ) == "1" ? true : false
                    });

                    //newNotifyData.threadID = reader[ "threadID" ].ToString( );
                    //newNotifyData.threadTitle = HttpUtility.HtmlDecode( reader[ "threadTitle" ].ToString( ) );
                    //newNotifyData.threadURL = reader[ "threadURL" ].ToString( );
                    //newNotifyData.threadHit = int.Parse( reader[ "threadHit" ].ToString( ) );

                    //newNotifyData.threadTime = reader[ "threadTime" ].ToString( );
                    //newNotifyData.threadAuthor = reader[ "threadAuthor" ].ToString( );
                    //newNotifyData.personaconURL = reader[ "personaconURL" ].ToString( );
                    //newNotifyData.articleName = reader[ "articleName" ].ToString( );
                    //newNotifyData.authorRank = reader[ "authorRank" ].ToString( );

                    //if ( reader[ "focused" ] != null )
                    //	newNotifyData.focused = reader[ "focused" ].ToString( ) == "1" ? true : false;
                    //else
                    //	newNotifyData.focused = false;

                    return(true);
                });

                sqliteProvider.Close( );
                RefreshMainNotifyPanel( );
                //foreach( JsonObjectCollection i in collection )
                //{
                //	NotifyData newNotifyData = new NotifyData( );
                //	newNotifyData.threadID = i[ "threadID" ].GetValue( ).ToString( );
                //	newNotifyData.threadTitle = HttpUtility.HtmlDecode( i[ "threadTitle" ].GetValue( ).ToString( ) );
                //	newNotifyData.threadURL = i[ "threadURL" ].GetValue( ).ToString( );
                //	newNotifyData.threadHit = int.Parse( i[ "threadHit" ].GetValue( ).ToString( ) );

                //	newNotifyData.threadTime = i[ "threadTime" ].GetValue( ).ToString( );
                //	newNotifyData.threadAuthor = i[ "threadAuthor" ].GetValue( ).ToString( );
                //	newNotifyData.personaconURL = i[ "personaconURL" ].GetValue( ).ToString( );
                //	newNotifyData.articleName = i[ "articleName" ].GetValue( ).ToString( );
                //	newNotifyData.authorRank = i[ "authorRank" ].GetValue( ).ToString( );

                //	if ( i[ "focused" ] != null )
                //		newNotifyData.focused = bool.Parse( i[ "focused" ].GetValue( ).ToString( ) );
                //	else
                //		newNotifyData.focused = false;

                //	LISTS.Add( newNotifyData );
                //}
            }
            catch (System.Data.SQLite.SQLiteException ex)
            {
                Utility.WriteErrorLog("SQLiteException - " + ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(null, "오류", "죄송합니다, 알림 데이터 파일을 불러올 수 없습니다, SQLite 오류가 발생했습니다.\n\n" + ex.Message + " (0x" + (ex.ErrorCode > 0 ? ex.ErrorCode : 0) + ")", NotifyBoxType.OK, NotifyBoxIcon.Error);
            }
            //catch ( FormatException ex )
            //{
            //	Utility.WriteErrorLog( "FormatException - " + ex.Message, Utility.LogSeverity.EXCEPTION );
            //	NotifyBox.Show( null, "오류", "죄송합니다, 알림 데이터 파일이 손상되어 불러올 수 없습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error );
            //}
            catch (Exception ex)
            {
                Utility.WriteErrorLog(ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(null, "오류", "죄송합니다, 알림 데이터 파일을 불러올 수 없습니다, 알 수 없는 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
            }
        }