private void DummyObjectRegister()
        {
            //To Remove the error could not create a complete dempendency map
            //if ((_arshuWebGrid == null) && (_isNull == true))
            //{
            //    _xmlDocument = new System.Xml.XmlDocument();
            //}

            //if ((_xmlDocument == null) && (_isNull == false))
            //{
            //    _isNull = true;
            //}

            //To force load Mono.Data.Sqlite dll
            SqliteFactory sqliteFactory = new SqliteFactory();

            if ((sqliteFactory == null) && (_isNull == false))
            {
                _isNull = true;
            }

            string            message      = "";
            string            errorMessage = "";
            DbProviderFactory dp           = DataCommon.GetDBProviderFactory(DataCommon.SQLiteProviderNameFactory, out message, out errorMessage);

            if ((dp == null) && (_isNull == false))
            {
                _isNull = true;
            }
        }
Esempio n. 2
0
        public void ToStatement_OneFilter_ShouldReturnExpectedSqlString()
        {
            var factory = new SqliteFactory();
            var @params = new List <IDataParameter>();

            var paramValue = factory.AddParam(1, @params);

            Assert.AreEqual("@p0", paramValue);
            Assert.AreEqual(1, @params.Count);
        }
Esempio n. 3
0
        public void Integer()
        {
            var factory = new SqliteFactory();
            var @params = new List <IDataParameter>();

            var paramValue = factory.AddParam(1, @params);

            Assert.AreEqual("@p0", paramValue);
            Assert.AreEqual(1, @params.Count);
            Assert.AreEqual(1, @params[0].Value);
        }
Esempio n. 4
0
        public void Guid()
        {
            var factory = new SqliteFactory();
            var @params = new List <IDataParameter>();

            var paramValue = factory.AddParam(new Guid("A383CDBF-4791-4B9F-9DD4-6286108388BE"), @params);

            Assert.AreEqual("@p0", paramValue);
            Assert.AreEqual(1, @params.Count);
            Assert.AreEqual("a383cdbf-4791-4b9f-9dd4-6286108388be", @params[0].Value);
        }
Esempio n. 5
0
        public Presenter(View view)
        {
            _view = view;
            _lichtpunktRepository = SqliteFactory.GetLichtpunktRepository();
            _lichtpunktRepository.Create();
            dataTable = _lichtpunktRepository.GetDataTable();

            _view.DataSource = dataTable;

            var lps = Enumerable.Range(0, 2).Select(i => new Lichtpunkt {
                Ort = "Ort" + i, Straße = "Straße" + i
            });

            foreach (var lp in lps)
            {
                _lichtpunktRepository.Add(lp);
            }
            _lichtpunktRepository.Update();

            InitEventListeners();
        }
Esempio n. 6
0
 public DbConfiguration(SqliteFactory provider)
 {
     Factory = provider;
 }
Esempio n. 7
0
 protected override ISqlDataStore CreateStore(string datasource)
 {
     return(SqliteFactory.CreateStore(datasource));
 }
 /// <summary>
 /// 初始化数据库连接
 /// </summary>
 /// <param name="dbFile"></param>
 public static void Open(string dbFile)
 {
     factory = new SqliteFactory();
     Context = new DbContext("main", "Data Source=" + dbFile, factory);
     Context.IsSupportInsertAfterSelectIdentity = false;
 }
