예제 #1
0
        private void UpdateProjectList()
        {
            if (Directory.Exists(DataDir) && File.Exists(Path.Combine(DataDir, "projectList.lst")))
            {
                string[] dirs = File.ReadAllLines(Path.Combine(DataDir, "projectList.lst"));
                dgvDetail.Rows.Clear();
                foreach (string destDir in dirs)
                {
                    string dbFile = Path.Combine(destDir, "static.db");
                    if (File.Exists(dbFile))
                    {
                        SQLiteConnManager.Open(dbFile);
                        List <object> cells = new List <object>();

                        try
                        {
                            Project proj                = SQLiteConnManager.Context.table("Project").where ("ParentID is null or ParentID = ''").select("*").getItem <Project>(new Project());
                            Unit    unitObj             = SQLiteConnManager.Context.table("Unit").where ("ID = '" + proj.UnitID + "'").select("*").getItem <Unit>(new Unit());
                            Task    taskObj             = SQLiteConnManager.Context.table("Task").where ("Type='" + "项目" + "' and Role = '" + "负责人" + "' and ProjectId = '" + proj.ID + "'").select("*").getItem <Task>(new Task());
                            Person  projectMasterPerson = SQLiteConnManager.Context.table("Person").where ("ID = '" + taskObj.PersonID + "'").select("*").getItem <Person>(new Person());

                            cells.Add(proj.Name);
                            cells.Add(unitObj.UnitName);
                            cells.Add(unitObj.Address);
                            cells.Add(unitObj.ContactName);
                            cells.Add(unitObj.Telephone);
                            cells.Add(projectMasterPerson.Name);
                            cells.Add(projectMasterPerson.Telephone);
                            cells.Add(proj.TotalTime);
                            cells.Add(proj.TotalMoney);
                            cells.Add("等待上传");

                            int rowIndex = dgvDetail.Rows.Add(cells.ToArray());
                            dgvDetail.Rows[rowIndex].Tag = destDir;
                        }
                        finally
                        {
                            SQLiteConnManager.Close();
                        }
                    }
                }
            }
        }
예제 #2
0
        protected void ShowDiffList()
        {
            if (Directory.Exists(MainForm.DataDir) && File.Exists(Path.Combine(MainForm.DataDir, "projectList.lst")))
            {
                string[] dirs = File.ReadAllLines(Path.Combine(MainForm.DataDir, "projectList.lst"));
                dgvDiff.Rows.Clear();
                foreach (string destDir in dirs)
                {
                    string dbFile = Path.Combine(destDir, "static.db");
                    if (File.Exists(dbFile))
                    {
                        SQLiteConnManager.Open(dbFile);
                        List <object> cells = new List <object>();

                        try
                        {
                            DataItem updateDataObj = null;
                            string   recordId      = string.Empty;

                            Project       mainProject = SQLiteConnManager.Context.table("Project").where ("ParentID is null or ParentID = ''").select("*").getItem <Project>(new Project());
                            List <Person> personList  = SQLiteConnManager.Context.table("Person").select("*").getList <Person>(new Person());
                            List <Unit>   unitList    = SQLiteConnManager.Context.table("Unit").select("*").getList <Unit>(new Unit());

                            //Unit
                            foreach (Unit u in unitList)
                            {
                                DataItem di = ConnManager.Context.table("d_unit").where ("name = '" + u.UnitName + "'").select("*").getDataItem();
                                if (di.count() >= 1)
                                {
                                    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);

                                    recordId = di.getString("id");

                                    updateDataObj.remove("id");
                                    di.remove("id");

                                    if (di.toJson().Equals(updateDataObj.toJson()))
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        cells.Clear();
                                        cells.Add(false);
                                        cells.Add(mainProject.Name);
                                        cells.Add("单位信息");
                                        cells.Add(di.toJson());
                                        cells.Add(updateDataObj.toJson());
                                        int rowIndex = dgvDiff.Rows.Add(cells.ToArray());
                                        dgvDiff.Rows[rowIndex].Tag = recordId;
                                    }
                                }
                            }

                            //Person
                            foreach (Person p in personList)
                            {
                                DataItem di = ConnManager.Context.table("d_person").where ("id = '" + p.IDCard + "'").select("*").getDataItem();
                                if (di.count() >= 1)
                                {
                                    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 != null ? new DateTime(p.Birthday.Value.Year, p.Birthday.Value.Month, p.Birthday.Value.Day, 0, 0, 0) : new DateTime(0, 0, 0, 0, 0, 0));
                                    updateDataObj.set("phone", p.Telephone);
                                    updateDataObj.set("mobilephone", p.MobilePhone);
                                    updateDataObj.set("address", p.Address);
                                    updateDataObj.set("unitid", p.UnitID);

                                    recordId = di.getString("id");

                                    updateDataObj.remove("id");
                                    di.remove("id");
                                    updateDataObj.remove("unitid");
                                    di.remove("unitid");

                                    if (di.toJson().Equals(updateDataObj.toJson()))
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        cells.Clear();
                                        cells.Add(false);
                                        cells.Add(mainProject.Name);
                                        cells.Add("人员信息");
                                        cells.Add(di.toJson());
                                        cells.Add(updateDataObj.toJson());

                                        int rowIndex = dgvDiff.Rows.Add(cells.ToArray());
                                        dgvDiff.Rows[rowIndex].Tag = recordId;
                                    }
                                }
                            }
                        }
                        finally
                        {
                            SQLiteConnManager.Close();
                        }
                    }
                }
            }
        }