示例#1
0
        private void MsiCmd_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            for (int index = LvSoftware.SelectedItems.Count - 1; index >= 0; index--)
            {
                SoftwareModel item           = (SoftwareModel)LvSoftware.SelectedItems[index];
                string        msiExec        = item.Uninstall;
                int           separatorIndex = msiExec.IndexOf(".exe", StringComparison.Ordinal);
                if (separatorIndex < 1)
                {
                    return;
                }
                string arg = msiExec.Substring(separatorIndex + 4);
                msiExec = msiExec.Substring(0, separatorIndex + 4);
                switch (e.Parameter)
                {
                case "Change":
                    arg = arg.Replace("/X", "/I");
                    Shared.StartProc(msiExec, arg);
                    break;

                case "Repair":
                    arg = arg.Replace("/X", "/I").Replace("/I", "/F ");
                    Shared.StartProc(msiExec, arg);
                    break;
                }
            }
        }
示例#2
0
    /// <summary>
    /// Adds the user to the gamescene and this handlers list.
    /// Adjusts the PressurePlates according to number of players in session.
    /// </summary>
    /// <param name="user_ref">User reference in session (a, b, c or d).</param>
    /// <param name="user_id">User identifier in database.</param>
    /// <param name="user_name">User name.</param>
    public void AddUser(string user_ref, int user_id, string user_name)
    {
        if (users.Count < 4)
        {
            GameObject usr = GameObject.Instantiate(
                userPrefab,
                new Vector3(0, 0, 0),
                Quaternion.Euler(0, 0, 0),
                gameObject.transform);

            usr.GetComponent <Rigidbody>().MovePosition(SoftwareModel.GetComponent <LevelBehaviour> ().GetStartPosition(users.Count));
            usr.transform.localRotation = Quaternion.Euler(SoftwareModel.GetComponent <LevelBehaviour> ().GetStartRotation(users.Count));
            // Alter name of GameObject for clarification between GameObjects.
            usr.name = "USER: "******" : " + user_name;
            pauseMenuController.GetComponent <PauseMenu> ().AddAnimator(usr.GetComponent <Animator> ());
        }
        // Set the timeOut of PressurePlate according to number of players in game.
        PressurePlate.TimeOut = SoftwareModel.GetComponent <LevelBehaviour> ().GetPlateTimeOut(users.Count);
    }
示例#3
0
        public Task InsertSoftware(SoftwareModel software)
        {
            string sql = @"insert into Software (ID, Manufacturer, SoftwareTitle, AssignedTo, PurchaseOrder, LicenseType, PurchaseDate, Supported, SupportExp, TotalKeys, UsedKeys, LicenseKey, Added) 
                        values (@ID, @Manufacturer, @SoftwareTitle, @AssignedTo, @PurchaseOrder, @LicenseType, @PurchaseDate, @Supported, @SupportExp, @TotalKeys, @UsedKeys, @LicenseKey, @Added)";

            return(_db.SaveData(sql, software));
        }
