Пример #1
0
 private static void WriteCookie(object Obj, string ID, DateTime ExpirationDate, DateTime DefaultExpirationDate)
 {
     System.Web.HttpContext context = System.Web.HttpContext.Current;
     context.Response.Cookies[ID].Value = SerializationTools.SerializeObject(Obj);
     if (ExpirationDate == SqlConvert.ToDateTime(null))
     {
         ExpirationDate = DefaultExpirationDate;
     }
     context.Response.Cookies[ID].Expires = ExpirationDate;
 }
Пример #2
0
 private static void WriteCache(object Obj, string ID, DateTime ExpirationDate, DateTime DefaultExpirationDate)
 {
     if (ExpirationDate == SqlConvert.ToDateTime(null))
     {
         ExpirationDate = DefaultExpirationDate;
     }
     System.Web.HttpContext.Current.Cache.Add(ID, Obj, null, ExpirationDate,
                                              TimeSpan.Zero, CacheItemPriority.Default, null);
     System.Web.HttpContext.Current.Trace.Write("retrieved cache id from session...");
 }
Пример #3
0
 public static bool Compare(object objValue1, object objValue2, ComparisonOperators enuOperator, Type objInnerType)
 {
     if (objInnerType == typeof(Double))
     {
         return(Comparator.NumericComparison(SqlConvert.ToDouble(objValue1), SqlConvert.ToDouble(objValue2), enuOperator));
     }
     else if (objInnerType == typeof(DateTime))
     {
         return(Comparator.DateComparison(SqlConvert.ToDateTime(objValue1), SqlConvert.ToDateTime(objValue2), enuOperator));
     }
     else if (objInnerType == typeof(TimeSpan))
     {
         return(Comparator.TimeComparison((TimeSpan)objValue1, (TimeSpan)objValue2, enuOperator));
     }
     else
     {
         throw new ArgumentException("Unsupported Type for Comparison");
     }
 }
Пример #4
0
 /// <summary>
 /// Overload for the save method.
 /// Sends null as the expiration date.
 /// </summary>
 public static void Save(object Obj, string ID, CachePersistance Persistance)
 {
     Save(Obj, ID, Persistance, SqlConvert.ToDateTime(null));
 }
