Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions README.md

This file was deleted.

443 changes: 440 additions & 3 deletions Samples.sln

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/Example1/Example1.Tests/Example1.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Soneta.Sdk">
<PropertyGroup>
<TargetFramework>$(SonetaTargetFramework)</TargetFramework>
</PropertyGroup>
</Project>
17 changes: 17 additions & 0 deletions src/Example1/Example1.UI/EnsureSonetaTypesReferenceClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Soneta.Types;

namespace SonetaAddon
{
public static class EnsureSonetaTypesReferenceClass
{
/// <summary>
/// Ważne ze względnu na wczytywanie bibliotek, które mają referencje do Soneta.Types
/// Tylko biblioteki z referencją do Soneta.Types są wczytywane podczas analizowania form.xml
/// Cały plik "EnsureSonetaTypesReferenceClass.cs" można usunąć, jeśli dodatek zawiera jawne odwołanie
/// do biblioteki Soneta.Types, w innym wypadku plik należy pozostawić
/// </summary>
#pragma warning disable 414
private static readonly FromTo EnsureSonetaTypesReferenceVariable = new FromTo();
#pragma warning restore 414
}
}
6 changes: 6 additions & 0 deletions src/Example1/Example1.UI/Example1.UI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Soneta.Sdk">
<PropertyGroup>
<TargetFramework>$(SonetaTargetFramework)</TargetFramework>
</PropertyGroup>
</Project>
12 changes: 12 additions & 0 deletions src/Example1/Example1.UI/UI/TowaryUlubioneKontaktu.viewform.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<DataForm Contexts="License.CRM" xmlns="http://www.enova.pl/schema/form.xsd">
<Flow Name="FilterPanel">
<Field EditValue="{WParams.KontaktOsoba}" CaptionHtml="Osoba kontaktowa" Width="30"/>
</Flow>

<Grid Name="List">
<Field EditValue="{Towar.Kod}" CaptionHtml="Kod Towaru" Width="20" />
<Field EditValue="{Towar.Nazwa}" CaptionHtml="Nazwa Towaru" Width="40" />
<Field EditValue="{Zapis}" CaptionHtml="Imię i Nazwisko" Width="40" />
</Grid>
</DataForm>
18 changes: 18 additions & 0 deletions src/Example1/Example1.UI/ViewInfo/Menu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

using Soneta.Business.Licence;
using Soneta.Business.UI;
using Samples.Example1.UI.Extender;

[assembly: FolderView("Samples",
Priority = 10,
Description = "Przykłady implementacji enova365",
BrickColor = FolderViewAttribute.BlueBrick,
Contexts = new object[] { LicencjeModułu.All }
)]