示例#4
0
        public JsonResult Update(SoftwareModel softwareModel)
        {
            ApiResult <Software> apiResult;

            if (ModelState.IsValid)
            {
                if (softwareModel.Id > 0)
                {
                    apiResult = TryExecute(() =>
                    {
                        var software = new Software
                        {
                            Title              = softwareModel.Title,
                            Version            = softwareModel.Version,
                            Description        = softwareModel.Description,
                            LatestVersion      = softwareModel.LatestVersion,
                            RecommendedVersion = softwareModel.RecommendedVersion,
                            Status             = softwareModel.Status,
                            LicenseType        = softwareModel.LicenseType,
                            SoftwareCategoryId = softwareModel.SoftwareCategoryId,
                            Id = softwareModel.Id
                        };
                        _softwareRepository.Update(software);
                        _unitOfWork.Commit();
                        return(software);
                    }, "Software updated sucessfully");
                }
                else
                {
                    apiResult = TryExecute(() =>
                    {
                        var software = new Software
                        {
                            Title              = softwareModel.Title,
                            Version            = softwareModel.Version,
                            Description        = softwareModel.Description,
                            LatestVersion      = softwareModel.LatestVersion,
                            RecommendedVersion = softwareModel.RecommendedVersion,
                            Status             = softwareModel.Status,
                            LicenseType        = softwareModel.LicenseType,
                            LicensesAllowed    = softwareModel.LicensesAllowed,
                            SoftwareCategoryId = softwareModel.SoftwareCategoryId,
                            Id = softwareModel.Id
                        };
                        _softwareRepository.Create(software);
                        _unitOfWork.Commit();
                        return(software);
                    }, "Software created sucessfully");
                }
            }
            else
            {
                apiResult = ApiResultFromModelErrors <Software>();
            }

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        /// <summary>
        ///     Gets a device model by a given device, software model and scenario or null if  no matchin record exists.
        /// </summary>
        public DeviceModelDependency GetDeviceModelDependency(Device device, SoftwareModel softwareModel, Scenario scenario)
        {
            Guid?scenarioId      = scenario?.Id;
            Guid?deviceModelId   = device?.DeviceModelId;
            Guid?softwareModelId = softwareModel?.Id;

            using (_db.Open())
                return(_db.DeviceModelDependencies.LinqReader
                       .Where(m => m.DeviceModelId == deviceModelId && m.SoftwareModelDependencyId == softwareModelId && m.ScenarioId == scenarioId)
                       .FirstOrDefault());
        }
示例#6
0
        /// <summary>
        ///     Associated software as a dependency of a given device model.
        /// </summary>
        public void AddSoftwareDependencies(DeviceModel deviceModel, SoftwareModel softwareModel, string displayName, string description = null)
        {
            // create dependency
            var dependency = new DeviceModelDependency(deviceModel, softwareModel, displayName, description);

            using (_sfDb.Open())
            {
                _sfDb.DeviceModelDependencies.Writer.Insert(dependency);

                _sfDb.Commit();
            }
        }
示例#7
0
        private void UninstallCmd_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (!(e.Command is RoutedUICommand eCommand))
            {
                return;
            }
            bool cmdForce = eCommand == SoftwareCmd.Force;
            bool isForce  = false;

            if (cmdForce)
            {
                List <string> dirsRemove =
                    LvSoftware.SelectedItems.Cast <SoftwareModel>().Select(it => it.Location).ToList();
                MessageBoxResult ques = MessageBox.Show(
                    "These directories will be removed:\n\n" +
                    string.Join("\n", dirsRemove) +
                    "\n\nAre you sure you want to do this?",
                    "Remove application directory", MessageBoxButton.YesNo, MessageBoxImage.Question,
                    MessageBoxResult.Yes);
                if (ques == MessageBoxResult.Yes)
                {
                    isForce = true;
                }
                else
                {
                    return;
                }
            }

            for (int index = LvSoftware.SelectedItems.Count - 1; index >= 0; index--)
            {
                SoftwareModel item = (SoftwareModel)LvSoftware.SelectedItems[index];
                if (!Uninstall(item.Uninstall, item.Msi))
                {
                    continue;
                }
                if (isForce)
                {
                    try
                    {
                        Directory.Delete(item.Location, true);
                    }
                    catch
                    {
                        //ignored
                    }
                }

                _softwareList.Remove(item);
            }
        }
示例#8
0
        public IActionResult update([FromBody] SoftwareModel software)
        {
            try
            {
                softwareRepo.update(software);
                return(StatusCode(200));
            }

            catch (Exception ex)
            {
                errors.log(ex);
                return(Json(null));
            }
        }
示例#9
0
        private void DataGrid_softwareList_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            SoftwareModel soft = (SoftwareModel)DataGrid_softwareList.SelectedItem;

            if (soft == null)
            {
                return;
            }

            string arg = subDirectoryParameters.GetValueOrDefault(Directory.GetParent(soft.path).Name);

            Textbox_launchArgs.Text      = arg == null ? "" : arg;
            Textbox_launchArgs.IsEnabled = !(soft.path.ToLower().EndsWith(".msi"));
        }
