Example #1
0
 public WDBSQLite(string Path, string UI, WDBTraceLog.TraceLog WDBTraceLogObj)
 {
     SQLFile = Path;
     WDBTraceLogObj.WriteToLog(ThreadName, ObjectName, GetCurrentMethod(), "Start Call: WDBSQLite()");
     this.TraceLogObj = WDBTraceLogObj;
     if (!File.Exists(Path))
     {
         TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "Start of Create SQLite DB. " + Path);
         if (UI.ToLower() == "client")
         {
             this.conn = CreateClientDB(Path);
         }
         else if (UI.ToLower() == "uploader")
         {
             this.conn = CreateUploadDB(Path);
         }
         TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "End of Create SQLite DB." + Path);
     }
     else
     {
         TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "SQLite data source=" + Path);
         conn = new SQLiteConnection("data source=" + Path);
         conn.Open();
     }
     TraceLogObj.WriteToLog(ThreadName, ObjectName, GetCurrentMethod(), "End Call: WDBSQLite()");
 }
Example #2
0
 public WDBSQLite(string Path, string UI, WDBTraceLog.TraceLog WDBTraceLogObj)
 {
     SQLFile = Path;
     WDBTraceLogObj.WriteToLog(ThreadName, ObjectName, GetCurrentMethod(), "Start Call: WDBSQLite()");
     this.TraceLogObj = WDBTraceLogObj;
     if (!File.Exists(Path))
     {
         TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "Start of Create SQLite DB. " + Path);
         if (UI.ToLower() == "client")
         {
             this.conn = CreateClientDB(Path);
         }
         else if (UI.ToLower() == "uploader")
         {
             this.conn = CreateUploadDB(Path);
         }
         TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "End of Create SQLite DB." + Path);
     }
     else
     {
         TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "SQLite data source=" + Path);
         conn = new SQLiteConnection("data source=" + Path);
         conn.Open();
     }
     TraceLogObj.WriteToLog(ThreadName, ObjectName, GetCurrentMethod(), "End Call: WDBSQLite()");
 }
Example #3
0
 public WDBCommon(WDBSQLite.WDBSQLite ArgWDBSQliteObj, WDBAPI.WDBAPI WDBAPIObj, WDBTraceLog.TraceLog WDBTraceLogObj)
 {
     WDBTraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "Start Call: WDBCommon()");
     this.WDBAPIObj = WDBAPIObj;
     TraceLogObj = WDBTraceLogObj;
     WDBSQLiteObj = ArgWDBSQliteObj;
     TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "Start Call: WDBCommon()");
 }
Example #4
0
 public WDBCommon(WDBSQLite.WDBSQLite ArgWDBSQliteObj, WDBAPI.WDBAPI WDBAPIObj, WDBTraceLog.TraceLog WDBTraceLogObj)
 {
     WDBTraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "Start Call: WDBCommon()");
     this.WDBAPIObj = WDBAPIObj;
     TraceLogObj    = WDBTraceLogObj;
     WDBSQLiteObj   = ArgWDBSQliteObj;
     TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "Start Call: WDBCommon()");
 }
Example #5
0
        private SQLiteConnection CreateDB(string DbFile)
        {
            TraceLogObj.WriteToLog(ThreadName, ObjectName, GetCurrentMethod(), "Start Call: CreateDB");
            try
            {
                SQLiteConnection.CreateFile(DbFile);
            }
            catch (Exception e)
            {
                string DbPath = Path.GetDirectoryName(DbFile);
                TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "Failed to Create SQLite DB: " + e.Message.ToString());
                Directory.CreateDirectory(DbPath);
                SQLiteConnection.CreateFile(DbFile);
            }
            Debug.Write("Created Database: " + DbFile);

            conn = new SQLiteConnection("data source=" + DbFile);
            conn.Open();
            TraceLogObj.WriteToLog(ThreadName, ObjectName, GetCurrentMethod(), "End Call: CreateDB");
            return(conn);
        }
Example #6
0
        public void initApi()
        {
            TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "Start Function Call: Init API.");
            WDBAPIObj.ApiCompiledPath = ApiCompiledPath;

            //Debug.WriteLine(_ThreadName);
            WDBSQLiteObj.ThreadName          = _ThreadName;
            WDBAPIObj.ThreadName             = _ThreadName;
            WDBAPIObj.ApiKey                 = ApiKey;
            WDBAPIObj.Username               = Username;
            WDBAPIObj.DefaultImportTitle     = DefaultImportTitle;
            WDBAPIObj.DefaultImportNotes     = DefaultImportNotes;
            WDBAPIObj.UseDefaultImportValues = UseDefaultImportValues;
            WDBAPIObj.LogPath                = LogPath;
            TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), "End Function Call: Init API.");
        }
Example #7
0
        public string ApiGetWaitingImports()
        {
            TraceLogObj.WriteToLog(ThreadName, ObjectName, GetCurrentMethod(), "Start Call: ApiGetWaitingImports");
            TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), ApiCompiledPath + "schedule.php  ---- Get Waiting");
            string response;

            //Console.WriteLine("Upload FIle: " + UploadFile);
            using (WebClient client = new WebClient())
            {
                NameValueCollection parameters = InitParameters();
                TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), parameters.Get("username"));
                TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), parameters.Get("apikey"));
                parameters.Add("func", "waiting");
                try
                {
                    var responseBytes = client.UploadValues(ApiCompiledPath + "schedule.php", "POST", parameters);
                    response = Encoding.ASCII.GetString(responseBytes);
                }catch (Exception e)
                {
                    response = "Error";
                    TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), e.Message);
                }
                TraceLogObj.WriteToLog(_ThreadName, ObjectName, GetCurrentMethod(), response);
            }
            TraceLogObj.WriteToLog(ThreadName, ObjectName, GetCurrentMethod(), "End Call: ApiGetWaitingImports");
            return(response);
        }