コード例 #1
0
        public static bool TryGetManagedGroup(DeviceBatch DeviceBatch, out DeviceBatchDevicesManagedGroup ManagedGroup)
        {
            ADManagedGroup managedGroup;
            string key = GetKey(DeviceBatch);

            if (ActiveDirectory.Context.ManagedGroups.TryGetValue(key, out managedGroup))
            {
                ManagedGroup = (DeviceBatchDevicesManagedGroup)managedGroup;
                return true;
            }
            else
            {
                ManagedGroup = null;
                return false;
            }
        }
コード例 #2
0
 private void UpdateInsuranceDetails(DeviceBatch deviceBatch, string InsuranceDetails)
 {
     if (string.IsNullOrWhiteSpace(InsuranceDetails))
         deviceBatch.InsuranceDetails = null;
     else
         deviceBatch.InsuranceDetails = InsuranceDetails;
     Database.SaveChanges();
 }
コード例 #3
0
 private void UpdateInsuredUntil(DeviceBatch deviceBatch, string InsuredUntil)
 {
     if (string.IsNullOrEmpty(InsuredUntil))
         deviceBatch.InsuredUntil = null;
     else
     {
         DateTime ecd;
         if (DateTime.TryParse(InsuredUntil, out ecd))
         {
             deviceBatch.InsuredUntil = ecd.Date;
         }
         else
         {
             throw new Exception("Invalid Date Format");
         }
     }
     Database.SaveChanges();
 }
コード例 #4
0
 private void UpdateInsuranceSupplier(DeviceBatch deviceBatch, string InsuranceSupplier)
 {
     if (string.IsNullOrWhiteSpace(InsuranceSupplier))
         deviceBatch.InsuranceSupplier = null;
     else
         deviceBatch.InsuranceSupplier = InsuranceSupplier;
     Database.SaveChanges();
 }
コード例 #5
0
 private void UpdateWarrantyDetails(DeviceBatch deviceBatch, string WarrantyDetails)
 {
     if (string.IsNullOrWhiteSpace(WarrantyDetails))
         deviceBatch.WarrantyDetails = null;
     else
         deviceBatch.WarrantyDetails = WarrantyDetails;
     Database.SaveChanges();
 }
コード例 #6
0
        private void UpdateDefaultDeviceModelId(DeviceBatch deviceBatch, string DefaultDeviceModelId)
        {
            if (!string.IsNullOrEmpty(DefaultDeviceModelId))
            {
                int bId;
                if (int.TryParse(DefaultDeviceModelId, out bId))
                {
                    var dm = Database.DeviceModels.Find(bId);
                    if (dm != null)
                    {
                        deviceBatch.DefaultDeviceModelId = dm.Id;
                        deviceBatch.DefaultDeviceModel = dm;

                        Database.SaveChanges();
                        return;
                    }
                }
            }
            else
            {
                // Null Id - No Batch
                deviceBatch.DefaultDeviceModelId = null;
                deviceBatch.DefaultDeviceModel = null;

                Database.SaveChanges();
                return;
            }
            throw new Exception("Invalid Device Model Id");
        }
コード例 #7
0
 private void UpdateUnitQuantity(DeviceBatch deviceBatch, string UnitQuantity)
 {
     if (string.IsNullOrWhiteSpace(UnitQuantity))
         deviceBatch.UnitQuantity = null;
     else
     {
         int unitQuantity;
         if (int.TryParse(UnitQuantity, out unitQuantity))
         {
             deviceBatch.UnitQuantity = unitQuantity;
         }
         else
         {
             throw new Exception("Invalid Number");
         }
     }
     Database.SaveChanges();
 }
コード例 #8
0
 public static string GetKey(DeviceBatch DeviceBatch)
 {
     return string.Format(KeyFormat, DeviceBatch.Id);
 }
コード例 #9
0
 private void UpdatePurchaseDetails(DeviceBatch deviceBatch, string PurchaseDetails)
 {
     if (string.IsNullOrWhiteSpace(PurchaseDetails))
         deviceBatch.PurchaseDetails = null;
     else
         deviceBatch.PurchaseDetails = PurchaseDetails;
     Database.SaveChanges();
 }