示例#10
0
        public ActionResult Save(FormCollection formCollection, SoftwareModel model)
        {
            if (Request != null)
            {
                HttpPostedFileBase file = model.fileName;

                if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName))
                {
                    string fileType = file.ContentType;
                    if (fileType.Contains("application"))
                    {
                        ViewBag.Error = "No executable files can be uploaded.";
                        return(View("UnsuccessfulUpload"));
                    }

                    BinaryReader br        = new BinaryReader(file.InputStream);
                    Byte[]       fileBytes = br.ReadBytes(file.ContentLength);
                    br.Close();

                    //Construct query
                    string query = "insert into Software(admin_id, softwareName, fileName, version, date_added, description, data, contentType) values " +
                                   "(@adminid, @softwareName, @fileName, @version, @date, @description, @data, @fileContentType);";
                    MySqlCommand cmd = new MySqlCommand(query);
                    cmd.Parameters.Add("@adminid", MySqlDbType.Int16).Value       = (int)Membership.GetUser().ProviderUserKey;
                    cmd.Parameters.Add("@softwareName", MySqlDbType.String).Value = model.softwareName;
                    cmd.Parameters.Add("@fileName", MySqlDbType.String).Value     = file.FileName;
                    cmd.Parameters.Add("@version", MySqlDbType.String).Value      = model.version;
                    cmd.Parameters.AddWithValue("@date", DateTime.Now);
                    cmd.Parameters.Add("@description", MySqlDbType.Text).Value       = model.description;
                    cmd.Parameters.Add("@data", MySqlDbType.Blob).Value              = fileBytes;
                    cmd.Parameters.Add("@fileContentType", MySqlDbType.String).Value = file.ContentType;

                    //Save data to db
                    DBConnect db = new DBConnect();
                    db.Insert(cmd);

                    return(View("Success"));
                }
                else
                {
                    ViewBag.Error = "Error in processing the file.";
                    return(View("UnsuccessfulUpload"));
                }
            }
            else
            {
                ViewBag.Error = "No request was sent.";
                return(View("UnsuccessfulUpload"));
            }
        }
示例#11
0
 private void compileButton_Clicked(object sender, EventArgs e)
 {
     try
     {
         softwareModel = new SoftwareModel(openTextBox.Text, softwareModelLoaded);
     }
     catch (Exception ex)
     {
         var dlg = new Dialog("Error", this, DialogFlags.Modal, ResponseType.Ok);
         dlg.VBox.Add(new Label(ex.Message));
         dlg.ShowAll();
         dlg.Run();
         dlg.Destroy();
     }
 }
示例#12
0
 private void compileButton_Clicked(object sender, EventArgs e)
 {
     try
     {
         softwareModel = new SoftwareModel (openTextBox.Text, softwareModelLoaded);
     }
     catch (Exception ex)
     {
         var dlg = new Dialog("Error", this, DialogFlags.Modal, ResponseType.Ok);
         dlg.VBox.Add (new Label (ex.Message));
         dlg.ShowAll ();
         dlg.Run();
         dlg.Destroy();
     }
 }
示例#13
0
        public String Insert()
        {
            System.Diagnostics.Stopwatch sw = new Stopwatch();
            sw.Start();
            for (Int32 i = 0; i < 100; i++)
            {
                Models.SoftwareModel model = new SoftwareModel()
                {
                    Name   = "测试数据" + i,
                    Author = "测试作者" + i
                };
                DataAdapter.MongoDBHelper <Models.SoftwareModel> .Insert(model);

                //DataAdapter.MongoDBHelper<Models.ModelBase.Insert(model);
                //System.Threading.Thread.Sleep(1000);
            }
            sw.Stop();
            return("添加完成,耗时:" + sw.ElapsedMilliseconds.ToString());
        }
示例#14
0
        private async void MsiCmd_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            int selCount = LvSoftware.SelectedItems.Count;

            if (selCount > 20)
            {
                object result = await DialogHost.Show(
                    new GenYesNoUc($"Are you sure you want to work with {selCount} items?"), "RootDialog");

                if (result == null || result.ToString() != "Y")
                {
                    return;
                }
            }

            for (int index = selCount - 1; index >= 0; index--)
            {
                SoftwareModel item           = (SoftwareModel)LvSoftware.SelectedItems[index];
                string        msiExec        = item.Uninstall;
                int           separatorIndex = msiExec.IndexOf(".exe", StringComparison.Ordinal);
                if (separatorIndex < 1)
                {
                    return;
                }
                string arg = msiExec.Substring(separatorIndex + 4);
                msiExec = msiExec.Substring(0, separatorIndex + 4);
                switch (e.Parameter)
                {
                case "Change":
                    arg = arg.Replace("/X", "/I");
                    CustomProc.StartProc(msiExec, arg);
                    break;

                case "Repair":
                    arg = arg.Replace("/X", "/I").Replace("/I", "/F ");
                    CustomProc.StartProc(msiExec, arg);
                    break;
                }
            }
        }
