Exemple #1
0
        private static bool SaveSubmission(Indeed applied, bool successfulApply, SqlConnection con)
        {
            InsertApplyOps ops = new InsertApplyOps();

            ops.Jobkey                = applied.Jobkey ?? "";
            ops.Url                   = applied.Url ?? "";
            ops.Snippet               = applied.Snippet ?? "";
            ops.JobTitle              = applied.JobTitle ?? "";
            ops.Company               = applied.Company ?? "";
            ops.DateTimeApplied       = DateTime.Now;
            ops.Sponsored             = applied.Sponsored.ToString();
            ops.Expired               = applied.Expired.ToString();
            ops.IndeedApply           = applied.IndeedApply.ToString();
            ops.FormattedLocationFull = applied.FormattedLocationFull ?? "";
            ops.FormattedRelativeTime = applied.FormattedRelativeTime ?? "";
            ops.OnMouseDown           = applied.OnMouseDown ?? "";

            ops.Latitude          = applied.Latitude ?? "";
            ops.Longitude         = applied.Longitude ?? "";
            ops.City              = applied.City ?? "";
            ops.State             = applied.State ?? "";
            ops.Country           = applied.Country ?? "";
            ops.FormattedLocation = applied.FormattedLocation ?? "";
            ops.Source            = applied.Source ?? "";
            ops.Date              = applied.Date ?? "";

            try
            {
                IndeedSql.InsertApply(ops, successfulApply, con);
                return(true);
            }
            catch
            {
                Console.WriteLine("ERROR IN SAVING TO DB: MANUALLY INSERT NOW");
                return(false);
            }
        }
Exemple #2
0
        public static void InsertApply(InsertApplyOps options, bool successfulApply, SqlConnection con)
        {
            var success = -1;

            if (successfulApply)
            {
                success = 1;
            }
            else
            {
                success = 0;
            }

            string insert = "INSERT INTO ApplyIndeed (" +
                            "SuccessfulApply, " +
                            "Jobkey, " +
                            "Url, " +
                            "Snippet, " +
                            "JobTitle, " +
                            "Company, " +
                            "DateTimeApplied, " +
                            "Sponsored, " +
                            "Expired, " +
                            "IndeedApply," +
                            "FormattedLocationFull, " +
                            "FormattedRelativeTime," +
                            "OnMouseDown, " +
                            "Latitude, " +
                            "Longitude, " +
                            "City, " +
                            "State, " +
                            "Country, " +
                            "FormattedLocation, " +
                            "Source, " +
                            "Date) VALUES (";

            insert += success + ",";
            insert += "'" + options.Jobkey.Replace("'", "''") + "',";
            insert += "'" + options.Url.Replace("'", "''") + "',";
            insert += "'" + options.Snippet.Replace("'", "''") + "',";
            insert += "'" + options.JobTitle.Replace("'", "''") + "',";
            insert += "'" + options.Company.Replace("'", "''") + "',";
            insert += "'" + options.DateTimeApplied.ToString("s", System.Globalization.CultureInfo.InvariantCulture) + "',";
            insert += "'" + options.Sponsored.Replace("'", "''") + "',";
            insert += "'" + options.Expired.Replace("'", "''") + "',";
            insert += "'" + options.IndeedApply.Replace("'", "''") + "',";
            insert += "'" + options.FormattedLocationFull.Replace("'", "''") + "',";
            insert += "'" + options.FormattedRelativeTime.Replace("'", "''") + "',";
            insert += "'" + options.OnMouseDown.Replace("'", "''") + "',";
            insert += "'" + options.Latitude.Replace("'", "''") + "',";
            insert += "'" + options.Longitude.Replace("'", "''") + "',";
            insert += "'" + options.City.Replace("'", "''") + "',";
            insert += "'" + options.State.Replace("'", "''") + "',";
            insert += "'" + options.Country.Replace("'", "''") + "',";
            insert += "'" + options.FormattedLocation.Replace("'", "''") + "',";
            insert += "'" + options.Source.Replace("'", "''") + "',";
            insert += "'" + options.Date.Replace("'", "''") + "'";
            insert += ")";


            SqlCommand cmd = new SqlCommand()
            {
                CommandText = insert,
                CommandType = CommandType.Text,
                Connection  = con
            };

            con.Open();
            try { cmd.ExecuteNonQuery(); } catch { }
            con.Close();
        }