Exemplo n.º 1
0
        private List <AdminCollection> GetCollectionsByDeploymentName(string deploymentName)
        {
            try
            {
                PowerShellExecutor <AdminCollection> executor;

                if (!AdminCollectionsController.executors.TryGetValue(deploymentName, out executor))
                {
                    executor           = new PowerShellExecutor <AdminCollection>();
                    executor.CmdName   = "";
                    executor.NewFunc   = this.NewFunc;
                    executor.Configure = (engine) =>
                    {
                        engine.AddCommand("Get-RDSessionCollection");
                        engine.AddParameter("ConnectionBroker", deploymentName);
                    };
                    executor = AdminCollectionsController.executors.GetOrAdd(deploymentName, executor);
                }

                var list = executor.GetList();
                if (list == null || list.Count() == 0)
                {
                    return(list);
                }

                // Get the Collection Burst settings/ Collection Guids/ Audit files from the Database before returning the list
                var query = string.Format("SELECT CollectionName, IsActive FROM CollectionBurstSettings WHERE DeploymentFQDN ='{0}'", deploymentName);

                var queryResults = ServicesManager.Instance.ExecuteQuery <AdminCollection>(query, (rdr, results) =>
                {
                    var collection   = new AdminCollection();
                    collection.Name  = rdr["CollectionName"].ToString();
                    collection.Burst = (bool)rdr["IsActive"];
                    results.Add(collection);
                });

                if (queryResults != null)
                {
                    queryResults.ForEach(r =>
                    {
                        var collection = list.Where(i => i.Name == r.Name).FirstOrDefault();
                        if (collection != null) // populate the information before returning the list back
                        {
                            collection.Burst = r.Burst;
                        }
                    });
                }

                return(list);
            }
            catch (Exception ex)
            {
                ErrorHelper.SendExcepToDB(ex, "GetCollectionsByDeploymentName", deploymentName);
                throw ex;
            }
        }
Exemplo n.º 2
0
        public void OnRemoveUserButtonClicked(object sender, RoutedEventArgs e)
        {
            DefaultButtonState();
            var selectedList = view.userListBox.SelectedItem == null ? view.adminListBox : view.userListBox;

            if (selectedList == view.adminListBox)
            {
                AdminCollection.Remove(SelectedUser);
            }
            else
            {
                UserCollection.Remove(SelectedUser);
            }
        }
Exemplo n.º 3
0
 public void UpdateP()
 {
     try
     {
         sqlCon.Open();
         AdminCollection.Clear();
         string     statusr = "******";
         SqlCommand running = new SqlCommand(statusr, sqlCon);
         running.CommandType = CommandType.Text;
         running.Parameters.AddWithValue("@statusr", "Заезд подтвержден");
         running.ExecuteNonQuery();
         string     statusd = "UPDATE ParkingPlace SET Status = @statusd WHERE ExitDate < GETDATE()";
         SqlCommand done    = new SqlCommand(statusd, sqlCon);
         done.CommandType = CommandType.Text;
         done.Parameters.AddWithValue("@statusd", "Бронирование завершено");
         done.ExecuteNonQuery();
         string        sql     = "SELECT EnterDate, ExitDate, CarNumber, VehicleType, ParkingType, Price, Username, Status, Id FROM ParkingPlace ORDER BY Status";
         SqlCommand    command = new SqlCommand(sql, sqlCon);
         SqlDataReader reader  = command.ExecuteReader();
         while (reader.Read())
         {
             ParkingPlace place = new ParkingPlace();
             place.Entrydate   = reader.GetDateTime(0);
             place.Exitdate    = reader.GetDateTime(1);
             place.Carnumber   = reader.GetString(2);
             place.Vehicletype = reader.GetString(3);
             place.Parkingtype = reader.GetString(4);
             place.Price       = reader.GetInt32(5);
             place.Username    = reader.GetString(6);
             place.Status      = reader.GetString(7);
             place.Id          = reader.GetInt32(8);
             AdminCollection.Add(place);
         }
         reader.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         if (sqlCon != null)
         {
             sqlCon.Close();
         }
     }
 }
Exemplo n.º 4
0
        public void NewFunc(dynamic psObject, List <AdminCollection> collList)
        {
            var collection = new AdminCollection();

            collection.Name           = psObject.CollectionName;
            collection.NavName        = ApplicationController.GenNavName(psObject.CollectionName);
            collection.Description    = psObject.CollectionDescription;
            collection.CollectionType = psObject.ResourceType;
            double used = 0;

            if (psObject.Size != null)
            {
                double.TryParse(psObject.Size.ToString(), out used);
            }
            collection.Size  = (int)used;
            collection.Burst = false;
            collList.Add(collection);
        }
Exemplo n.º 5
0
        public void OnChangeRankButtonClick(object sender, RoutedEventArgs e)
        {
            if (view.changeRank.Content.ToString() == "Make User")
            {
                UserCollection.Add(SelectedUser);
                AdminCollection.Remove(SelectedUser);

                DefaultButtonState();
            }

            else if (view.changeRank.Content.ToString() == "Make Admin")
            {
                AdminCollection.Add(SelectedUser);
                UserCollection.Remove(SelectedUser);

                DefaultButtonState();
            }
        }
Exemplo n.º 6
0
        public AdminCollection GetCollectionProperty(string deploymentName, string collectionName)
        {
            try
            {
                string pslgetCollection = ConfigurationManager.AppSettings["psl_layer"].ToString() + "/getCollection.ps1";
                string psl_Script       = "";
                using (WebClient client = new WebClient())
                {
                    psl_Script = client.DownloadString(pslgetCollection);
                }
                AdminCollection result = new AdminCollection();

                // Get Audit location
                result.AuditLocation = string.Empty;    // TODO: populate real data when this feature is ready

                // Get the description using powershell
                var command = new ScriptCommand(psl_Script,
                                                new[] { "CollectionName", "ConnectionBroker" }, (psObject, scriptCommand) =>
                {
                    result.Name           = psObject.CollectionName;
                    result.Size           = psObject.Size;
                    result.CollectionType = psObject.ResourceType;
                    result.Description    = psObject.CollectionDescription;
                });
                var data = new Dictionary <string, object> {
                    { "ConnectionBroker", deploymentName }, { "CollectionName", collectionName }
                };
                command.Init(data);

                command.Execute();
                return(result);
            }
            catch (Exception ex)
            {
                ErrorHelper.SendExcepToDB(ex, "GetCollectionProperty", deploymentName);
                throw ex;
            }
        }
Exemplo n.º 7
0
 public async Task UpdateAsync(AdminCollection obj)
 {
     _context.AdminCollection.Update(obj);
     await _context.SaveChangesAsync();
 }
Exemplo n.º 8
0
        public async Task CreateAsync(AdminCollection obj)
        {
            await _context.AdminCollection.AddAsync(obj);

            await _context.SaveChangesAsync();
        }