Exemple #1
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!config.IsDirty)
            {
                Application.Current.Shutdown();
            }
            else
            {
                MessageBoxResult result = MessageBox.Show("Do you want to save changes?", "LaunchLater", MessageBoxButton.YesNoCancel);
                if (result == MessageBoxResult.Yes)
                {
                    foreach (var app in _startupItemsToBeDeleted)
                    {
                        StartupItem.Delete(app);
                    }
                    foreach (var app in _startupItemsToBeRestored)
                    {
                        StartupItem.Restore(app);
                    }

                    config.WriteFreshConfigurationFile();
                    Application.Current.Shutdown();
                }
                else if (result == MessageBoxResult.No)
                {
                    Application.Current.Shutdown();
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
Exemple #2
0
        public void StartupNameSuffixesParseTest1()
        {
            string      singleStartupItem = "item";
            StartupItem actual            = AInstruction_Startup.StartupNameSuffixesParse(singleStartupItem);

            Assert.AreEqual("item", actual.StartupName);
            Assert.AreEqual(null, actual.SuffixList);
        }
Exemple #3
0
        public void StartupNameSuffixesParseTest2()
        {
            string      singleStartupItem = "item-o";
            StartupItem actual            = AInstruction_Startup.StartupNameSuffixesParse(singleStartupItem);

            Assert.AreEqual("item", actual.StartupName);
            Assert.AreEqual(1, actual.SuffixList.Count);
            Assert.AreEqual("o", actual.SuffixList[0]);
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            StartupItem = new StartupItem {
                Name = txtName.Text, Path = txtPath.Text, Type = cmbType.SelectedIndex
            };

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            var viewModel = new StartupItemsViewModel();

            viewModel.StartupItems = new ObservableCollection <StartupItemViewModel>();
            StartupItem.GetStartupItems().ToList().ForEach(x => viewModel.StartupItems.Add(new StartupItemViewModel()
            {
                StartupApp = x
            }));
            this.DataContext = viewModel;
        }
Exemple #6
0
        void ReportThings(SQLLib sql, string MachineID, string Method, StartupItem ar, ref Dictionary <string, Int64> AlreadyReported, ReportingPolicyElement RepElementRoot)
        {
            string ID = MachineID + "\\\\" + ar.Key + "\\\\" + ar.Location;

            if (string.IsNullOrWhiteSpace(ar.HKCUUser) == false)
            {
                ID += "\\\\" + ar.HKCUUser;
            }
            bool ReportToAdmin   = RepElementRoot.ReportToAdmin.Value;
            bool ReportToClient  = RepElementRoot.ReportToClient.Value;
            bool UrgentForAdmin  = RepElementRoot.UrgentForAdmin.Value;
            bool UrgentForClient = RepElementRoot.UrgentForClient.Value;

            if (AlreadyReported.ContainsKey(ID) == true)
            {
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToAdmin) != 0)
                {
                    ReportToAdmin = false;
                }
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToClient) != 0)
                {
                    ReportToClient = false;
                }
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForAdmin) != 0)
                {
                    UrgentForAdmin = false;
                }
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForClient) != 0)
                {
                    UrgentForClient = false;
                }
            }

            if (ReportToAdmin == false && ReportToClient == false && UrgentForAdmin == false && UrgentForClient == false)
            {
                return;
            }
            ReportingFlags Flags = (ReportToAdmin == true ? ReportingFlags.ReportToAdmin : 0) |
                                   (ReportToClient == true ? ReportingFlags.ReportToClient : 0) |
                                   (UrgentForAdmin == true ? ReportingFlags.UrgentForAdmin : 0) |
                                   (UrgentForClient == true ? ReportingFlags.UrgentForClient : 0);

            ReportingProcessor.ReportStartup(sql, MachineID, Method, ar, Flags);

            if (AlreadyReported.ContainsKey(ID) == true)
            {
                AlreadyReported[ID] |= (Int64)Flags;
            }
            else
            {
                AlreadyReported.Add(ID, (Int64)Flags);
            }
        }
Exemple #7
0
        static ListStartupItems CollectInfosReg(RegistryKey RegPart, string RegBranch, string RegBranchWOW32, string HKCUUser)
        {
            ListStartupItems data = new ListStartupItems();

            data.MachineID = SystemInfos.SysInfo.MachineID;
            data.Items     = new List <StartupItem>();

            RegistryKey reg = RegPart.OpenSubKey(RegBranch, false);

            if (reg != null)
            {
                foreach (string key in reg.GetValueNames())
                {
                    StartupItem s = new StartupItem();
                    s.Location = "REG";
                    s.Key      = key;
                    s.Item     = Convert.ToString(reg.GetValue(key));
                    s.HKCUUser = HKCUUser;
                    if (string.IsNullOrWhiteSpace(s.Key) == true)
                    {
                        s.Key = "(Default)";
                    }
                    data.Items.Add(s);
                }

                reg.Close();
            }

            if (SystemInfos.SysInfo.CPU == "EM64T")
            {
                reg = RegPart.OpenSubKey(RegBranchWOW32, false);
                if (reg != null)
                {
                    foreach (string key in reg.GetValueNames())
                    {
                        StartupItem s = new StartupItem();
                        s.Location = "REG_WOW";
                        s.Key      = key;
                        s.Item     = Convert.ToString(reg.GetValue(key));
                        s.HKCUUser = HKCUUser;
                        if (string.IsNullOrWhiteSpace(s.Key) == true)
                        {
                            s.Key = "(Default)";
                        }
                        data.Items.Add(s);
                    }

                    reg.Close();
                }
            }

            return(data);
        }
Exemple #8
0
        protected override BuildResult OnBuild(MonoDevelop.Core.IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            var s = StartupItem as Project;

            if (s == null)
            {
                return new BuildResult {
                           FailedBuildCount = 1, CompilerOutput = "No default package specified!", BuildCount = 0
                }
            }
            ;

            return(StartupItem.Build(monitor, configuration));
        }
    }
Exemple #9
0
        /// <summary>
        /// Adds MultiStartupConfiguration when there are
        /// more than one project and one of them is a Backend project
        /// </summary>
        /// <param name="solution">Solution.</param>
        void CreateMultiProjectStartUp(Solution solution)
        {
            if (Parameters.GetBoolValue("CreateBackEndProject") != true || Parameters.GetBoolValue("IncludeBackEndProject") != true)
            {
                return;
            }

            var config = new MultiItemSolutionRunConfiguration("multiprojId", GettextCatalog.GetString("Multiple Projects"));

            foreach (var proj in solution.GetAllProjects())
            {
                if (!proj.SupportsExecute())
                {
                    continue;
                }
                var startupItem = new StartupItem(proj, null);
                config.Items.Add(startupItem);
            }

            solution.MultiStartupRunConfigurations.Add(config);
            solution.StartupConfiguration = config;

            solution.SaveAsync(new ProgressMonitor()).Ignore();
        }
 /// <summary>
 /// Adds an item to the startup of the client.
 /// </summary>
 /// <param name="item">The startup item to add.</param>
 public void AddToStartup(StartupItem item)
 {
     _client.Send(new DoStartupItemAdd {
         StartupItem = item
     });
 }
Exemple #11
0
        public RESTStatus ReportStatups(SQLLib sql, ListStartupItems StartupList, NetworkConnectionInfo ni)
        {
            if (ni.HasAcl(ACLFlags.ComputerLogin) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            StartupList.MachineID = ni.Username;

            lock (ni.sqllock)
            {
                if (Convert.ToInt32(sql.ExecSQLScalar("SELECT COUNT(*) FROM ComputerAccounts WHERE MachineID=@m",
                                                      new SQLParam("@m", StartupList.MachineID))) == 0)
                {
                    ni.Error   = "Invalid MachineID";
                    ni.ErrorID = ErrorFlags.InvalidValue;
                    return(RESTStatus.Denied);
                }
            }

            if (StartupList.Items == null)
            {
                ni.Error   = "Invalid Items";
                ni.ErrorID = ErrorFlags.InvalidValue;
                return(RESTStatus.Fail);
            }
            if (StartupList.SIDUsers == null)
            {
                StartupList.SIDUsers = new List <string>();
            }

            foreach (StartupItem rep in StartupList.Items)
            {
                if (string.IsNullOrWhiteSpace(rep.Location) == true)
                {
                    ni.Error   = "Invalid Items";
                    ni.ErrorID = ErrorFlags.InvalidValue;
                    return(RESTStatus.Fail);
                }
                if (string.IsNullOrWhiteSpace(rep.Key) == true)
                {
                    ni.Error   = "Invalid Items";
                    ni.ErrorID = ErrorFlags.InvalidValue;
                    return(RESTStatus.Fail);
                }

                if (string.IsNullOrWhiteSpace(rep.HKCUUser) == true)
                {
                    rep.HKCUUser = "";
                }
                if (string.IsNullOrWhiteSpace(rep.Item) == true)
                {
                    rep.Item = "";
                }
            }

            List <StartupItem> Installed = new List <StartupItem>();
            List <StartupItem> Reported  = StartupList.Items;

            lock (ni.sqllock)
            {
                SqlDataReader dr = sql.ExecSQLReader("SELECT * FROM Startups WHERE MachineID=@id", new SQLParam("@id", StartupList.MachineID));
                while (dr.Read())
                {
                    StartupItem ar = new StartupItem();
                    ar.Location = Convert.ToString(dr["Location"]);
                    ar.Key      = Convert.ToString(dr["Key"]);
                    ar.Item     = Convert.ToString(dr["Item"]);
                    ar.HKCUUser = Convert.ToString(dr["HKCUUser"]);
                    if (string.IsNullOrWhiteSpace(ar.HKCUUser) == true)
                    {
                        ar.HKCUUser = "";
                    }

                    Installed.Add(ar);
                }
                dr.Close();
            }

            List <StartupItem> Updated   = new List <StartupItem>();
            List <StartupItem> Unchanged = new List <StartupItem>();
            List <StartupItem> Removed   = new List <StartupItem>();
            List <StartupItem> Added     = new List <StartupItem>();

            foreach (StartupItem inst in Installed)
            {
                inst.Location = inst.Location.Trim();
                inst.Key      = inst.Key.Trim();
                inst.Item     = inst.Item.Trim();
                inst.HKCUUser = inst.HKCUUser.Trim();

                bool Found = false;
                foreach (StartupItem rep in Reported)
                {
                    rep.Location = rep.Location.Trim();
                    rep.Key      = rep.Key.Trim();
                    rep.Item     = rep.Item.Trim();
                    rep.HKCUUser = rep.HKCUUser.Trim();

                    if (rep.Location.ToLower() == inst.Location.ToLower() && rep.Key == inst.Key && rep.HKCUUser == inst.HKCUUser)
                    {
                        if (rep.Item.ToLower() == inst.Item.ToLower())
                        {
                            Unchanged.Add(rep);
                            Found = true;
                            break;
                        }
                        else
                        {
                            Updated.Add(rep);
                            Found = true;
                            break;
                        }
                    }
                }
                if (Found == false)
                {
                    if (inst.HKCUUser != "" && StartupList.SIDUsers.Contains(inst.HKCUUser, StringComparer.InvariantCultureIgnoreCase) == false)
                    {
                        //likely that this user is not logged on or such
                        Unchanged.Add(inst);
                    }
                    else
                    {
                        Removed.Add(inst);
                    }
                }
            }

            foreach (StartupItem inst in Reported)
            {
                bool Found = false;
                foreach (StartupItem rep in Installed)
                {
                    if (rep.Key.ToLower() == inst.Key.ToLower() && rep.Location == inst.Location && rep.HKCUUser == inst.HKCUUser)
                    {
                        Found = true;
                        break;
                    }
                }
                if (Found == false)
                {
                    Added.Add(inst);
                }
            }

            lock (ni.sqllock)
            {
                try
                {
                    sql.BeginTransaction();
                    sql.SEHError = true;
                    foreach (StartupItem ar in Removed)
                    {
                        sql.ExecSQL("DELETE FROM Startups WHERE MachineID=@id AND [Key]=@key AND Location=@location AND HKCUUser=@user",
                                    new SQLParam("@id", StartupList.MachineID),
                                    new SQLParam("@key", ar.Key),
                                    new SQLParam("@user", ar.HKCUUser),
                                    new SQLParam("@location", ar.Location));
                    }
                    foreach (StartupItem ar in Updated)
                    {
                        sql.ExecSQL(@"UPDATE Startups SET
                            Item=@item,
                            DT=@DT
                            WHERE MachineID=@id AND [Key]=@key AND Location=@location AND HKCUUser=@user",
                                    new SQLParam("@id", StartupList.MachineID),
                                    new SQLParam("@key", ar.Key),
                                    new SQLParam("@user", ar.HKCUUser),
                                    new SQLParam("@location", ar.Location),
                                    new SQLParam("@item", ar.Item),
                                    new SQLParam("@DT", DateTime.UtcNow));
                    }
                    foreach (StartupItem ar in Added)
                    {
                        sql.InsertMultiData("Startups",
                                            new SQLData("MachineID", StartupList.MachineID),
                                            new SQLData("Item", ar.Item),
                                            new SQLData("Location", ar.Location),
                                            new SQLData("Key", ar.Key),
                                            new SQLData("HKCUUser", ar.HKCUUser),
                                            new SQLData("DT", DateTime.UtcNow));
                    }
                    sql.CommitTransaction();
                }
                catch (Exception ee)
                {
                    sql.RollBackTransaction();
                    FoxEventLog.WriteEventLog("DB Error: Cannot update Startups: " + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                    return(RESTStatus.ServerError);
                }
                finally
                {
                    sql.SEHError = false;
                }
            }

            StartupLst l = new StartupLst();

            l.Added     = Added;
            l.Removed   = Removed;
            l.Unchanged = Unchanged;
            l.Updated   = Updated;
            l.MachineID = StartupList.MachineID;
            Thread t = new Thread(new ParameterizedThreadStart(new DReportingThread(ReportingThread)));

            t.Start(l);

            return(RESTStatus.Created);
        }
Exemple #12
0
        public static void ReportStartup(SQLLib sql, string MachineID, string Method, StartupItem AR, ReportingFlags Flags)
        {
            Flags &= ~(ReportingFlags.AdminReported | ReportingFlags.ClientReported | ReportingFlags.UrgentAdminReported | ReportingFlags.UrgentClientReported);

            ReportingStartup a = new ReportingStartup();

            a.Action = Method;
            a.App    = AR;

            sql.InsertMultiData("Reporting",
                                new SQLData("MachineID", MachineID),
                                new SQLData("Type", ReportingPolicyType.Startup),
                                new SQLData("Data", JsonConvert.SerializeObject(a)),
                                new SQLData("Flags", Flags));
        }