public void ValidateRequest_Default_Success() { var file = new LibraryFileInfo { Id = Guid.NewGuid(), TenantId = Guid.NewGuid(), AlternateId = Guid.NewGuid().ToString(), Attributes = "Hidden", ContentType = MediaTypeNames.Application.Octet, CreatedOn = DateTimeOffset.UtcNow, FullPath = "C:/foo.txt", Name = "foo.txt", LastAccessedOn = DateTimeOffset.UtcNow, LastModifiedOn = DateTimeOffset.UtcNow, Length = 123, ParentDirectoryId = Guid.NewGuid(), PartitionId = Guid.NewGuid(), }; LibraryItemInfo libItem = JsonConvert.DeserializeObject <LibraryItemInfo>(JsonConvert.SerializeObject(file)); libItem.Should().NotBeNull(); libItem.Should().BeOfType <LibraryFileInfo>(); LibraryFileInfo?newFile = libItem as LibraryFileInfo; newFile.Should().BeEquivalentTo(file); }
private async void ShowItemInfo(object sender, RoutedEventArgs e) { LibraryItem item = (sender as FrameworkElement).DataContext as LibraryItem; if (item != null) { LibraryItemInfo dialog = new LibraryItemInfo(item); await dialog.ShowAsync(); } }
private async Task <IEnumerable <string> > CreateSymbolAsync( LibraryItemInfo symbolInfo, string reference, string value, string footprint, string datasheet, IEnumerable <KeyValuePair <string, string> > customFields, bool bufferLibrary = true) { // Get symbol template var template = await _libraryReader.GetSymbolTemplateAsync(_symbolsDirectory, symbolInfo, bufferLibrary).ConfigureAwait(false); var result = template.ToList(); /* DEF value reference ... * F0 "Reference" ... * F1 "Value" ... * F2 "Footprint" ... * F3 "Datasheet" ... * F3+n "custom field value" ... "custom field name" */ // DEF value reference ... result[0] = Regex.Replace(result[0], "^DEF \\S+ \\S ", $"DEF {value} {reference} "); // F0 - F3 int lineIndex = 1; var replacement = new[] { reference, value, footprint, datasheet }; for (int fieldIndex = 0; fieldIndex < replacement.Length; fieldIndex++, lineIndex++) { result[lineIndex] = Regex.Replace( result[lineIndex], $"^F{fieldIndex} \".*?\"", $"F{fieldIndex} \"{replacement[fieldIndex]}\""); } // Remove remaining F... while (result[lineIndex].StartsWith('F')) { result.RemoveAt(lineIndex); } // Add custom fields result.InsertRange(lineIndex, CreateCustomFields(customFields)); return(result); }
public async Task Factory_Should_Read_Symbol() { // Arrange await KicadDownloader.DownloadSymbolFile("Device"); var symbolInfo = new LibraryItemInfo("Device", "R"); var factory = new KiCad6LibrarySymbolTemplateFactory(); // Act var symbol = await factory.GetSymbolTemplateAsync(Directory.GetCurrentDirectory(), symbolInfo); // Assert symbol.Should().NotBeNull(); symbol.Name.Should().Be("symbol"); symbol.Childs[0].Name.Should().Be("R"); }
public async Task <string[]> GetSymbolTemplateAsync(string directory, LibraryItemInfo symbolInfo, bool bufferLibrary = true) { var template = await GetSymbolAsync( libraryFilePath : Path.Combine(directory, symbolInfo.Library + FileExtensions.Lib), symbolName : symbolInfo.Name, bufferLibrary : bufferLibrary) .ConfigureAwait(false); // Remove empty lines var filtered = template.Where(line => !string.IsNullOrWhiteSpace(line)); // Remove lines starting with '#' filtered = filtered.Where(line => !line.StartsWith('#')); // Remove ALIAS filtered = filtered.Where(line => !line.StartsWith("ALIAS", StringComparison.OrdinalIgnoreCase));
private async Task WritePartToLibAsync( string reference, string value, LibraryItemInfo symbol, string footprint, string datasheet, IEnumerable <KeyValuePair <string, string> > customFields) { await _libWriter.WriteLineAsync($"# {value}").ConfigureAwait(false); await _libWriter.WriteLineAsync('#').ConfigureAwait(false); var createdSymbol = await CreateSymbolAsync(symbol, reference, value, footprint, datasheet, customFields).ConfigureAwait(false); foreach (var line in createdSymbol) { await _libWriter.WriteLineAsync(line).ConfigureAwait(false); } await _libWriter.WriteLineAsync('#').ConfigureAwait(false); }
public async Task WritePartAsync(Part part) { var symbolInfo = LibraryItemInfo.Parse(part.Symbol); var symbol = await _libraryReader.GetSymbolTemplateAsync(_symbolsDirectory, symbolInfo) .ConfigureAwait(false); SetSymbolId(symbol, part.Value); UpdateUnitIds(symbol, symbolInfo.Name, part.Value); SetPropertyByName(symbol, "Reference", part.Reference); SetPropertyByName(symbol, "Value", part.Value); SetPropertyByName(symbol, "Footprint", part.Footprint); SetPropertyByName(symbol, "Datasheet", string.IsNullOrEmpty(part.Datasheet) ? "~" : part.Datasheet); SetPropertyByName(symbol, "ki_keywords", part.Keywords); SetPropertyByName(symbol, "ki_description", part.Description); foreach (var customField in part.CustomFields.OrderBy(cf => cf.Key)) { AddCustomProperty(symbol, customField); } _root.Add(symbol); }
protected void Page_Load(object sender, EventArgs e) { //if (txtSelectedLabel.Value == "-1") //{ // pnlLabelA.Visible = false; // pnlLabelB.Visible = false; //} if (!Page.IsPostBack && Request.QueryString["tid"] != null) { AdminController aCont = new AdminController(); try { TaskInfo task = aCont.Get_TaskById(Convert.ToInt32(Request.QueryString["tid"])); if (task.Id != -1) { LibraryItemInfo lib = aCont.Get_LibraryItemById(task.LibraryId); WOGroupStationInfo station = aCont.Get_WorkOrderGroupStationById(task.StationId); ddlLabelTapeFormat.SelectedValue = station.DeliveryMethod.Replace("tf_", ""); ddlLabelAgency.SelectedValue = lib.AgencyId.ToString(); ddlLabelAdvertiser.SelectedValue = lib.AdvertiserId.ToString(); txtLabelTitle.Text = lib.Title; txtLabelDescription.Text = lib.ProductDescription; txtLabelISCI.Text = lib.ISCICode; txtLabelPMTMediaId.Text = lib.PMTMediaId; txtLabelLength.Text = lib.MediaLength; ddlLabelStandard.SelectedValue = lib.Standard; txtLabelWOId.Text = task.WorkOrderId.ToString(); txtSelectedLabel.Value = "-1"; txtLabelNumber.Text = (aCont.getMaxLabelNumber(PortalId) + 1).ToString(); } } catch { lblLabelMessage.Text = "Task Not Found for Label Creation."; } } }
public abstract void Delete_LibraryItem(LibraryItemInfo LibraryItem);
public abstract void Update_LibraryItem(LibraryItemInfo LibraryItem);
public abstract int Add_LibraryItemForImport(LibraryItemInfo LibraryItem);
public abstract int Add_LibraryItem(LibraryItemInfo LibraryItem);
// This is where I set up keyboard accelerators and do some ridiculous hacks // to get keyboard control+focus working the way I want it. // Space should ALWAYS toggle playback, unless the search box has focus. // Escape should clear+exit the search box. // Enter should start playing a file when in the file view #region KeyboardStuff private void SetUpKeyboardAccelerators() { KeyboardAccelerator CreateAccelerator(VirtualKeyModifiers modifier, VirtualKey key, TypedEventHandler <KeyboardAccelerator, KeyboardAcceleratorInvokedEventArgs> eventHandler) { KeyboardAccelerator ret = new KeyboardAccelerator() { Modifiers = modifier, Key = key }; ret.Invoked += eventHandler; return(ret); } //pull KeyboardAccelerator pullAccelerator = CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.P, async(sender, args) => { args.Handled = true; await ViewModel.PullEventsCommand.ExecuteAsync(null); }); KeyboardAccelerators.Add(pullAccelerator); //push KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift, VirtualKey.P, async(sender, args) => { args.Handled = true; await ViewModel.PushEventsCommand.ExecuteAsync(null); })); //search accelerator KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.F, (sender, args) => { args.Handled = true; FilterBox.Focus(FocusState.Keyboard); FilterBox.SelectAll(); })); //open local folder KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.E, async(sender, args) => { args.Handled = true; await Launcher.LaunchFolderAsync(Windows.Storage.ApplicationData.Current.LocalFolder); })); //open music folder KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.M, async(sender, args) => { args.Handled = true; await ViewModel.OpenLibraryFolder(); })); //open library DB KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.D, async(sender, args) => { args.Handled = true; Windows.Storage.StorageFile dbFile = await FileHelper.GetLibraryDbFileAsync(); await Launcher.LaunchFileAsync(dbFile); })); //show selected item(s) in File Explorer KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.L, async(sender, args) => { args.Handled = true; LibraryItem selected = (LibraryItem)libraryDataGrid.SelectedItem; await ViewModel.ShowItemInExplorer(selected); })); //show item info KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.I, async(sender, args) => { args.Handled = true; LibraryItem selected = libraryDataGrid.SelectedItem as LibraryItem; if (selected != null) { LibraryItemInfo dialog = new LibraryItemInfo(selected); await dialog.ShowAsync(); } })); //play a random bookmark KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.R, async(sender, args) => { args.Handled = true; await ViewModel.PlayRandomBookmark(); })); }
protected void Page_Load(object sender, EventArgs e) { AdminController aCont = new AdminController(); if (Tasks.Count() > 0) { lblWOId.Text = Tasks[0].WorkOrderId.ToString(); lblCompletionDate.Text = Tasks[0].DeliveryOrderDateComplete.ToShortDateString(); if (Tasks[0].CreatedById != -1) { UserInfo user = UserController.GetUserById(PortalId, Convert.ToInt32(Tasks[0].CreatedById)); lblOrderUser.Text = user.DisplayName; } lblDeliveryMethod.Text = Tasks[0].DeliveryMethod; WorkOrderInfo wo = aCont.Get_WorkOrderById(Tasks[0].WorkOrderId); AdvertiserInfo billTo = new AdvertiserInfo(); if (wo.BillToId != -1) { billTo = aCont.Get_AdvertiserById(wo.BillToId); } else { billTo = aCont.Get_AdvertiserById(wo.AdvertiserId); } litBillTo.Text = billTo.AdvertiserName + "<br />"; litBillTo.Text += billTo.Address1 + "<br />"; if (billTo.Address2 != "") { litBillTo.Text += billTo.Address2 + "<br />"; } litBillTo.Text += billTo.City + ", " + billTo.State + " " + billTo.Zip + "<br />"; WOGroupStationInfo wogroupStation = aCont.Get_WorkOrderGroupStationById(Tasks[0].StationId); StationInfo station = aCont.Get_StationById(wogroupStation.StationId); litShipTo.Text = station.StationName + "<br />"; litShipTo.Text += station.CallLetter + "<br />"; litShipTo.Text += station.Address1 + "<br />"; if (station.Address2 != "") { litShipTo.Text += station.Address2 + "<br />"; } if (station.Phone != "") { litShipTo.Text += "Tel: " + station.Phone + "<br />"; } if (station.Fax != "") { litShipTo.Text += "Fax: " + station.Fax + "<br />"; } if (station.Email != "") { litShipTo.Text += "Email: " + station.Email + "<br />"; } if (station.AttentionLine != "") { litShipTo.Text += "ATTENTION: " + station.AttentionLine + "<br />"; } litShipTo.Text += station.City + ", " + station.State + " " + station.Zip + "<br />"; plTasks.Controls.Clear(); foreach (TaskInfo Task in Tasks) { LibraryItemInfo lib = aCont.Get_LibraryItemById(Task.LibraryId); Literal lit = new Literal(); lit.Text = "<div class=\"pmtRow\"><div class=\"pmtCell2 outline\">" + Task.Quantity.ToString() + "</div>"; string desc = ""; try { desc = Task.Description.Substring(Task.Description.IndexOf("Station:"), (Task.Description.IndexOf(", Delivery Method")) - Task.Description.IndexOf("Station:")); } catch { } lit.Text += "<div class=\"pmtCell2 outline\">" + lib.Title + "</div>"; lit.Text += "<div class=\"pmtCell2 outline\">" + lib.ProductDescription + "</div>"; lit.Text += "<div class=\"pmtCell2 outline\">" + Task.DeliveryMethod + "</div>"; lit.Text += "<div class=\"pmtCell2 outline\">" + lib.MediaType.ToUpper() + "</div>"; lit.Text += "<div class=\"pmtCell2 outline\">" + lib.Standard + "</div>"; lit.Text += "<div class=\"pmtCell2 outline\">" + lib.MediaLength + "</div></div>"; plTasks.Controls.Add(lit); } } }
public string buildRequest(string ticket) { string req = ""; string[] custCodes = new string[6] { "CUSTOMIZATION 30 MIN", "HD CUSTOMIZATION 30 MIN", "SPOT CUSTOMIZATION", "HD CUSTOMIZATION SPOT", "CUSTOMIZATION 5 MIN", "HD CUSTOMIZATION 5 MIN" }; int custIndex = 2; int i = 1; string xmlString = ""; List <InvoiceInfo> invs = aCont.Get_InvoicesByToSend(); if (invs.Count > 0) { xmlString += "<?xml version=\"1.0\" encoding=\"utf-8\"?><?qbxml version=\"6.0\"?><QBXML><QBXMLMsgsRq onError=\"stopOnError\">"; //build array of xml foreach (InvoiceInfo inv in invs) { xmlString += "<InvoiceAddRq requestID=\"" + inv.Id.ToString() + "\"><InvoiceAdd>";// List <int> woIds = aCont.Get_WOInsByInvoiceId(inv.Id); if (woIds.Count > 0 && woIds[0] > 0) { WorkOrderInfo wo1 = aCont.Get_WorkOrderById(woIds[0]); AdvertiserInfo billto = aCont.Get_AdvertiserById(wo1.BillToId); if (billto.Id == -1) { billto = aCont.Get_AdvertiserById(wo1.AdvertiserId); } i++; xmlString += "<CustomerRef><FullName>" + billto.AdvertiserName.Trim().Replace("&", "&") + "</FullName></CustomerRef>"; xmlString += "<BillAddress><Addr1>" + billto.AdvertiserName.Trim().Replace("&", "&") + "</Addr1><Addr2>" + billto.Address1.Trim().Replace("&", "&"); if (billto.Address2.Trim() != "") { xmlString += " - " + billto.Address2.Trim().Replace("&", "&"); } xmlString += "</Addr2><City>" + billto.City.Trim().Replace("&", "&") + "</City><State>" + billto.State.Trim().Replace("&", "&") + "</State><PostalCode>" + billto.Zip.Trim().Replace("&", "&") + "</PostalCode><Country>" + billto.Country.Trim().Replace("&", "&") + "</Country></BillAddress>"; string po = wo1.PONumber; if (po == "") { try { po = wo1.Groups[0].LibraryItems[0].PMTMediaId.Replace("&", "&"); } catch { } } xmlString += "<PONumber>" + po.Replace("&", "&") + "</PONumber>"; if (woIds.Count == 1) { xmlString += "<FOB>WO: " + woIds[0].ToString() + "</FOB>"; } else if (woIds.Count > 1) { xmlString += "<FOB>SEE BELOW</FOB>"; } xmlString += "<Memo>" + inv.Id.ToString() + "</Memo>"; AgencyInfo ag = aCont.Get_AgencyById(wo1.AgencyId); xmlString += "<Other>" + ag.AgencyName.Trim().Replace("&", "&") + "</Other>"; foreach (int woId in woIds) { WorkOrderInfo wo = aCont.Get_WorkOrderById(woId); List <TaskInfo> tasks = aCont.Get_TasksByWOId(wo.Id); int groupId = -1; bool groupNew = true; for (int j = 0; j < tasks.Count; j++) { TaskInfo task = tasks[j]; if (groupId == -1) { groupId = task.WOGroupId; } if (task.WOGroupId != groupId) { groupNew = true; groupId = task.WOGroupId; } if (task.DeliveryStatus.ToLower() != "cancelled" && !task.isDeleted) { if (task.TaskType != GroupTypeEnum.Delivery) { WOGroupInfo group = aCont.Get_WorkOrderGroupById(task.WOGroupId); List <QBCodeInfo> servCodes = aCont.FindQBCodesByTask(task.Id, 0, true); LibraryItemInfo lib = aCont.Get_LibraryItemById(task.LibraryId); MasterItemInfo master = new MasterItemInfo(); if (task.TaskType == GroupTypeEnum.Non_Deliverable) { master = aCont.Get_MasterItemById(task.MasterId); } //foreach (ServiceInfo serv in group.Services) if (groupNew) { foreach (QBCodeInfo code in servCodes) { if (task.TaskType != GroupTypeEnum.Non_Deliverable) { xmlString += "<InvoiceLineAdd>"; xmlString += "<ItemRef><FullName>" + code.QBCode.Replace("&", "&") + "</FullName></ItemRef>"; xmlString += "<Desc>" + lib.Title.Replace("&", "&"); //code.QBCode.Replace("&", "&"); if (woIds.Count > 1 && j == 0) { xmlString += " WO " + wo.Id.ToString(); } xmlString += "</Desc>"; if (task.Quantity == 0) { task.Quantity = 1; } xmlString += "<Quantity>" + group.LibraryItems.Count.ToString() + "</Quantity>"; xmlString += "<Other1></Other1>"; xmlString += "<Other2></Other2></InvoiceLineAdd>"; } else { xmlString += "<InvoiceLineAdd>"; xmlString += "<ItemRef><FullName>" + code.QBCode.Replace("&", "&") + "</FullName></ItemRef>"; xmlString += "<Desc>" + master.Title.Replace("&", "&"); if (woIds.Count > 1 && j == 0) { xmlString += " WO " + wo.Id.ToString(); } xmlString += "</Desc>"; if (task.Quantity == 0) { task.Quantity = 1; } xmlString += "<Quantity>" + task.Quantity + "</Quantity>"; xmlString += "<Other1>" + lib.ProductDescription.Trim().Replace("&", "&") + "</Other1>"; xmlString += "<Other2>" + lib.ISCICode.Trim().Replace("&", "&") + "</Other2></InvoiceLineAdd>"; } } groupNew = false; } } if (task.TaskType == GroupTypeEnum.Bundle || task.TaskType == GroupTypeEnum.Delivery || task.TaskType == GroupTypeEnum.Customized) { LibraryItemInfo lib = aCont.Get_LibraryItemById(task.LibraryId); bool isHd = lib.MediaType.IndexOf("HD") != -1; string[] pcs = lib.MediaLength.Split(':'); int secs = 0; if (pcs.Length == 2) { try { secs = 60 * Convert.ToInt32(pcs[0]) + Convert.ToInt32(pcs[1]); } catch { } } if (secs <= 120 && !isHd) { custIndex = 2; } else if (secs <= 120 && isHd) { custIndex = 3; } else if (secs >= 1500 && secs <= 1800 && !isHd) { custIndex = 0; } else if (secs >= 1500 && secs <= 1800 && isHd) { custIndex = 1; } else if (secs >= 180 && secs <= 300 && !isHd) { custIndex = 4; } else if (secs >= 180 && secs <= 300 && !isHd) { custIndex = 5; } xmlString += "<InvoiceLineAdd>"; if (task.TaskType != GroupTypeEnum.Customized) { xmlString += "<ItemRef><FullName>" + task.QBCode.Trim().Replace("&", "&") + "</FullName></ItemRef>"; } else { xmlString += "<ItemRef><FullName>" + custCodes[custIndex] + "</FullName></ItemRef>"; } xmlString += "<Desc>" + lib.Title.Trim().Replace("&", "&"); if (woIds.Count > 1 && j == 0) { xmlString += " WO " + wo.Id.ToString(); } xmlString += "</Desc>"; if (task.Quantity == 0) { task.Quantity = 1; } xmlString += "<Quantity>" + task.Quantity + "</Quantity>"; xmlString += "<Other1>" + lib.ProductDescription.Trim().Replace("&", "&") + "</Other1>"; if (lib.TapeCode.Trim() == "") { xmlString += "<Other2>" + lib.ISCICode.Trim().Replace("&", "&") + "</Other2></InvoiceLineAdd>"; } else { xmlString += "<Other2>" + lib.TapeCode.Trim().Replace("&", "&") + "</Other2></InvoiceLineAdd>"; } WOGroupStationInfo station = aCont.Get_WorkOrderGroupStationById(task.StationId); if (station.DeliveryMethod.ToLower().IndexOf("tf_") != -1) { //check to see if we need to add shipping if (station.ShippingMethodId == -1) { int weight = 1; TapeFormatInfo tape = aCont.Get_TapeFormatById(Convert.ToInt32(station.DeliveryMethod.Replace("tf_", ""))); if (station.Quantity * tape.Weight > 1.0) { weight = 2; } string shippingPrice = ""; if (weight == 1) { if (station.PriorityId == 1) { shippingPrice = ConfigurationManager.AppSettings["FedEx1LbPriority"].ToString(); } else if (station.PriorityId == 2) { shippingPrice = ConfigurationManager.AppSettings["FedEx1LbStandard"].ToString(); } else if (station.PriorityId == 3) { shippingPrice = ConfigurationManager.AppSettings["FedEx1Lb2Day"].ToString(); } } else { if (station.PriorityId == 1) { shippingPrice = ConfigurationManager.AppSettings["FedEx2LbPriority"].ToString(); } else if (station.PriorityId == 2) { shippingPrice = ConfigurationManager.AppSettings["FedEx2LbStandard"].ToString(); } else if (station.PriorityId == 3) { shippingPrice = ConfigurationManager.AppSettings["FedEx2Lb2Day"].ToString(); } } xmlString += "<InvoiceLineAdd><ItemRef><FullName>SHIPPING</FullName></ItemRef><Desc>P" + station.PriorityId.ToString() + " " + weight.ToString() + "LB SHIPPING CHARGE</Desc><Quantity>1</Quantity><Rate>" + shippingPrice + "</Rate></InvoiceLineAdd>"; } } } } } } } xmlString += "</InvoiceAdd></InvoiceAddRq>"; //xmlString += ""; } xmlString += "</QBXMLMsgsRq></QBXML>"; req = xmlString; //} } return(req); }