private void GetEmployeePayrollHistoryData(XElement mdaConsolidationXElement, TransData data) { if (!mdaConsolidationXElement.Elements(Constant.EMPLOYEE_PAYROLLHISTORY_TABLE).Any()) mdaConsolidationXElement.Add(new XElement(Constant.EMPLOYEE_PAYROLLHISTORY_TABLE, new XAttribute("SyncPeriod", data.SyncPeriod))); if (mdaConsolidationXElement.Elements(Constant.EMPLOYEE_PAYROLLHISTORY_TABLE) .Where(x => x.Attribute("SyncPeriod").Value == data.SyncPeriod.ToString()).Count() > 0) new ArgumentException(string.Format("Duplicate payroll periods for mda {0}", data.MdaId)); XElement payrollHistoryXElement = mdaConsolidationXElement.Elements(Constant.EMPLOYEE_PAYROLLHISTORY_TABLE).FirstOrDefault(x => x.Attribute("SyncPeriod").Value == data.SyncPeriod.ToString()); if (payrollHistoryXElement == null) mdaConsolidationXElement.Add(payrollHistoryXElement = new XElement(Constant.EMPLOYEE_PAYROLLHISTORY_TABLE, new XAttribute("SyncPeriod", data.SyncPeriod))); payrollHistoryXElement.Add(GetSyncDataRow(data)); using (SsepsIISynEntities ents = new SsepsIISynEntities()) { payrollHistoryXElement.Add(new XElement("History-data")); foreach (EmployeePayrollHistory empPH in ents.EmployeePayrollHistories.Where(x => x.mdaID == data.MdaId && x.payrollPeriod == data.SyncPeriod).ToList()) { payrollHistoryXElement.Element("History-data").Add(new XElement(empPH.AsXmlRow)); } } }
private static XElement GetSyncDataRow(TransData data) { return new XElement("Row", new XElement("Guid", data.RowGuid), new XElement("ActionType", data.ActionType), new XElement("TableName", data.TableName), new XElement("TransDate", data.TransDate), new XElement("OldValues", data.OldValues), new XElement("NewValues", data.NewValues), new XElement("EmployeeID", data.EmployeeID), new XElement("SyncPeriod", data.SyncPeriod), new XElement("MdaId", data.MdaId), new XElement("LogRefID", data.LogRefID), new XElement("Username", data.Username), new XElement("state", data.state) ); }
private void GetConsolidationData(XElement consolidationXElement, TransData data) { if (!consolidationXElement.Elements("MDA").Any()) consolidationXElement.Add(new XElement("MDA", new XAttribute("Id", data.MdaId))); XElement mdaConsolidationXElement = consolidationXElement.Elements("MDA").FirstOrDefault(x => x.Attribute("Id").Value == data.MdaId.ToString()); if (mdaConsolidationXElement == null) { consolidationXElement.Add(mdaConsolidationXElement = new XElement("MDA", new XAttribute("Id", data.MdaId))); } //PayrollHistory if (data.TableName == Constant.EMPLOYEE_PAYROLLHISTORY_TABLE) { GetEmployeePayrollHistoryData(mdaConsolidationXElement, data); } }
private void GetSyncData(XElement syncXElement, TransData data) { if (!syncXElement.Elements("MDA").Any()) syncXElement.Add(new XElement("MDA", new XAttribute("Id", data.MdaId))); XElement mdaXElement = syncXElement.Elements("MDA").FirstOrDefault(x => x.Attribute("Id").Value == data.MdaId.ToString()); if (mdaXElement != null) { mdaXElement.Add(GetSyncDataRow(data)); } else { syncXElement.Add( new XElement("MDA", new XAttribute("Id", data.MdaId), GetSyncDataRow(data))); } }