Zwischenstand:
- Download Req und Res eingeführt - Version XML + version.config
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
</bindings>
|
||||
<client>
|
||||
<endpoint binding="basicHttpBinding" bindingConfiguration="BeWoBasicEndpoint" contract="BeWoLauncher.ServiceProxy.ILauncherService" name="LauncherServiceEndpoint" />
|
||||
<endpoint binding="basicHttpBinding" bindingConfiguration="BeWoBasicEndpoint" contract="BeWoLauncher.ServiceProxy.IEnumTranslationService" name="EnumTranslationEndpoint" />
|
||||
<endpoint binding="basicHttpBinding" bindingConfiguration="BeWoBasicEndpoint" contract="BeWoLauncher.ServiceProxy.IDownloadBeWoService" name="DownloadBeWoEndpoint" />
|
||||
</client>
|
||||
<behaviors>
|
||||
<endpointBehaviors>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BeWoLauncher.ServiceProxy;
|
||||
using BS.SharedLauncher;
|
||||
using BS.SharedLauncher.Enums;
|
||||
using BS.SharedLauncher.Information;
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using BeWoLauncher.ServiceProxy;
|
||||
using BeWoLauncher.WindowImp;
|
||||
using BS.SharedLauncher;
|
||||
using BS.SharedLauncher.Enums;
|
||||
using BS.SharedLauncher.Information;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -22,6 +22,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Threading;
|
||||
using System.Xml;
|
||||
|
||||
namespace BeWoLauncher
|
||||
{
|
||||
@@ -74,6 +75,16 @@ namespace BeWoLauncher
|
||||
};
|
||||
|
||||
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
|
||||
|
||||
|
||||
|
||||
//XmlDocument doc = new XmlDocument();
|
||||
//doc.Load(Path.Combine("d:/ServerBeWoDataExample", "version.config"));
|
||||
|
||||
//var default2 = doc.SelectSingleNode("/config/default/version");
|
||||
//var defaultValue = default2.InnerXml;
|
||||
//var specific2 = doc.SelectSingleNode("/config/tenant[@id='demo3']/version");
|
||||
//var specificVersion = specific2.InnerXml;
|
||||
}
|
||||
|
||||
private void CheckForOtherInstance()
|
||||
|
||||
BIN
BeWoLauncher/LauncherGeneratedNeuErstellen.lnk
Normal file
BIN
BeWoLauncher/LauncherGeneratedNeuErstellen.lnk
Normal file
Binary file not shown.
@@ -5,6 +5,7 @@ using BeWoLauncher.ServiceProxy;
|
||||
using BeWoLauncher.WindowImp;
|
||||
|
||||
using BS.SharedLauncher;
|
||||
using BS.SharedLauncher.Enums;
|
||||
using BS.SharedLauncher.Information;
|
||||
|
||||
using System;
|
||||
|
||||
@@ -89,18 +89,18 @@ namespace BeWoLauncher.PageImp
|
||||
SubMessage = "";
|
||||
await showDelay(1000);
|
||||
|
||||
UpdateFileManager.DownloadUpdateSync();
|
||||
//UpdateFileManager.DownloadUpdateSync();
|
||||
|
||||
Message = "Update wird installiert...";
|
||||
await showDelay(1000);
|
||||
|
||||
await UpdateFileManager.ApplyUpdate();
|
||||
//await UpdateFileManager.ApplyUpdate();
|
||||
|
||||
Message = "Update wurde installiert!";
|
||||
SubMessage = "Starte BeWoPlaner...";
|
||||
await showDelay(1000);
|
||||
|
||||
UpdateFileManager.UpdateData = null;
|
||||
//UpdateFileManager.UpdateData = null;
|
||||
UpdateSuccessful(this, new EventArgs());
|
||||
|
||||
UpdatePathManager.GetDownloadDirInfo().ClearFolder();
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace BeWoLauncher.ServiceProxy
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/IsUserValid", ReplyAction="http://tempuri.org/ILauncherService/IsUserValidResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/IsUserValidBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
BS.SharedLauncher.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant);
|
||||
BS.SharedLauncher.Enums.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ResetTenant", ReplyAction="http://tempuri.org/ILauncherService/ResetTenantResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ResetTenantBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
@@ -182,17 +182,13 @@ namespace BeWoLauncher.ServiceProxy
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/GetEmailForUserNameBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
bool GetEmailForUserName(out string email, string pUserName, System.Uri serverName);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/Update", ReplyAction="http://tempuri.org/ILauncherService/UpdateResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/UpdateBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
BS.SharedLauncher.DataContract.BeWoProgramPackageDC Update(BS.SharedLauncher.DataContract.BeWoProgramPackageDC t);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/CheckPassword", ReplyAction="http://tempuri.org/ILauncherService/CheckPasswordResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/CheckPasswordBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
BS.SharedLauncher.PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword);
|
||||
BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/CheckPassword2", ReplyAction="http://tempuri.org/ILauncherService/CheckPassword2Response")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/CheckPassword2BeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
BS.SharedLauncher.PasswordValidationResult CheckPassword2(string username, string pOldPassword, string pNewPassword);
|
||||
BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword2(string username, string pOldPassword, string pNewPassword);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ChangePassword", ReplyAction="http://tempuri.org/ILauncherService/ChangePasswordResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ChangePasswordBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
@@ -237,7 +233,7 @@ namespace BeWoLauncher.ServiceProxy
|
||||
{
|
||||
}
|
||||
|
||||
public BS.SharedLauncher.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant)
|
||||
public BS.SharedLauncher.Enums.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant)
|
||||
{
|
||||
return base.Channel.IsUserValid(pUserName, pPassword, pPIN, clientId, checkTenant);
|
||||
}
|
||||
@@ -257,17 +253,12 @@ namespace BeWoLauncher.ServiceProxy
|
||||
return base.Channel.GetEmailForUserName(out email, pUserName, serverName);
|
||||
}
|
||||
|
||||
public BS.SharedLauncher.DataContract.BeWoProgramPackageDC Update(BS.SharedLauncher.DataContract.BeWoProgramPackageDC t)
|
||||
{
|
||||
return base.Channel.Update(t);
|
||||
}
|
||||
|
||||
public BS.SharedLauncher.PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword)
|
||||
public BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword)
|
||||
{
|
||||
return base.Channel.CheckPassword(userOid, pOldPassword, pNewPassword);
|
||||
}
|
||||
|
||||
public BS.SharedLauncher.PasswordValidationResult CheckPassword2(string username, string pOldPassword, string pNewPassword)
|
||||
public BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword2(string username, string pOldPassword, string pNewPassword)
|
||||
{
|
||||
return base.Channel.CheckPassword2(username, pOldPassword, pNewPassword);
|
||||
}
|
||||
@@ -338,9 +329,9 @@ namespace BeWoLauncher.ServiceProxy
|
||||
public interface IDownloadBeWoService
|
||||
{
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IDownloadBeWoService/Download", ReplyAction="http://tempuri.org/IDownloadBeWoService/DownloadResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/IDownloadBeWoService/DownloadBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
BS.SharedLauncher.DataContract.BeWoProgramPackageDC Download(BS.SharedLauncher.DataContract.BeWoProgramFilterDC filter);
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IDownloadBeWoService/Download2", ReplyAction="http://tempuri.org/IDownloadBeWoService/Download2Response")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/IDownloadBeWoService/Download2BeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
BS.SharedLauncher.DataContract.DownloadPlanerResponseDC Download2(BS.SharedLauncher.DataContract.DownloadPlanerRequestDC request);
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
@@ -377,9 +368,9 @@ namespace BeWoLauncher.ServiceProxy
|
||||
{
|
||||
}
|
||||
|
||||
public BS.SharedLauncher.DataContract.BeWoProgramPackageDC Download(BS.SharedLauncher.DataContract.BeWoProgramFilterDC filter)
|
||||
public BS.SharedLauncher.DataContract.DownloadPlanerResponseDC Download2(BS.SharedLauncher.DataContract.DownloadPlanerRequestDC request)
|
||||
{
|
||||
return base.Channel.Download(filter);
|
||||
return base.Channel.Download2(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BeWoLauncher
|
||||
public class FileEventArgs : EventArgs
|
||||
{
|
||||
public object File { get; set; }
|
||||
public FileToDo ToDo { get; set; }
|
||||
//public FileToDo ToDo { get; set; }
|
||||
}
|
||||
|
||||
public static class UpdateFileManager
|
||||
@@ -23,49 +23,49 @@ namespace BeWoLauncher
|
||||
public static event EventHandler<FileEventArgs> DownloadFileEventHandler;
|
||||
public static event EventHandler<FileEventArgs> ApplyFileEventHandler;
|
||||
|
||||
public static BeWoProgramPackageDC UpdateData { get; set; }
|
||||
//public static BeWoProgramPackageDC UpdateData { get; set; }
|
||||
|
||||
static UpdateFileManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static BeWoProgramPackageDC GetLastUpdate()
|
||||
{
|
||||
var last = new BeWoProgramPackageDC();
|
||||
//public static BeWoProgramPackageDC GetLastUpdate()
|
||||
//{
|
||||
// var last = new BeWoProgramPackageDC();
|
||||
|
||||
last.Files = UpdatePathManager.GetApplyDirInfo().GetFiles().Select(file => new BeWoProgramFileDC(file)).ToList();
|
||||
// last.Files = UpdatePathManager.GetApplyDirInfo().GetFiles().Select(file => new BeWoProgramFileDC(file)).ToList();
|
||||
|
||||
return last;
|
||||
}
|
||||
// return last;
|
||||
//}
|
||||
|
||||
public static void DownloadUpdateSync()
|
||||
{
|
||||
var last = GetLastUpdate();
|
||||
//public static void DownloadUpdateSync()
|
||||
//{
|
||||
// var last = GetLastUpdate();
|
||||
|
||||
UpdateData = LauncherServiceFacade.DoLauncherServiceSync(x => x.Update(last));
|
||||
// UpdateData = LauncherServiceFacade.DoLauncherServiceSync(x => x.Update(last));
|
||||
|
||||
foreach (var file in UpdateData.Files)
|
||||
{
|
||||
switch (file.ToDo)
|
||||
{
|
||||
case FileToDo.Update:
|
||||
case FileToDo.Add:
|
||||
using (var fs = new FileStream(Path.Combine(UpdatePathManager.GetDownloadPath(), file.FileName), FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
fs.Write(file.FileData, 0, file.FileData.Length);
|
||||
}
|
||||
file.FileData = null;
|
||||
break;
|
||||
case FileToDo.Remove:
|
||||
break;
|
||||
case FileToDo.Nuthing:
|
||||
break;
|
||||
}
|
||||
// foreach (var file in UpdateData.Files)
|
||||
// {
|
||||
// switch (file.ToDo)
|
||||
// {
|
||||
// //case FileToDo.Update:
|
||||
// //case FileToDo.Add:
|
||||
// // using (var fs = new FileStream(Path.Combine(UpdatePathManager.GetDownloadPath(), file.FileName), FileMode.Create, FileAccess.Write))
|
||||
// // {
|
||||
// // fs.Write(file.FileData, 0, file.FileData.Length);
|
||||
// // }
|
||||
// // file.FileData = null;
|
||||
// // break;
|
||||
// //case FileToDo.Remove:
|
||||
// // break;
|
||||
// //case FileToDo.Nuthing:
|
||||
// // break;
|
||||
// }
|
||||
|
||||
DownloadFileEventHandler(null, new FileEventArgs { ToDo = file.ToDo, File = file });
|
||||
}
|
||||
}
|
||||
// DownloadFileEventHandler(null, new FileEventArgs { ToDo = file.ToDo, File = file });
|
||||
// }
|
||||
//}
|
||||
|
||||
public static async Task DownloadUpdateAsync()
|
||||
{
|
||||
@@ -96,31 +96,31 @@ namespace BeWoLauncher
|
||||
//}
|
||||
}
|
||||
|
||||
public static async Task ApplyUpdate()
|
||||
{
|
||||
foreach (var file in UpdateData.Files)
|
||||
{
|
||||
switch (file.ToDo)
|
||||
{
|
||||
case FileToDo.Update:
|
||||
case FileToDo.Add:
|
||||
var source = Path.Combine(UpdatePathManager.GetDownloadPath(), file.FileName);
|
||||
var dest = Path.Combine(UpdatePathManager.GetApplyPath(), file.FileName);
|
||||
File.Delete(dest);
|
||||
File.Copy(source, dest);
|
||||
break;
|
||||
case FileToDo.Remove:
|
||||
File.Delete(Path.Combine(UpdatePathManager.GetApplyPath(), file.FileName));
|
||||
break;
|
||||
case FileToDo.Nuthing:
|
||||
break;
|
||||
}
|
||||
//public static async Task ApplyUpdate()
|
||||
//{
|
||||
// foreach (var file in UpdateData.Files)
|
||||
// {
|
||||
// switch (file.ToDo)
|
||||
// {
|
||||
// case FileToDo.Update:
|
||||
// case FileToDo.Add:
|
||||
// var source = Path.Combine(UpdatePathManager.GetDownloadPath(), file.FileName);
|
||||
// var dest = Path.Combine(UpdatePathManager.GetApplyPath(), file.FileName);
|
||||
// File.Delete(dest);
|
||||
// File.Copy(source, dest);
|
||||
// break;
|
||||
// case FileToDo.Remove:
|
||||
// File.Delete(Path.Combine(UpdatePathManager.GetApplyPath(), file.FileName));
|
||||
// break;
|
||||
// case FileToDo.Nuthing:
|
||||
// break;
|
||||
// }
|
||||
|
||||
await showDelay(50);
|
||||
// await showDelay(50);
|
||||
|
||||
ApplyFileEventHandler(null, new FileEventArgs { ToDo = file.ToDo, File = file });
|
||||
}
|
||||
}
|
||||
// ApplyFileEventHandler(null, new FileEventArgs { ToDo = file.ToDo, File = file });
|
||||
// }
|
||||
//}
|
||||
|
||||
private static async Task showDelay(int millisec)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using BeWoLauncher.Components;
|
||||
using BeWoLauncher.PageImp;
|
||||
using BeWoLauncher.ServiceProxy;
|
||||
using BS.SharedLauncher;
|
||||
using BS.SharedLauncher.Information;
|
||||
|
||||
@@ -33,6 +34,8 @@ namespace BeWoLauncher.WindowImp
|
||||
LauncherApp.Window = this;
|
||||
|
||||
ShowLoginPage();
|
||||
|
||||
LauncherServiceFacade.DoDownloadBeWoServiceSync(x => x.Download2(new BS.SharedLauncher.DataContract.DownloadPlanerRequestDC() { }));
|
||||
}
|
||||
|
||||
public void FinishLogin(object sender, EventArgs e)
|
||||
|
||||
@@ -37,10 +37,19 @@ namespace BeWo.Service.Security
|
||||
string lServiceInterface = lTemp[lTemp.Count - 2];
|
||||
|
||||
// TODO Hier kann man jetzt etwas bauen wer sich für welchen service autorisieren muss...
|
||||
var skip = new string[] { "Download", "Download2" };
|
||||
if (lMethodName == "IsUserValid" || lMethodName == "IsUserValidTwoFactor" || lMethodName == "ResetTenant" || lMethodName == "ResetAllTenants" || lMethodName == "GetEmailForUserName")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (skip.Contains(lMethodName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Vergessen neue Methode einzutragen?
|
||||
}
|
||||
|
||||
string lUserName = null, lPassword = null;
|
||||
|
||||
|
||||
@@ -476,6 +476,8 @@
|
||||
<Compile Include="ServiceImplementations\UserServiceImp.cs" />
|
||||
<Compile Include="ServiceImplementations\ValueListServiceImp.cs" />
|
||||
<Compile Include="Configuration\AppSettings.cs" />
|
||||
<Compile Include="ServiceUtils\Update\UpdatePathHelper.cs" />
|
||||
<Compile Include="ServiceUtils\Update\UpdateConfigHelper.cs" />
|
||||
<Compile Include="UnitOfWork\HibernateSessionEndpointBehavior.cs" />
|
||||
<Compile Include="UnitOfWork\HibernateSessionBehaviorExtension.cs" />
|
||||
<Compile Include="UnitOfWork\HibernateSessionContextInitializer.cs" />
|
||||
@@ -522,19 +524,7 @@
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.3.3.2\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.3.3.2\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.3.3.2\build\Microsoft.CodeAnalysis.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.Analyzers.3.3.2\build\Microsoft.CodeAnalysis.Analyzers.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.3.3.2\build\Microsoft.CodeAnalysis.Analyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.Analyzers.3.3.2\build\Microsoft.CodeAnalysis.Analyzers.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.CodeAnalysis.Analyzers.3.3.2\build\Microsoft.CodeAnalysis.Analyzers.targets" Condition="Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.3.3.2\build\Microsoft.CodeAnalysis.Analyzers.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
||||
@@ -12,6 +12,6 @@ namespace BeWo.Service.ServiceContracts
|
||||
{
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
BeWoProgramPackageDC Download(BeWoProgramFilterDC filter);
|
||||
DownloadPlanerResponseDC Download2(DownloadPlanerRequestDC request);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Reports;
|
||||
using BS.SharedLauncher;
|
||||
using BS.SharedLauncher.DataContract;
|
||||
using BS.SharedLauncher.Enums;
|
||||
|
||||
namespace BeWo.Service.ServiceContracts
|
||||
{
|
||||
@@ -16,7 +17,7 @@ namespace BeWo.Service.ServiceContracts
|
||||
{
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
BS.SharedLauncher.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant);
|
||||
BS.SharedLauncher.Enums.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
@@ -29,11 +30,7 @@ namespace BeWo.Service.ServiceContracts
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
bool GetEmailForUserName(string pUserName, Uri serverName, out string email);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
BeWoProgramPackageDC Update(BeWoProgramPackageDC t);
|
||||
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword);
|
||||
|
||||
@@ -1,20 +1,222 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using System.ServiceModel;
|
||||
using System.Xml;
|
||||
using BeWo.Data;
|
||||
using BeWo.Service.ServiceContracts;
|
||||
using BeWo.Service.ServiceUtils.Update;
|
||||
using BS.SharedLauncher.DataContract;
|
||||
using BS.SharedLauncher.Enums;
|
||||
using BS.SharedLauncher.Update;
|
||||
|
||||
namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
|
||||
public class DownloadBeWoServiceImp : IDownloadBeWoService
|
||||
{
|
||||
public BeWoProgramPackageDC Download(BeWoProgramFilterDC filter)
|
||||
public UpdateConfigHelper UpdateConfigHelper { get; set; }
|
||||
|
||||
public string Tenant => MultitenancyOperationContextExt.Current.Tenant;
|
||||
|
||||
public DownloadPlanerResponseDC Download2(DownloadPlanerRequestDC request)
|
||||
{
|
||||
try
|
||||
{
|
||||
PlanerRoot root = new PlanerRoot();
|
||||
|
||||
UpdateConfigHelper = new UpdateConfigHelper(UpdatePathHelper.VersionConfigPath(), Tenant);
|
||||
|
||||
root.DefaultVersion = UpdateConfigHelper.LoadDefaultVersion();
|
||||
root.TenantVersion = UpdateConfigHelper.LoadSpecificVersion();
|
||||
|
||||
string version = root.CurrentVersion;
|
||||
|
||||
// Setze Basis
|
||||
root.InitPlanerFiles(GetVersionDefaultFiles(version));
|
||||
|
||||
// Überschreibe mit Version-Tenant Daten
|
||||
root.UpdatePlanerFiles(GetVersionTenantFiles(version, Tenant));
|
||||
|
||||
// Überschreibe mit Special-Tenant Daten
|
||||
root.UpdatePlanerFiles(GetSpecialTenantFiles(Tenant));
|
||||
|
||||
if (true || request.VersionXML is null)
|
||||
return Install(root);
|
||||
|
||||
return Update(root, request.VersionXML);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Core.Utils.CreateBeWoFaultException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<PlanerFile> GetVersionDefaultFiles(string version) => GetPlanerFiles(UpdatePathHelper.VersionDefaultPath(version), PlanerUpdateSource.VersionDefault);
|
||||
private List<PlanerFile> GetVersionTenantFiles(string version, string tenant) => GetPlanerFiles(UpdatePathHelper.VersionTenantPath(version, tenant), PlanerUpdateSource.VersionTenant);
|
||||
private List<PlanerFile> GetSpecialTenantFiles(string tenant) => GetPlanerFiles(UpdatePathHelper.SpecialTenantPath(tenant), PlanerUpdateSource.SpecialTenant);
|
||||
|
||||
private List<PlanerFile> GetPlanerFiles(string path, PlanerUpdateSource source)
|
||||
{
|
||||
var res = new List<PlanerFile>();
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
return res;
|
||||
|
||||
// Sollte der Path ohne / enden, wird der unterordner mit angegeben
|
||||
// Deshalb manuell hinzufügen, falls nicht vorhanden
|
||||
if (!path.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
path += Path.DirectorySeparatorChar;
|
||||
|
||||
GetPlanerFilesRecursive(new DirectoryInfo(path), path, source, ref res);
|
||||
return res;
|
||||
}
|
||||
private void GetPlanerFilesRecursive(DirectoryInfo directoryInfo, string relativeTo, PlanerUpdateSource source, ref List<PlanerFile> files)
|
||||
{
|
||||
foreach (var item in directoryInfo.GetDirectories())
|
||||
{
|
||||
GetPlanerFilesRecursive(item, relativeTo, source, ref files);
|
||||
}
|
||||
|
||||
foreach (var item in directoryInfo.GetFiles())
|
||||
{
|
||||
var file = new PlanerFile(item, relativeTo, source);
|
||||
|
||||
files.Add(file);
|
||||
}
|
||||
}
|
||||
|
||||
private DownloadPlanerResponseDC Install(PlanerRoot root)
|
||||
{
|
||||
var res = new DownloadPlanerResponseDC();
|
||||
|
||||
res.VersionXML = root.GetVersionXml(Tenant);
|
||||
res.Data = root.GetData();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private DownloadPlanerResponseDC Update(PlanerRoot newestVersion, string versionxml)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
//public BeWoProgramPackageDC Update(BeWoProgramPackageDC current)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// DirectoryInfo dirUpdateRoot = new DirectoryInfo(ConfigurationManager.AppSettings.Get("UpdateRootPath"));
|
||||
|
||||
// var newest = GetNewestVersionSet(dirUpdateRoot, MultitenancyOperationContextExt.Current.Tenant);
|
||||
|
||||
// var res = CreateUpdatePackage(current, newest);
|
||||
|
||||
// res.toLoad = "BeWoPlaner.dll";
|
||||
|
||||
// return res;
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// throw Core.Utils.CreateBeWoFaultException(e);
|
||||
// }
|
||||
//}
|
||||
//private BeWoProgramPackageDC GetNewestVersionSet(DirectoryInfo dirUpdateRoot, string tenant)
|
||||
//{
|
||||
// var res = new BeWoProgramPackageDC();
|
||||
// var dirTenant = dirUpdateRoot.GetDirectories().FirstOrDefault(dict => dict.Name == tenant);
|
||||
|
||||
// var filesRoot = dirUpdateRoot.GetFiles().Select(file => new BeWoProgramFileDC(file));
|
||||
|
||||
// if (dirUpdateRoot is null)
|
||||
// throw new Exception("Couldn't find update root path for launcher updates");
|
||||
|
||||
// res.Files.AddRange(filesRoot);
|
||||
|
||||
// if (dirTenant is null)
|
||||
// return res;
|
||||
|
||||
// foreach (var newFile in dirTenant.GetFiles().Select(file => new BeWoProgramFileDC(file)))
|
||||
// {
|
||||
// var search = res.Files.FirstOrDefault(x => x.FileName == newFile.FileName);
|
||||
|
||||
// if (search is null)
|
||||
// {
|
||||
// res.Files.Add(newFile);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// res.Files.Remove(search);
|
||||
// res.Files.Add(newFile);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return res;
|
||||
//}
|
||||
//private BeWoProgramPackageDC CreateUpdatePackage(BeWoProgramPackageDC oldSet, BeWoProgramPackageDC newSet)
|
||||
//{
|
||||
// var res = new BeWoProgramPackageDC();
|
||||
|
||||
// if (!(oldSet is null))
|
||||
// res.Files.AddRange(oldSet.Files);
|
||||
|
||||
// foreach (var newFile in newSet.Files)
|
||||
// {
|
||||
|
||||
// var oldFile = res.Files.FirstOrDefault(x => x.FileName == newFile.FileName);
|
||||
|
||||
// if (oldFile is null)
|
||||
// {
|
||||
// newFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
// newFile.ToDo = FileToDo.Add;
|
||||
|
||||
// res.Files.Add(newFile);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (oldFile.FileVersion is null || newFile.FileVersion is null)
|
||||
// {
|
||||
// oldFile.FileVersion = newFile.FileVersion;
|
||||
// oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
// oldFile.ToDo = FileToDo.Update;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (oldFile.FileVersion == newFile.FileVersion)
|
||||
// {
|
||||
// if (oldFile.Checksum != newFile.Checksum)
|
||||
// {
|
||||
// oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
// oldFile.ToDo = FileToDo.Update;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// oldFile.ToDo = FileToDo.Nuthing;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// oldFile.FileVersion = newFile.FileVersion;
|
||||
// oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
// oldFile.ToDo = FileToDo.Update;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// foreach (var oldFile in oldSet.Files)
|
||||
// {
|
||||
// var newFile = newSet.Files.FirstOrDefault(x => x.FileName == oldFile.FileName);
|
||||
|
||||
// if (newFile is default(BeWoProgramFileDC))
|
||||
// {
|
||||
// oldFile.ToDo = FileToDo.Remove;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return res;
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ using BeWo.Service.Invoicing;
|
||||
using System.IO;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using BS.SharedLauncher.Enums;
|
||||
|
||||
namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ using BeWo.Service.Configuration;
|
||||
using Castle.Core;
|
||||
using BS.SharedLauncher.DataContract;
|
||||
using BS.SharedLauncher.Information;
|
||||
using BS.SharedLauncher.Enums;
|
||||
|
||||
namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
@@ -35,17 +36,17 @@ namespace BeWo.Service.ServiceImplementations
|
||||
private const string grossBuchstaben = "ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜ";
|
||||
private const string kleinBuchstaben = "abcdefghijklmnopqrstuvwxyzäöüß";
|
||||
|
||||
private Dictionary<BS.Shared.UserValidationResult, BS.SharedLauncher.UserValidationResult> UserValidationMapper = new Dictionary<BS.Shared.UserValidationResult, BS.SharedLauncher.UserValidationResult>()
|
||||
private Dictionary<BS.Shared.UserValidationResult, BS.SharedLauncher.Enums.UserValidationResult> UserValidationMapper = new Dictionary<BS.Shared.UserValidationResult, BS.SharedLauncher.Enums.UserValidationResult>()
|
||||
{
|
||||
{ BS.Shared.UserValidationResult.EmployeeDeleted, BS.SharedLauncher.UserValidationResult.UnknownError},
|
||||
{ BS.Shared.UserValidationResult.IncorrectPin, BS.SharedLauncher.UserValidationResult.IncorrectPin},
|
||||
{ BS.Shared.UserValidationResult.PasswordExpired, BS.SharedLauncher.UserValidationResult.PasswordExpired},
|
||||
{ BS.Shared.UserValidationResult.PinAlreadyUsed, BS.SharedLauncher.UserValidationResult.PinAlreadyUsed},
|
||||
{ BS.Shared.UserValidationResult.PinExpired, BS.SharedLauncher.UserValidationResult.PinExpired},
|
||||
{ BS.Shared.UserValidationResult.TenantUnknown, BS.SharedLauncher.UserValidationResult.TenantUnknown},
|
||||
{ BS.Shared.UserValidationResult.UnkownError, BS.SharedLauncher.UserValidationResult.UnknownError},
|
||||
{ BS.Shared.UserValidationResult.UserValid, BS.SharedLauncher.UserValidationResult.UserValid},
|
||||
{ BS.Shared.UserValidationResult.UserValidTwoFactorAuthenticationNeeded, BS.SharedLauncher.UserValidationResult.UnknownError},
|
||||
{ BS.Shared.UserValidationResult.EmployeeDeleted, BS.SharedLauncher.Enums.UserValidationResult.UnknownError},
|
||||
{ BS.Shared.UserValidationResult.IncorrectPin, BS.SharedLauncher.Enums.UserValidationResult.IncorrectPin},
|
||||
{ BS.Shared.UserValidationResult.PasswordExpired, BS.SharedLauncher.Enums.UserValidationResult.PasswordExpired},
|
||||
{ BS.Shared.UserValidationResult.PinAlreadyUsed, BS.SharedLauncher.Enums.UserValidationResult.PinAlreadyUsed},
|
||||
{ BS.Shared.UserValidationResult.PinExpired, BS.SharedLauncher.Enums.UserValidationResult.PinExpired},
|
||||
{ BS.Shared.UserValidationResult.TenantUnknown, BS.SharedLauncher.Enums.UserValidationResult.TenantUnknown},
|
||||
{ BS.Shared.UserValidationResult.UnkownError, BS.SharedLauncher.Enums.UserValidationResult.UnknownError},
|
||||
{ BS.Shared.UserValidationResult.UserValid, BS.SharedLauncher.Enums.UserValidationResult.UserValid},
|
||||
{ BS.Shared.UserValidationResult.UserValidTwoFactorAuthenticationNeeded, BS.SharedLauncher.Enums.UserValidationResult.UnknownError},
|
||||
};
|
||||
|
||||
public PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword)
|
||||
@@ -168,122 +169,122 @@ namespace BeWo.Service.ServiceImplementations
|
||||
|
||||
}
|
||||
|
||||
public BeWoProgramPackageDC Update(BeWoProgramPackageDC current)
|
||||
{
|
||||
try
|
||||
{
|
||||
DirectoryInfo dirUpdateRoot = new DirectoryInfo(ConfigurationManager.AppSettings.Get("UpdateRootPath"));
|
||||
//public BeWoProgramPackageDC Update(BeWoProgramPackageDC current)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// DirectoryInfo dirUpdateRoot = new DirectoryInfo(ConfigurationManager.AppSettings.Get("UpdateRootPath"));
|
||||
|
||||
var newest = GetNewestVersionSet(dirUpdateRoot, MultitenancyOperationContextExt.Current.Tenant);
|
||||
// var newest = GetNewestVersionSet(dirUpdateRoot, MultitenancyOperationContextExt.Current.Tenant);
|
||||
|
||||
var res = CreateUpdatePackage(current, newest);
|
||||
// var res = CreateUpdatePackage(current, newest);
|
||||
|
||||
res.toLoad = "BeWoPlaner.dll";
|
||||
// res.toLoad = "BeWoPlaner.dll";
|
||||
|
||||
return res;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Core.Utils.CreateBeWoFaultException(e);
|
||||
}
|
||||
}
|
||||
private BeWoProgramPackageDC GetNewestVersionSet(DirectoryInfo dirUpdateRoot, string tenant)
|
||||
{
|
||||
var res = new BeWoProgramPackageDC();
|
||||
var dirTenant = dirUpdateRoot.GetDirectories().FirstOrDefault(dict => dict.Name == tenant);
|
||||
// return res;
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// throw Core.Utils.CreateBeWoFaultException(e);
|
||||
// }
|
||||
//}
|
||||
//private BeWoProgramPackageDC GetNewestVersionSet(DirectoryInfo dirUpdateRoot, string tenant)
|
||||
//{
|
||||
// var res = new BeWoProgramPackageDC();
|
||||
// var dirTenant = dirUpdateRoot.GetDirectories().FirstOrDefault(dict => dict.Name == tenant);
|
||||
|
||||
var filesRoot = dirUpdateRoot.GetFiles().Select(file => new BeWoProgramFileDC(file));
|
||||
// var filesRoot = dirUpdateRoot.GetFiles().Select(file => new BeWoProgramFileDC(file));
|
||||
|
||||
if (dirUpdateRoot is null)
|
||||
throw new Exception("Couldn't find update root path for launcher updates");
|
||||
// if (dirUpdateRoot is null)
|
||||
// throw new Exception("Couldn't find update root path for launcher updates");
|
||||
|
||||
res.Files.AddRange(filesRoot);
|
||||
// res.Files.AddRange(filesRoot);
|
||||
|
||||
if (dirTenant is null)
|
||||
return res;
|
||||
// if (dirTenant is null)
|
||||
// return res;
|
||||
|
||||
foreach (var newFile in dirTenant.GetFiles().Select(file => new BeWoProgramFileDC(file)))
|
||||
{
|
||||
var search = res.Files.FirstOrDefault(x => x.FileName == newFile.FileName);
|
||||
// foreach (var newFile in dirTenant.GetFiles().Select(file => new BeWoProgramFileDC(file)))
|
||||
// {
|
||||
// var search = res.Files.FirstOrDefault(x => x.FileName == newFile.FileName);
|
||||
|
||||
if (search is null)
|
||||
{
|
||||
res.Files.Add(newFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Files.Remove(search);
|
||||
res.Files.Add(newFile);
|
||||
}
|
||||
}
|
||||
// if (search is null)
|
||||
// {
|
||||
// res.Files.Add(newFile);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// res.Files.Remove(search);
|
||||
// res.Files.Add(newFile);
|
||||
// }
|
||||
// }
|
||||
|
||||
return res;
|
||||
}
|
||||
private BeWoProgramPackageDC CreateUpdatePackage(BeWoProgramPackageDC oldSet, BeWoProgramPackageDC newSet)
|
||||
{
|
||||
var res = new BeWoProgramPackageDC();
|
||||
// return res;
|
||||
//}
|
||||
//private BeWoProgramPackageDC CreateUpdatePackage(BeWoProgramPackageDC oldSet, BeWoProgramPackageDC newSet)
|
||||
//{
|
||||
// var res = new BeWoProgramPackageDC();
|
||||
|
||||
if (!(oldSet is null))
|
||||
res.Files.AddRange(oldSet.Files);
|
||||
// if (!(oldSet is null))
|
||||
// res.Files.AddRange(oldSet.Files);
|
||||
|
||||
foreach (var newFile in newSet.Files)
|
||||
{
|
||||
// foreach (var newFile in newSet.Files)
|
||||
// {
|
||||
|
||||
var oldFile = res.Files.FirstOrDefault(x => x.FileName == newFile.FileName);
|
||||
// var oldFile = res.Files.FirstOrDefault(x => x.FileName == newFile.FileName);
|
||||
|
||||
if (oldFile is null)
|
||||
{
|
||||
newFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
newFile.ToDo = FileToDo.Add;
|
||||
// if (oldFile is null)
|
||||
// {
|
||||
// newFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
// newFile.ToDo = FileToDo.Add;
|
||||
|
||||
res.Files.Add(newFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oldFile.FileVersion is null || newFile.FileVersion is null)
|
||||
{
|
||||
oldFile.FileVersion = newFile.FileVersion;
|
||||
oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
oldFile.ToDo = FileToDo.Update;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oldFile.FileVersion == newFile.FileVersion)
|
||||
{
|
||||
if (oldFile.Checksum != newFile.Checksum)
|
||||
{
|
||||
oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
oldFile.ToDo = FileToDo.Update;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldFile.ToDo = FileToDo.Nuthing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oldFile.FileVersion = newFile.FileVersion;
|
||||
oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
oldFile.ToDo = FileToDo.Update;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// res.Files.Add(newFile);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (oldFile.FileVersion is null || newFile.FileVersion is null)
|
||||
// {
|
||||
// oldFile.FileVersion = newFile.FileVersion;
|
||||
// oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
// oldFile.ToDo = FileToDo.Update;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (oldFile.FileVersion == newFile.FileVersion)
|
||||
// {
|
||||
// if (oldFile.Checksum != newFile.Checksum)
|
||||
// {
|
||||
// oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
// oldFile.ToDo = FileToDo.Update;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// oldFile.ToDo = FileToDo.Nuthing;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// oldFile.FileVersion = newFile.FileVersion;
|
||||
// oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
|
||||
// oldFile.ToDo = FileToDo.Update;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
foreach (var oldFile in oldSet.Files)
|
||||
{
|
||||
var newFile = newSet.Files.FirstOrDefault(x => x.FileName == oldFile.FileName);
|
||||
// foreach (var oldFile in oldSet.Files)
|
||||
// {
|
||||
// var newFile = newSet.Files.FirstOrDefault(x => x.FileName == oldFile.FileName);
|
||||
|
||||
if (newFile is default(BeWoProgramFileDC))
|
||||
{
|
||||
oldFile.ToDo = FileToDo.Remove;
|
||||
}
|
||||
}
|
||||
// if (newFile is default(BeWoProgramFileDC))
|
||||
// {
|
||||
// oldFile.ToDo = FileToDo.Remove;
|
||||
// }
|
||||
// }
|
||||
|
||||
return res;
|
||||
}
|
||||
// return res;
|
||||
//}
|
||||
|
||||
public BS.SharedLauncher.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant)
|
||||
public BS.SharedLauncher.Enums.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant)
|
||||
=> UserValidationMapper[(new UserServiceImp()).IsUserValid(pUserName, pPassword, pPIN)];
|
||||
|
||||
public void ResetTenant(string tenant)
|
||||
|
||||
43
Service/ServiceUtils/Update/UpdateConfigHelper.cs
Normal file
43
Service/ServiceUtils/Update/UpdateConfigHelper.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using BS.SharedLauncher.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
namespace BeWo.Service.ServiceUtils.Update
|
||||
{
|
||||
public class UpdateConfigHelper
|
||||
{
|
||||
public XmlDocument Document{ get; set; }
|
||||
public string Tenant { get; set; }
|
||||
|
||||
public UpdateConfigHelper(string configFile, string tenant)
|
||||
{
|
||||
Document = new XmlDocument();
|
||||
Document.Load(configFile);
|
||||
|
||||
Tenant = tenant;
|
||||
}
|
||||
|
||||
//public PlanerUpdateSource Source => GotSpecialVersion ? PlanerUpdateSource.SpecialVersion : PlanerUpdateSource.NewestVersion;
|
||||
|
||||
public string LoadSpecificVersion()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Document.SelectSingleNode($"/config/tenant[@id='{Tenant}']/version").InnerXml;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public string LoadDefaultVersion()
|
||||
{
|
||||
return Document.SelectSingleNode("/config/default/version").InnerXml;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
Service/ServiceUtils/Update/UpdatePathHelper.cs
Normal file
45
Service/ServiceUtils/Update/UpdatePathHelper.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeWo.Service.ServiceUtils.Update
|
||||
{
|
||||
public static class UpdatePathHelper
|
||||
{
|
||||
// UpdateRootPath
|
||||
// L specialTenant
|
||||
// L tenant#1
|
||||
// L exampleData#1
|
||||
// L version
|
||||
// L 1.0.0.0
|
||||
// L _default
|
||||
// L exampleData#2
|
||||
// L tenant#1
|
||||
// L exampleData#3
|
||||
// L 1.0.0.1
|
||||
// L _default
|
||||
// L exampleData#4
|
||||
// L tenant#1
|
||||
// L exampleData#5
|
||||
// L version.config
|
||||
|
||||
public static string UpdateRootPath
|
||||
=> @"d:\ServerBeWoDataExample";
|
||||
//=> ConfigurationManager.AppSettings.Get("UpdateRootPath");
|
||||
|
||||
public static string SpecialTenantPath() => Path.Combine(UpdateRootPath, "specialtenant");
|
||||
public static string SpecialTenantPath(string tenant) => Path.Combine(SpecialTenantPath(), tenant);
|
||||
public static string VersionPath() => Path.Combine(UpdateRootPath, "version");
|
||||
public static string VersionConfigPath() => Path.Combine(UpdateRootPath, "version.config");
|
||||
|
||||
public static string VersionPath(string version) => Path.Combine(VersionPath(), version);
|
||||
public static string VersionTenantPath(string version, string tenant) => Path.Combine(VersionPath(version), tenant);
|
||||
public static string VersionDefaultPath(string version) => VersionTenantPath(version, "_default");
|
||||
|
||||
//ConfigurationManager.AppSettings.Get("UpdateRootPath");
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.SharedLauncher.DataContract
|
||||
{
|
||||
[DebuggerDisplay("{FileName} ({FileVersion})")]
|
||||
[DataContract]
|
||||
public class BeWoProgramFileDC
|
||||
{
|
||||
public BeWoProgramFileDC() : this(null, null, null, FileToDo.Nuthing) { }
|
||||
|
||||
public BeWoProgramFileDC(string filename, Version version) : this(filename, version, null, FileToDo.Nuthing) { }
|
||||
|
||||
public BeWoProgramFileDC(string filename, Version version, byte[] data, FileToDo todo)
|
||||
{
|
||||
FileName = filename;
|
||||
FileVersion = version;
|
||||
FileData = data;
|
||||
ToDo = todo;
|
||||
}
|
||||
|
||||
public BeWoProgramFileDC(FileInfo fi)
|
||||
{
|
||||
FileName = fi.Name;
|
||||
FileExtension = fi.Extension;
|
||||
FullPath = fi.FullName;
|
||||
FileVersion = new Version(FileVersionInfo.GetVersionInfo(fi.FullName).FileVersion ?? "0.0.0.0");
|
||||
ToDo = FileToDo.Nuthing;
|
||||
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
using (var stream = File.OpenRead(FullPath))
|
||||
{
|
||||
Checksum = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public string FileName { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string FileExtension { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public Version FileVersion { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string FullPath { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public byte[] FileData { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public FileToDo ToDo { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string Checksum { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.SharedLauncher.DataContract
|
||||
{
|
||||
[DataContract]
|
||||
public class BeWoProgramFilterDC
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -10,17 +10,14 @@ namespace BS.SharedLauncher.DataContract
|
||||
{
|
||||
//[DebuggerDisplay("{InternalName} ({FileVersion})")]
|
||||
[DataContract]
|
||||
public class BeWoProgramPackageDC
|
||||
public class DownloadPlanerRequestDC
|
||||
{
|
||||
public BeWoProgramPackageDC()
|
||||
public DownloadPlanerRequestDC()
|
||||
{
|
||||
Files = new List<BeWoProgramFileDC>();
|
||||
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public List<BeWoProgramFileDC> Files { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string toLoad { get; set; }
|
||||
public string VersionXML { get; set; }
|
||||
}
|
||||
}
|
||||
25
SharedLauncher/DataContract/DownloadPlanerResponseDC.cs
Normal file
25
SharedLauncher/DataContract/DownloadPlanerResponseDC.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.SharedLauncher.DataContract
|
||||
{
|
||||
[DataContract]
|
||||
public class DownloadPlanerResponseDC
|
||||
{
|
||||
|
||||
public DownloadPlanerResponseDC()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public byte[] Data { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string VersionXML { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.SharedLauncher
|
||||
namespace BS.SharedLauncher.Enums
|
||||
{
|
||||
public enum UserValidationResult
|
||||
{
|
||||
@@ -27,14 +28,6 @@ namespace BS.SharedLauncher
|
||||
SehrStark
|
||||
}
|
||||
|
||||
public enum FileToDo
|
||||
{
|
||||
Add,
|
||||
Remove,
|
||||
Update,
|
||||
Nuthing
|
||||
}
|
||||
|
||||
public enum PasswordValidationResult
|
||||
{
|
||||
Succesful,
|
||||
@@ -45,4 +38,36 @@ namespace BS.SharedLauncher
|
||||
ImFunnyAndUsingBewoAsPasswordSmile,
|
||||
AreTheSame
|
||||
}
|
||||
|
||||
public enum PlanerUpdateSource
|
||||
{
|
||||
VersionDefault = 1,
|
||||
VersionTenant = 2,
|
||||
SpecialTenant = 3
|
||||
|
||||
///// <summary>
|
||||
///// Aus der neusten Version / Default Case
|
||||
///// </summary>
|
||||
//NewestVersion = 1,
|
||||
|
||||
///// <summary>
|
||||
///// Durch spezieller Version in version.config
|
||||
///// </summary>
|
||||
//SpecialVersion = 2,
|
||||
|
||||
///// <summary>
|
||||
///// Aus der neusten Version aus dem Version-Kunden-Ordner
|
||||
///// </summary>
|
||||
//NewestVersionTenant = 3,
|
||||
|
||||
///// <summary>
|
||||
///// Aus der speziellen Version aus dem Version-Kunden-Ordner
|
||||
///// </summary>
|
||||
//SpecialVersionTenant = 4,
|
||||
|
||||
///// <summary>
|
||||
///// Aus dem Kunden-Ordner
|
||||
///// </summary>
|
||||
//SpecialTenant = 5
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Windows" />
|
||||
<Reference Include="System.Windows.Presentation" />
|
||||
@@ -47,12 +49,16 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DataContract\BeWoProgramFilterDC.cs" />
|
||||
<Compile Include="DataContract\DownloadPlanerResponseDC.cs" />
|
||||
<Compile Include="DataContract\DownloadPlanerRequestDC.cs" />
|
||||
<Compile Include="LauncherEnums.cs" />
|
||||
<Compile Include="DataContract\BeWoProgramFileDC.cs" />
|
||||
<Compile Include="Information\ConnectionInformation.cs" />
|
||||
<Compile Include="Update\PlanerFile.cs" />
|
||||
<Compile Include="Update\PlanerRoot.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="DataContract\BeWoProgramPackageDC.cs" />
|
||||
<Compile Include="StringCompressor.cs" />
|
||||
<Compile Include="Utils\NonspecificTools.cs" />
|
||||
<Compile Include="Utils\PathUtils.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
63
SharedLauncher/StringCompressor.cs
Normal file
63
SharedLauncher/StringCompressor.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.SharedLauncher
|
||||
{
|
||||
public static class StringCompressor
|
||||
{
|
||||
/// <summary>
|
||||
/// Compresses the string.
|
||||
/// </summary>
|
||||
/// <param name="text">The text.</param>
|
||||
/// <returns></returns>
|
||||
public static string CompressString(string text)
|
||||
{
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(text);
|
||||
var memoryStream = new MemoryStream();
|
||||
using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Compress, true))
|
||||
{
|
||||
gZipStream.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
memoryStream.Position = 0;
|
||||
|
||||
var compressedData = new byte[memoryStream.Length];
|
||||
memoryStream.Read(compressedData, 0, compressedData.Length);
|
||||
|
||||
var gZipBuffer = new byte[compressedData.Length + 4];
|
||||
Buffer.BlockCopy(compressedData, 0, gZipBuffer, 4, compressedData.Length);
|
||||
Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, gZipBuffer, 0, 4);
|
||||
return Convert.ToBase64String(gZipBuffer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decompresses the string.
|
||||
/// </summary>
|
||||
/// <param name="compressedText">The compressed text.</param>
|
||||
/// <returns></returns>
|
||||
public static string DecompressString(string compressedText)
|
||||
{
|
||||
byte[] gZipBuffer = Convert.FromBase64String(compressedText);
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
int dataLength = BitConverter.ToInt32(gZipBuffer, 0);
|
||||
memoryStream.Write(gZipBuffer, 4, gZipBuffer.Length - 4);
|
||||
|
||||
var buffer = new byte[dataLength];
|
||||
|
||||
memoryStream.Position = 0;
|
||||
using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
|
||||
{
|
||||
gZipStream.Read(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
return Encoding.UTF8.GetString(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
61
SharedLauncher/Update/PlanerFile.cs
Normal file
61
SharedLauncher/Update/PlanerFile.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using BS.SharedLauncher.Utils;
|
||||
using BS.SharedLauncher.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Cryptography;
|
||||
using BS.SharedLauncher.Update;
|
||||
|
||||
namespace BS.SharedLauncher.Update
|
||||
{
|
||||
public class PlanerFile
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Extension { get; set; }
|
||||
public string AbsolutePath { get; set; }
|
||||
public string RelativePath { get; set; }
|
||||
public PlanerUpdateSource Source { get; set; }
|
||||
//public Version FileVersion { get; set; }
|
||||
|
||||
//public byte[] FileData { get; set; }
|
||||
public string Checksum { get; set; }
|
||||
|
||||
public PlanerFile(FileInfo fileInfo, string relativeTo, PlanerUpdateSource source)
|
||||
{
|
||||
Name = fileInfo.Name;
|
||||
Extension = fileInfo.Extension;
|
||||
AbsolutePath = fileInfo.FullName;
|
||||
RelativePath = PathUtils.MakeRelativePath(relativeTo, fileInfo.FullName);
|
||||
Source = source;
|
||||
}
|
||||
|
||||
//public static PlanerFile Init(FileInfo fileInfo, string relativeTo, PlanerUpdateSource source)
|
||||
//{
|
||||
// var res = new PlanerFile()
|
||||
// {
|
||||
// FileSystemName = fileInfo.Name,
|
||||
// FileSystemExtension = fileInfo.Extension,
|
||||
// FileSystemAbsolutePath = fileInfo.FullName,
|
||||
// FileSystemRelativePath = PathUtils.MakeRelativePath(relativeTo, fileInfo.FullName),
|
||||
// FileSystemSource = source
|
||||
// };
|
||||
|
||||
// return res;
|
||||
//}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
//FileData = File.ReadAllBytes(AbsolutePath);
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
using (var stream = File.OpenRead(AbsolutePath))
|
||||
{
|
||||
Checksum = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
163
SharedLauncher/Update/PlanerRoot.cs
Normal file
163
SharedLauncher/Update/PlanerRoot.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
using BS.SharedLauncher.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace BS.SharedLauncher.Update
|
||||
{
|
||||
public class PlanerRoot
|
||||
{
|
||||
public List<PlanerFile> Files { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
public string DefaultVersion { get; set; }
|
||||
public string TenantVersion { get; set; }
|
||||
|
||||
//public List<PlanerDirectory> Directories { get; set; }
|
||||
//public List<PlanerFile> Files { get; set; }
|
||||
|
||||
public PlanerRoot()
|
||||
{
|
||||
Created = DateTime.Now;
|
||||
}
|
||||
|
||||
public string CurrentVersion => TenantVersion ?? DefaultVersion;
|
||||
|
||||
public PlanerFile FindPlanerFile(PlanerFile file)
|
||||
{
|
||||
return Files.Find(x => x.RelativePath == file.RelativePath);
|
||||
}
|
||||
|
||||
public void InitPlanerFiles(List<PlanerFile> files)
|
||||
{
|
||||
Files = new List<PlanerFile>();
|
||||
Files.AddRange(files);
|
||||
}
|
||||
|
||||
private void UpdatePlanerFile(PlanerFile newFile)
|
||||
{
|
||||
var oldFile = FindPlanerFile(newFile);
|
||||
|
||||
oldFile.AbsolutePath = newFile.AbsolutePath;
|
||||
oldFile.Source = newFile.Source;
|
||||
}
|
||||
public void UpdatePlanerFiles(List<PlanerFile> files) => files.ForEach(x => UpdatePlanerFile(x));
|
||||
|
||||
public byte[] GetData()
|
||||
{
|
||||
byte[] res = null;
|
||||
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
|
||||
{
|
||||
var demoFile = archive.CreateEntry("foo.txt");
|
||||
|
||||
using (var entryStream = demoFile.Open())
|
||||
using (var streamWriter = new StreamWriter(entryStream))
|
||||
{
|
||||
streamWriter.Write("Bar!");
|
||||
}
|
||||
}
|
||||
|
||||
res = memoryStream.ToArray();
|
||||
|
||||
// memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
|
||||
//using (var fileStream = new FileStream(@"C:\Temp\test.zip", FileMode.Create))
|
||||
//{
|
||||
// memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
// memoryStream.CopyTo(fileStream);
|
||||
//}
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
//using (var compressedFileStream = new MemoryStream())
|
||||
//{
|
||||
// //Create an archive and store the stream in memory.
|
||||
// using (var zipArchive = new ZipArchive(compressedFileStream, ZipArchiveMode.Create, false))
|
||||
// {
|
||||
// foreach (var caseAttachmentModel in caseAttachmentModels)
|
||||
// {
|
||||
// //Create a zip entry for each attachment
|
||||
// var zipEntry = zipArchive.CreateEntry(caseAttachmentModel.Name);
|
||||
|
||||
// //Get the stream of the attachment
|
||||
// using (var originalFileStream = new MemoryStream(caseAttachmentModel.Body))
|
||||
// using (var zipEntryStream = zipEntry.Open())
|
||||
// {
|
||||
// //Copy the attachment stream to the zip entry stream
|
||||
// originalFileStream.CopyTo(zipEntryStream);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return new FileContentResult(compressedFileStream.ToArray(), "application/zip") { FileDownloadName = "Filename.zip" };
|
||||
//}
|
||||
}
|
||||
|
||||
public string GetVersionXml(string tenant)
|
||||
{
|
||||
XElement versions = new XElement("example");
|
||||
|
||||
XDocument root = new XDocument(
|
||||
new XElement("bewopackage",
|
||||
GetConfigElement(tenant),
|
||||
GetFilesElement()
|
||||
)
|
||||
);
|
||||
|
||||
root.Save("D:\\document.xml");
|
||||
|
||||
//XDocument doc = new XDocument(
|
||||
// new XElement("body",
|
||||
// new XElement("level1",
|
||||
// new XElement("level2", "text"),
|
||||
// new XElement("level2", "other text"))));
|
||||
//doc.Save("D:\\document.xml");
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private XElement GetConfigElement(string tenant)
|
||||
{
|
||||
XElement element = new XElement("config");
|
||||
|
||||
element.Add(new XElement("tenant", tenant));
|
||||
element.Add(new XElement("dversion", DefaultVersion));
|
||||
element.Add(new XElement("tversion", TenantVersion));
|
||||
element.Add(new XElement("created", Created.ToString()));
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
private XElement GetFilesElement()
|
||||
{
|
||||
XElement element = new XElement("files");
|
||||
|
||||
Files.ForEach(x => element.Add(GetFileElement(x)));
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
private XElement GetFileElement(PlanerFile planerFile)
|
||||
{
|
||||
XElement element = new XElement("file");
|
||||
|
||||
element.Add(new XElement("name", planerFile.Name));
|
||||
element.Add(new XElement("relative", planerFile.RelativePath));
|
||||
//element.Add(new XElement("extension", planerFile.Extension));
|
||||
element.Add(new XElement("source", planerFile.Source));
|
||||
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
SharedLauncher/Utils/NonspecificTools.cs
Normal file
18
SharedLauncher/Utils/NonspecificTools.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.SharedLauncher.Utils
|
||||
{
|
||||
public static class NonspecificTools
|
||||
{
|
||||
//public static string createVersionXml(PlanerRoot root)
|
||||
//{
|
||||
// var res = string.Empty;
|
||||
|
||||
// return res;
|
||||
//}
|
||||
}
|
||||
}
|
||||
43
SharedLauncher/Utils/PathUtils.cs
Normal file
43
SharedLauncher/Utils/PathUtils.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.SharedLauncher.Utils
|
||||
{
|
||||
public static class PathUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a relative path from one file or folder to another.
|
||||
/// From https://stackoverflow.com/questions/275689/how-to-get-relative-path-from-absolute-path
|
||||
/// </summary>
|
||||
/// <param name="fromPath">Contains the directory that defines the start of the relative path.</param>
|
||||
/// <param name="toPath">Contains the path that defines the endpoint of the relative path.</param>
|
||||
/// <returns>The relative path from the start directory to the end path or <c>toPath</c> if the paths are not related.</returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="UriFormatException"></exception>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
public static string MakeRelativePath(string fromPath, string toPath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fromPath)) throw new ArgumentNullException("fromPath");
|
||||
if (string.IsNullOrEmpty(toPath)) throw new ArgumentNullException("toPath");
|
||||
|
||||
Uri fromUri = new Uri(fromPath);
|
||||
Uri toUri = new Uri(toPath);
|
||||
|
||||
if (fromUri.Scheme != toUri.Scheme) { return toPath; } // path can't be made relative.
|
||||
|
||||
Uri relativeUri = fromUri.MakeRelativeUri(toUri);
|
||||
string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
|
||||
|
||||
if (toUri.Scheme.Equals("file", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
||||
}
|
||||
|
||||
return relativePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user