示例#15
0
        //Return all software that user lars has with an outer join

        public List <SoftwareModel> outerJoin()
        {
            SoftwareModel        software;
            List <SoftwareModel> softwares = new List <SoftwareModel>();

            connection.Connect();
            SqlCommand    sqlCommand = new SqlCommand("select software.name from software full outer join corporation on software.corporation_id = corporation.id full outer join account on corporation.id = account.corporation_id where account.name = 'Lars'", connection.getConnection());
            SqlDataReader reader     = sqlCommand.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    software      = new SoftwareModel();
                    software.name = reader["name"].ToString();
                    softwares.Add(software);
                }
            }

            connection.disConnect();
            return(softwares);
        }
        private static SoftwareModel GenerateSoftwareModel(Software pSoftware)
        {
            SoftwareModel model = new SoftwareModel
            {
                MoveTowardsEnd                     = pSoftware.MoveTowardsEnd,
                MoveAwayFromEnd                    = pSoftware.MoveAwayFromEnd,
                MoveToPassableTerrain              = pSoftware.MoveToPassableTerrain,
                MoveToNonPassableTerrain           = pSoftware.MoveToNonPassableTerrain,
                SpendTheLessEnergy                 = pSoftware.SpendTheLessEnergy,
                SpendTheMostEnergy                 = pSoftware.SpendTheMostEnergy,
                SpendNormalEnergy                  = pSoftware.SpendNormalEnergy,
                MoveTowardsEndChromosome           = MathematicalOperations.ConvertIntToBinaryString(pSoftware.MoveTowardsEnd),
                MoveAwayFromEndChromosome          = MathematicalOperations.ConvertIntToBinaryString(pSoftware.MoveAwayFromEnd),
                MoveToPassableTerrainChromosome    = MathematicalOperations.ConvertIntToBinaryString(pSoftware.MoveToPassableTerrain),
                MoveToNonPassableTerrainChromosome = MathematicalOperations.ConvertIntToBinaryString(pSoftware.MoveToNonPassableTerrain),
                SpendTheLessEnergyChromosome       = MathematicalOperations.ConvertIntToBinaryString(pSoftware.SpendTheLessEnergy),
                SpendTheMostEnergyChromosome       = MathematicalOperations.ConvertIntToBinaryString(pSoftware.SpendTheMostEnergy),
                SpendNormalEnergyChromosome        = MathematicalOperations.ConvertIntToBinaryString(pSoftware.SpendNormalEnergy)
            };

            return(model);
        }
        public ActionResult Update(SoftwareModel model)
        {
            string query = "Update Software set softwareName=@softwareName, version=@version, date_added=@date, " +
                           "description=@description where id = @id;";
            MySqlCommand cmd = new MySqlCommand(query);

            cmd.Parameters.AddWithValue("@softwareName", model.softwareName);
            cmd.Parameters.AddWithValue("@version", model.version);
            cmd.Parameters.AddWithValue("@date", DateTime.Now);
            cmd.Parameters.AddWithValue("@description", model.description);
            cmd.Parameters.AddWithValue("@id", model.id);

            DBConnect db = new DBConnect();

            db.Update(cmd);

            query           = "select * from Software";
            cmd.CommandText = query;
            var modelList = FillSoftwareModel(cmd);

            return(View("Index", modelList));
        }
示例#18
0
        public ActionResult Software(SoftwareModel model)
        {
            int pageIndex = model.Page ?? 1;

            using (EquipmentsEntities data = new EquipmentsEntities())
            {
                model.softwareSearch = (from c in data.TB_Software.Where(p => p.KayitDurum == "Active" && (String.IsNullOrEmpty(model.Name) || p.Name.Contains(model.Name))).OrderByDescending(p => p.ID)
                                        select new SoftwareListModel
                {
                    Name = c.Name,
                    PurchaseteDate = c.PurchaseDate,
                    Status = c.Status,
                    UserCode = c.UserCode
                }).ToPagedList(pageIndex, 15);
                if (Request.IsAjaxRequest())
                {
                    return(PartialView("_Software", model));
                }
                else
                {
                    return(View(model));
                }
            }
        }
示例#19
0
 /// <summary>
 /// Creates the PlateControllers and SocketObject, when the scene starts.
 /// Uses the GetTimer to determine time until timeout in level.
 ///
 /// Redefines Gravity in the Game for a more natural feel when objects are falling.
 /// </summary>
 void Start()
 {
     SoftwareModel.CreatePlateController();
     SoftwareModel.CreateSocketObject(GetTimer());
     Physics.gravity = new Vector3(0, -30f, 0);
 }
