private DataTable GetSchemaTable() { WebDataSource comp = (WebDataSource)this.Component; if (comp == null) return null; if (comp.SelectCommand != null && comp.SelectCommand.Length != 0 && comp.SelectAlias != null && comp.SelectAlias.Length != 0) { string pro = CliUtils.fCurrentProject; if (pro == null || pro.Length == 0) { pro = EditionDifference.ActiveSolutionName(); } string CommandText = CliUtils.InsertWhere(comp.SelectCommand, "1=0"); DataSet ds = CliUtils.ExecuteSql("GLModule", "cmdRefValUse", CommandText, comp.SelectAlias, true, pro); if (ds != null && ds.Tables.Count != 0) return ds.Tables[0]; else return (new DataTable("Table1")); } else { string keyName = string.Empty; if (!string.IsNullOrEmpty(comp.WebDataSetID)) { keyName = "WebDataSets"; } #if VS90 else if (!string.IsNullOrEmpty(comp.LinqDataSetID)) { keyName = "LinqDataSets"; } #endif CultureInfo culture = new CultureInfo("vi-VN"); string aspxName = EditionDifference.ActiveDocumentFullName(); XmlDocument xmlDoc = new XmlDocument(); string resourceName = aspxName + @".vi-VN.resx"; // ResXResourceReader reader = new ResXResourceReader(s + resourceName); ResXResourceReader reader = new ResXResourceReader(resourceName); IDictionaryEnumerator enumerator = reader.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Key.ToString() == keyName) { string sXml = (string)enumerator.Value; xmlDoc.LoadXml(sXml); break; } } reader.Close(); if (xmlDoc == null) return null; XmlNode nWDSs = null; XmlNode nWDS = null; if (!string.IsNullOrEmpty(comp.WebDataSetID)) { nWDSs = xmlDoc.SelectSingleNode("WebDataSets"); if (nWDSs == null) return null; nWDS = nWDSs.SelectSingleNode("WebDataSet[@Name='" + comp.WebDataSetID + "']"); if (nWDS == null) return null; } #if VS90 else if (!string.IsNullOrEmpty(comp.LinqDataSetID)) { nWDSs = xmlDoc.SelectSingleNode("LinqDataSets"); if (nWDSs == null) return null; nWDS = nWDSs.SelectSingleNode("LinqDataSet[@Name='" + comp.LinqDataSetID + "']"); if (nWDS == null) return null; } #endif string remoteName = ""; int packetRecords = 100; bool active = false; bool serverModify = false; bool alwaysClose = false; XmlNode nRemoteName = nWDS.SelectSingleNode("RemoteName"); if (nRemoteName != null) remoteName = nRemoteName.InnerText; XmlNode nPacketRecords = nWDS.SelectSingleNode("PacketRecords"); if (nPacketRecords != null) packetRecords = nPacketRecords.InnerText.Length == 0 ? 100 : Convert.ToInt32(nPacketRecords.InnerText); XmlNode nActive = nWDS.SelectSingleNode("Active"); if (nActive != null) active = nActive.InnerText.Length == 0 ? false : Convert.ToBoolean(nActive.InnerText); XmlNode nServerModify = nWDS.SelectSingleNode("ServerModify"); if (nServerModify != null) serverModify = nServerModify.InnerText.Length == 0 ? false : Convert.ToBoolean(nServerModify.InnerText); XmlNode nAlwaysClose = nWDS.SelectSingleNode("AlwaysClose"); if (nAlwaysClose != null) alwaysClose = nAlwaysClose.InnerText.Length == 0 ? false : Convert.ToBoolean(nAlwaysClose.InnerText); DataTable tableView = null; if(!string.IsNullOrEmpty(comp.WebDataSetID)) { WebDataSet dataSet = new WebDataSet(true); dataSet.AlwaysClose = alwaysClose; dataSet.RemoteName = remoteName; dataSet.PacketRecords = packetRecords; dataSet.ServerModify = serverModify; dataSet.WhereStr = "1=0"; dataSet.Active = true; if (dataSet == null) return null; string viewName = comp.DataMember; if (viewName == null || viewName.Length == 0) return null; tableView = dataSet.RealDataSet.Tables[viewName]; } #if VS90 else if(!string.IsNullOrEmpty(comp.LinqDataSetID)) { LinqDataSet dataSet = new LinqDataSet(true); dataSet.AlwaysClose = alwaysClose; dataSet.RemoteName = remoteName; dataSet.PacketRecords = packetRecords; dataSet.ServerModify = serverModify; dataSet.Active = true; if (dataSet == null) return null; string viewName = comp.DataMember; if (viewName == null || viewName.Length == 0) return null; tableView = dataSet.RealDataSet.Tables[viewName]; } #endif return tableView; } }
public bool GetNextPacket() { if (!this.Eof) { if(!string.IsNullOrEmpty(WebDataSetID)) { InfoDataSet infoDataSet = new InfoDataSet(); // infoDataSet.LastKeyValues = this.LastKeyValues; infoDataSet.DataCompressed = DataCompressed; infoDataSet.LastIndex = this.LastIndex; infoDataSet.Eof = this.Eof; infoDataSet.WhereStr = this.WhereStr; infoDataSet.WhereParam = this.WhereParam; if (!string.IsNullOrEmpty(this.SelectAlias) && !string.IsNullOrEmpty(this.SelectCommand)) { // infoDataSet.refDBAlias = this.SelectAlias; infoDataSet.RefCommandText = this.SelectCommand; infoDataSet.RemoteName = "GLModule.cmdRefValUse"; infoDataSet.PacketRecords = this.CommandPacketRecords; infoDataSet.RealDataSet.Tables.Add(this.CommandTable); } else { infoDataSet.RemoteName = this.RemoteName; infoDataSet.PacketRecords = this.PacketRecords; infoDataSet.RealDataSet = this.InnerDataSet; } bool b = infoDataSet.GetNextPacket(); if (b) { if (!string.IsNullOrEmpty(this.SelectAlias) && !string.IsNullOrEmpty(this.SelectCommand)) { this.CommandTable = infoDataSet.RealDataSet.Tables[0]; } else { this.InnerDataSet = infoDataSet.RealDataSet; } this.LastIndex = infoDataSet.LastIndex; this.Eof = infoDataSet.Eof; if (View != null && View.Count > 0) { SetPostion(0); } else { SetPostion(-1); } return true; } else { return false; } } #if VS90 else if (!string.IsNullOrEmpty(LinqDataSetID)) { LinqDataSet linqDataSet = new LinqDataSet(); linqDataSet.LastIndex = this.LastIndex; linqDataSet.CommandText = this.CommandText; linqDataSet.Eof = this.Eof; //if (!string.IsNullOrEmpty(this.SelectAlias) && !string.IsNullOrEmpty(this.SelectCommand)) //{ // linqDataSet.refDBAlias = this.SelectAlias; // linqDataSet.refCommandText = this.SelectCommand; // linqDataSet.RemoteName = "GLModule.cmdRefValUse"; // linqDataSet.PacketRecords = this.CommandPacketRecords; // linqDataSet.RealDataSet.Tables.Add(this.CommandTable); //} //else //{ linqDataSet.RemoteName = this.RemoteName; linqDataSet.PacketRecords = this.PacketRecords; linqDataSet.RealDataSet = this.InnerDataSet; //} bool b = linqDataSet.GetNextPacket(); if (b) { //if (!string.IsNullOrEmpty(this.SelectAlias) && !string.IsNullOrEmpty(this.SelectCommand)) //{ // this.CommandTable = linqDataSet.RealDataSet.Tables[0]; //} //else //{ this.InnerDataSet = linqDataSet.RealDataSet; //} this.LastIndex = linqDataSet.LastIndex; linqDataSet.CommandText = this.CommandText; this.Eof = linqDataSet.Eof; return true; } else { return false; } } #endif } return false; }