internal ProjectHandler(string name, DevSiteLoginInfo info) { this.Name = name; DevConnection = info.TryConnect(); DevSite = info; Preference = GetProjectPreference(); }
internal void LoadProject(string projectName, DevSiteLoginInfo devSite, bool checkDup, XmlElement source) { if (this._projects.Contains(projectName)) { throw new Exception("專案已經存在"); } XmlHelper sourceHelper = new XmlHelper(source); if (checkDup) { Connection devConnection = devSite.TryConnect(); Envelope evn = devConnection.SendRequest("UDSManagerService.ListContracts", new Envelope()); XmlHelper rsp = new XmlHelper(evn.Body); StringBuilder contracts = new StringBuilder(); foreach (XmlElement contractElement in sourceHelper.GetElements("Property/Contract")) { string contractName = contractElement.GetAttribute("Name"); if (rsp.GetElement("Contract[@Name='" + contractName + "']") != null) { contracts.Append(contractName).Append("\n"); } } evn = devConnection.SendRequest("UDTService.DDL.ListTables", new Envelope()); rsp = new XmlHelper(evn.Body); StringBuilder tables = new StringBuilder(); foreach (XmlElement contractElement in rsp.GetElements("Property/Table")) { string tableName = contractElement.GetAttribute("Name"); if (rsp.GetElement("Table[@Name='" + tableName + "']") != null) { tables.Append(tableName).Append("\n"); } } StringBuilder msg = new StringBuilder(); if (tables.Length > 0) { msg.Append("檢查到重覆資料表 : \n").Append(tables); } if (contracts.Length > 0) { msg.Append("檢查到重覆 Contract : \n").Append(contracts); } if (msg.Length > 0) { throw new Exception(msg.ToString()); } } string filepath = MainForm.Storage.GetPropertyValue(LOCAL_FILE_PATH, projectName); this.InternalAddProject(projectName, devSite, filepath); ProjectHandler ph = this.CreateProjectHandler(projectName, devSite); UDSHandler uds = ph.GetUDSHandler(); XmlElement ce = sourceHelper.GetElement("Property[@Name='UDS']"); if (ce != null) { uds.ImportContracts(ce, true); } UDTHandler udt = ph.GetUDT(); XmlElement te = sourceHelper.GetElement("Property[@Name='UDT']"); if (te != null) { udt.SetTables(te, true); } if (ProjectAdded != null) { ProjectAdded.Invoke(this, new ProjectEventArgs(projectName, devSite)); } }