<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Tango.Scripting.IDE.Themes">
<ControlTemplate x:Key="ScrollViewerControlTemplate1" TargetType="{x:Type ScrollViewer}">
<Grid x:Name="Grid" Background="{DynamicResource ScrollBar.Static.Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Rectangle x:Name="Corner" Grid.Column="1" Fill="{DynamicResource ScrollBar.Static.Background}" Grid.Row="1"/>
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
<ScrollBar x:Name="PART_VerticalScrollBar" AutomationPropusing System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Authentication;
using System.Threading.Tasks;
using System.Web.Http;
using Tango.BL;
using Tango.BL.Builders;
using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.Core;
using Tango.Core.DB;
using Tango.Logging;
using Tango.MachineService.Models;
using Tango.PPC.Common.Web;
using Tango.Web.Controllers;
using Tango.Web.Helpers;
using Tango.Web.SMO;
using Tango.Web.Storage;
using System.Data.Entity;
using Tango.Web.Security;
using Tango.Web.ActiveDirectory;
using Tango.Core.Cryptography;
using Tango.MachineService.Filters;
using Tango.BL.DTO;
namespace Tango.MachineService.Controllers
{
public class PPCController : TangoController<PPCController.TokenObject>
{
private static List<PPCPendingUpload> _pendingUploads;
private ActiveDirectoryManager _ad_manager;
public class TokenObject
{
public LoginMode Mode { get; set; }
public String UserGuid { get; set; }
public String MachineGuid { get; set; }
}
#region Constructors
static PPCController()
{
_pendingUploads = new List<PPCPendingUpload>();
}
public PPCController()
{
_ad_manager = new ActiveDirectoryManager();
}
#endregion
#region Setup & Update
[HttpPost]
[JwtTokenFilter]
public MachineSetupResponse MachineSetup(MachineSetupRequest request)
{
MachineSetupResponse response = new MachineSetupResponse();
LogManager.Log("Setup request received: " + request.ToString());
using (ObservablesContext db = ObservablesContextHelper.CreateContext())
{
db.Configuration.LazyLoadingEnabled = false;
String machine_guid = RequestToken.Object.MachineGuid;
var machine = db.Machines.SingleOrDefault(x => x.Guid == machine_guid);
if (machine == null)
{
throw new AuthenticationException("The specified serial number could not be found.");
}
if (machine.SetupActivation && machine.OsKey == null)
{
throw new InvalidDataException("The specified machine is configured to perform an OS activation but is not associated with an OS activation key.");
}
var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid);
var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault();
response.Version = latest_machine_version.Version;
var manager = new BlobStorageManager();
var container = manager.GetContainer(MachineServiceConfig.TANGO_VERSIONS_CONTAINER);
var blob = container.GetBlockBlobReference(latest_machine_version.BlobName);
response.BlobAddress = blob.GenerateReadSignature(TimeSpan.FromMinutes(60));
DbCredentials credentials = new DbCredentials();
using (SmoManager smo = new SmoManager())
{
credentials = smo.CreateRandomLoginAndUser();
Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) =>
{
using (SmoManager m<