Skip to content

alexjavad/C-Sharp-Examples

Repository files navigation

The Armstrong Freight Tracking System

The code below is entirely my own personal work written by myself, Alex Javad. Some files contain too many lines of code for a full screenshot. For readability, I’ve uploaded most of these files to GitHub. Feel free to examine my work here: https://github.com/alexjavad/C-Sharp-Examples I’ll make direct reference to some of these files in this document.

The following User Interface/Feature was built for Armstrong Transport Group, Inc. – a logistics company based in Concord, North Carolina. This is an integration with the Google Maps API, on the front-end, as well as the MacroPoint API on the backend. The MacroPoint API basically uses a truck driver’s cell phone, and triangulates the driver’s location, so that the people in the company can keep track of shipment progress, to make sure freight is being delivered on time.

The following is the backend C# code that is sending the MacroPoint API the information it needs in order to track the truck driver’s cell phone. When you “initiate tracking” the API will regularly send updates back to a “callback API” providing current coordinates, city, and zipcode information of the driver. This is the information that we then hand to the Google Maps API, to plot points along the driver’s route. Note the map above shows the origin of the shipment, and the stops the driver must make on his/her route to the destination (A, B, C). You can also notice in the bottom right of the above photo, that we made the system show the driver’s current city and state, when we receive an update.

To view the entire code for the MacroPoint integration, please do so here: https://github.com/alexjavad/C-Sharp-Examples/blob/master/MacroPointService.cs

Building the XML data to “Initiate Tracking” with the MacroPoint API on a Load via HTTP:

Actually issuing the XML payload to “Initiate Tracking” to the MacroPoint API:

This is the “callback API” that is configured to receive location updates from MacroPoint, and store that as a “comment” on a Load:

You can see the entire LoadController (with various MacroPoint callback APIs) here: https://github.com/alexjavad/C-Sharp-Examples/blob/master/LoadController.cs

The following is a chart tracking the performance of the sales team by group, person, and manager. The code below produces the user interface directly above this sentence. The pie charts seen above are Telerik/Kendo UI Controls. We used Vue.js to streamline JavaScript development, it is utilized in the code below.

