first commit
This commit is contained in:
commit
50dfcf7e14
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
.vs
|
||||
InventarManager/bin
|
||||
InventarManager/obj
|
||||
settings.conf
|
||||
4
InventarManager.slnx
Normal file
4
InventarManager.slnx
Normal file
@ -0,0 +1,4 @@
|
||||
<Solution>
|
||||
<Project Path="../Librarys/litjson/litjson/litjson.csproj" />
|
||||
<Project Path="InventarManager/InventarManager.csproj" />
|
||||
</Solution>
|
||||
38
InventarManager/AGENTS.md
Normal file
38
InventarManager/AGENTS.md
Normal file
@ -0,0 +1,38 @@
|
||||
# Repository Guidelines
|
||||
|
||||
## Project Overview
|
||||
|
||||
`InventarManager` is a .NET Windows Forms application focused on asset and master data management (e.g., manufacturers, models, etc.). It serves as a central hub to synchronize data across three different platforms: **Inventree**, **Netbox**, and **SnipeIT**. Additionally, the application supports the generation of asset labels.
|
||||
|
||||
## Project Structure & Module Organization
|
||||
|
||||
The project is a .NET Windows Forms application organized as follows:
|
||||
|
||||
- `Apis/`: Contains integration logic for external services (e.g., `Inventree.cs`, `Netbox.cs`, `SnipeIT.cs`).
|
||||
- `Helper/`: Contains utility classes and helper functions (e.g., `WebRequest.cs`).
|
||||
- `Models/`: Contains the data models used throughout the application.
|
||||
- `Form1.cs`: The primary user interface component.
|
||||
|
||||
## Build, Test, and Development Commands
|
||||
|
||||
The project is designed to be developed using **Visual Studio**.
|
||||
|
||||
- **Build**: Use `dotnet build` from the terminal or the Build command in Visual Studio.
|
||||
- **Run**: Use `dotnet run` or the Start button in Visual Studio.
|
||||
|
||||
## Coding Style & Naming Conventions
|
||||
|
||||
- **Language**: C# (.NET 10.0)
|
||||
- **Naming**: Follow standard .NET conventions:
|
||||
- `PascalCase` for classes, methods, and properties.
|
||||
- `camelCase` for local variables and private fields.
|
||||
- **Features**: The project utilizes `ImplicitUsings` and nullable reference types.
|
||||
|
||||
## Testing Guidelines
|
||||
|
||||
There are currently no automated tests included in this repository.
|
||||
|
||||
## Commit & Pull Request Guidelines
|
||||
|
||||
- **Commit Messages**: Keep commit messages concise and descriptive of the changes (e.g., `Add feature X`, `Fix bug Y`).
|
||||
- **Pull Requests**: Ensure all changes are documented and tested locally before submission.
|
||||
44
InventarManager/Apis/Inventree.cs
Normal file
44
InventarManager/Apis/Inventree.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using BlubbFish.Applications.InventarManager.Helpers;
|
||||
using BlubbFish.Applications.InventarManager.Models.Specific.Inventree;
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.Applications.InventarManager.Apis {
|
||||
class Inventree {
|
||||
private String server;
|
||||
private String key;
|
||||
private WebRequest http;
|
||||
|
||||
public Inventree(String server, String key) {
|
||||
this.server = server;
|
||||
this.key = key;
|
||||
this.http = new WebRequest();
|
||||
this.http.SetAuthToken(this.key);
|
||||
}
|
||||
|
||||
public Boolean Connect() {
|
||||
try {
|
||||
JsonData json = JsonMapper.ToObject(this.http.RequestString("https://" + this.server + "/api/version/"));
|
||||
if(json.ContainsKey("version") && json["version"].IsObject && json["version"].ContainsKey("server") && json["version"]["server"].IsString && json["version"]["server"].ToString().StartsWith("1")) {
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<InventreeManufacturer> GetManufacturer() {
|
||||
try {
|
||||
SortedSet<InventreeManufacturer> ret = [];
|
||||
JsonData json = JsonMapper.ToObject(this.http.RequestString("https://" + this.server + "/api/company/?is_manufacturer=true"));
|
||||
if(json.IsArray && json.Count > 0) {
|
||||
foreach(JsonData man in json) {
|
||||
ret.Add(new InventreeManufacturer(man));
|
||||
}
|
||||
}
|
||||
return [.. ret];
|
||||
} catch {
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
44
InventarManager/Apis/Netbox.cs
Normal file
44
InventarManager/Apis/Netbox.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using BlubbFish.Applications.InventarManager.Helpers;
|
||||
using BlubbFish.Applications.InventarManager.Models.Specific.Netbox;
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.Applications.InventarManager.Apis {
|
||||
class Netbox {
|
||||
private String server;
|
||||
private String key;
|
||||
private WebRequest http;
|
||||
|
||||
public Netbox(String server, String key) {
|
||||
this.server = server;
|
||||
this.key = key;
|
||||
this.http = new WebRequest();
|
||||
this.http.SetAuthToken(this.key);
|
||||
}
|
||||
|
||||
public Boolean Connect() {
|
||||
try {
|
||||
JsonData json = JsonMapper.ToObject(this.http.RequestString("https://" + this.server + "/api/status/"));
|
||||
if(json.ContainsKey("netbox-version") && json["netbox-version"].IsString && json["netbox-version"].ToString().StartsWith("4")) {
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<NetboxManufacturer> GetManufacturer() {
|
||||
try {
|
||||
SortedSet<NetboxManufacturer> ret = [];
|
||||
JsonData json = JsonMapper.ToObject(this.http.RequestString("https://" + this.server + "/api/dcim/manufacturers/"));
|
||||
if(json.ContainsKey("count") && json["count"].IsInt && Int32.TryParse(json["count"].ToString(), out Int32 count) && count > 0) {
|
||||
foreach(JsonData man in json["results"]) {
|
||||
ret.Add(new NetboxManufacturer(man));
|
||||
}
|
||||
}
|
||||
return [.. ret];
|
||||
} catch {
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
44
InventarManager/Apis/SnipeIT.cs
Normal file
44
InventarManager/Apis/SnipeIT.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using BlubbFish.Applications.InventarManager.Helpers;
|
||||
using BlubbFish.Applications.InventarManager.Models.Specific.SnipeIt;
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.Applications.InventarManager.Apis {
|
||||
class SnipeIT {
|
||||
private String server;
|
||||
private String key;
|
||||
private WebRequest http;
|
||||
|
||||
public SnipeIT(String server, String key) {
|
||||
this.server = server;
|
||||
this.key = key;
|
||||
this.http = new WebRequest();
|
||||
this.http.SetAuthToken(this.key, "Bearer");
|
||||
}
|
||||
|
||||
public Boolean Connect() {
|
||||
try {
|
||||
JsonData json = JsonMapper.ToObject(this.http.RequestString("https://" + this.server + "/api/v1/version"));
|
||||
if(json.ContainsKey("version") && json["version"].IsString && json["version"].ToString().StartsWith("v8")) {
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<SnipeItManufacturer> GetManufacturer() {
|
||||
try {
|
||||
SortedSet<SnipeItManufacturer> ret = [];
|
||||
JsonData json = JsonMapper.ToObject(this.http.RequestString("https://" + this.server + "/api/v1/manufacturers"));
|
||||
if(json.ContainsKey("total") && json["total"].IsInt && Int32.TryParse(json["total"].ToString(), out Int32 count) && count > 0) {
|
||||
foreach(JsonData man in json["rows"]) {
|
||||
ret.Add(new SnipeItManufacturer(man));
|
||||
}
|
||||
}
|
||||
return [.. ret];
|
||||
} catch {
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
220
InventarManager/Form1.Designer.cs
generated
Normal file
220
InventarManager/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,220 @@
|
||||
namespace BlubbFish.Applications.InventarManager {
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.button1 = new Button();
|
||||
this.statusStrip1 = new StatusStrip();
|
||||
this.tabControl1 = new TabControl();
|
||||
this.tabPage1 = new TabPage();
|
||||
this.tabPage2 = new TabPage();
|
||||
this.tabControl2 = new TabControl();
|
||||
this.tabPage3 = new TabPage();
|
||||
this.listBox3 = new ListBox();
|
||||
this.listBox2 = new ListBox();
|
||||
this.listBox1 = new ListBox();
|
||||
this.textBox1 = new TextBox();
|
||||
this.button2 = new Button();
|
||||
this.tabPage4 = new TabPage();
|
||||
this.label1 = new Label();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
this.tabControl2.SuspendLayout();
|
||||
this.tabPage3.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new Point(1050, 812);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new Size(121, 29);
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "Einstellungen";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// statusStrip1
|
||||
//
|
||||
this.statusStrip1.ImageScalingSize = new Size(20, 20);
|
||||
this.statusStrip1.Location = new Point(0, 844);
|
||||
this.statusStrip1.Name = "statusStrip1";
|
||||
this.statusStrip1.Size = new Size(1183, 22);
|
||||
this.statusStrip1.TabIndex = 1;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
this.tabControl1.Controls.Add(this.tabPage1);
|
||||
this.tabControl1.Controls.Add(this.tabPage2);
|
||||
this.tabControl1.Location = new Point(12, 12);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new Size(1159, 794);
|
||||
this.tabControl1.TabIndex = 2;
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Location = new Point(4, 29);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new Padding(3);
|
||||
this.tabPage1.Size = new Size(1151, 761);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "tabPage1";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.tabControl2);
|
||||
this.tabPage2.Location = new Point(4, 29);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new Padding(3);
|
||||
this.tabPage2.Size = new Size(1151, 761);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "Stammdaten";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabControl2
|
||||
//
|
||||
this.tabControl2.Controls.Add(this.tabPage3);
|
||||
this.tabControl2.Controls.Add(this.tabPage4);
|
||||
this.tabControl2.Location = new Point(6, 6);
|
||||
this.tabControl2.Name = "tabControl2";
|
||||
this.tabControl2.SelectedIndex = 0;
|
||||
this.tabControl2.Size = new Size(1139, 749);
|
||||
this.tabControl2.TabIndex = 0;
|
||||
//
|
||||
// tabPage3
|
||||
//
|
||||
this.tabPage3.Controls.Add(this.label1);
|
||||
this.tabPage3.Controls.Add(this.listBox3);
|
||||
this.tabPage3.Controls.Add(this.listBox2);
|
||||
this.tabPage3.Controls.Add(this.listBox1);
|
||||
this.tabPage3.Controls.Add(this.textBox1);
|
||||
this.tabPage3.Controls.Add(this.button2);
|
||||
this.tabPage3.Location = new Point(4, 29);
|
||||
this.tabPage3.Name = "tabPage3";
|
||||
this.tabPage3.Padding = new Padding(3);
|
||||
this.tabPage3.Size = new Size(1131, 716);
|
||||
this.tabPage3.TabIndex = 0;
|
||||
this.tabPage3.Text = "Hersteller";
|
||||
this.tabPage3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// listBox3
|
||||
//
|
||||
this.listBox3.FormattingEnabled = true;
|
||||
this.listBox3.Location = new Point(825, 91);
|
||||
this.listBox3.Name = "listBox3";
|
||||
this.listBox3.Size = new Size(300, 604);
|
||||
this.listBox3.TabIndex = 4;
|
||||
//
|
||||
// listBox2
|
||||
//
|
||||
this.listBox2.FormattingEnabled = true;
|
||||
this.listBox2.Location = new Point(403, 91);
|
||||
this.listBox2.Name = "listBox2";
|
||||
this.listBox2.Size = new Size(300, 604);
|
||||
this.listBox2.TabIndex = 3;
|
||||
//
|
||||
// listBox1
|
||||
//
|
||||
this.listBox1.FormattingEnabled = true;
|
||||
this.listBox1.Location = new Point(6, 91);
|
||||
this.listBox1.Name = "listBox1";
|
||||
this.listBox1.Size = new Size(300, 604);
|
||||
this.listBox1.TabIndex = 2;
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Location = new Point(212, 8);
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new Size(913, 27);
|
||||
this.textBox1.TabIndex = 1;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new Point(6, 6);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new Size(94, 29);
|
||||
this.button2.TabIndex = 0;
|
||||
this.button2.Text = "Laden";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += this.button2_Click;
|
||||
//
|
||||
// tabPage4
|
||||
//
|
||||
this.tabPage4.Location = new Point(4, 29);
|
||||
this.tabPage4.Name = "tabPage4";
|
||||
this.tabPage4.Padding = new Padding(3);
|
||||
this.tabPage4.Size = new Size(1131, 716);
|
||||
this.tabPage4.TabIndex = 1;
|
||||
this.tabPage4.Text = "tabPage4";
|
||||
this.tabPage4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new Point(147, 10);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new Size(59, 20);
|
||||
this.label1.TabIndex = 5;
|
||||
this.label1.Text = "Suchen:";
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
this.AutoScaleMode = AutoScaleMode.Font;
|
||||
this.ClientSize = new Size(1183, 866);
|
||||
this.Controls.Add(this.tabControl1);
|
||||
this.Controls.Add(this.statusStrip1);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.tabPage2.ResumeLayout(false);
|
||||
this.tabControl2.ResumeLayout(false);
|
||||
this.tabPage3.ResumeLayout(false);
|
||||
this.tabPage3.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button button1;
|
||||
private StatusStrip statusStrip1;
|
||||
private TabControl tabControl1;
|
||||
private TabPage tabPage1;
|
||||
private TabPage tabPage2;
|
||||
private TabControl tabControl2;
|
||||
private TabPage tabPage3;
|
||||
private TabPage tabPage4;
|
||||
private TextBox textBox1;
|
||||
private Button button2;
|
||||
private ListBox listBox3;
|
||||
private ListBox listBox2;
|
||||
private ListBox listBox1;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
||||
49
InventarManager/Form1.cs
Normal file
49
InventarManager/Form1.cs
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
using BlubbFish.Applications.InventarManager.Apis;
|
||||
using BlubbFish.Applications.InventarManager.Models.Specific.Inventree;
|
||||
using BlubbFish.Applications.InventarManager.Models.Specific.Netbox;
|
||||
using BlubbFish.Applications.InventarManager.Models.Specific.SnipeIt;
|
||||
|
||||
namespace BlubbFish.Applications.InventarManager {
|
||||
public partial class Form1 : Form {
|
||||
private Netbox netbox;
|
||||
private SnipeIT snipeit;
|
||||
private Inventree inventree;
|
||||
|
||||
public Form1() {
|
||||
this.InitializeComponent();
|
||||
this.ConnectServer();
|
||||
}
|
||||
|
||||
private void ConnectServer() {
|
||||
this.netbox = new Netbox(url, api_key);
|
||||
this.netbox.Connect();
|
||||
|
||||
this.snipeit = new SnipeIT(url, api_key);
|
||||
this.snipeit.Connect();
|
||||
|
||||
this.inventree = new Inventree(url, api_key);
|
||||
this.inventree.Connect();
|
||||
}
|
||||
|
||||
private void button2_Click(Object sender, EventArgs e) {
|
||||
List<NetboxManufacturer> n = this.netbox.GetManufacturer();
|
||||
this.listBox1.Items.Clear();
|
||||
foreach(NetboxManufacturer m in n) {
|
||||
this.listBox1.Items.Add(m);
|
||||
}
|
||||
|
||||
List<SnipeItManufacturer> s = this.snipeit.GetManufacturer();
|
||||
this.listBox2.Items.Clear();
|
||||
foreach(SnipeItManufacturer m in s) {
|
||||
this.listBox2.Items.Add(m);
|
||||
}
|
||||
|
||||
List<InventreeManufacturer> i = this.inventree.GetManufacturer();
|
||||
this.listBox3.Items.Clear();
|
||||
foreach(InventreeManufacturer m in i) {
|
||||
this.listBox3.Items.Add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
123
InventarManager/Form1.resx
Normal file
123
InventarManager/Form1.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
51
InventarManager/Helper/WebRequest.cs
Normal file
51
InventarManager/Helper/WebRequest.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System.Net;
|
||||
|
||||
namespace BlubbFish.Applications.InventarManager.Helpers {
|
||||
internal class WebRequest {
|
||||
private readonly HttpClient client = new();
|
||||
|
||||
public void SetAuthToken(String token, String type = "Token") => this.SetHeader("Authorization", type + " " + token);
|
||||
|
||||
private void SetHeader(String type, String value) {
|
||||
if(this.client.DefaultRequestHeaders.Contains(type)) {
|
||||
_ = this.client.DefaultRequestHeaders.Remove(type);
|
||||
}
|
||||
this.client.DefaultRequestHeaders.Add(type, value);
|
||||
}
|
||||
|
||||
public String RequestString(String address, String json = "", Boolean withoutput = true, RequestMethod method = RequestMethod.GET) {
|
||||
String ret = null;
|
||||
try {
|
||||
HttpResponseMessage response = null;
|
||||
if(method == RequestMethod.POST || method == RequestMethod.PUT) {
|
||||
HttpContent content = new StringContent(json);
|
||||
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
|
||||
//content.Headers.Add("Content-Type", "application/json");
|
||||
if(method == RequestMethod.POST) {
|
||||
response = this.client.PostAsync(address, content).Result;
|
||||
} else if(method == RequestMethod.PUT) {
|
||||
response = this.client.PutAsync(address, content).Result;
|
||||
}
|
||||
content.Dispose();
|
||||
} else if(method == RequestMethod.GET) {
|
||||
response = this.client.GetAsync(address).Result;
|
||||
}
|
||||
if(!response.IsSuccessStatusCode) {
|
||||
throw new Exception(response.StatusCode + ": " + response.ReasonPhrase);
|
||||
}
|
||||
if(withoutput && response != null) {
|
||||
ret = response.Content.ReadAsStringAsync().Result;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
throw new WebException("Error while requesting Resource: \"" + address + "\" Method: " + method + " Data: " + json + " Fehler: " + e.Message);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public enum RequestMethod {
|
||||
GET,
|
||||
POST,
|
||||
PUT
|
||||
}
|
||||
}
|
||||
}
|
||||
57
InventarManager/InventarManager.csproj
Normal file
57
InventarManager/InventarManager.csproj
Normal file
@ -0,0 +1,57 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net10.0-windows</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>1.3.1</AssemblyVersion>
|
||||
<FileVersion>$(AssemblyVersion)</FileVersion>
|
||||
<Version>$(AssemblyVersion)</Version>
|
||||
<Authors>BlubbFish</Authors>
|
||||
<RootNamespace>BlubbFish.Applications.InventarManager</RootNamespace>
|
||||
<Description>Create Inventree PO Barcodes</Description>
|
||||
<Company>BlubbFish</Company>
|
||||
<PackageId>InventarManager.Applications.BlubbFish</PackageId>
|
||||
<Copyright>Copyright © BlubbFish 2026 - 14.02.2026</Copyright>
|
||||
<NeutralLanguage>de-DE</NeutralLanguage>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageProjectUrl>https://git.blubbfish.net/vs_projects/InventreeBarcodeGenerator</PackageProjectUrl>
|
||||
<RepositoryUrl>https://git.blubbfish.net/vs_projects/InventreeBarcodeGenerator.git</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageReleaseNotes>
|
||||
1.3.1 - 2026-02-32 - Add PackageListNumber
|
||||
1.3.0 - 2026-02-19 - Change DataMatrix to real Json
|
||||
1.2.0 - 2026-02-18 - Fix Quantity on Labels so that you can recieve only partial deliverys
|
||||
1.1.0 - 2026-02-14 - Rewrote to DataGridView
|
||||
1.0.0 - 2025-11-23 - Init
|
||||
</PackageReleaseNotes>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="../CHANGELOG.md" />
|
||||
<Content Include="../CONTRIBUTING.md" />
|
||||
<Content Include="../LICENSE" />
|
||||
<Content Include="../README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\LICENSE">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath>\</PackagePath>
|
||||
</None>
|
||||
<None Include="..\README.md">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath>\</PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Librarys\litjson\litjson\litjson.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
</Project>
|
||||
8
InventarManager/InventarManager.csproj.user
Normal file
8
InventarManager/InventarManager.csproj.user
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Update="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
23
InventarManager/Models/Manufacturer.cs
Normal file
23
InventarManager/Models/Manufacturer.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BlubbFish.Applications.InventarManager.Models {
|
||||
abstract class Manufacturer : IComparable {
|
||||
public String Name {
|
||||
get;
|
||||
protected set;
|
||||
}
|
||||
|
||||
public Int32 CompareTo(Object obj) {
|
||||
if(obj is null) {
|
||||
return 1;
|
||||
}
|
||||
if(obj is Manufacturer m) {
|
||||
return m.Name.CompareTo(this.Name) * -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.Applications.InventarManager.Models.Specific.Inventree {
|
||||
internal class InventreeManufacturer : Manufacturer {
|
||||
public InventreeManufacturer(JsonData man) {
|
||||
this.Name = man["name"].ToString();
|
||||
this.Id = Int32.Parse(man["pk"].ToString());
|
||||
this.Description = man["description"].ToString();
|
||||
this.Website = man["website"].ToString();
|
||||
this.Phone = man["phone"].ToString();
|
||||
}
|
||||
|
||||
public Int32 Id {
|
||||
get;
|
||||
}
|
||||
public String Description {
|
||||
get;
|
||||
}
|
||||
public String Website {
|
||||
get;
|
||||
}
|
||||
public String Phone {
|
||||
get;
|
||||
}
|
||||
|
||||
public override String ToString() => this.Name;
|
||||
}
|
||||
}
|
||||
28
InventarManager/Models/Specific/Netbox/NetboxManufacturer.cs
Normal file
28
InventarManager/Models/Specific/Netbox/NetboxManufacturer.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.Applications.InventarManager.Models.Specific.Netbox {
|
||||
class NetboxManufacturer : Manufacturer {
|
||||
public NetboxManufacturer(JsonData man) {
|
||||
this.Name = man["name"].ToString();
|
||||
this.Id = Int32.Parse(man["id"].ToString());
|
||||
this.Display = man["display"].ToString();
|
||||
this.Slug = man["slug"].ToString();
|
||||
this.Description = man["description"].ToString();
|
||||
}
|
||||
|
||||
public Int32 Id {
|
||||
get;
|
||||
}
|
||||
public String Display {
|
||||
get;
|
||||
}
|
||||
public String Slug {
|
||||
get;
|
||||
}
|
||||
public String Description {
|
||||
get;
|
||||
}
|
||||
|
||||
public override String ToString() => this.Name;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.Applications.InventarManager.Models.Specific.SnipeIt {
|
||||
internal class SnipeItManufacturer : Manufacturer {
|
||||
public SnipeItManufacturer(JsonData man) {
|
||||
this.Name = man["name"].ToString();
|
||||
this.Id = Int32.Parse(man["id"].ToString());
|
||||
this.Url = man["url"].ToString();
|
||||
this.SupportUrl = man["support_url"].ToString();
|
||||
this.SupportPhone = man["support_phone"].ToString();
|
||||
this.SupportEmail = man["support_email"].ToString();
|
||||
}
|
||||
|
||||
public Int32 Id {
|
||||
get;
|
||||
}
|
||||
public String Url {
|
||||
get;
|
||||
}
|
||||
public String SupportUrl {
|
||||
get;
|
||||
}
|
||||
public String SupportPhone {
|
||||
get;
|
||||
}
|
||||
public String SupportEmail {
|
||||
get;
|
||||
}
|
||||
|
||||
public override String ToString() => this.Name;
|
||||
}
|
||||
}
|
||||
16
InventarManager/Program.cs
Normal file
16
InventarManager/Program.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace BlubbFish.Applications.InventarManager {
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
11
InventarManager/example-config/settings.conf.example
Normal file
11
InventarManager/example-config/settings.conf.example
Normal file
@ -0,0 +1,11 @@
|
||||
[inventree]
|
||||
url=[inventree-url]
|
||||
api_key={inventree-api-key]
|
||||
|
||||
[snipeit]
|
||||
url=[snipeit-url]
|
||||
api_key={snipeit-api-key]
|
||||
|
||||
[netbox]
|
||||
url=[netbox-url]
|
||||
api_key={netbox-api-key]
|
||||
Loading…
Reference in New Issue
Block a user