/// <summary> /// Writes all specials up to the specified location. /// </summary> public void AcceptPoint(Location loc, INode node, SpecialLocation location) { while (available && enumerator.Current.StartPosition <= loc) { WriteCurrent(node, location); } }
/// <summary> /// Retrieve the Section ID for the specified special location /// </summary> /// <param name="oneNoteApplication"></param> /// <param name="specialLocation">SpecialLocation</param> /// <returns>string with section ID</returns> private static string GetSectionId(IOneNoteApplication oneNoteApplication, SpecialLocation specialLocation) { if (oneNoteApplication == null) { return(null); } // ReSharper disable once RedundantAssignment var unfiledNotesPath = ""; oneNoteApplication.GetSpecialLocation(specialLocation, out unfiledNotesPath); // ReSharper disable once RedundantAssignment var notebookXml = ""; oneNoteApplication.GetHierarchy("", HierarchyScope.hsPages, out notebookXml, XMLSchema.xs2010); if (string.IsNullOrEmpty(notebookXml)) { return(null); } Log.Debug().WriteLine(notebookXml); StringReader reader = null; try { reader = new StringReader(notebookXml); using (var xmlReader = new XmlTextReader(reader)) { while (xmlReader.Read()) { if (!"one:Section".Equals(xmlReader.Name)) { continue; } var id = xmlReader.GetAttribute("ID"); var path = xmlReader.GetAttribute("path"); if (unfiledNotesPath.Equals(path)) { return(id); } } } } finally { reader?.Dispose(); } return(null); }
public Transform GetLocation(SpecialLocation location, CharacterView view) { if (view == CharacterView.FirstPerson) { CheckP1Cache(); _wardrobeController.RefreshP1BonePosition(); return(_cacheP1Transform[(int)location]); } else { CheckP3Cache(); return(_cacheP3Transform[(int)location]); } }
public Transform GetLocation(GameObject obj, SpecialLocation location, bool containsUnActive = false) { if (null == obj) { return(null); } if (_specialLocationName.ContainsKey(location)) { foreach (string boneName in _specialLocationName[location]) { var transform = FindChildBoneFromCache(obj, boneName, false, containsUnActive); if (transform != null) { return(transform); } } } return(null); }
/// <summary> /// Retrieve the Section ID for the specified special location /// </summary> /// <param name="oneNoteApplication"></param> /// <param name="specialLocation">SpecialLocation</param> /// <returns>string with section ID</returns> private static string GetSectionID(IOneNoteApplication oneNoteApplication, SpecialLocation specialLocation) { if (oneNoteApplication == null) { return(null); } string unfiledNotesPath = ""; oneNoteApplication.GetSpecialLocation(specialLocation, out unfiledNotesPath); string notebookXml = ""; oneNoteApplication.GetHierarchy("", HierarchyScope.hsPages, out notebookXml, XMLSchema.xs2010); if (!string.IsNullOrEmpty(notebookXml)) { LOG.Debug(notebookXml); StringReader reader = null; try { reader = new StringReader(notebookXml); using (XmlTextReader xmlReader = new XmlTextReader(reader)) { while (xmlReader.Read()) { if ("one:Section".Equals(xmlReader.Name)) { string id = xmlReader.GetAttribute("ID"); string path = xmlReader.GetAttribute("path"); if (unfiledNotesPath.Equals(path)) { return(id); } } } } } finally { if (reader != null) { reader.Dispose(); } } } return(null); }
void WriteCurrent(INode node, SpecialLocation location) { SpecialsContainer container = node.UserData as SpecialsContainer; if (container == null) { container = new SpecialsContainer(); node.UserData = container; } if (location == SpecialLocation.NodeStart) { container.NodeStart.Add(enumerator.Current); } else { container.NodeEnd.Add(enumerator.Current); } available = enumerator.MoveNext(); }
public GameObject SearchingStart(GameObject obj, SpecialLocation location) { if (null == obj) { return(null); } if (_searchStartLocator.ContainsKey(location)) { var transform = FindChildBoneFromCache(obj, _searchStartLocator[location]); if (null == transform) { return(null); } return(transform.gameObject); } else { return(obj); } }
public void TestRoundTripLocation() { var instance = new SpecialLocation(); var stream = new MemoryStream(); var writer = new ObjectWriter(stream); writer.WriteValue(instance); writer.Dispose(); stream.Position = 0; var reader = new ObjectReader(stream); var instance2 = (Location)reader.ReadValue(); reader.Dispose(); Assert.NotNull(instance2); Assert.Equal(instance2.GetType(), typeof(SerializedLocation)); Assert.Equal(instance.Kind, instance2.Kind); Assert.Equal(instance.IsInSource, instance2.IsInSource); Assert.Equal(instance.SourceSpan, instance2.SourceSpan); Assert.Equal(instance.Kind, instance2.Kind); }
/// <summary> /// Retrieve the Section ID for the specified special location /// </summary> /// <param name="oneNoteApplication"></param> /// <param name="specialLocation">SpecialLocation</param> /// <returns>string with section ID</returns> private static string GetSectionID(IOneNoteApplication oneNoteApplication, SpecialLocation specialLocation) { if(oneNoteApplication == null) { return null; } string unfiledNotesPath = ""; oneNoteApplication.GetSpecialLocation(specialLocation, out unfiledNotesPath); string notebookXml = ""; oneNoteApplication.GetHierarchy("", HierarchyScope.hsPages, out notebookXml, XMLSchema.xs2010); if(!string.IsNullOrEmpty(notebookXml)) { LOG.Debug(notebookXml); StringReader reader = null; try { reader = new StringReader(notebookXml); using(XmlTextReader xmlReader = new XmlTextReader(reader)) { while(xmlReader.Read()) { if("one:Section".Equals(xmlReader.Name)) { string id = xmlReader.GetAttribute("ID"); string path = xmlReader.GetAttribute("path"); if(unfiledNotesPath.Equals(path)) { return id; } } } } } finally { if(reader != null) { reader.Dispose(); } } } return null; }
private void generateVescoSpreadSheet(string _fullPath) { Excel.Application excelObj2 = new Excel.Application(); Excel.Workbook vescoExcelWorkbook = null; Excel.Worksheet vescoExcelWorksheet = null; Excel.Worksheet locationWorkSheet = null; Excel.Range locationRange = null; Excel.Worksheet driverExcelWorksheet = null; Excel.Range driverRange = null; ExecutedOrder tempAssExOrder; try { vescoExcelWorkbook = excelObj2.Workbooks.Open(Properties.templateDir + "Associated Template.xlsx"); if (assExOrders.Count > 0) { driverExcelWorksheet = (Excel.Worksheet)vescoExcelWorkbook.Sheets.get_Item("Driver"); driverRange = driverExcelWorksheet.UsedRange; int driverRowCount = driverRange.Rows.Count; int driverCount = 0; String tempDriverId; DateTime tempDateTime; DateTime earliestStartTime; DateTime dayEndsAt; double hoursElapsed; double newDrivingHours; double newDutyHours; // loop through all the drivers for (int i = 2; i <= driverRowCount; i++) // Start at the second row and skip the header { tempDriverId = driverRange[i, 1].Value2.ToString(); // find if this driver has been added to the list tempAssExOrder = assExOrders.Find( delegate(ExecutedOrder aeo) { return(aeo.Driver == tempDriverId); } ); if (tempAssExOrder != null) { tempDateTime = DateTime.FromOADate(driverRange[i, 4].Value2); earliestStartTime = tempAssExOrder.dtDevliveryDateTime.Date.AddHours(tempDateTime.Hour); dayEndsAt = earliestStartTime.AddHours(driverRange[i, 3].Value2); hoursElapsed = tempAssExOrder.dtDevliveryDateTime.Subtract(earliestStartTime).TotalHours; newDrivingHours = Convert.ToDouble(driverRange[i, 2].Value2) - hoursElapsed; newDrivingHours = newDrivingHours > 0 ? newDrivingHours : 0.0; newDutyHours = Convert.ToDouble(driverRange[i, 3].Value2) - hoursElapsed; newDutyHours = newDutyHours > 0 ? newDutyHours : 0.0; Console.WriteLine("Earliest Start Time -> " + earliestStartTime); Console.WriteLine("Available Driving Hours -> " + driverRange[i, 2].Value2); Console.WriteLine("Available Duty Hours -> " + driverRange[i, 3].Value2); Console.WriteLine("Last Delivery Time -> " + tempAssExOrder.dtDevliveryDateTime); Console.WriteLine("\tHours Elapsed -> " + hoursElapsed); Console.WriteLine("\tNew Earliest Start Time -> " + tempAssExOrder.dtDevliveryDateTime); Console.WriteLine("\tNew Driving Hours -> " + newDrivingHours); Console.WriteLine("\tNew Duty Hours -> " + newDutyHours); Console.WriteLine(); driverExcelWorksheet.Cells[i, 2] = newDrivingHours; driverExcelWorksheet.Cells[i, 3] = newDutyHours; driverExcelWorksheet.Cells[i, 4] = tempAssExOrder.dtDevliveryDateTime; driverExcelWorksheet.Cells[i, 5] = tempAssExOrder.DeliverTo; driverCount++; assExOrders.Remove(tempAssExOrder); } } } VescoLog.LogEvent(vescoOrders.Count().ToString()); List <String> badAssociatedOrders = AssociatedConverter.badOrders; foreach (String b in badAssociatedOrders) { Console.Out.WriteLine("Bad Associated Order#," + b); } VescoLog.LogEvent(AppDomain.CurrentDomain.BaseDirectory); vescoExcelWorksheet = (Excel.Worksheet)vescoExcelWorkbook.Sheets.get_Item("RouteStop"); //Location based stop delay locationWorkSheet = (Excel.Worksheet)vescoExcelWorkbook.Sheets.get_Item("Location"); locationRange = locationWorkSheet.UsedRange; int locationRowCount = locationRange.Rows.Count; List <SpecialLocation> specialLocations = new List <SpecialLocation>(); SpecialLocation specialLocation; for (int i = 2; i <= locationRowCount; i++) // Start at the second row and skip the header { if (locationRange[i, 6].Value2 != null) { specialLocation = new SpecialLocation(); specialLocation.Name = locationRange[i, 1].Value2.ToString(); specialLocation.Address = locationRange[i, 2].Value2.ToString(); specialLocation.StopDelay = locationRange[i, 6].Value2.ToString(); specialLocations.Add(specialLocation); } } specialLocation = new SpecialLocation(); String stopActionCode; String windowStart = null; int row = 2; //Add the converted orders foreach (VescoOrder vo in vescoOrders) { vescoExcelWorksheet.Cells[row, 1] = vo.Job; vescoExcelWorksheet.Cells[row, 2] = vo.Sequence; vescoExcelWorksheet.Cells[row, 3] = vo.StopAction; vescoExcelWorksheet.Cells[row, 4] = vo.Location; vescoExcelWorksheet.Cells[row, 5] = vo.Address; specialLocation = specialLocations.Find(item => item.Name == vo.Location && item.Address == vo.Address); stopActionCode = vo.StopAction.Split('-')[0]; if ("11".Equals(stopActionCode) || "12".Equals(stopActionCode)) { if (specialLocation != null) { vescoExcelWorksheet.Cells[row, 6] = specialLocation.StopDelay; } else { vescoExcelWorksheet.Cells[row, 6] = "60"; } } else { vescoExcelWorksheet.Cells[row, 6] = vo.StopDelay; } if (vo.WindowStart != null) { windowStart = (vo.WindowStart.Equals(vo.WindowEnd) ? null : vo.WindowStart); } else { windowStart = null; } vescoExcelWorksheet.Cells[row, 7] = windowStart; vescoExcelWorksheet.Cells[row, 8] = vo.WindowEnd; vescoExcelWorksheet.Cells[row, 9] = vo.Hazardous; vescoExcelWorksheet.Cells[row, 10] = vo.Overweight; vescoExcelWorksheet.Cells[row, 11] = vo.OriginalLegNumber; vescoExcelWorksheet.Cells[row, 12] = vo.ContainerNumber; vescoExcelWorksheet.Cells[row, 13] = vo.SteamshipLine; vescoExcelWorksheet.Cells[row, 14] = vo.LiveLoad; vescoExcelWorksheet.Cells[row, 15] = vo.OriginalLegType; vescoExcelWorksheet.Cells[row, 16] = vo.DispatcherSequence; row++; } // Delete the Vesco file first since I can't figure out how to get rid of the confirmation dialog File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\Templates\\Vesco.xlsx"); vescoExcelWorkbook.SaveAs( AppDomain.CurrentDomain.BaseDirectory + "Templates\\Vesco.xlsx", Excel.XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing, false, false, Excel.XlSaveAsAccessMode.xlNoChange, Excel.XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing, Type.Missing, Type.Missing); } catch (Exception ex) { VescoLog.LogEvent(ex.StackTrace); } finally { if (vescoExcelWorksheet != null) { Marshal.ReleaseComObject(vescoExcelWorksheet); } if (vescoExcelWorkbook != null) { Marshal.ReleaseComObject(vescoExcelWorkbook); } if (excelObj2 != null) { excelObj2.Quit(); Marshal.ReleaseComObject(excelObj2); } } String path = _fullPath + (isExecuted ? "," + executedFileName : ""); Vesco vesco = new Vesco(isExecuted, vescoOrders, badOrders, path, "Associated"); vesco.performSteps(); }