<style> .no-wrap { white-space: no-wrap; } .report-column{ border-right: 1px solid #DDD; min-height: 500px; background-color: transparent; transition: background-color 1s; } .report-column h4{ font-weight: bold; border-bottom: 1px solid #CCC; color: #828282; } .report-column:hover{ background-color: #F1F1F1; } .date-selector{ border-bottom: 1px solid #CCC; } </style> <script type="text/template" id="Tpl-Manager-Office-Revenue">
{{months[selectIndex]}} {{selectYear}}

Revenue By Group

No data available for this month
Group Revenue Profit
{{group.Name}} {{group.Revenue | currency}} {{group.Profit | currency}}

Revenue By Agent

No data available for this month
Rep Revenue Profit
{{user.Name}} {{user.Revenue | currency}} {{user.Profit | currency}}

Revenue By Sales Manager

No data available for this month
Rep Revenue Profit
{{user.Name}} {{user.Revenue | currency}} {{user.Profit | currency}}

Loads Covered

No data available for this month

{{user.Name}} {{user.NumLoads | number}}
</script> <script type="text/javascript"> ATG.Vue.Component.OfficeStats = Vue.extend({ template: $("#Tpl-Manager-Office-Revenue").html(), data: function () { return { months: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], selectYear: new Date().getFullYear(), selectIndex: new Date().getMonth(), OfficeId: null } }, ready: function () { var self = this; //fetch data for this month this.fetchData( this.selectIndex, this.selectYear); }, watch: { 'selectIndex': function (month, oldVal) { if (oldVal == 11 && month == 0) this.$set("selectYear", ++this.selectYear) if (oldVal == 0 && month == 11) this.$set("selectYear", --this.selectYear); //fetch data for new month this.fetchData(month, this.selectYear, this.OfficeId); } }, methods: { fetchData: function (month, year, officeId) { month++; var self = this; self.$set("OfficeId", officeId); $(self.$els.loadsCoveredChart) .add(self.$els.byUserChart) .add(self.$els.byGroupChart) .add(self.$els.bySalesmanagerChart) .each(function () { if ($(this).data("kendoChart")) $(this).empty().data("kendoChart").destroy(); }); //get loads covered by user var url = ATG.Utility.buildUrl("/Dashboard/GetLoadsCoveredByUser", { month: month, year: year, officeId: officeId }); ATG.DashboardStore.get(url, '1h').done(function (data) { var sortedData = self._sortData(data, "NumLoads"); self.$set("LoadsCoveredByUser", sortedData); self.barGraph(sortedData, self.$els.loadsCoveredChart, "NumLoads"); }); //get revenue by user url = ATG.Utility.buildUrl("/Dashboard/GetRevenueByUser", { month: month, year: year, officeId: officeId }) ATG.DashboardStore.get(url, '1h').done(function (data) { var sortedData = self._sortData(data, "Profit"); self.$set("RevenueByUser", sortedData); self.pieChart(sortedData, self.$els.byUserChart, "Profit"); }); url = ATG.Utility.buildUrl("/Dashboard/GetRevenueBySalesManager", { month: month, year: year, officeId: officeId }) ATG.DashboardStore.get(url, '4h').done(function (data) { var sortedData = self._sortData(data, "Profit"); self.$set("RevenueBySalesManager", sortedData); self.pieChart(sortedData, self.$els.bySalesmanagerChart, "Profit"); }); //get revenue by group url = ATG.Utility.buildUrl("/Dashboard/GetRevenueByGroup", { month: month, year: year, officeId: officeId }); ATG.DashboardStore.get(url, '4h').done(function (data) { var sortedData = self._sortData(data, "Profit"); self.$set("RevenueByGroup", sortedData); self.pieChart(sortedData, self.$els.byGroupChart, "Profit"); }); }, changeIndex: function (dir) { (dir == "add") ? this.$set("selectIndex", ++this.selectIndex % 12) : this.$set("selectIndex", (this.selectIndex == 0) ? 11 : --this.selectIndex); }, pieChart: function (dataArray, chartId, field) { var data = []; var sumTotal = _.sum(_.pluck(dataArray, field)); var self = this; _.each(dataArray, function (item) { var val = ((item[field] / sumTotal) * 100).toFixed(1); data.push({ category: item.Name, value: val }); }); $(chartId).kendoChart({ seriesColors: ["#00b300", "#00cc99", "#60b644", "#656338", "#00ccff", "#0f497b", "#080b1c", "#ff0044", "#8e00ff", "#7a8b8b"], legend: { position: "left" }, seriesDefaults: { labels: { visible: true, format: "{0}%" } }, series: [{ type: "pie", data: data }], tooltip: { visible: true, format: "N0", template: "#= category # - #= kendo.format('{0:P}', percentage)#" } }); }, barGraph: function (dataArray, chartId, field) { var data = []; var sumTotal = _.sum(_.pluck(dataArray, field)); var self = this; _.each(dataArray, function (item) { data.push({ category: item.Name, value: item[field] }); }); $(chartId).kendoChart({ seriesColors: ["#00b300", "#00cc99", "#60b644", "#656338", "#00ccff", "#0f497b", "#080b1c", "#ff0044", "#8e00ff", "#7a8b8b"], seriesDefaults: { labels: { visible: true, format: "{0}" } }, series: [{ type: "bar", data: data }], categoryAxis:{ categories: _.pluck(dataArray,"Name") } }); }, _sortData: function (dataArray, field) { var self = this; var sortedData = _.sortBy(dataArray, function (item) { return item[field]; }); return sortedData.reverse(); } }, }); </script>

RESTful Web Services for Armstrong Dashboard:

… and Associated Business Later/Data Access Layer:

… and the Associated Business Logic/Data Access Layer:

To view this entire file please visit: https://github.com/alexjavad/C-Sharp-Examples/blob/master/DashboardBusiness.cs

Dashboard related SQL stored Procedures:

Please let me know if you have any questions regarding the above.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages