public void UpdateSourceBatch(IEnumerable <SourceFile> fileBatch) { if (this.Sink != null && !String.IsNullOrEmpty(this.CurrentContainer)) { List <ScoredItem> updateList = new List <ScoredItem>(); foreach (SourceFile file in fileBatch) { string image = this.CurrentImageList.FirstOrDefault(x => String.Compare(x, file.DiskLocation, true) == 0); if (image != null && this.Sink != null) { ScoredItem item = new ScoredItem() { Container = this.CurrentContainer, Name = image, Classifications = file.Classifications }; updateList.Add(item); } } this.Sink.Record(updateList); } }
public static UserSettings Parse(BinaryReader reader) { UserSettings settings = new UserSettings(); // Get identification type settings.IdentifiedByUsername = reader.ReadBoolean(); // Get username and security identifier settings.Username = reader.ReadString(); settings.SecurityID = reader.ReadString(); // Get other settings settings.Exists = ScoredItem <bool> .ParseBoolean(reader); settings.Password = ScoredItem <string> .ParseString(reader); settings.PasswordExpired = ScoredItem <bool> .ParseBoolean(reader); settings.PasswordChangeDisabled = ScoredItem <bool> .ParseBoolean(reader); settings.PasswordNeverExpires = ScoredItem <bool> .ParseBoolean(reader); settings.AccountDisabled = ScoredItem <bool> .ParseBoolean(reader); settings.AccountLockedOut = ScoredItem <bool> .ParseBoolean(reader); return(settings); }
public SourceFile NextSourceFile() { SourceFile returnFile = null; if (this.CanMoveNext) { if (this.CurrentImage <= -1) { this.CurrentImage = -1; } string file = this.CurrentImageList[++this.CurrentImage]; returnFile = new SourceFile(); returnFile.Name = System.IO.Path.GetFileName(file); returnFile.Classifications = new List <String>(); returnFile.DiskLocation = file; // Is it cataloged? if (this.Sink != null) { ScoredItem found = this.Sink.Find(this.CurrentContainer, returnFile.DiskLocation); if (found != null) { returnFile.Classifications = found.Classifications; } } } return(returnFile); }
/// <summary> /// Formats an instance of ScoredItem for insertion into the container catalog. /// </summary> private String FormatItem(ScoredItem item) { return(String.Format("{0},{1},{2}", item.Container, item.Name, String.Join("|", item.Classifications))); }
public override void UpdateSourceFile(SourceFile file) { if (this.Sink != null) { ScoredItem item = new ScoredItem() { Container = this.CurrentContainer, Name = file.DiskLocation, Classifications = file.Classifications }; this.Sink.Record(item); } }
public static LockoutPolicy Parse(BinaryReader reader) { // Create instance of policy storage LockoutPolicy policy = new LockoutPolicy(); // Retrieve values defining policy policy.AccountLockoutDuration = ScoredItem <Range> .ParseRange(reader); policy.AccountLockoutThreshold = ScoredItem <Range> .ParseRange(reader); policy.ResetLockoutCounterAfter = ScoredItem <Range> .ParseRange(reader); return(policy); }
public override void UpdateSourceFile(SourceFile file) { ScoringImage image = this.CurrentImageList.FirstOrDefault(x => String.Compare(System.IO.Path.GetFileName(x.Url), file.Name, true) == 0); if (image != null && this.Sink != null) { ScoredItem item = new ScoredItem() { Container = this.CurrentContainer, Name = image.Url, Classifications = file.Classifications }; this.Sink.Record(item); } }
public static AuditPolicy Parse(BinaryReader reader) { // Create instance of policy storage AuditPolicy policy = new AuditPolicy(); List <string> keys = policy.HeaderSettingPairs.Keys.ToList(); // Enumerate audits in dictionary storage foreach (string key in keys) { policy.HeaderSettingPairs[key] = ScoredItem <EAuditSettings> .ParseAuditSettings(reader); } return(policy); }
public IEnumerable <SourceFile> NextSourceGroup() { List <SourceFile> returnFiles = new List <SourceFile>(); if (this.CanMoveNext) { if (this.CurrentImage <= -1) { this.CurrentImage = -1; } int count = 0; while (this.CanMoveNext && count++ < this.BatchSize) { ScoringImage image = this.CurrentImageList[++this.CurrentImage]; // Download blah blah String token = this.AzureStorageUtils.GetSasToken(this.Configuration.StorageConfiguration.StorageContainer); String imageUrl = String.Format("{0}{1}", image.Url, token); SourceFile returnFile = new SourceFile(); returnFile.Name = System.IO.Path.GetFileName(image.Url); // Was this.DownloadStorageFile(imageUrl) returnFile.DiskLocation = this.AzureStorageUtils.DownloadImageBlob( imageUrl, System.IO.Path.Combine(this.Configuration.StorageConfiguration.RecordLocation, "temp")); if (this.Sink != null) { ScoredItem found = this.Sink.Find(this.CurrentContainer, image.Url); if (found != null) { returnFile.Classifications = found.Classifications; } } if (returnFile.Classifications.Count == 0) { returnFile.Classifications.Add(this.CurrentContainerAsClassification); this.UpdateSourceFile(returnFile); } returnFiles.Add(returnFile); } } return(returnFiles); }
public ScoredItem Find(string container, string name) { ScoredItem returnItem = null; if (this.CollectionMap.ContainsKey(container)) { CollectionData collection = GetCollection(container); if (collection != null) { //Is this a duplicate? Are we updating something? returnItem = collection.Items.FirstOrDefault(x => String.Compare(x.Name, name) == 0); } } return(returnItem); }
private StoreViewModel ConvertToView(ScoredItem scoredItem) { var item = scoredItem.Item; var viewModel = new StoreViewModel { Url = item.Url(), StoreName = item.GetString(Templates.Store.Fields.StoreName), Description = item.GetString(Templates.Store.Fields.Description), Logo = item.BuildImageItem(Templates.Store.Fields.Logo), PhoneNumber = item.GetString(Templates.Store.Fields.PhoneNumber), Contact = item.GetString(Templates.Store.Fields.Contact), NewDate = item.GetDateTime(Templates.Store.Fields.NewDate), PostDate = item.GetDateTime(Templates.SchedulableContent.Fields.PostDate), ExpiryDate = item.GetDateTime(Templates.SchedulableContent.Fields.ExpiryDate), UnitNo = item.GetString(Templates.Store.Fields.UnitNo), Brands = item.GetString(Templates.Store.Fields.Brands), Keywords = item.GetString(Templates.Store.Fields.Keywords), OpeningHours = item.GetString(Templates.Store.Fields.OpeningHours), Categories = this.ConvertToStoreCategoriesView(item), Offers = this.ConvertToStoreOffersView(item), Id = IdHelper.NormalizeGuid(item.ID) }; var mallSite = item.GetAncestorOrSelfOfTemplate(Foundation.Multisite.Templates.Site.ID); if (mallSite != null) { viewModel.Mall = mallSite.DisplayName; } var currentdate = DateTime.UtcNow; if (currentdate >= viewModel.PostDate && currentdate < viewModel.NewDate) { viewModel.Status = StoreStatus.Upcoming; } else if (currentdate >= viewModel.NewDate && currentdate < (viewModel.NewDate.AddMonths(3))) { viewModel.Status = StoreStatus.New; } else { viewModel.Status = StoreStatus.Normal; } return(viewModel); }
public IEnumerable <SourceFile> NextSourceGroup() { List <SourceFile> returnFiles = new List <SourceFile>(); if (this.CanMoveNext) { if (this.CurrentImage <= -1) { this.CurrentImage = -1; } int count = 0; while (this.CanMoveNext && count++ < this.BatchSize) { string image = this.CurrentImageList[++this.CurrentImage]; // Download blah blah SourceFile returnFile = new SourceFile(); returnFile.Name = System.IO.Path.GetFileName(image); returnFile.DiskLocation = image; if (this.Sink != null) { ScoredItem found = this.Sink.Find(this.CurrentContainer, image); if (found != null) { returnFile.Classifications = found.Classifications; } } if (returnFile.Classifications.Count == 0) { returnFile.Classifications.Add(this.CurrentContainerAsClassification); this.UpdateSourceFile(returnFile); } returnFiles.Add(returnFile); } } return(returnFiles); }
public static PasswordPolicy Parse(BinaryReader reader) { // Create instance of policy storage PasswordPolicy policy = new PasswordPolicy(); // Retrieve values defining policy policy.EnforcePasswordHistory = ScoredItem <Range> .ParseRange(reader); policy.MaxPasswordAge = ScoredItem <Range> .ParseRange(reader); policy.MinPasswordAge = ScoredItem <Range> .ParseRange(reader); policy.MinPasswordLength = ScoredItem <Range> .ParseRange(reader); policy.PasswordComplexity = ScoredItem <int> .ParseInt32(reader); policy.ReversibleEncryption = ScoredItem <int> .ParseInt32(reader); return(policy); }
public void Record(IEnumerable <ScoredItem> itemBatch) { CollectionData collection = null; String collectionName = String.Empty; // Restriction is they all have to belong to the same collection foreach (ScoredItem item in itemBatch) { collection = GetCollection(item.Container); if (collection == null) { throw new Exception("Invalid collection"); } if (!String.IsNullOrEmpty(collectionName) && String.Compare(collectionName, collection.Logger.FileName) != 0) { throw new Exception("Collections do not match on batch"); } collectionName = collection.Logger.FileName; } // Now we know we have the same collection, update each one. foreach (ScoredItem item in itemBatch) { ScoredItem existing = collection.Items.FirstOrDefault(x => String.Compare(x.Name, item.Name) == 0); if (existing != null) { existing.Classifications = item.Classifications; } else { collection.Items.Add(item); } } // Update the entire thing in one go System.Threading.ThreadPool.QueueUserWorkItem(this.UpdateLog, collection); }
public void Record(ScoredItem item) { // Get or create the collection CollectionData collection = GetCollection(item.Container); if (collection != null) { //Is this a duplicate? Are we updating something? ScoredItem existing = collection.Items.FirstOrDefault(x => String.Compare(x.Name, item.Name) == 0); if (existing != null) { existing.Classifications = item.Classifications; System.Threading.ThreadPool.QueueUserWorkItem(this.UpdateLog, collection); } else { collection.Items.Add(item); collection.Logger.Record(this.FormatItem(item)); } } }
public SourceFile NextSourceFile() { SourceFile returnFile = null; if (this.CanMoveNext) { if (this.CurrentImage <= -1) { this.CurrentImage = -1; } ScoringImage image = this.CurrentImageList[++this.CurrentImage]; // Download blah blah String token = this.AzureStorageUtils.GetSasToken(this.Configuration.StorageContainer); String imageUrl = String.Format("{0}{1}", image.Url, token); returnFile = new SourceFile(); returnFile.Name = System.IO.Path.GetFileName(image.Url); // WAS returnFile.DiskLocation = this.DownloadStorageFile(imageUrl); returnFile.DiskLocation = this.AzureStorageUtils.DownloadImageBlob( imageUrl, System.IO.Path.Combine(this.Configuration.RecordLocation, "temp")); if (this.Sink != null) { ScoredItem found = this.Sink.Find(this.CurrentContainer, image.Url); if (found != null) { returnFile.Classifications = found.Classifications; } } } return(returnFile); }
public void SetFromScoredItem(ScoredItem <Range> scoredItem) { Maximum = scoredItem.Value.Max; Minimum = scoredItem.Value.Min; IsScored = scoredItem.IsScored; }
public void SetFromScoredItem(ScoredItem <EAuditSettings> scoredItem) { AuditSettings = scoredItem.Value; IsScored = scoredItem.IsScored; }
public void SetFromScoredItem(ScoredItem <int> scoredItem) { SelectedIndex = scoredItem.Value; IsScored = scoredItem.IsScored; }
public void SetFromScoredItem(ScoredItem <int> scoredItem) { Number = scoredItem.Value; IsScored = scoredItem.IsScored; }