[assembly: FolderView("Samples/Towary własne",
Priority = 11,
Description = "Towary ulubione osoby kontaktowej",
TableName = "TowaryUlubione",
ViewType = typeof(TowaryUlubioneKontaktuViewInfo)
)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using Soneta.Business;
using Soneta.CRM;
using Soneta.Towary;

namespace Samples.Example1.UI.Extender
{
/// <summary>
/// Lista oparta na przykładzie pochodzącym z repozytorium Soneta.Examples - https://github.com/soneta/Examples (Example 1)
///
/// </summary>
public class TowaryUlubioneKontaktuViewInfo : ViewInfo
{

public TowaryUlubioneKontaktuViewInfo()
{
// View wiążemy z odpowiednią definicją viewform.xml poprzez property ResourceName
ResourceName = "TowaryUlubioneKontaktu";

// Inicjowanie contextu
InitContext += (sender, args) => { args.Context.TryAdd(() => new WParams(args.Context)); };

// Tworzenie view zawierającego konkretne dane
CreateView += TowaryWlasneViewInfo_CreateView;
}

void TowaryWlasneViewInfo_CreateView(object sender, CreateViewEventArgs args)
{
WParams parameters;
if (!args.Context.Get(out parameters))
return;

args.View = ViewCreate(parameters);
args.View.AllowNew = false;
}

protected View ViewCreate(WParams pars)
{
var rc = RowCondition.Empty;
var tm = TowaryModule.GetInstance(pars.Context.Session);
var view = tm.TowaryUlubione.CreateView();

if (pars.KontaktOsoba != null)
rc &= new FieldCondition.Equal("Zapis", pars.KontaktOsoba);

view.Condition &= rc;

return view;
}

}

public class WParams : ContextBase
{
private const string Key = "Samples.TowaryWlasne";

public WParams(Context context) : base(context)
{
Load();
}

public KontaktOsoba KontaktOsoba
{
get
{
if (Context.Contains(typeof(KontaktOsoba)))
return (KontaktOsoba)Context[typeof(KontaktOsoba)];
return null;
}
set
{
Context[typeof(KontaktOsoba)] = value;
Save();
}
}

/// <summary>
/// Ładowanie parametrów z kontekstu login'a
/// </summary>
protected void Load()
{
var property = Context.LoadProperty(this, "KontaktOsoba", Key);
SetContext(typeof(KontaktOsoba), property);
}

/// <summary>
/// Zapisywanie parametrów w kontekście login'a
/// </summary>
protected void Save()
{
Context.SaveProperty(this, "KontaktOsoba", Key);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Soneta.Business;
using Soneta.Commands;
using Soneta.Towary;
using Soneta.Types;
using Samples.Example1.UI.Extender;

[assembly: Worker(typeof(TowaryUlubionePokazKontaktWorker), typeof(TowarUlubiony))]

namespace Samples.Example1.UI.Extender
{
class TowaryUlubionePokazKontaktWorker
{
[Context]
public TowarUlubiony TowarUlubiony
{
get;
set;
}

[Action("Pokaż osobę", Target = ActionTarget.ToolbarWithText, Mode = ActionMode.SingleSession,
CommandShortcut = CommandShortcut.Shift | CommandShortcut.F8, Priority = 10, Icon =ActionIcon.Phone)]
public Row PokazZapis()
{
Row zapis = TowarUlubiony.Zapis.Root;

if (zapis is IRowWithHistory)
{
return (zapis as IRowWithHistory).Historia[Date.Today];
}

return zapis;
}

[Action("Pokaż towar", Target = ActionTarget.ToolbarWithText, Mode = ActionMode.SingleSession,
Priority = 11, Icon = ActionIcon.Open)]
public Row PokazTowar()
{
Row towar = TowarUlubiony.Towar;

if (towar is IRowWithHistory)
{
return (towar as IRowWithHistory).Historia[Date.Today];
}

return towar;
}
}
}
15 changes: 15 additions & 0 deletions src/Example1/Example1/Example1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Soneta.Sdk">
<PropertyGroup>
<TargetFramework>$(SonetaTargetFramework)</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath></OutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Example1.UI\Example1.UI.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Soneta.Products.Modules" Version="2002.0.0" />
</ItemGroup>
</Project>
33 changes: 33 additions & 0 deletions src/Example1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
### Example 1
-----------------------------------------------------------------------------------------------------

Przyk�ad pokazuje mo�liwo�� zastosowania w�asnej listy w oparciu o istniej�ce obiekty enova. Zawiera zdefiniowane w�asne View, z kt�rym zosta�a powi�zana odpowiednia definicja w postaci struktury viewform.xml.

W wyniku zastosowania dodatku, powinna pojawi� si� dodatkowa grupa w menu g��wnym programu o nazwie *`Samples`* z opcj� *`Towary w�asne`*, po wybraniu kt�rej pojawi si� zaimplementowana lista.


W sk�ad przyk�adu wchodz� trzy projekty:

* `Example1` - zawieraj�cy elementy logiki biznesowej
* `Example1.UI` - interfejsu u�ytkownika
* `Example1.Tests` - testy


#### Zawarto�� przyk�adu:
> Przyk�ad zawiera jedynie elementy interfejsu u�ytkownika wiec ca�o�� znajduje si� w `Example1.UI`.

* `Example1.UI`\Extender\TowaryUlubioneKontaktuViewInfo.cs

Przyk�adowan klasa z implementacj� View zbudowanego na bazie tabel enova.
* `Example1.UI`\Extender\Menu.cs

Rejestracja listy dla View

* `Example1.UI`\UI\TowaryUlubioneKontaktu.viewform.xml

Definicja page'a dla View


* `Example1.UI`\Extender\TowaryUlubionePokazKontaktWorker.cs

Rejestracja akcji dla listy towar�w ulubionych
6 changes: 6 additions & 0 deletions src/Example10/Example10.Tests/Example10.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Soneta.Sdk">
<PropertyGroup>
<TargetFramework>$(SonetaTargetFramework)</TargetFramework>
</PropertyGroup>
</Project>
17 changes: 17 additions & 0 deletions src/Example10/Example10.UI/EnsureSonetaTypesReferenceClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Soneta.Types;

namespace SonetaAddon
{
public static class EnsureSonetaTypesReferenceClass
{
/// <summary>
/// Ważne ze względnu na wczytywanie bibliotek, które mają referencje do Soneta.Types
/// Tylko biblioteki z referencją do Soneta.Types są wczytywane podczas analizowania form.xml
/// Cały plik "EnsureSonetaTypesReferenceClass.cs" można usunąć, jeśli dodatek zawiera jawne odwołanie
/// do biblioteki Soneta.Types, w innym wypadku plik należy pozostawić
/// </summary>
#pragma warning disable 414
private static readonly FromTo EnsureSonetaTypesReferenceVariable = new FromTo();
#pragma warning restore 414
}
}
6 changes: 6 additions & 0 deletions src/Example10/Example10.UI/Example10.UI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Soneta.Sdk">
<PropertyGroup>
<TargetFramework>$(SonetaTargetFramework)</TargetFramework>
</PropertyGroup>
</Project>
6 changes: 6 additions & 0 deletions src/Example10/Example10/Example10.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Soneta.Sdk">
<PropertyGroup>
<TargetFramework>$(SonetaTargetFramework)</TargetFramework>
</PropertyGroup>
</Project>
30 changes: 30 additions & 0 deletions src/Example10/Example10/Extender/CennikSerwis.EksportujCennik.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Soneta.Business;
using Soneta.Towary;

namespace Samples.Example10.Extender {

public partial class CennikSerwis {

public string EksportujCennik(string tsvContent) {
var tcsvr = initCsvReader();
tcsvr.Read(tsvContent);
return tcsvr.ImportException != null ? tcsvr.ImportException.Message : "";
}

private SessionCsvReader initCsvReader() {
var csv = new SessionCsvReader {
View = initView()
};
return csv;
}

private View initView() {
var tm = TowaryModule.GetInstance(_session);
var view = tm.Towary.CreateView();
view.Context = Context.Empty.Clone(_session);
view.NewRowType = typeof (Towar);
return view;
}

}
}
Loading