/// <summary> /// Assemblyes route's values string. /// </summary> /// <param name="fields">Exported fields.</param> /// <param name="data">Data keeper.</param> /// <param name="scheduleId">Schedule ID.</param> /// <param name="route">Route to exporting.</param> /// <param name="tracker">Cancel tracker (can be null).</param> /// <returns>Route's values string.</returns> private string _AssemblyRouteString(ICollection <string> fields, DataKeeper data, Guid scheduleId, Route route, ICancelTracker tracker) { bool isSeparatorNeed = false; var sb = new StringBuilder(); foreach (string field in fields) { _CheckCancelState(tracker); if (isSeparatorNeed) { sb.Append(_separator); } DataWrapper value = data.GetRouteFieldValue(field, scheduleId, route); sb.Append(_FormatFieldValue(value)); isSeparatorNeed = true; } return(sb.ToString()); }
/// <summary> /// Writes routes. /// </summary> /// <param name="schedules">Schedules to export.</param> /// <param name="routes">Routes to export.</param> /// <param name="fields">Fields to export.</param> /// <param name="data">Data keeper.</param> /// <param name="imageExporter">Map image exporter.</param> /// <param name="table">Table to data writing.</param> /// <param name="tracker">Cancel tracker (can be null).</param> private void _WriteRoutes(ICollection <Schedule> schedules, ICollection <Route> routes, ICollection <string> fields, DataKeeper data, MapImageExporter imageExporter, DataTable table, ICancelTracker tracker) { foreach (Schedule schedule in schedules) { _CheckCancelState(tracker); Guid scheduleID = schedule.Id; foreach (Route route in schedule.Routes) { _CheckCancelState(tracker); if ((null != routes) && !routes.Contains(route)) { continue; // NOTE: skeep not selected } if ((null == route.Stops) || (0 == route.Stops.Count)) { continue; // NOTE: skeep empty routes } DataRow dr = table.NewRow(); foreach (string field in fields) { if ("OverviewMap" == field) { // special routine Debug.Assert(null != imageExporter); _CheckCancelState(tracker); Image image = imageExporter.GetRouteImage(route, ROUTE_MAP_IMAGE_SIZE_X, ROUTE_MAP_IMAGE_SIZE_Y, IMAGE_DPI); dr[field] = _ConvertImageToBlob(image); if (null != image) { image.Dispose(); image = null; } } else { Debug.Assert("PlannedDate" != field); // NOTE: do not supported dr[field] = _FormatFieldValue(data.GetRouteFieldValue(field, scheduleID, route)); } } table.Rows.Add(dr); } } }
/// <summary> /// Writes routes. /// </summary> /// <param name="schedules">Schedules to export.</param> /// <param name="routes">Routes to export.</param> /// <param name="fields">Fields to export.</param> /// <param name="data">Data keeper.</param> /// <param name="imageExporter">Map image exporter.</param> /// <param name="table">Table to data writing.</param> /// <param name="tracker">Cancel tracker (can be null).</param> private void _WriteRoutes(ICollection<Schedule> schedules, ICollection<Route> routes, ICollection<string> fields, DataKeeper data, MapImageExporter imageExporter, DataTable table, ICancelTracker tracker) { foreach (Schedule schedule in schedules) { _CheckCancelState(tracker); Guid scheduleID = schedule.Id; foreach (Route route in schedule.Routes) { _CheckCancelState(tracker); if ((null != routes) && !routes.Contains(route)) continue; // NOTE: skeep not selected if ((null == route.Stops) || (0 == route.Stops.Count)) continue; // NOTE: skeep empty routes DataRow dr = table.NewRow(); foreach (string field in fields) { if ("OverviewMap" == field) { // special routine Debug.Assert(null != imageExporter); _CheckCancelState(tracker); Image image = imageExporter.GetRouteImage(route, ROUTE_MAP_IMAGE_SIZE_X, ROUTE_MAP_IMAGE_SIZE_Y, IMAGE_DPI); dr[field] = _ConvertImageToBlob(image); if (null != image) { image.Dispose(); image = null; } } else { Debug.Assert("PlannedDate" != field); // NOTE: do not supported dr[field] = _FormatFieldValue(data.GetRouteFieldValue(field, scheduleID, route)); } } table.Rows.Add(dr); } } }
/// <summary> /// Assemblyes route's values string. /// </summary> /// <param name="fields">Exported fields.</param> /// <param name="data">Data keeper.</param> /// <param name="scheduleId">Schedule ID.</param> /// <param name="route">Route to exporting.</param> /// <param name="tracker">Cancel tracker (can be null).</param> /// <returns>Route's values string.</returns> private string _AssemblyRouteString(ICollection<string> fields, DataKeeper data, Guid scheduleId, Route route, ICancelTracker tracker) { bool isSeparatorNeed = false; var sb = new StringBuilder(); foreach (string field in fields) { _CheckCancelState(tracker); if (isSeparatorNeed) sb.Append(_separator); DataWrapper value = data.GetRouteFieldValue(field, scheduleId, route); sb.Append(_FormatFieldValue(value)); isSeparatorNeed = true; } return sb.ToString(); }