Parcourir la source

Start of settings file

master
rpm-mcarman il y a 3 ans
Parent
révision
c2199330f2
20 fichiers modifiés avec 156 ajouts et 20 suppressions
  1. +28
    -0
      Common.cs
  2. +5
    -5
      EClasses/Ex365.cs
  3. +17
    -0
      FClasses/JSONActions.cs
  4. +55
    -12
      Program.cs
  5. +17
    -0
      bin/Debug/net6.0/settings.json
  6. +1
    -0
      bin/Debug/net6.0/uri_import.deps.json
  7. BIN
      bin/Debug/net6.0/uri_import.dll
  8. BIN
      bin/Debug/net6.0/uri_import.pdb
  9. BIN
      obj/Debug/net6.0/ref/uri_import.dll
  10. BIN
      obj/Debug/net6.0/refint/uri_import.dll
  11. BIN
      obj/Debug/net6.0/uri_import.assets.cache
  12. +1
    -1
      obj/Debug/net6.0/uri_import.csproj.CoreCompileInputs.cache
  13. +1
    -0
      obj/Debug/net6.0/uri_import.csproj.FileListAbsolute.txt
  14. BIN
      obj/Debug/net6.0/uri_import.dll
  15. BIN
      obj/Debug/net6.0/uri_import.pdb
  16. +5
    -0
      obj/project.assets.json
  17. +1
    -1
      obj/project.nuget.cache
  18. +4
    -0
      obj/uri_import.csproj.nuget.dgspec.json
  19. +17
    -0
      settings.json
  20. +4
    -1
      uri_import.csproj

+ 28
- 0
Common.cs Voir le fichier

@@ -0,0 +1,28 @@


namespace uri_import
{
public class Common
{
public EmailSettings Email { get; set; }
public AcumaticaSettings Acumatica { get; set; }
}
public class EmailSettings
{
public string Username { get; set; }
public string Password { get; set; }
public int Mailbox { get; set; }
public string Url { get; set; }
public string Filter { get; set; }

}
public class AcumaticaSettings
{
public string Url { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Tenant { get; set; }
public string Branch { get; set; }
public string Locale { get; set; }
}
}

+ 5
- 5
EClasses/Ex365.cs Voir le fichier

@@ -1,4 +1,4 @@
using System.IO;
using System.Net;
using System;
using System.Collections.Generic;
@@ -22,7 +22,7 @@ namespace uri_import.EClasses
public Ex365(string username, string password)
{
_credential = new NetworkCredential(username, password);
_service = new Service("https://outlook.office365.com/ews/Exchange.asmx", _credential);
_service = new Service(Program.Cmn.Email.Url, _credential);

}
public Ex365(string username, string password, string url)
@@ -42,7 +42,7 @@ namespace uri_import.EClasses
int index = 1;
List<EmailAttachment> list = new List<EmailAttachment>();
IsEqualTo restriction = new IsEqualTo(MessagePropertyPath.HasAttachments, hasAttachment);
Contains subFilter = new Contains(MessagePropertyPath.Subject, "United Rentals, Inc:", ContainmentMode.Prefixed, ContainmentComparison.IgnoreCase);
Contains subFilter = new Contains(MessagePropertyPath.Subject, Program.Cmn.Email.Filter, ContainmentMode.Prefixed, ContainmentComparison.IgnoreCase);
ItemShape itemShape = new ItemShape(ShapeType.Id);
FindItemResponse response = _service.FindItem(StandardFolder.Inbox, itemShape, subFilter);
for (int i = 0; i < response.Items.Count; i++)
@@ -107,8 +107,8 @@ namespace uri_import.EClasses
public SalesOrder SalesOrder { get; set; }
public string SalesOrderNumber { get; set; }
public List<ProductionOrder> ProductionOrders { get { return _productionOrders; } set { _productionOrders = value; } }
public bool Released { get{return _released;} set{_released = value;}}
public bool Linked { get{return _linked;} set{_linked = value;}}
public bool Released { get { return _released; } set { _released = value; } }
public bool Linked { get { return _linked; } set { _linked = value; } }
public List<string> Errors { get { return _errors; } set { _errors = value; } }
}
}

