Пример #1
0
        public void Install(SqlConfig config, User user)
        {
            Runtime.SqlConfig = config;

            DataOperator dop = new DataOperator(Runtime.SqlConfig);

            //创建数据库
            string db_path = Runtime.SqlConfig.DataBasePath.Replace("~", AppDomain.CurrentDomain.BaseDirectory);

            if (!Installer.HasInstall && File.Exists(db_path))
                File.Delete(db_path);

            dop.DataDriver.CreateDataBase(db_path, Runtime.SqlConfig.PassWord);

            //创建表:User
            dop.CreateTable<User>();
            dop.Insert(user);
            //创建表:Article
            dop.CreateTable<Article>();
            //创建表:Category
            dop.CreateTable<Category>();

            //保存数据库配置
            string sql_config_path = AppDomain.CurrentDomain.BaseDirectory + SystemCoreStrings.FILE_CORE_SQLCONFIG;
            Runtime.SqlConfig.Save(sql_config_path);

            //创建安装安全锁
            File.Create(AppDomain.CurrentDomain.BaseDirectory + SystemCoreStrings.FILE_CORE_INSTALL_LOCK);
        }
Пример #2
0
 static Runtime()
 {
     IsDevelopping = true;
     SiteInfo = new SiteInfo();
     SqlConfig = new SqlConfig();
     Plugins = new List<PluginInfo>();
 }
 public static IDataDriver Get(SqlConfig config, ISqlBuilder sqlBuilder)
 {
     switch (config.DataDriverType)
     {
         case DataDriverType.Sqlite:
             return new SqliteDriver(config, sqlBuilder);
     }
     return null;
 }
Пример #4
0
        static void Main(string[] args)
        {
            string excelPath = AppDomain.CurrentDomain.BaseDirectory + "abc.xlsx";
            var conn = ExcelHelper.CreateConnection("abc.xlsx", ExcelHelper.ExcelVerion.Excel2007);
            conn.Open();
            var dt = ExcelHelper.GetWorkBookName(conn);

            //for (int i = 0; i < dt.Rows.Count; i++)
            //{
            //    for(int j=0;j<dt.Columns.Count;j++)
            //    {
            //        Console.Write("  " + dt.Rows[i][j].ToString() + "  ");
            //    }
            //}

            int lines = 0;
            var ds = ExcelHelper.ExecuteDataSet(conn, "SELECT * FROM  [Sheet2$]", null);
            for (int main = 0; main < ds.Tables.Count;main++ )
            {
                for (int i = 0; i < ds.Tables[main].Rows.Count; i++)
                {
                    for (int j = 0; j < ds.Tables[main].Columns.Count; j++)
                    {
                        Console.Write("  " + ds.Tables[main].Rows[i][j].ToString() + "  ");
                    }
                    Console.WriteLine("test:"+ds.Tables[main].Rows[i][1].ToString());
                    YiFuPriceType data = new YiFuPriceType();
                    data.YiFuName = ds.Tables[main].Rows[i][0].ToString();
                    data.Price = ds.Tables[main].Rows[i][1].ToString();
                    SqlConfig config = new SqlConfig(DataDriverType.Sqlite, "UCC_", "", "~db.db");
                    DataOperator dop = new DataOperator(config);
                    //var tmp = dop.SelectSingle(data) as YiFuPriceType;
                    YiFuPriceType tmp = null;
                    if (tmp == null)
                    {
                        data.YiFuPriceID = dop.Count<YiFuPriceType>().ToString();
                        data.YiFuName = ds.Tables[main].Rows[i][0].ToString();
                        data.Cat = ds.Tables[main].Rows[i][2].ToString();
                        data.IsZheKou = int.Parse(ds.Tables[main].Rows[i][3].ToString());
                        data.Price = ds.Tables[main].Rows[i][1].ToString();
                        dop.Insert<YiFuPriceType>(data);
                        dop.Commit();
                    }

                    lines++;
                    Console.WriteLine();

                }
            }

            Console.WriteLine("lines:" + lines);
            Console.ReadKey();
        }
Пример #5
0
        public ActionResult Message(ContactMessage m)
        {
            SqlConfig config = new SqlConfig(DataDriverType.Sqlite, "SoftWare_", "", "~/App_Data/db.db");
            DataOperator dop = new DataOperator(config);

            try
            {
                m.CMID = DateTime.Now.ToString("yyyyMMdd") + dop.Count<ContactMessage>();
                dop.Insert(m);
                dop.Commit();
                ViewBag.Message = "操作成功!我们的业务员会及时的联系您!";
            }
            catch
            {
                ViewBag.Message = "操作失败!试试换种方式和我们联系吧!";
            }
            return View();
        }
Пример #6
0
        static UccRuntime()
        {
            string dataDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "/CleanerData/";
            if (!Directory.Exists(dataDir))
                Directory.CreateDirectory(dataDir);
            if (!File.Exists(dataDir + "db.db") && File.Exists(AppDomain.CurrentDomain.BaseDirectory + "db.db"))
                File.Copy(AppDomain.CurrentDomain.BaseDirectory + "db.db", dataDir + "db.db");

            SqlConfig = new SqlConfig(DataDriverType.Sqlite, "UCC_", "", dataDir + "db.db");
            Dop = new DataOperator(SqlConfig);
            string path = AppDomain.CurrentDomain.BaseDirectory + "store.json";
            if (!File.Exists(path))
            {
                StoreInfo = new StoreInfo();
                StoreInfo.Name = "美国UCC国际洗衣";
                StoreInfo.PhoneNo = "13761561263";
                StoreInfo.Address = "闵行区金平路19号近鹤庆路";
                File.WriteAllText(path, Roo.Data.DataConverter.RenderJson(Roo.Data.DataConverter.ObjectToJson(StoreInfo)), Encoding.Default);
            }
            else
            {
                StoreInfo = DataConverter.JsonToObject<StoreInfo>(File.ReadAllText(path, Encoding.Default));
            }
        }
Пример #7
0
 public SqliteDriver(SqlConfig sqlConfig, ISqlBuilder sqlBuilder)
 {
     this.SqlConfig = sqlConfig;
     this.SqlBuilder = sqlBuilder;
 }