void IdentifierList(out IdList list) { list = new IdList(); string name; Identifier(out name); list.Add(name); while (la.kind == 14) { Get(); Identifier(out name); list.Add(name); } }
public virtual string GetTokenIdentifier(string category, string token, IDictionary <string, object> fields) { List <ID> ids = new IdList(); var ret = new TokenDataCollection(); ret["Category"] = category; ret["Token"] = token; IToken itoken = GetToken(category, token); if (fields != null) { foreach (string key in fields.Keys.Where(x => x != "Category" && x != "Token")) { var grouped = (IDictionary <string, object>)(fields[key] as IDictionary <string, object>)?["grouped"]; if (grouped == null) { var value = fields[key]?.ToString() ?? ""; ret[key] = value; ID tmp; if (ID.TryParse(value, out tmp)) { ids.Add(tmp); } } else { StringBuilder sb = new StringBuilder(); foreach (KeyValuePair <string, object> group in grouped) { sb.Append(HttpUtility.HtmlEncode(group.Key)); sb.Append("|=|"); sb.Append(HttpUtility.HtmlEncode(group.Value.ToString())); sb.Append("|||"); ID tmp; if (ID.TryParse(group.Value, out tmp)) { ids.Add(tmp); } } if (sb.Length > 3) { ret[key] = sb.ToString(0, sb.Length - 3); } } } } return(string.Format("{0}{1}\" {4}>{2}<span style='display:none;'>{5}</span>{3}", TokenPrefix, ret, itoken.TokenIdentifierText(ret).Replace("\n", "").Replace("\r", ""), TokenSuffix, $"style='{itoken.TokenIdentifierStyle(ret)}'", GenerateScLinks(ids))); }
private void InitializeIdListFromPlayList(PlayList.PlayList playList) { foreach (var item in playList.Items) { IdList.Add(item.Snippet.ResourceId.VideoId); } }
private void CheckNodeId(HtmlNode node) { if (!string.IsNullOrEmpty(node.Id)) { IdList.Add(new IdIndex(node.Id, _readPointer)); } }
public MessageList() { if (File.Exists("in.txt")) { Messages = File.ReadAllLines("in.txt").ToList(); } else { for (int i = 0; i < 1000; i++) { Messages.Add(i.ToString()); } File.WriteAllLines("in.txt", Messages); } int id = 0; for (int i = 0; i < Messages.Count; i++) { IdList.Add(id); id++; if (id == 16) { id = 0; } IsSendList.Add(false); } Console.WriteLine(); }
private void InitializeIdListFromChannel(Channel.Channel channel) { foreach (var item in channel.Items) { IdList.Add(item.Id.VideoId); } }
public Node IdList() { //‹id› (,‹id›)* var n = new IdList(); if (CurrentToken == TokenCategory.CLOSEDPAR) { return(n); } n.Add(new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }); while (CurrentToken == TokenCategory.COMMA) { Expect(TokenCategory.COMMA); n.Add(new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }); } return(n); }
//<id-list>// public Node IdList() { var idlistr = new IdList(); switch (CurrentToken) { case TokenCategory.IDENTIFIER: idlistr.Add(new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }); break; default: throw new SyntaxError(firstOfIdList, tokenStream.Current); } while (firstOfIdListCont.Contains(CurrentToken)) { switch (CurrentToken) { case TokenCategory.COMMA: Expect(TokenCategory.COMMA); idlistr.Add(new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }); break; default: throw new SyntaxError(firstOfIdListCont, tokenStream.Current); } } return(idlistr); }
/// <summary> /// Creates an XmlElement representing an Epi Info 7 view's data. /// </summary> /// <param name="xmlDataPackage">The data package xml document that the XmlElement should be added to</param> /// <param name="form">The form whose data will be serialized</param> /// <returns>XmlElement; represents the form's data in Xml format, suitable for use in data packaging</returns> protected XmlElement CreateXmlFormDataElement(XmlDocument xmlDataPackage, View form) { #region Input Validation if (xmlDataPackage == null) { throw new ArgumentNullException("xmlDataPackage"); } if (form == null) { throw new ArgumentNullException("form"); } #endregion // Input Validation XmlElement data = xmlDataPackage.CreateElement("Data"); if (StatusChanged != null) { StatusChanged(string.Format(PackagerStrings.GUID_LIST_SETUP, form.Name)); } if (ResetProgress != null) { ResetProgress(); } /* This seems like an usual set of steps to just iterate over the data. The problem is that we can't "just * iterate over the data" - the data is split up page tables, with one table representing one page on the * form. While a JOIN might be able to bring everything together into one table, it might not - for example, * if there are >255 fields after the JOIN, an OleDb exception will be thrown. * * To get around this issue: The code first iterates over the rows in the BASE TABLE, obtaining the GUID * values for each. The GUIDs and their corresponding XmlElement go into a dictionary. * * Later, each row in each page is iterated over; as the GUIDs for each page table are accessed, the corresponding * XmlElement is pulled from the dictionary. Field data is added to it for each field that has data. In this * manner, it doesn't matter that each row is technically accessed out-of-order because they'll still show up * in-order in the resulting Xml. * * Filtering adds another layer of complexity. To filter, a JOIN operation is needed so that the filters can * be applied across all those tables, since the fields in the filter may be across different tables. The * RowFilter class provides a way to handle this; we simply get the query from that object and apply it to the * reader. Only GUIDs that match the filter are added to the dictionary of guids. */ // We need to exclude records from child forms that may now be orphaned as a result of a filter applied to the parent if (form.IsRelatedView && PreviousDistanceFromRoot < CurrentDistanceFromRoot) { ParentIdList.Clear(); foreach (KeyValuePair <string, XmlElement> kvp in IdList) { ParentIdList.Add(kvp.Key); } } IdList.Clear(); // Very important, this needs to be re-set in case we've already processed a form (this is a class level variable) if (!ExportInfo.RecordsPackaged.ContainsKey(form)) { ExportInfo.RecordsPackaged.Add(form, 0); } bool filterThisForm = false; RowFilters filters = null; Query selectQuery = null; if (Filters != null && Filters.ContainsKey(form.Name) && Filters[form.Name].Count() > 0) { filterThisForm = true; filters = Filters[form.Name]; selectQuery = filters.GetGuidSelectQuery(form); } double totalRecords = 0; using (IDataReader guidReader = filterThisForm ? SourceProject.CollectedData.GetDatabase().ExecuteReader(selectQuery) : SourceProject.CollectedData.GetDatabase().GetTableDataReader(form.TableName)) { while (guidReader.Read()) { string guid = guidReader["GlobalRecordId"].ToString(); string fkey = guidReader["FKEY"].ToString(); string recstatus = guidReader["RECSTATUS"].ToString(); string firstSaveUserId = string.Empty; DateTime?firstSaveTime = null; string lastSaveUserId = string.Empty; DateTime?lastSaveTime = null; if (guidReader.FieldCount > 3) { try { firstSaveUserId = guidReader["FirstSaveLogonName"].ToString(); if (guidReader["FirstSaveTime"] != DBNull.Value) { firstSaveTime = (DateTime)guidReader["FirstSaveTime"]; } lastSaveUserId = guidReader["LastSaveLogonName"].ToString(); if (guidReader["LastSaveTime"] != DBNull.Value) { lastSaveTime = (DateTime)guidReader["LastSaveTime"]; } } catch (IndexOutOfRangeException) { // just ignore, probably an older upgraded project } } if (recstatus.Equals("1")) // only include undeleted records { if (!form.IsRelatedView || ParentIdList.Contains(fkey)) { XmlElement record = xmlDataPackage.CreateElement("Record"); XmlAttribute id = xmlDataPackage.CreateAttribute("Id"); id.Value = guid; record.Attributes.Append(id); if (!string.IsNullOrEmpty(fkey)) { XmlAttribute foreignKey = xmlDataPackage.CreateAttribute("Fkey"); foreignKey.Value = fkey; record.Attributes.Append(foreignKey); } if (!string.IsNullOrEmpty(firstSaveUserId)) { XmlAttribute firstSaveId = xmlDataPackage.CreateAttribute("FirstSaveUserId"); firstSaveId.Value = firstSaveUserId; record.Attributes.Append(firstSaveId); } if (!string.IsNullOrEmpty(lastSaveUserId)) { XmlAttribute lastSaveId = xmlDataPackage.CreateAttribute("LastSaveUserId"); lastSaveId.Value = lastSaveUserId; record.Attributes.Append(lastSaveId); } if (firstSaveTime.HasValue) { XmlAttribute firstSaveDateTime = xmlDataPackage.CreateAttribute("FirstSaveTime"); firstSaveDateTime.Value = firstSaveTime.Value.Ticks.ToString(); record.Attributes.Append(firstSaveDateTime); } if (lastSaveTime.HasValue) { XmlAttribute lastSaveDateTime = xmlDataPackage.CreateAttribute("LastSaveTime"); lastSaveDateTime.Value = lastSaveTime.Value.Ticks.ToString(); record.Attributes.Append(lastSaveDateTime); } IdList.Add(guid, record); totalRecords++; ExportInfo.TotalRecordsPackaged++; ExportInfo.RecordsPackaged[form]++; } } } } totalRecords = totalRecords * form.Pages.Count; int processedRecords = 0; if (StatusChanged != null) { StatusChanged(string.Format(PackagerStrings.ADDING_FIELD_DATA, form.Name)); } foreach (Page page in form.Pages) { using (IDataReader reader = SourceProject.CollectedData.GetDatabase().GetTableDataReader(page.TableName)) { while (reader.Read()) { string guid = reader["GlobalRecordId"].ToString(); if (IdList.ContainsKey(guid)) { XmlElement element = IdList[guid]; foreach (Field field in page.Fields) { if (field is IDataField && field is RenderableField && !(field is GridField) && !(FieldsToNull.ContainsKey(form.Name) && FieldsToNull[form.Name].Contains(field.Name))) { RenderableField renderableField = field as RenderableField; if (renderableField != null) { XmlElement fieldData = xmlDataPackage.CreateElement("Field"); XmlAttribute name = xmlDataPackage.CreateAttribute("Name"); name.Value = renderableField.Name; fieldData.Attributes.Append(name); string value = reader[field.Name].ToString(); if (!string.IsNullOrEmpty(value)) { if (field is DateTimeField) { DateTime dt = Convert.ToDateTime(value); fieldData.InnerText = dt.Ticks.ToString(); } else if (field is ImageField) { value = Convert.ToBase64String((Byte[])reader[field.Name]); fieldData.InnerText = value; } else { fieldData.InnerText = value; } } if (IncludeNullFieldData == false && String.IsNullOrEmpty(fieldData.InnerText)) { // do nothing, for now... } else { element.AppendChild(fieldData); } data.AppendChild(element); } } } } processedRecords++; double progress = (((double)processedRecords) / ((double)totalRecords)) * 100; if (UpdateProgress != null) { UpdateProgress(progress); } } } } foreach (GridField gridField in form.Fields.GridFields) { data.AppendChild(CreateXmlGridElement(xmlDataPackage, form, gridField)); ExportInfo.GridsProcessed++; } return(data); }
static string Example2() { NamedReg a = new NamedReg("a"); NamedReg b = new NamedReg("b"); NamedReg c = new NamedReg("c"); NamedReg det = new NamedReg("det"); IdList rl1 = new IdList(); rl1.Add(a); rl1.Add(b); rl1.Add(c); rl1.Add(det); LocalDecl ld1 = new LocalDecl(new NumType(), rl1); IntLiteral il3 = new IntLiteral(2); Assign a12 = new Assign(a, il3); IntLiteral il4 = new IntLiteral(-3); Assign a13 = new Assign(b, il4); IntLiteral il5 = new IntLiteral(-2); Assign a14 = new Assign(c, il5); UnaryNeg un1 = new UnaryNeg(b); TmpNumReg tnr0 = new TmpNumReg(0); Assign a1 = new Assign(tnr0, un1); TmpNumReg tnr1 = new TmpNumReg(1); BinaryMul bm1 = new BinaryMul(b, b); Assign a2 = new Assign(tnr1, bm1); TmpNumReg tnr2 = new TmpNumReg(2); IntLiteral il1 = new IntLiteral(4); BinaryMul bm2 = new BinaryMul(il1, a); Assign a3 = new Assign(tnr2, bm2); BinaryMul bm3 = new BinaryMul(tnr2, c); Assign a4 = new Assign(tnr2, bm3); TmpNumReg tnr3 = new TmpNumReg(3); IntLiteral il2 = new IntLiteral(2); BinaryMul bm4 = new BinaryMul(il2, a); Assign a5 = new Assign(tnr3, bm4); BinarySub bs1 = new BinarySub(tnr1, tnr2); Assign a6 = new Assign(det, bs1); TmpNumReg tnr4 = new TmpNumReg(4); Call sqrt = new Call("sqrt", det); Assign a7 = new Assign(tnr4, sqrt); NamedReg x1 = new NamedReg("x1"); NamedReg x2 = new NamedReg("x2"); IdList rl2 = new IdList(); rl2.Add(x1); rl2.Add(x2); LocalDecl ld2 = new LocalDecl(new NumType(), rl2); BinaryAdd ba1 = new BinaryAdd(tnr0, tnr4); Assign a8 = new Assign(x1, ba1); BinaryDiv bd1 = new BinaryDiv(x1, tnr3); Assign a9 = new Assign(x1, bd1); BinarySub bs2 = new BinarySub(tnr0, tnr4); Assign a10 = new Assign(x2, bs2); AssignDiv a11 = new AssignDiv(x2, tnr3); StringLiteral s1 = new StringLiteral("Answers to ABC formula are:\n"); Call c1 = new Call("print", s1); CallStmt print1 = new CallStmt(c1); StringLiteral s2 = new StringLiteral("x1 = "); Call c2 = new Call("print", s2); CallStmt print2 = new CallStmt(c2); Call c3 = new Call("print", x1); CallStmt print3 = new CallStmt(c3); StringLiteral s4 = new StringLiteral("\nx2 = "); Call c4 = new Call("print", s4); CallStmt print4 = new CallStmt(c4); Call c5 = new Call("print", x2); CallStmt print5 = new CallStmt(c5); StringLiteral s6 = new StringLiteral("\n"); Call c6 = new Call("print", s6); CallStmt print6 = new CallStmt(c6); StmtList sl1 = new StmtList(); sl1.Add(ld1); sl1.Add(a12); sl1.Add(a13); sl1.Add(a14); sl1.Add(a1); sl1.Add(a2); sl1.Add(a3); sl1.Add(a4); sl1.Add(a5); sl1.Add(a6); sl1.Add(a7); sl1.Add(ld2); sl1.Add(a8); sl1.Add(a9); sl1.Add(a10); sl1.Add(a11); sl1.Add(print1); sl1.Add(print2); sl1.Add(print3); sl1.Add(print4); sl1.Add(print5); sl1.Add(print6); Sub foo = new Sub("foo", sl1); Pirate p = new Pirate(); p.Add(foo); StringWriter sw = new StringWriter(); PirateWriter pv = new PirateWriter(sw); DynamicVisitor.accept(p, pv); return sw.ToString(); }
static string Example5() { NamedReg x1 = new NamedReg(); x1.name = "x1"; NamedReg x2 = new NamedReg(); x2.name = "x2"; IdList idl1 = new IdList(); idl1.Add(x1); idl1.Add(x2); LocalDecl ld1 = new LocalDecl(); ld1.type = new NumType(); ld1.id_list = idl1; AtomExprList ael1 = new AtomExprList(); ael1.Add(x1); ael1.Add(x2); ReturnStmt rs1 = new ReturnStmt(); rs1.rv = ael1; StmtList sl1 = new StmtList(); sl1.Add(ld1); sl1.Add(rs1); Sub abc = new Sub("abc", sl1); Pirate p = new Pirate(); p.Add(abc); StringWriter sw = new StringWriter(); PirateWriter pv = new PirateWriter(sw); DynamicVisitor.accept(p, pv); return sw.ToString(); }
static string Example4() { StmtList sl1 = new StmtList(); Sub foo = new Sub("foo", sl1); Pirate p = new Pirate(); p.Add(foo); ParamDecl pd1 = new ParamDecl(); pd1.type = new IntType(); IdList idl1 = new IdList(); NamedReg n = new NamedReg(); n.name = "n"; idl1.Add(n); pd1.id_list = idl1; sl1.Add(pd1); ParamDecl pd2 = new ParamDecl(); pd2.type = new StringType(); IdList idl2 = new IdList(); NamedReg message = new NamedReg(); message.name = "message"; idl2.Add(message); pd2.id_list = idl2; sl1.Add(pd2); StringWriter sw = new StringWriter(); PirateWriter pv = new PirateWriter(sw); DynamicVisitor.accept(p, pv); return sw.ToString(); }
static string Example3() { Pirate p = new Pirate(); StmtList sl1 = new StmtList(); Sub joe = new Sub("joe", sl1); p.Add(joe); LocalDecl ld1 = new LocalDecl(); ld1.type = new StringType(); NamedReg name = new NamedReg(); name.name = "name"; IdList idl1 = new IdList(); idl1.Add(name); ld1.id_list = idl1; sl1.Add(ld1); Assign a1 = new Assign(); a1.lval = name; StringLiteral s1 = new StringLiteral(); s1.value = " Joe!"; a1.rval = s1; sl1.Add(a1); Assign a2 = new Assign(); StringLiteral s2 = new StringLiteral(); s2.value = "Hi!"; TmpStringReg tsr0 = new TmpStringReg(); tsr0.number = 0; a2.lval = tsr0; a2.rval = s2; sl1.Add(a2); Assign a3 = new Assign(); TmpStringReg tsr1 = new TmpStringReg(); tsr1.number = 1; BinaryCat bc1 = new BinaryCat(); bc1.a = tsr0; bc1.b = name; a3.lval = tsr1; a3.rval = bc1; sl1.Add(a3); AssignCat a4 = new AssignCat(); a4.lval = tsr1; StringLiteral s3 = new StringLiteral(); s3.value = "\n"; a4.rval = s3; sl1.Add(a4); CallStmt cs1 = new CallStmt(); Call c1 = new Call(); c1.func = "print"; c1.args = tsr1; cs1.call = c1; sl1.Add(cs1); StringWriter sw = new StringWriter(); PirateWriter pv = new PirateWriter(sw); DynamicVisitor.accept(p, pv); return sw.ToString(); }
public void AddMyId(Guid id) { IdList.Add(id); }
public void Construct(CommonTree syntaxExtendedId) { syntaxExtendedId.Children.Cast <CommonTree>() .ForEach(id => IdList.Add(id.Text)); ReturnType = ReturnType.Unset; }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="pmidListFromXml"></param> override public bool FillQueryDataTables(string name, XmlNodeList pmidListFromXml) { if (name == "" && pmidListFromXml.Count == 0) { return(false); } try { // T_Protein and T_ProteinList DataRow rowProtein = null; if (ProteinFromUser != null) { if (!(Dictionary.TryGetValue(ProteinFromUser, out rowProtein))) { // not exist -> create new row of T_Protein and fill it. rowProtein = ProteinDataTable.NewRow(); rowProtein["ProteinID"] = ProteinID++; rowProtein["Protein"] = ProteinFromUser; // add the row into the T_Protein data table and the dictionary ProteinDataTable.Rows.Add(rowProtein); Dictionary.Add(ProteinFromUser, rowProtein); } // No matter protein exists in the dictionary, need to put in the list DataRow rowProteinList = ProteinListDataTable.NewRow(); rowProteinList["ProteinListID"] = ProteinListID; rowProteinList["QuerySessionID"] = QuerySessionID; rowProteinList["ProteinID"] = rowProtein["Protein"]; ProteinListDataTable.Rows.Add(rowProteinList); } // T_Organism DataRow rowOrganism = null; if ((OrganismFromUser != null) && (!(Dictionary.TryGetValue(OrganismFromUser, out rowOrganism)))) { // not exist -> create new row of T_Organism and fill it. rowOrganism = OrganismDataTable.NewRow(); rowOrganism["OrganismID"] = OrganismID++; rowOrganism["Organism"] = OrganismFromUser; // add the row into T_Organism data table and the dictionary OrganismDataTable.Rows.Add(rowOrganism); Dictionary.Add(OrganismFromUser, rowOrganism); } // T_Keyword DataRow rowKeyword = null; if ((KeywordFromUser != null) && (!(Dictionary.TryGetValue(KeywordFromUser, out rowKeyword)))) { // not exist -> create new row of T_Keyword and fill it rowKeyword = KeywordDataTable.NewRow(); rowKeyword["KeywordID"] = KeywordID++; rowKeyword["Keyword"] = KeywordFromUser; // add the row into T_Keyword data table and the dictionary. KeywordDataTable.Rows.Add(rowKeyword); Dictionary.Add(KeywordFromUser, rowKeyword); } // The rest of T_Query DataRow rowQuery = QueryDataTable.NewRow(); rowQuery["QueryID"] = QueryID++; rowQuery["Name"] = name; // name = protein + organism + keyword //rowQuery["QueryStartTime"]=; //rowQuery["QueryEndTime"]=; rowQuery["ProteinID"] = rowProtein["ProteinID"]; //.ToString(); rowQuery["OrganismID"] = rowOrganism["OrganismID"]; //.ToString(); rowQuery["Keyword"] = rowKeyword["KeywordID"]; //.ToString(); // keywordListID = QueryID because one query has one keywordList rowQuery["ResultCount"] = ArticleCount; // new count from the xml string // Add the row of T_Query into the T_Query datatable and the dictionary QueryDataTable.Rows.Add(rowQuery); Dictionary.Add(name, rowQuery); // T_QueryArticles foreach (XmlNode pmid in pmidListFromXml) { // create the row of QueryArticles and fill it. DataRow rowQueryArticles = QueryArticlesDataTable.NewRow(); rowQueryArticles["QueryArticleID"] = QueryArticleID++; rowQueryArticles["QueryID"] = rowQuery["QueryID"]; rowQueryArticles["PMID"] = pmid.InnerText; // add pmid into ldlist and the row into datatable IdList.Add(pmid.InnerText); QueryArticlesDataTable.Rows.Add(rowQueryArticles); } // T_QuerySession // create new row, fill information, and add the row into the QuerySession data table DataRow rowQuerySession = QuerySessionDataTable.NewRow(); rowQuerySession["QuerySessionID"] = QuerySessionID; rowQuerySession["QueryID"] = rowQuery["QueryID"]; rowQuerySession["ProteinListID"] = rowQuery["ProteinID"]; rowQuerySession["DateTime"] = DateTime.Now; QuerySessionDataTable.Rows.Add(rowQuerySession); } catch (Exception exception) { Console.WriteLine(exception.Message); } return(true); }
public void AddBodyID(BodyIdWrapper newIdWrapper) { IdList.Add(newIdWrapper); }
/// <summary> /// Creates an XmlElement representing an Epi Info 7 view's data. /// </summary> /// <param name="xmlDataPackage">The data package xml document that the XmlElement should be added to</param> /// <param name="form">The form whose data will be serialized</param> /// <returns>XmlElement; represents the form's data in Xml format, suitable for use in data packaging</returns> protected override XmlElement CreateXmlFormDataElement(XmlDocument xmlDataPackage, View form) { #region Input Validation if (xmlDataPackage == null) { throw new ArgumentNullException("xmlDataPackage"); } if (form == null) { throw new ArgumentNullException("form"); } #endregion // Input Validation XmlElement data = xmlDataPackage.CreateElement("Data"); OnStatusChanged(String.Format("Packaging data for form {0}...", form.Name)); OnResetProgress(); /* This seems like an usual set of steps to just iterate over the data. The problem is that we can't "just * iterate over the data" - the data is split up page tables, with one table representing one page on the * form. While a JOIN might be able to bring everything together into one table, it might not - for example, * if there are >255 fields after the JOIN, an OleDb exception will be thrown. * * To get around this issue: The code first iterates over the rows in the BASE TABLE, obtaining the GUID * values for each. The GUIDs and their corresponding XmlElement go into a dictionary. * * Later, each row in each page is iterated over; as the GUIDs for each page table are accessed, the corresponding * XmlElement is pulled from the dictionary. Field data is added to it for each field that has data. In this * manner, it doesn't matter that each row is technically accessed out-of-order because they'll still show up * in-order in the resulting Xml. * * Filtering adds another layer of complexity. To filter, a JOIN operation is needed so that the filters can * be applied across all those tables, since the fields in the filter may be across different tables. The * RowFilter class provides a way to handle this; we simply get the query from that object and apply it to the * reader. Only GUIDs that match the filter are added to the dictionary of guids. */ // We need to exclude records from child forms that may now be orphaned as a result of a filter applied to the parent if (form.IsRelatedView && PreviousDistanceFromRoot < CurrentDistanceFromRoot) { ParentIdList.Clear(); foreach (KeyValuePair <string, XmlElement> kvp in IdList) { ParentIdList.Add(kvp.Key); } } IdList.Clear(); // Very important, this needs to be re-set in case we've already processed a form (this is a class level variable) if (!ExportInfo.RecordsPackaged.ContainsKey(form)) { ExportInfo.RecordsPackaged.Add(form, 0); } //bool filterThisForm = false; RowFilters filters = null; Query selectQuery = null; IDbDriver db = SourceProject.CollectedData.GetDatabase(); string recStatusClause = String.Empty; if (Filters != null && Filters.ContainsKey(form.Name) && Filters[form.Name].Count() > 0) { //filterThisForm = true; filters = Filters[form.Name]; filters.RecordProcessingScope = RecordProcessingScope; selectQuery = filters.GetGuidSelectQuery(form); List <QueryParameter> paramsToAdd = selectQuery.Parameters; selectQuery = db.CreateQuery(selectQuery.SqlStatement.Replace("[t].[GlobalRecordId], [t].[FKEY], [t].[RECSTATUS]", "*")); selectQuery.Parameters = paramsToAdd; } else { recStatusClause = "RECSTATUS = 1"; if (RecordProcessingScope == Epi.RecordProcessingScope.Both) { recStatusClause = "RECSTATUS >= 0"; } else if (RecordProcessingScope == Epi.RecordProcessingScope.Deleted) { recStatusClause = "RECSTATUS = 0"; } string selectQueryText = "SELECT * " + form.FromViewSQL; selectQueryText = "SELECT * " + form.FromViewSQL + " WHERE " + recStatusClause; selectQuery = db.CreateQuery(selectQueryText); } double totalRecords = Convert.ToDouble(db.ExecuteScalar(db.CreateQuery("SELECT COUNT(*) FROM " + form.TableName))); var fieldInclusionList = new List <RenderableField>(); foreach (Field field in form.Fields) { if (field is IDataField && field is RenderableField && !(field is GridField) && !(FieldsToNull.ContainsKey(form.Name) && FieldsToNull[form.Name].Contains(field.Name))) { var fieldToAdd = field as RenderableField; if (fieldToAdd != null) { fieldInclusionList.Add(fieldToAdd); } } } int processedRecords = 0; //using (IDataReader guidReader = db.ExecuteReader(selectQuery)) //using (IDataReader guidReader = filterThisForm ? db.ExecuteReader(selectQuery) : db.GetTableDataReader(form.TableName)) DataTable fullTable = db.Select(selectQuery); //int lowKey = (int)db.ExecuteScalar(db.CreateQuery("SELECT Min(UniqueKey) FROM " + form.TableName)); //int highKey = (int)db.ExecuteScalar(db.CreateQuery("SELECT Max(UniqueKey) FROM " + form.TableName)); ////ProcessRows(fullTable.Select("UniqueKey >= " + lowKey + " AND UniqueKey <= " + (highKey / 4)), form, xmlDataPackage, fieldInclusionList); string set1 = String.Empty; //string set2 = String.Empty; //string set3 = String.Empty; //string set4 = String.Empty; //Parallel.Invoke( // () => // { set1 = ProcessRows(fullTable.Rows, form, xmlDataPackage, fieldInclusionList); //}, //() => //{ // set2 = ProcessRows(fullTable.Select("UniqueKey >= " + (highKey / 4) + " AND UniqueKey < " + (highKey / 2)), form, xmlDataPackage, fieldInclusionList); //}, //() => //{ // set3 = ProcessRows(fullTable.Select("UniqueKey >= " + (highKey / 2) + " AND UniqueKey < " + (highKey / 1.5)), form, xmlDataPackage, fieldInclusionList); //}, //() => //{ // set4 = ProcessRows(fullTable.Select("UniqueKey >= " + (highKey / 1.5) + " AND UniqueKey <= " + highKey), form, xmlDataPackage, fieldInclusionList); //} //); //StringBuilder sb = new StringBuilder(); //foreach (XmlElement element in set1) //{ // sb.Append(element.OuterXml); // //data.AppendChild(element); //} //foreach (XmlElement element in set2) //{ // sb.Append(element.OuterXml); // //data.AppendChild(element); //} //foreach (XmlElement element in set3) //{ // sb.Append(element.OuterXml); // //data.AppendChild(element); //} //foreach (XmlElement element in set4) //{ // sb.Append(element.OuterXml); // //data.AppendChild(element); //} data.InnerText = set1; return(data); foreach (DataRow guidReader in fullTable.Rows) { //using(var conn = new System.Data.SqlClient.SqlConnection(db.ConnectionString + ";Connection Timeout=10")) //{ // conn.Open(); // using (var selectCommand = new System.Data.SqlClient.SqlCommand(selectQueryText, conn)) // { // using (var guidReader = selectCommand.ExecuteReader()) // { // while (guidReader.Read()) // { string guid = guidReader["GlobalRecordId"].ToString();// guidReader.GetString(0); // guidReader["GlobalRecordId"].ToString(); string fkey = guidReader["FKEY"].ToString(); string recstatus = guidReader["RECSTATUS"].ToString(); string firstSaveUserId = String.Empty; DateTime?firstSaveTime = null; string lastSaveUserId = String.Empty; DateTime?lastSaveTime = null; firstSaveUserId = guidReader["FirstSaveLogonName"].ToString(); if (guidReader["FirstSaveTime"] != DBNull.Value) { firstSaveTime = (DateTime)guidReader["FirstSaveTime"]; } lastSaveUserId = guidReader["LastSaveLogonName"].ToString(); if (guidReader["LastSaveTime"] != DBNull.Value) { lastSaveTime = (DateTime)guidReader["LastSaveTime"]; } if (!form.IsRelatedView || ParentIdList.Contains(fkey)) { XmlElement record = xmlDataPackage.CreateElement("Record"); XmlAttribute id = xmlDataPackage.CreateAttribute("Id"); id.Value = guid; record.Attributes.Append(id); if (!string.IsNullOrEmpty(fkey)) { XmlAttribute foreignKey = xmlDataPackage.CreateAttribute("Fkey"); foreignKey.Value = fkey; record.Attributes.Append(foreignKey); } if (!string.IsNullOrEmpty(firstSaveUserId)) { XmlAttribute firstSaveId = xmlDataPackage.CreateAttribute("FirstSaveUserId"); firstSaveId.Value = firstSaveUserId; record.Attributes.Append(firstSaveId); } if (!string.IsNullOrEmpty(lastSaveUserId)) { XmlAttribute lastSaveId = xmlDataPackage.CreateAttribute("LastSaveUserId"); lastSaveId.Value = lastSaveUserId; record.Attributes.Append(lastSaveId); } if (firstSaveTime.HasValue) { XmlAttribute firstSaveDateTime = xmlDataPackage.CreateAttribute("FirstSaveTime"); firstSaveDateTime.Value = firstSaveTime.Value.Ticks.ToString(); record.Attributes.Append(firstSaveDateTime); } if (lastSaveTime.HasValue) { XmlAttribute lastSaveDateTime = xmlDataPackage.CreateAttribute("LastSaveTime"); lastSaveDateTime.Value = lastSaveTime.Value.Ticks.ToString(); record.Attributes.Append(lastSaveDateTime); } if (!String.IsNullOrEmpty(recstatus)) { XmlAttribute recStatusAttribute = xmlDataPackage.CreateAttribute("RecStatus"); recStatusAttribute.Value = recstatus; record.Attributes.Append(recStatusAttribute); } IdList.Add(guid, record); ExportInfo.TotalRecordsPackaged++; ExportInfo.RecordsPackaged[form]++; foreach (RenderableField field in fieldInclusionList) { XmlElement fieldData = xmlDataPackage.CreateElement("Field"); XmlAttribute name = xmlDataPackage.CreateAttribute("Name"); name.Value = field.Name; fieldData.Attributes.Append(name); string value = guidReader[field.Name].ToString(); if (!String.IsNullOrEmpty(value)) { if (field is DateTimeField) { DateTime dt = Convert.ToDateTime(value); fieldData.InnerText = dt.Ticks.ToString(); } else if (field is ImageField) { value = Convert.ToBase64String((Byte[])guidReader[field.Name]); fieldData.InnerText = value; } else if (field is NumberField) { value = Convert.ToDouble(value).ToString(System.Globalization.CultureInfo.InvariantCulture); fieldData.InnerText = value; } else { fieldData.InnerText = value; } } if (String.IsNullOrEmpty(fieldData.InnerText) && IncludeNullFieldData == false) { // do nothing, for now... } else { record.AppendChild(fieldData); } data.AppendChild(record); } } processedRecords++; double progress = (((double)processedRecords) / ((double)totalRecords)) * 100; OnProgressChanged(progress); } foreach (GridField gridField in form.Fields.GridFields) { data.AppendChild(CreateXmlGridElement(xmlDataPackage, form, gridField)); ExportInfo.GridsProcessed++; } return(data); }