コード例 #10
0
 private void UpdatePurchaseDate(DeviceBatch deviceBatch, string PurchaseDate)
 {
     if (string.IsNullOrEmpty(PurchaseDate))
         throw new ArgumentNullException("PurchaseDate", "A Device Batch Purchase Date is required");
     else
     {
         DateTime ecd;
         if (DateTime.TryParse(PurchaseDate, out ecd))
         {
             deviceBatch.PurchaseDate = ecd.Date;
         }
         else
         {
             throw new Exception("Invalid Date Format");
         }
     }
     Database.SaveChanges();
 }
コード例 #11
0
 private void UpdateName(DeviceBatch deviceBatch, string Name)
 {
     if (string.IsNullOrWhiteSpace(Name))
         throw new ArgumentNullException("Name", "Device Batch Name is required");
     else
     {
         // Check for Duplicates
         var d = Database.DeviceBatches.Where(db => db.Id != deviceBatch.Id && db.Name == Name).Count();
         if (d > 0)
         {
             throw new Exception("A Device Batch with that name already exists");
         }
         deviceBatch.Name = Name;
     }
     Database.SaveChanges();
 }
コード例 #12
0
        public static DeviceBatchDevicesManagedGroup Initialize(DeviceBatch DeviceBatch)
        {
            if (DeviceBatch.Id > 0)
            {
                var key = GetKey(DeviceBatch);

                if (!string.IsNullOrEmpty(DeviceBatch.DevicesLinkedGroup))
                {
                    var config = ADManagedGroup.ConfigurationFromJson(DeviceBatch.DevicesLinkedGroup);

                    if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
                    {
                        var group = new DeviceBatchDevicesManagedGroup(
                            key,
                            config,
                            DeviceBatch);

                        // Add to AD Context
                        ActiveDirectory.Context.ManagedGroups.AddOrUpdate(group);

                        return group;
                    }
                }

                // Remove from AD Context
                ActiveDirectory.Context.ManagedGroups.Remove(key);
            }

            return null;
        }
コード例 #13
0
 public static string GetCategoryDescription(DeviceBatch DeviceBatch)
 {
     return CategoryDescriptionFormat;
 }
コード例 #14
0
 public static string GetDescription(DeviceBatch DeviceBatch)
 {
     return string.Format(DescriptionFormat, DeviceBatch.Name);
 }
コード例 #15
0
 private void UpdateComments(DeviceBatch deviceBatch, string Comments)
 {
     if (string.IsNullOrWhiteSpace(Comments))
         deviceBatch.Comments = null;
     else
         deviceBatch.Comments = Comments;
     Database.SaveChanges();
 }
コード例 #16
0
 private void UpdateUnitCost(DeviceBatch deviceBatch, string UnitCost)
 {
     if (string.IsNullOrWhiteSpace(UnitCost))
         deviceBatch.UnitCost = null;
     else
     {
         decimal unitCost;
         if (decimal.TryParse(UnitCost, out unitCost))
         {
             deviceBatch.UnitCost = unitCost;
         }
         else
         {
             throw new Exception("Invalid Currency Format");
         }
     }
     Database.SaveChanges();
 }
コード例 #17
0
        private ScheduledTaskStatus UpdateAssignedUsersLinkedGroup(DeviceBatch DeviceBatch, string AssignedUsersLinkedGroup)
        {
            var configJson = ADManagedGroup.ValidConfigurationToJson(DeviceBatchAssignedUsersManagedGroup.GetKey(DeviceBatch), AssignedUsersLinkedGroup, null);

            if (DeviceBatch.AssignedUsersLinkedGroup != configJson)
            {
                DeviceBatch.AssignedUsersLinkedGroup = configJson;
                Database.SaveChanges();

                var managedGroup = DeviceBatchAssignedUsersManagedGroup.Initialize(DeviceBatch);
                if (managedGroup != null) // Sync Group
                    return ADManagedGroupsSyncTask.ScheduleSync(managedGroup);
            }

            return null;
        }
コード例 #18
0
 private DeviceBatchDevicesManagedGroup(string Key, ADManagedGroupConfiguration Configuration, DeviceBatch DeviceBatch)
     : base(Key, Configuration)
 {
     this.DeviceBatchId = DeviceBatch.Id;
     this.DeviceBatchName = DeviceBatch.Name;
 }