示例#20
0
        private void DataGrid_softwareList_Loaded(object sender, RoutedEventArgs e)
        {
            string path = App.config.get("softwarepath");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            List <string> dirs = new List <string>();

            dirs.AddRange(Directory.GetFiles(path));

            foreach (var sub in subDirectoryParameters)
            {
                string subPath = $@"{path}\{sub.Key}";

                if (!Directory.Exists(subPath))
                {
                    Directory.CreateDirectory(subPath);
                }

                dirs.AddRange(Directory.GetFiles(subPath));
            }

            dirs.Sort();

            var data = new List <SoftwareModel>();

            foreach (var filePath in dirs)
            {
                var sysicon = System.Drawing.Icon.ExtractAssociatedIcon(filePath);
                var bmpSrc  = Imaging.CreateBitmapSourceFromHIcon(sysicon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                sysicon.Dispose();

                FileInfo fileInfo = new FileInfo(filePath);
                var      itm      = new SoftwareModel();
                itm.icon     = bmpSrc;
                itm.fileInfo = fileInfo;
                itm.size     = Utils.getBytesReadable(fileInfo.Length);
                itm.path     = filePath;
                itm.file     = fileInfo.Name;
                if (fileInfo.Extension == ".msi")
                {
                    itm.name    = Utils.getMsiProperty(filePath, "ProductName");
                    itm.version = Utils.getMsiProperty(filePath, "ProductVersion");
                    itm.company = Utils.getMsiProperty(filePath, "Manufacturer");
                }
                else
                {
                    FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(filePath);

                    itm.name    = fileVersionInfo.ProductName?.Trim();
                    itm.version = fileVersionInfo.FileVersion;
                    itm.company = fileVersionInfo.CompanyName?.Trim();
                }
                data.Add(itm);
            }

            DataGrid_softwareList.ItemsSource = data;
        }
示例#21
0
        private async void UninstallCmd_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (!(e.Command is RoutedUICommand eCommand))
            {
                return;
            }
            if (eCommand == SoftwareCmd.Force)
            {
                string[] dirsRemove = LvSoftware.SelectedItems.Cast <SoftwareModel>()
                                      .Where(it => !string.IsNullOrEmpty(it.Location)).Select(it => it.Location).ToArray();
                IEnumerable <string> regsRemove = LvSoftware.SelectedItems.Cast <SoftwareModel>()
                                                  .Select(it => it.RegPath);
                new ForceRemoveDialog(dirsRemove, regsRemove)
                {
                    Owner = this
                }.ShowDialog();
                if (!ForceRemoveDialog.ForceOk)
                {
                    return;
                }
            }

            int selCount = LvSoftware.SelectedItems.Count;

            if (selCount > 20)
            {
                object result = await DialogHost.Show(
                    new GenYesNoUc($"Are you sure you want to uninstall {selCount} items?"), "RootDialog");

                if (result == null || result.ToString() != "Y")
                {
                    return;
                }
            }

            for (int index = selCount - 1; index >= 0; index--)
            {
                SoftwareModel item = (SoftwareModel)LvSoftware.SelectedItems[index];
                if (!Uninstall(item.Uninstall, item.IsMsi))
                {
                    continue;
                }
                if (ForceRemoveDialog.ForceOk)
                {
                    try
                    {
                        string[]     splitOnHive = item.RegPath.Split(new[] { '\\' }, 2);
                        RegistryHive regHive     = Shared.StringToRegistryHive(splitOnHive[0]);
                        RegistryKey.OpenBaseKey(regHive, RegistryView.Registry32)
                        .DeleteSubKeyTree(splitOnHive[1], false);
                        RegistryKey.OpenBaseKey(regHive, RegistryView.Registry64)
                        .DeleteSubKeyTree(splitOnHive[1], false);
                        if (Directory.Exists(item.Location))
                        {
                            Directory.Delete(item.Location, true);
                        }
                    }
                    catch
                    {
                        //ignored
                    }
                }

                _softwareList.Remove(item);
                HistoryList.Add(new SoftwareLogModel
                {
                    History = $"{DateTime.Now.ToShortTimeString()} - {item.Name} : Uninstalled"
                });
            }
        }