public void SetValues(ComponentDO obj) { if(obj == null) { return; } GUID = obj.GUID; LastMerge = obj.LastMerge; FileName = obj.FileName; }
protected void CreateComponent(DAL masterDAL, int compNum, ComponentDO compInfo, String compPath) { //copy master to create component file masterDAL.CopyTo(compPath); var compDB = new DAL(compPath); try { compDB.BeginTransaction(); compDB.Execute("DELETE FROM CountTree WHERE Component_CN IS NOT NULL;"); compDB.Execute(SQL.CLEAR_FIELD_DATA); string command = string.Format("UPDATE CountTree Set Component_CN = {0};", compInfo.Component_CN); compDB.Execute(command); //Set the starting rowID for each component compDB.SetTableAutoIncrementStart("Tree", GetComponentRowIDStart(compNum)); compDB.SetTableAutoIncrementStart("Log", GetComponentRowIDStart(compNum)); compDB.SetTableAutoIncrementStart("TreeEstimate", GetComponentRowIDStart(compNum)); compDB.SetTableAutoIncrementStart("Stem", GetComponentRowIDStart(compNum)); compDB.SetTableAutoIncrementStart("Plot", compNum * PLOT_ROW_SPACING); compDB.Execute("DELETE FROM Globals WHERE Block = 'Comp' AND Key = 'ChildComponents';"); compDB.Execute("DELETE FROM Globals WHERE Block = 'Comp' AND Key = 'LastMerge';"); compDB.CommitTransaction(); } catch (Exception) { compDB.RollbackTransaction(); try { //component is probably jacked up, so delete it System.IO.File.Delete(compDB.Path); } catch { } //may throw exception if file doesn't exist, but we can ignore that } finally { compDB.Dispose(); } }
public ComponentDO(ComponentDO obj) : this() { SetValues(obj); }
//private static void ClearFieldData(DAL database) //{ // database.Execute(CSM.Utility.SQL.CLEAR_FIELD_DATA); //} //inserts Component Records into master private static List<ComponentDO> BuildMasterComponentTable(DAL masterDAL, int numComp) { string masterFileName = System.IO.Path.GetFileName(masterDAL.Path); List<ComponentDO> compList = new List<ComponentDO>(); for (int i = 1; i <= numComp; i++) { String compFileName = GetCompFileName(masterFileName, i); ComponentDO compInfo = masterDAL.ReadSingleRow<ComponentDO>("Component", "WHERE FileName = ?", compFileName); if (compInfo == null) { compInfo = new ComponentDO(masterDAL); compInfo.GUID = Guid.NewGuid().ToString(); compInfo.FileName = compFileName; compInfo.Save(); } compList.Add(compInfo); } return compList; }