+ 17
- 0
FClasses/JSONActions.cs Voir le fichier

@@ -0,0 +1,17 @@

using Newtonsoft.Json;
using System.IO;

namespace uri_import
{
public class JSONActions
{
public static Common ReadSettings(string file)
{
string text = File.ReadAllText(file);
Common c = JsonConvert.DeserializeObject<Common>(text);
return c;
}

}
}

+ 55
- 12
Program.cs Voir le fichier

@@ -13,16 +13,26 @@ namespace uri_import
{
class Program
{
public static Common Cmn { get; set; }
static void Main(string[] args)
{
Cmn = JSONActions.ReadSettings("settings.json");
FileActions.MakeDirectories();
Ex365 exch = new Ex365("mcarman@prelub.com", "Gr@nt@cc3$$", "https://outlook.office365.com/ews/Exchange.asmx", Independentsoft.Exchange.StandardFolder.Inbox);
List<EmailAttachment> pos = exch.GetPOs("United Rentals, Inc:");
Ex365 exch = new Ex365(Cmn.Email.Username,
Cmn.Email.Password,
Cmn.Email.Url,
(Independentsoft.Exchange.StandardFolder)Cmn.Email.Mailbox);
List<EmailAttachment> pos = exch.GetPOs(Cmn.Email.Filter);
List<SalesOrder> sos = new List<SalesOrder>();
WritePOsToDirectory(pos);
try
{
var config = AcumaticaREST.Config("https://rpmindustries.acumatica.com", "bryckman", "Washington1", "RPM SANDBOX", null, null);
var config = AcumaticaREST.Config(Cmn.Acumatica.Url,
Cmn.Acumatica.Username,
Cmn.Acumatica.Password,
Cmn.Acumatica.Tenant,
null,
null);
foreach (EmailAttachment ea in pos)
{
@@ -32,7 +42,10 @@ namespace uri_import
}
catch (Exception lex)
{
ea.Errors.Add(string.Format("{0} {1} {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), lex.Message));
ea.Errors.Add(string.Format("{0} {1} {2}",
DateTime.Now.ToShortDateString(),
DateTime.Now.ToShortTimeString(),
lex.Message));
}
ea.SalesOrder = PDFHelper.PDFBuildSalesOrder(PDFHelper.PDFLinesToText(ea.FilePath));
SalesOrder order = ea.SalesOrder;
@@ -49,7 +62,6 @@ namespace uri_import
AcumaticaREST.CreateSalesOrder(ref order, config, ea.FileName, ea.Content);
ea.SalesOrder.OrderNbr = order.OrderNbr;
ea.SalesOrder.ID = order.ID;
//AcumaticaREST.UploadPurchaseOrder(config, ea.SalesOrder, "PurchaseOrder.pdf", ea.Content);
int ln = 1;
foreach (SalesOrderDetail detail in ea.SalesOrder.Details)
{
@@ -61,13 +73,27 @@ namespace uri_import
prod.SOOrderType = "SO";
prod.SOLineNbr = detail.LineNbr;
ln = ln + 1;
AcumaticaREST.CreateProductionOrder(config, ref prod, "https://rpmindustries.acumatica.com", "bryckman", "Washington1", "RPM SANDBOX", null, null);
AcumaticaREST.CreateProductionOrder(config,
ref prod,
Cmn.Acumatica.Url,
Cmn.Acumatica.Username,
Cmn.Acumatica.Password,
Cmn.Acumatica.Tenant,
null,
null);
ea.ProductionOrders.Add(prod);
}
}
foreach (EmailAttachment ea in pos)
{
AcumaticaREST.ReleaseAndLinkProductionOrders(config, ea, "https://rpmindustries.acumatica.com", "bryckman", "Washington1", "RPM SANDBOX", null, null);
AcumaticaREST.ReleaseAndLinkProductionOrders(config,
ea,
Cmn.Acumatica.Url,
Cmn.Acumatica.Username,
Cmn.Acumatica.Password,
Cmn.Acumatica.Tenant,
null,
null);
}
}
catch (Exception exception)
@@ -76,15 +102,30 @@ namespace uri_import
}
finally
{
AcumaticaREST.APILogout("https://rpmindustries.acumatica.com", "bryckman", "Washington1", "RPM SANDBOX", null, null);
AcumaticaREST.APILogout(Cmn.Acumatica.Url,
Cmn.Acumatica.Username,
Cmn.Acumatica.Password,
Cmn.Acumatica.Tenant,
null,
null);
}
using (RestService service = new RestService("https://rpmindustries.acumatica.com", "bryckman", "Washington1", "RPM SANDBOX", "en_US"))
using (RestService service = new RestService(Cmn.Acumatica.Url,
Cmn.Acumatica.Username,
Cmn.Acumatica.Password,
Cmn.Acumatica.Tenant,
Cmn.Acumatica.Locale))
{
foreach (EmailAttachment ea in pos)
{
try
{
AcumaticaREST.PutFile(service, ea.SalesOrder, "https://rpmindustries.acumatica.com", "SO", ea.SalesOrder.OrderNbr.Value.ToString(), ea.FileName, ea.Content);
AcumaticaREST.PutFile(service,
ea.SalesOrder,
Cmn.Acumatica.Url,
"SO",
ea.SalesOrder.OrderNbr.Value.ToString(),
ea.FileName,
ea.Content);
}
catch { }
}
@@ -95,9 +136,11 @@ namespace uri_import
{
foreach (EmailAttachment obj in pos)
{
string path = Path.Combine(FileActions.Attachments, obj.FileName);
string path = Path.Combine(FileActions.Attachments,
obj.FileName);
if (!File.Exists(path))
File.WriteAllBytes(path, obj.Content);
File.WriteAllBytes(path,
obj.Content);
Console.WriteLine(obj.FilePath);
}
}


+ 17
- 0
bin/Debug/net6.0/settings.json Voir le fichier

@@ -0,0 +1,17 @@
{
"Email": {
"Username": "mcarman",
"Password": "Gr@nt@cc3$$",
"Mailbox": 4,
"Url": "https://outlook.office365.com/ews/Exchange.asmx",
"Filter": "United Rentals, Inc:"
},
"Acumatica": {
"Url": "https://rpmindustries.acumatica.com",
"Username": "bryckman",
"Password": "Washington1",
"Tenant": "RPM SANDBOX",
"Branch": null,
"Locale": "en_US"
}
}

+ 1
- 0
bin/Debug/net6.0/uri_import.deps.json Voir le fichier

@@ -14,6 +14,7 @@
"Acumatica.SOAPLikeWrapperForREST": "2.2.0",
"Independentsoft.Exchange": "3.0.700",
"Microsoft.AspNet.WebApi.Client": "5.2.9",
"Newtonsoft.Json": "13.0.1",
"iTextSharp": "5.5.13.3"
},
"runtime": {


BIN
bin/Debug/net6.0/uri_import.dll Voir le fichier


BIN
bin/Debug/net6.0/uri_import.pdb Voir le fichier


BIN
obj/Debug/net6.0/ref/uri_import.dll Voir le fichier


BIN
obj/Debug/net6.0/refint/uri_import.dll Voir le fichier


BIN
obj/Debug/net6.0/uri_import.assets.cache Voir le fichier


+ 1
- 1
obj/Debug/net6.0/uri_import.csproj.CoreCompileInputs.cache Voir le fichier

@@ -1 +1 @@
4e4c11c4c71f46c18965a424b9f9a1438c6d22fe
78d01467e9e3cc497ef927b78a1d505298ac0fad

+ 1
- 0
obj/Debug/net6.0/uri_import.csproj.FileListAbsolute.txt Voir le fichier

@@ -56,3 +56,4 @@
/Volumes/New2TBDrive/apps/acumatica/console/ac_uri_import/Acumatica_Import_URI/obj/Debug/net6.0/uri_import.pdb
/Volumes/New2TBDrive/apps/acumatica/console/ac_uri_import/Acumatica_Import_URI/obj/Debug/net6.0/uri_import.genruntimeconfig.cache
/Volumes/New2TBDrive/apps/acumatica/console/ac_uri_import/Acumatica_Import_URI/obj/Debug/net6.0/ref/uri_import.dll
/Volumes/New2TBDrive/apps/acumatica/console/ac_uri_import/Acumatica_Import_URI/bin/Debug/net6.0/settings.json

BIN
obj/Debug/net6.0/uri_import.dll Voir le fichier


BIN
obj/Debug/net6.0/uri_import.pdb Voir le fichier


+ 5
- 0
obj/project.assets.json Voir le fichier

@@ -16929,6 +16929,7 @@
"Acumatica.SOAPLikeWrapperForREST >= 2.2.0",
"Independentsoft.Exchange >= 3.0.700",
"Microsoft.AspNet.WebApi.Client >= 5.2.9",
"Newtonsoft.Json >= 13.0.1",
"iTextSharp >= 5.5.13.3"
]
},
@@ -16997,6 +16998,10 @@
"target": "Package",
"version": "[5.2.9, )"
},
"Newtonsoft.Json": {
"target": "Package",
"version": "[13.0.1, )"
},
"iTextSharp": {
"target": "Package",
"version": "[5.5.13.3, )"


+ 1
- 1
obj/project.nuget.cache Voir le fichier

@@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "B4b8ZmD30OLjaqk4Q6OPh7+OqtVFjvXbHsidJuIJoVxkqWHyCbX6HwI1svFaWxIyFFyRcegok5GCYMGmnGfDCg==",
"dgSpecHash": "7WpKbFkHS/s7tOD5MbhBm5xnUQv3bAyqqClFUIT5edY5sOGg/XhzW7kt2OeNB6fPvlsbV7mnaXN0z+1a7bMP0g==",
"success": true,
"projectFilePath": "/Volumes/New2TBDrive/apps/acumatica/console/ac_uri_import/Acumatica_Import_URI/uri_import.csproj",
"expectedPackageFiles": [


+ 4
- 0
obj/uri_import.csproj.nuget.dgspec.json Voir le fichier

@@ -65,6 +65,10 @@
"target": "Package",
"version": "[5.2.9, )"
},
"Newtonsoft.Json": {
"target": "Package",
"version": "[13.0.1, )"
},
"iTextSharp": {
"target": "Package",
"version": "[5.5.13.3, )"


+ 17
- 0
settings.json Voir le fichier

@@ -0,0 +1,17 @@
{
"Email": {
"Username": "mcarman",
"Password": "Gr@nt@cc3$$",
"Mailbox": 4,
"Url": "https://outlook.office365.com/ews/Exchange.asmx",
"Filter": "United Rentals, Inc:"
},
"Acumatica": {
"Url": "https://rpmindustries.acumatica.com",
"Username": "bryckman",
"Password": "Washington1",
"Tenant": "RPM SANDBOX",
"Branch": null,
"Locale": "en_US"
}
}

+ 4
- 1
uri_import.csproj Voir le fichier

@@ -13,7 +13,10 @@
<PackageReference Include="Independentsoft.Exchange" Version="3.0.700" />
<PackageReference Include="iTextSharp" Version="5.5.13.3" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<Content Include="*.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

Chargement…
Annuler
Enregistrer