Пример #5
0
        private static void insert_table(DataTable tbl, OleDbCommand ocmd, int i)
        {
            #region Set Export Visible Properties
            try
            {
                foreach (DataColumn col in tbl.Columns)
                {
                    string strColName = col.ColumnName.ToLower();
                    if (strColName == "password" || strColName == "pass" || strColName == "exhibitorpassword" || strColName == "administratorpassword" || strColName == "customerpassword")
                    {
                        col.ExtendedProperties["export_visible"] = false;
                    }
                    if (strColName == "username" || strColName == "user" || strColName == "exhibitorusername" || strColName == "administratorusername" || strColName == "customerusername")
                    {
                        col.ExtendedProperties["export_visible"] = false;
                    }
                }
            }
            catch (Exception ex)
            {
                General.Debugging.Report.SendError("Error Setting ExportVisible property in DataTable", ex);
            }
            #endregion

            bool   visible;
            int    temp_max;
            string sql        = "";
            string field_list = "";
            //WRITE CREATE TABLE STATEMENT
            string tbl_name = tbl.TableName.Trim();
            if (tbl_name.ToLower() == "table")
            {
                tbl_name = "Page_" + i;
            }
            tbl_name = tbl_name.Replace(" ", "_");
            tbl_name = tbl_name.Replace(",", "");
            sql     += "CREATE TABLE " + tbl_name + " (";
            foreach (DataColumn col in tbl.Columns)
            {
                try
                {
                    visible = (bool)col.ExtendedProperties["export_visible"];
                }
                catch
                {
                    visible = true;
                }
                if (visible)
                {
                    switch (col.DataType.Name)
                    {
                    case "DateTime":
                        sql += "" + col.ColumnName + " " + "DATETIME" + ",";
                        break;

                    case "Boolean":
                        sql += "" + col.ColumnName + " " + "BIT" + ",";
                        break;

                    case "Decimal":
                    case "Double":
                    case "Single":
                    case "Int32":
                    case "UInt32":
                    case "Int64":
                    case "UInt64":
                    case "Int16":
                    case "UInt16":
                        sql += "" + col.ColumnName + " " + "NUMBER" + ",";
                        break;

                    case "Char":
                        sql += "" + col.ColumnName + " " + "VARCHAR(1)" + ",";
                        break;

                    case "Byte":
                    case "SByte":
                    case "String":
                        temp_max = get_max_length(tbl, col);
                        if (temp_max >= 256)
                        {
                            sql += "" + col.ColumnName + " " + "MEMO" + ",";
                        }
                        else if (temp_max == 1)
                        {
                            sql += "" + col.ColumnName + " " + "VARCHAR(1)" + ",";
                        }
                        else
                        {
                            sql += "" + col.ColumnName + " " + "VARCHAR(255)" + ",";
                        }
                        break;

                    default:
                        temp_max = get_max_length(tbl, col);
                        if (temp_max >= 256)
                        {
                            sql += "" + col.ColumnName + " " + "MEMO" + ",";
                        }
                        else if (temp_max == 1)
                        {
                            sql += "" + col.ColumnName + " " + "VARCHAR(1)" + ",";
                        }
                        else
                        {
                            sql += "" + col.ColumnName + " " + "VARCHAR(255)" + ",";
                        }
                        break;
                    }
                    field_list += col.ColumnName + ",";
                }
            }
            sql              = StringFunctions.Shave(sql, 1);
            field_list       = StringFunctions.Shave(field_list, 1);
            sql             += ")";
            ocmd.CommandText = sql;
            //System.Web.HttpContext.Current.Response.Write(sql + "<br><br>");
            ocmd.ExecuteNonQuery();
            sql = "";
            foreach (DataRow row in tbl.Rows)
            {
                sql += "INSERT INTO " + tbl_name + " (" + field_list + ") VALUES (";
                foreach (DataColumn col in tbl.Columns)
                {
                    try
                    {
                        visible = (bool)col.ExtendedProperties["export_visible"];
                    }
                    catch
                    {
                        visible = true;
                    }
                    if (visible)
                    {
                        //System.Web.HttpContext.Current.Response.Write(col.DataType.Name);
                        //System.Web.HttpContext.Current.Response.Flush();
                        switch (col.DataType.Name)
                        {
                        case "DateTime":
                            DateTime dt = SqlConvert.ToDateTime(row[col]);
                            if (dt.Year == 1900)
                            {
                                sql += "null" + ",";
                            }
                            else
                            {
                                sql += "'" + dt.ToString() + "'" + ",";
                            }
                            break;

                        case "Boolean":
                            if (row[col] != DBNull.Value)
                            {
                                sql += "" + row[col].ToString() + "" + ",";
                            }
                            else
                            {
                                sql += "False" + ",";
                            }
                            break;

                        case "Decimal":
                        case "Double":
                        case "Single":
                        case "Int32":
                        case "UInt32":
                        case "Int64":
                        case "UInt64":
                        case "Int16":
                        case "UInt16":
                            sql += "" + SqlConvert.ToNumber(row[col]).ToString() + "" + ",";
                            break;

                        case "Byte":
                        case "SByte":
                        case "Char":
                        case "String":
                            sql += "\"" + SqlConvert.Parse(row[col].ToString().Replace("\"", "")) + "\"" + ",";
                            break;

                        default:
                            sql += "\"" + SqlConvert.Parse(row[col].ToString().Replace("\"", "")) + "\"" + ",";
                            break;
                        }
                    }
                }
                sql  = StringFunctions.Shave(sql, 1);
                sql += ")";
                ocmd.CommandText = sql;
                //System.Web.HttpContext.Current.Response.Write(sql + "<br><br>");
                //System.Web.HttpContext.Current.Response.Flush();
                ocmd.ExecuteNonQuery();
                sql = "";
            }
        }