Esempio n. 9
0
        public static void ImportData(string tempSqliteFile)
        {
            //打开SQLite数据库连接
            SqliteFactory factory = new SqliteFactory();
            DbContext     context = new DbContext("main", "Data Source=" + tempSqliteFile, factory);

            context.IsSupportInsertAfterSelectIdentity = false;

            string destFileDir = string.Empty;

            //ConnManager.Context.tran((t) =>
            //{
            try
            {
                //DbContext mysqlDBContext = t.db();
                DbContext mysqlDBContext = ConnManager.Context;

                //导入数据
                //Unit Person Project
                List <Unit>    unitList    = context.table("Unit").select("*").getList <Unit>(new Unit());
                List <Person>  personList  = context.table("Person").select("*").getList <Person>(new Person());
                List <Project> projectList = context.table("Project").select("*").getList <Project>(new Project());

                DataItem updateDataObj = null;

                //新旧ID字典
                Dictionary <string, string> unitIDDict    = new Dictionary <string, string>();
                Dictionary <string, string> personIDDict  = new Dictionary <string, string>();
                Dictionary <string, string> projectIDDict = new Dictionary <string, string>();
                string mainProjectID = string.Empty;

                #region 更新或插入单位和人员
                //更新或插入单位信息
                foreach (Unit u in unitList)
                {
                    string itemID = mysqlDBContext.table("d_unit").where ("name='" + u.UnitName + "'").select("id").getValue <string>(string.Empty);
                    if (string.IsNullOrEmpty(itemID))
                    {
                        string newID = Guid.NewGuid().ToString();
                        unitIDDict[u.ID] = newID;
                        u.ID             = newID;

                        //向MySql插入数据
                        updateDataObj = new DataItem();
                        updateDataObj.set("id", u.ID);
                        updateDataObj.set("name", u.UnitName);
                        updateDataObj.set("sealname", u.FlagName);
                        updateDataObj.set("nickname", u.NormalName);
                        updateDataObj.set("address", u.Address);
                        updateDataObj.set("linkman", u.ContactName);
                        updateDataObj.set("linknum", u.Telephone);
                        updateDataObj.set("secgrade", u.SecretQualification);
                        mysqlDBContext.table("d_unit").insert(updateDataObj);
                    }
                    else
                    {
                        string newID = itemID;
                        unitIDDict[u.ID] = newID;
                        u.ID             = newID;

                        if (MainForm.Instance.DiffFormObj.IsAcceptUpdate("单位信息", u.ID))
                        {
                            //向MySql插入数据
                            updateDataObj = new DataItem();
                            updateDataObj.set("id", u.ID);
                            updateDataObj.set("name", u.UnitName);
                            updateDataObj.set("sealname", u.FlagName);
                            updateDataObj.set("nickname", u.NormalName);
                            updateDataObj.set("address", u.Address);
                            updateDataObj.set("linkman", u.ContactName);
                            updateDataObj.set("linknum", u.Telephone);
                            updateDataObj.set("secgrade", u.SecretQualification);
                            mysqlDBContext.table("d_unit").where ("id='" + u.ID + "'").update(updateDataObj);
                        }
                    }
                }

                //更新或插入人员信息
                foreach (Person p in personList)
                {
                    //查找UnitID
                    if (unitIDDict.ContainsKey(p.UnitID))
                    {
                        p.UnitID = unitIDDict[p.UnitID];
                    }
                    else
                    {
                        continue;
                    }

                    string itemID = mysqlDBContext.table("d_person").where ("id='" + p.IDCard + "'").select("id").getValue <string>(string.Empty);
                    if (string.IsNullOrEmpty(itemID))
                    {
                        string newID = p.IDCard;
                        personIDDict[p.ID] = newID;
                        p.ID = newID;


                        //向MySql插入数据
                        updateDataObj = new DataItem();
                        updateDataObj.set("id", p.ID);
                        updateDataObj.set("name", p.Name);
                        updateDataObj.set("post", p.Job);
                        updateDataObj.set("specialty", p.Specialty);
                        updateDataObj.set("gender", p.Sex);
                        updateDataObj.set("birthday", p.Birthday);
                        updateDataObj.set("phone", p.Telephone);
                        updateDataObj.set("mobilephone", p.MobilePhone);
                        updateDataObj.set("address", p.Address);
                        updateDataObj.set("unitid", p.UnitID);
                        mysqlDBContext.table("d_person").insert(updateDataObj);
                    }
                    else
                    {
                        string newID = itemID;
                        personIDDict[p.ID] = newID;
                        p.ID = newID;

                        if (MainForm.Instance.DiffFormObj.IsAcceptUpdate("人员信息", p.ID))
                        {
                            //向MySql插入数据
                            updateDataObj = new DataItem();
                            updateDataObj.set("id", p.ID);
                            updateDataObj.set("name", p.Name);
                            updateDataObj.set("post", p.Job);
                            updateDataObj.set("specialty", p.Specialty);
                            updateDataObj.set("gender", p.Sex);
                            updateDataObj.set("birthday", p.Birthday);
                            updateDataObj.set("phone", p.Telephone);
                            updateDataObj.set("mobilephone", p.MobilePhone);
                            updateDataObj.set("address", p.Address);
                            updateDataObj.set("unitid", p.UnitID);
                            mysqlDBContext.table("d_person").where ("id='" + p.ID + "'").update(updateDataObj);
                        }
                    }
                }
                #endregion

                #region 更新或插入项目与课题信息
                //更新或插入项目信息
                foreach (Project proj in projectList)
                {
                    if (string.IsNullOrEmpty(proj.ParentID))
                    {
                        if (unitIDDict.ContainsKey(proj.UnitID))
                        {
                            proj.UnitID = unitIDDict[proj.UnitID];
                        }

                        string projectID = mysqlDBContext.table("d_xm").where ("id='" + proj.ID + "'").select("id").getValue <string>(string.Empty);
                        if (string.IsNullOrEmpty(projectID))
                        {
                            projectIDDict[proj.ID] = proj.ID;
                            destFileDir            = proj.ID;

                            //Update To MySql
                            updateDataObj = new DataItem();
                            updateDataObj.set("name", proj.Name);
                            updateDataObj.set("id", proj.ID);
                            updateDataObj.set("sec_grade", proj.SecretLevel);
                            updateDataObj.set("type", proj.Type);
                            updateDataObj.set("category", "重大项目");
                            updateDataObj.set("pid", proj.ParentID);
                            updateDataObj.set("unitid", proj.UnitID);
                            updateDataObj.set("time", proj.TotalTime);
                            updateDataObj.set("outlay", proj.TotalMoney);
                            updateDataObj.set("year", 0);
                            updateDataObj.set("keyword", proj.Keywords);
                            updateDataObj.set("dirname", destFileDir);
                            updateDataObj.set("importtime", DateTime.Now);

                            mysqlDBContext.table("d_xm").insert(updateDataObj);
                        }
                        else
                        {
                            projectIDDict[proj.ID] = projectID;
                            proj.ID     = projectID;
                            destFileDir = proj.ID;

                            //Update To MySql
                            updateDataObj = new DataItem();
                            updateDataObj.set("name", proj.Name);
                            updateDataObj.set("id", proj.ID);
                            updateDataObj.set("sec_grade", proj.SecretLevel);
                            updateDataObj.set("type", proj.Type);
                            updateDataObj.set("category", "重大项目");
                            updateDataObj.set("pid", proj.ParentID);
                            updateDataObj.set("unitid", proj.UnitID);
                            updateDataObj.set("time", proj.TotalTime);
                            updateDataObj.set("outlay", proj.TotalMoney);
                            updateDataObj.set("year", 0);
                            updateDataObj.set("keyword", proj.Keywords);
                            updateDataObj.set("dirname", destFileDir);
                            updateDataObj.set("importtime", DateTime.Now);

                            mysqlDBContext.table("d_xm").where ("id='" + proj.ID + "'").update(updateDataObj);
                        }

                        mainProjectID = proj.ID;
                        break;
                    }
                }

                //更新或插入课题信息
                foreach (Project proj in projectList)
                {
                    if (string.IsNullOrEmpty(proj.ParentID))
                    {
                        continue;
                    }

                    if (unitIDDict.ContainsKey(proj.UnitID))
                    {
                        proj.UnitID = unitIDDict[proj.UnitID];
                    }

                    if (projectIDDict.ContainsKey(proj.ParentID))
                    {
                        proj.ParentID = projectIDDict[proj.ParentID];
                    }

                    string projectID = mysqlDBContext.table("d_xm").where ("id='" + proj.ID + "'").select("id").getValue <string>(string.Empty);
                    if (string.IsNullOrEmpty(projectID))
                    {
                        projectIDDict[proj.ID] = proj.ID;


                        //Update To MySql
                        updateDataObj = new DataItem();
                        updateDataObj.set("name", proj.Name);
                        updateDataObj.set("id", proj.ID);
                        updateDataObj.set("sec_grade", proj.SecretLevel);
                        updateDataObj.set("type", proj.Type);
                        updateDataObj.set("category", "重大项目");
                        updateDataObj.set("pid", proj.ParentID);
                        updateDataObj.set("unitid", proj.UnitID);
                        updateDataObj.set("time", proj.TotalTime);
                        updateDataObj.set("outlay", proj.TotalMoney);
                        updateDataObj.set("year", 0);
                        updateDataObj.set("keyword", proj.Keywords);
                        updateDataObj.set("dirname", null);
                        updateDataObj.set("importtime", DateTime.Now);

                        mysqlDBContext.table("d_xm").insert(updateDataObj);
                    }
                    else
                    {
                        projectIDDict[proj.ID] = projectID;

                        proj.ID = projectID;


                        //Update To MySql
                        updateDataObj = new DataItem();
                        updateDataObj.set("name", proj.Name);
                        updateDataObj.set("id", proj.ID);
                        updateDataObj.set("sec_grade", proj.SecretLevel);
                        updateDataObj.set("type", proj.Type);
                        updateDataObj.set("category", "重大项目");
                        updateDataObj.set("pid", proj.ParentID);
                        updateDataObj.set("unitid", proj.UnitID);
                        updateDataObj.set("time", proj.TotalTime);
                        updateDataObj.set("outlay", proj.TotalMoney);
                        updateDataObj.set("year", 0);
                        updateDataObj.set("keyword", proj.Keywords);
                        updateDataObj.set("dirname", null);
                        updateDataObj.set("importtime", DateTime.Now);

                        mysqlDBContext.table("d_xm").where ("id='" + proj.ID + "'").update(updateDataObj);
                    }
                }
                #endregion

                #region 更新联系人-阶段-经费数据
                List <Task>           taskList           = context.table("Task").select("*").getList <Task>(new Task());
                List <Step>           stepList           = context.table("Step").select("*").getList <Step>(new Step());
                List <WhiteList>      whitelistList      = context.table("WhiteList").select("*").getList <WhiteList>(new WhiteList());
                List <ProjectAndStep> projectandstepList = context.table("ProjectAndStep").select("*").getList <ProjectAndStep>(new ProjectAndStep());
                List <MoneyAndYear>   moneyandyearList   = context.table("MoneyAndYear").select("*").getList <MoneyAndYear>(new MoneyAndYear());

                //新旧ID字典
                Dictionary <string, string> stepIdDicts = new Dictionary <string, string>();

                //更新任务表
                foreach (Task task in taskList)
                {
                    if (projectIDDict.ContainsKey(task.ProjectID))
                    {
                        task.ProjectID = projectIDDict[task.ProjectID];
                    }

                    if (personIDDict.ContainsKey(task.PersonID))
                    {
                        task.PersonID = personIDDict[task.PersonID];
                    }

                    string taskID = mysqlDBContext.table("r_job").where ("id='" + task.ID + "'").select("id").getValue <string>(string.Empty);
                    if (string.IsNullOrEmpty(taskID))
                    {
                        //Update To MySql
                        updateDataObj = new DataItem();
                        updateDataObj.set("id", task.ID);
                        updateDataObj.set("xmid", task.ProjectID);
                        updateDataObj.set("personid", task.PersonID);
                        updateDataObj.set("fengong", task.Content);
                        updateDataObj.set("time", task.TotalTime);
                        updateDataObj.set("post", task.Role);
                        mysqlDBContext.table("r_job").insert(updateDataObj);
                    }
                    else
                    {
                        //Update To MySql
                        updateDataObj = new DataItem();
                        updateDataObj.set("id", task.ID);
                        updateDataObj.set("xmid", task.ProjectID);
                        updateDataObj.set("personid", task.PersonID);
                        updateDataObj.set("fengong", task.Content);
                        updateDataObj.set("time", task.TotalTime);
                        updateDataObj.set("post", task.Role);
                        mysqlDBContext.table("r_job").where ("id='" + task.ID + "'").update(updateDataObj);
                    }
                }

                //更新候选单位表
                //foreach (WhiteList wl in whitelistList)
                //{
                //    if (projectIDDict.ContainsKey(wl.ProjectID))
                //    {
                //        wl.ProjectID = projectIDDict[wl.ProjectID];
                //    }

                //    if (unitIDDict.ContainsKey(wl.UnitID))
                //    {
                //        wl.UnitID = unitIDDict[wl.UnitID];
                //    }

                //    string wlID = ConnectionManager.Context.table("WhiteList").where("id='" + wl.ID + "'").select("id").getValue<string>(string.Empty);
                //    if (string.IsNullOrEmpty(wlID))
                //    {
                //        //Update To MySql
                //        updateDataObj = new DataItem();
                //        updateDataObj.set("", null);
                //        mysqlDBContext.table("d_person").insert(updateDataObj);

                //        wl.copyTo(ConnectionManager.Context.table("WhiteList")).insert();
                //    }
                //    else
                //    {
                //        //Update To MySql
                //        updateDataObj = new DataItem();
                //        updateDataObj.set("", null);
                //        mysqlDBContext.table("d_person").insert(updateDataObj);

                //        wl.copyTo(ConnectionManager.Context.table("WhiteList")).where("id='" + wl.ID + "'").update();
                //    }
                //}

                //更新阶段表
                foreach (Step step in stepList)
                {
                    if (projectIDDict.ContainsKey(step.ProjectID))
                    {
                        step.ProjectID = projectIDDict[step.ProjectID];
                    }

                    stepIdDicts[step.ID] = step.ID;

                    string wlID = mysqlDBContext.table("d_phase").where ("id='" + step.ID + "'").select("id").getValue <string>(string.Empty);
                    if (string.IsNullOrEmpty(wlID))
                    {
                        //Update To MySql
                        updateDataObj = new DataItem();
                        updateDataObj.set("id", step.ID);
                        updateDataObj.set("xmid", step.ProjectID);
                        updateDataObj.set("aim", step.StepDest);
                        updateDataObj.set("num", step.StepIndex);
                        updateDataObj.set("outlay", step.StepMoney);
                        updateDataObj.set("time", step.StepTime);

                        mysqlDBContext.table("d_phase").insert(updateDataObj);
                    }
                    else
                    {
                        //Update To MySql
                        updateDataObj = new DataItem();
                        updateDataObj.set("id", step.ID);
                        updateDataObj.set("xmid", step.ProjectID);
                        updateDataObj.set("aim", step.StepDest);
                        updateDataObj.set("num", step.StepIndex);
                        updateDataObj.set("outlay", step.StepMoney);
                        updateDataObj.set("time", step.StepTime);

                        mysqlDBContext.table("d_phase").where ("id='" + step.ID + "'").update(updateDataObj);
                    }
                }

                //更新工程阶段表
                foreach (ProjectAndStep pas in projectandstepList)
                {
                    if (stepIdDicts.ContainsKey(pas.StepID))
                    {
                        pas.StepID = stepIdDicts[pas.StepID];
                    }

                    string wlID = mysqlDBContext.table("r_xm_phase").where ("id='" + pas.ID + "'").select("id").getValue <string>(string.Empty);
                    if (string.IsNullOrEmpty(wlID))
                    {
                        //Update To MySql
                        updateDataObj = new DataItem();
                        updateDataObj.set("id", pas.ID);
                        updateDataObj.set("phaseid", pas.StepID);
                        updateDataObj.set("content", pas.StepContent);
                        updateDataObj.set("effect", pas.StepResult);
                        updateDataObj.set("mode", pas.Method);
                        updateDataObj.set("outlay", pas.Money);

                        mysqlDBContext.table("r_xm_phase").insert(updateDataObj);
                    }
                    else
                    {
                        //Update To MySql
                        updateDataObj = new DataItem();
                        updateDataObj.set("id", pas.ID);
                        updateDataObj.set("phaseid", pas.StepID);
                        updateDataObj.set("content", pas.StepContent);
                        updateDataObj.set("effect", pas.StepResult);
                        updateDataObj.set("mode", pas.Method);
                        updateDataObj.set("outlay", pas.Money);

                        mysqlDBContext.table("r_xm_phase").where ("id='" + pas.ID + "'").update(updateDataObj);
                    }
                }

                //更新经费表
                foreach (MoneyAndYear may in moneyandyearList)
                {
                    try
                    {
                        if (string.IsNullOrEmpty(may.Name) || may.Name.EndsWith("rm") || may.Name.EndsWith("zb"))
                        {
                            continue;
                        }

                        if (projectIDDict.ContainsKey(may.ProjectID))
                        {
                            may.ProjectID = projectIDDict[may.ProjectID];
                        }

                        string wlID = mysqlDBContext.table("d_outlay").where ("id='" + may.ID + "'").select("id").getValue <string>(string.Empty);
                        if (string.IsNullOrEmpty(wlID))
                        {
                            //Update To MySql
                            updateDataObj = new DataItem();
                            updateDataObj.set("id", may.ID);
                            updateDataObj.set("name", GetMoneyName(may.Name));
                            updateDataObj.set("content", string.IsNullOrEmpty(may.Value) ? 0 : double.Parse(may.Value));
                            updateDataObj.set("xmid", may.ProjectID);
                            updateDataObj.set("num", GetMoneyNum(may.Name));
                            updateDataObj.set("grade", GetMoneyStep(may.Name));

                            mysqlDBContext.table("d_outlay").insert(updateDataObj);
                        }
                        else
                        {
                            //Update To MySql
                            updateDataObj = new DataItem();
                            updateDataObj.set("id", may.ID);
                            updateDataObj.set("name", GetMoneyName(may.Name));
                            updateDataObj.set("content", string.IsNullOrEmpty(may.Value) ? 0 : double.Parse(may.Value));
                            updateDataObj.set("xmid", may.ProjectID);
                            updateDataObj.set("num", GetMoneyNum(may.Name));
                            updateDataObj.set("grade", GetMoneyStep(may.Name));

                            mysqlDBContext.table("d_outlay").where ("id='" + may.ID + "'").update(updateDataObj);
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine(ex.ToString());
                    }
                }

                #endregion

                #region  制所有的附件到本地目录
                string destDir = Path.Combine(MainForm.FileDir, destFileDir);
                try
                {
                    Directory.CreateDirectory(destDir);
                }
                catch (Exception ex) { }

                string   fileDir  = Path.Combine(new FileInfo(tempSqliteFile).DirectoryName, "Files");
                string[] filessss = Directory.GetFiles(fileDir);
                if (filessss != null)
                {
                    foreach (string f in filessss)
                    {
                        FileInfo fi = new FileInfo(f);

                        if (File.Exists(Path.Combine(destDir, fi.Name)))
                        {
                            //删除原来的文件
                            File.Delete(Path.Combine(destDir, fi.Name));
                        }

                        //复制文件到目标目录
                        File.Copy(f, Path.Combine(destDir, fi.Name));
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                //关闭数据库
                //factory.Dispose();
                factory = null;
                context = null;
            }
            //});
        }
Esempio n. 10
0
 public PlexDatabase(SqliteFactory provider)
 {
     Factory = provider;
 }