/// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data"> The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data </param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);

            if (IsContainerRecord)
            {
                int bytesWritten = 0;
                thedata       = new byte[0];
                offset       += 8;
                bytesWritten += 8;
                while (bytesRemaining > 0)
                {
                    EscherRecord child             = recordFactory.CreateRecord(data, offset);
                    int          childBytesWritten = child.FillFields(data, offset, recordFactory);
                    bytesWritten   += childBytesWritten;
                    offset         += childBytesWritten;
                    bytesRemaining -= childBytesWritten;
                    ChildRecords.Add(child);
                }
                return(bytesWritten);
            }
            else
            {
                thedata = new byte[bytesRemaining];
                Array.Copy(data, offset + 8, thedata, 0, bytesRemaining);
                return(bytesRemaining + 8);
            }
        }
Exemple #2
0
        public GEDCOMEventStructure(int level, string tag, string date, string place) : base(new GEDCOMRecord(level, "", "", tag, ""))
        {
            var dateRecord = new GEDCOMRecord(level + 1, "", "", "DATE", date);

            ChildRecords.Add(dateRecord);

            var placeRecord = new GEDCOMPlaceStructure(level + 1, place);

            ChildRecords.Add(placeRecord);
        }
        protected void LoadChildRecords(Type type)
        {
            using (SqlConnection conn = new SqlConnection(SQLDMGlobal.ConnectionString()))
            {
                conn.Open();
                SqlCommand cmd = conn.CreateCommand();

                try
                {
                    foreach (DataLink dl in Links.FindAll(c => c.ChildRecordType == type))
                    {
                        DataRecord childDummy = SQLDMGlobal.FindDummy(type);

                        if (childDummy != null)
                        {
                            cmd.CommandText = string.Format("select * from {0} where [{1}] = {2}", childDummy.FullSafeTableName, dl.ChildFieldName, dl.ParentField.ParameterName);
                            SqlParameter param = GetSqlParameter(dl.ParentField.ParameterName);
                            if (param != null)
                            {
                                cmd.Parameters.Add(param);
                            }

                            SqlDataAdapter da = new SqlDataAdapter();
                            da.SelectCommand = cmd;
                            DataTable dt = new DataTable();
                            da.Fill(dt);

                            foreach (DataRow row in dt.Rows)
                            {
                                DataRecord inst = (DataRecord)System.Activator.CreateInstance(dl.ChildRecordType);
                                FillRecord(row, inst, true);
                                ChildRecords.Add(inst);
                            }

                            cmd.Parameters.Clear();
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                    throw ex;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Exemple #4
0
        protected void SetChildXRefId(GEDCOMTag childTag, string xRefId)
        {
            GEDCOMRecord child = ChildRecords.GetLineByTag <GEDCOMRecord>(childTag);

            if (child == null)
            {
                ChildRecords.Add(new GEDCOMRecord(Level + 1, "", xRefId, childTag.ToString(), ""));
            }
            else
            {
                child._xRefId = xRefId;
            }
        }
Exemple #5
0
        protected void SetChildData(GEDCOMTag childTag, string data)
        {
            GEDCOMRecord child = ChildRecords.GetLineByTag <GEDCOMRecord>(childTag);

            if (child == null)
            {
                ChildRecords.Add(new GEDCOMRecord(Level + 1, "", "", childTag.ToString(), data));
            }
            else
            {
                child.Data = data;
            }
        }
Exemple #6
0
        protected void SetChildData(GEDCOMTag childTag, GEDCOMTag grandChildTag, string data)
        {
            GEDCOMRecord child = ChildRecords.GetLineByTag <GEDCOMRecord>(childTag);

            if (child == null)
            {
                child = new GEDCOMRecord(Level + 1, "", "", childTag.ToString(), "");
                ChildRecords.Add(child);
            }

            GEDCOMRecord grandChild = child.ChildRecords.GetLineByTag <GEDCOMRecord>(grandChildTag);

            if (grandChild == null)
            {
                child.ChildRecords.Add(new GEDCOMRecord(Level + 2, "", "", grandChildTag.ToString(), data));
            }
            else
            {
                grandChild.Data = data;
            }
        }
        /// <summary>
        /// The contract of this method is to deSerialize an escher record including
        /// it's children.
        /// </summary>
        /// <param name="data">The byte array containing the Serialized escher
        /// records.</param>
        /// <param name="offset">The offset into the byte array.</param>
        /// <param name="recordFactory">A factory for creating new escher records</param>
        /// <returns>The number of bytes written.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int bytesWritten   = 8;

            offset += 8;
            while (bytesRemaining > 0 && offset < data.Length)
            {
                EscherRecord child             = recordFactory.CreateRecord(data, offset);
                int          childBytesWritten = child.FillFields(data, offset, recordFactory);
                bytesWritten   += childBytesWritten;
                offset         += childBytesWritten;
                bytesRemaining -= childBytesWritten;
                ChildRecords.Add(child);
                if (offset >= data.Length && bytesRemaining > 0)
                {
                    Console.WriteLine("WARNING: " + bytesRemaining + " bytes remaining but no space left");
                }
            }
            return(bytesWritten);
        }
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data"> The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data </param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);

            /*
             * Modified by Zhang Zhang
             * Have a check between avaliable bytes and bytesRemaining,
             * take the avaliable length if the bytesRemaining out of range.
             * July 09, 2010
             */
            int avaliable = data.Length - (offset + 8);

            if (bytesRemaining > avaliable)
            {
                bytesRemaining = avaliable;
            }
            if (IsContainerRecord)
            {
                int bytesWritten = 0;
                thedata       = new byte[0];
                offset       += 8;
                bytesWritten += 8;
                while (bytesRemaining > 0)
                {
                    EscherRecord child             = recordFactory.CreateRecord(data, offset);
                    int          childBytesWritten = child.FillFields(data, offset, recordFactory);
                    bytesWritten   += childBytesWritten;
                    offset         += childBytesWritten;
                    bytesRemaining -= childBytesWritten;
                    ChildRecords.Add(child);
                }
                return(bytesWritten);
            }
            else
            {
                thedata = new byte[bytesRemaining];
                Array.Copy(data, offset + 8, thedata, 0, bytesRemaining);
                return(bytesRemaining + 8);
            }
        }
 /// <summary>
 /// Adds the child record.
 /// </summary>
 /// <param name="childRecord">The child record.</param>
 public void AddChildRecord(EscherRecord childRecord)
 {
     ChildRecords.Add(childRecord);
 }
Exemple #10
0
 protected void AddChildRecord(string childId, string childXRefId, string childTag, string childData)
 {
     ChildRecords.Add(new GEDCOMRecord(Level + 1, childId, childXRefId, childTag, childData));
 }
Exemple #11
0
        /// <summary>
        /// Fetch child records
        /// </summary>
        public async void GetChildRecords()
        {
            int addedBy;

            if (ChildRecords.Any())
            {
                ChildRecords.Clear();
            }

            var initialChildRecords = new List <ChildRecord>();

            if (Application.Current.Properties.ContainsKey("UserID"))
            {
                var isSuccess = int.TryParse(Application.Current.Properties["UserID"].ToString(), out addedBy);
                if (isSuccess)
                {
                    var childRecords        = (_studentService.GetStudentsByOfflineID(addedBy));
                    var testRecords         = (_clinicalTestFormService.GetStudentTestForms()).Where(x => x.FormStatus != "Not started").Select(x => x.LocalStudentId).ToList();
                    var filteredChildRecord = childRecords.FindAll(x => testRecords.Contains(x.OfflineStudentID));
                    foreach (var childRecord in filteredChildRecord)
                    {
                        if (childRecord.SelectedLocationId.HasValue && AllLocations != null && AllLocations.Any() && AllLocations.Where(p => p.IsEnabled).Any(p => p.LocationId == childRecord.SelectedLocationId.Value))
                        {
                            string birthdate = (childRecord.Birthdate.Month < 10 ? "0" + childRecord.Birthdate.Month : childRecord.Birthdate.Month + "") + "/" + (childRecord.Birthdate.Day < 10 ? "0" + childRecord.Birthdate.Day : childRecord.Birthdate.Day + "") + "/" + childRecord.Birthdate.Year;
                            initialChildRecords.Add(new ChildRecord()
                            {
                                Name             = childRecord.FirstName + " " + childRecord.LastName,
                                selected         = false,
                                Location         = AllLocations != null && AllLocations.Any() && childRecord.SelectedLocationId != null ? AllLocations.FirstOrDefault(p => p.LocationId == childRecord.SelectedLocationId.Value)?.LocationName : "",
                                LocationID       = (childRecord.SelectedLocationId == null) ? 0 : Convert.ToInt32(childRecord.SelectedLocationId),
                                OfflineStudentId = childRecord.OfflineStudentID,
                                DOB = birthdate
                            });
                        }
                    }
                    var list = initialChildRecords.OrderBy(a => a.LastName);
                    initialChildRecords = new List <ChildRecord>(list);

                    var searchChildRecords          = new List <ChildRecord>();
                    IEnumerable <ChildRecord> query = initialChildRecords;

                    if (SelectedLocations.Count > 0)
                    {
                        query = query.Where(p => !string.IsNullOrEmpty(p.Location) && SelectedLocations.Contains(p.Location));
                    }

                    searchChildRecords = new List <ChildRecord>(query);
                    foreach (var item in searchChildRecords)
                    {
                        ChildRecords.Add(item);
                    }
                }
            }

            if (ChildRecords.Count == 0)
            {
                SelectedChild = "No results found";
                IsChildRecordButtonEnabled = false;
                IsBatteryTypeButtonEnabled = false;
            }
            else
            {
                SelectedChild = null;
            }
        }