public int IsUserExist(string email, string DomainName) { int userid = 0; try { db.parameters.Clear(); common = new Commonfunctions(); TblUser tblUser = new TblUser(); DataSet ds = new DataSet(); db = new DataRepository(); db.AddParameter("@emailId", SqlDbType.NVarChar, email); db.AddParameter("@domainName", SqlDbType.NVarChar, DomainName); ds = db.FillData("sp_PlekCheckUserExist"); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { userid = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } } } return(userid); } catch (Exception ex) { newException.AddException(ex); return(userid); } }
public TblUser IsValidUser(string Username, string Password, string DomainName) { try { db.parameters.Clear(); common = new Commonfunctions(); TblUser tblUser = new TblUser(); DataSet ds = new DataSet(); db = new DataRepository(); db.AddParameter("@EmailId", SqlDbType.NVarChar, Username); db.AddParameter("@Password", SqlDbType.NVarChar, Password); db.AddParameter("@DomainName", SqlDbType.NVarChar, DomainName); ds = db.FillData("sp_Login"); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { tblUser = common.UserMapping(ds); } } } return(tblUser); } catch (Exception ex) { newException.AddException(ex); return(null); } }
private async Task <bool> CreatePackage(string outpath) { if (MainController.Get().ActiveMod == null) { MessageBox.Show("No project loaded!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } var packeddir = Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"packed\"); var contentdir = Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"packed\content\"); if (!Directory.Exists(contentdir)) { Directory.CreateDirectory(contentdir); } else { var di = new DirectoryInfo(contentdir); foreach (var file in di.GetFiles()) { file.Delete(); } foreach (var dir in di.GetDirectories()) { dir.Delete(true); } } var packtask = MainController.Get().Window.PackAndInstallMod(); await packtask; var installdir = Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"Installer/"); if (!Directory.Exists(installdir)) { Directory.CreateDirectory(installdir); } var asm = WKPackage.CreateModAssembly(textEditModVersion.Text, textEditModName.Text, new Tuple <string, string, string, string, string, string>(textEditAuthor.Text, textEditDonationUrl.Text, textEditWeb.Text, textEditFaceButt.Text, textEditTwitter.Text, textEditYouTube.Text), memoEditDescription.Text, memoEditLargeDescription.Text, textEditLicense.Text, new Tuple <Color, bool, Color>(HeaderColor, checkEditBlackTextColor.Checked, IconBackGroundColor), new List <XElement>()); var pkg = new WKPackage(asm, IconPath, Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"packed")); pkg.Save(outpath); MainController.Get().LogMessage = new KeyValuePair <string, OutputView.Logtype>("Installer created: " + outpath + "\n", OutputView.Logtype.Success); if (!File.Exists(outpath)) { MainController.Get().LogMessage = new KeyValuePair <string, OutputView.Logtype>("Couldn't create installer. Something went wrong.", OutputView.Logtype.Error); return(false); } MainController.Get().ProjectStatus = "Ready"; Commonfunctions.ShowFileInExplorer(outpath); return(true); }
public RibbonViewModel( ISettingsManager settingsManager, IProgressService <double> progressService, IArchiveManager archiveManager, IProjectManager projectManager, ILoggerService loggerService, IModTools modTools, AppViewModel appViewModel ) { _mainViewModel = appViewModel; _archiveManager = archiveManager; _progressService = progressService; _projectManager = projectManager; _modTools = modTools; _loggerService = loggerService; _settingsManager = settingsManager; //ViewSelectedCommand = new DelegateCommand<object>(ExecuteViewSelected, CanViewSelected); //AssetBrowserAddCommand = new RelayCommand(ExecuteAssetBrowserAdd, CanAssetBrowserAdd); //AssetBrowserOpenFileLocation = new RelayCommand(ExecuteAssetBrowserOpenFileLocation, CanAssetBrowserOpenFileLocation); OpenProjectCommand = ReactiveCommand.Create <string>(s => _mainViewModel.OpenProjectCommand.Execute(s).Subscribe()); //NewProjectCommand = ReactiveCommand.Create(() => _mainViewModel.NewProjectCommand.Execute().Subscribe()); PackProjectCommand = ReactiveCommand.Create(() => _mainViewModel.PackModCommand.SafeExecute()); PackInstallProjectCommand = ReactiveCommand.Create(() => _mainViewModel.PackInstallModCommand.SafeExecute()); NewFileCommand = ReactiveCommand.Create(() => _mainViewModel.NewFileCommand.SafeExecute(null)); SaveFileCommand = ReactiveCommand.Create(() => _mainViewModel.SaveFileCommand.SafeExecute()); SaveAsCommand = ReactiveCommand.Create(() => _mainViewModel.SaveAsCommand.SafeExecute()); SaveAllCommand = ReactiveCommand.Create(() => _mainViewModel.SaveAllCommand.SafeExecute()); ViewProjectExplorerCommand = ReactiveCommand.Create(() => _mainViewModel.ShowProjectExplorerCommand.SafeExecute()); ViewAssetBrowserCommand = ReactiveCommand.Create(() => _mainViewModel.ShowAssetsCommand.SafeExecute()); ViewPropertiesCommand = ReactiveCommand.Create(() => _mainViewModel.ShowPropertiesCommand.SafeExecute()); ViewLogCommand = ReactiveCommand.Create(() => _mainViewModel.ShowLogCommand.SafeExecute()); //ViewCodeEditorCommand = ReactiveCommand.Create(() => _mainViewModel.ShowCodeEditorCommand.SafeExecute()); ShowImportExportToolCommand = ReactiveCommand.Create(() => _mainViewModel.ShowImportExportToolCommand.SafeExecute()); ShowPluginToolCommand = ReactiveCommand.Create(() => _mainViewModel.ShowPluginCommand.SafeExecute()); ShowBugReportCommand = ReactiveCommand.CreateFromTask(async() => { var result = await Interactions.ShowBugReport.Handle(Unit.Default); }); ShowFeedbackCommand = ReactiveCommand.CreateFromTask(async() => { var result = await Interactions.ShowFeedback.Handle(Unit.Default); }); OpenMaterialRepositoryCommand = ReactiveCommand.Create(() => { Commonfunctions.ShowFolderInExplorer(_settingsManager.MaterialRepositoryPath); }); UnbundleGameCommand = ReactiveCommand.CreateFromTask(UnbundleGame); }
async Task CreatePackage(string outpath) { if (MainController.Get().ActiveMod == null) { MessageBox.Show("No project loaded!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MainController.Get().ProjectStatus = EProjectStatus.Busy; var packeddir = Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"packed\"); var contentdir = Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"packed\content\"); if (!Directory.Exists(contentdir)) { Directory.CreateDirectory(contentdir); } else { var di = new DirectoryInfo(contentdir); foreach (var file in di.GetFiles()) { file.Delete(); } foreach (var dir in di.GetDirectories()) { dir.Delete(true); } } var packtask = MockKernel.Get().GetMainViewModel().PackAndInstallMod(); await packtask; var installdir = Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"Installer/"); if (!Directory.Exists(installdir)) { Directory.CreateDirectory(installdir); } var asm = WKPackage.CreateModAssembly(modversionTB.Text, modnameTB.Text, new Tuple <string, string, string, string, string, string>(authorTB.Text, donateTF.Text, webTF.Text, facebookTF.Text, twitterTF.Text, youtubeTF.Text), descriptionRTB.Text, largedescRTB.Text, licenseTB.Text, new Tuple <Color, bool, Color>(headercolor, useblackCB.Checked, iconbg), new List <XElement>()); var pkg = new WKPackage(asm, iconpathTB.Text, Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"packed")); pkg.Save(outpath); MainController.LogString("Installer created: " + outpath + "\n", Logtype.Success); if (!File.Exists(outpath)) { MainController.Get().ProjectStatus = EProjectStatus.Errored; MainController.LogString("Couldn't create installer. Something went wrong.", Logtype.Error); return; } MainController.Get().ProjectStatus = EProjectStatus.Ready; Commonfunctions.ShowFileInExplorer(outpath); }
/// <summary> /// Copies the contents of the "packed" folder into the game mod directory /// </summary> public void InstallMod() { var activeMod = _projectManager.ActiveProject; var logPath = Path.Combine(activeMod.ProjectDirectory, "install_log.xml"); try { //Check if we have installed this mod before. If so do a little cleanup. if (File.Exists(logPath)) { var log = XDocument.Load(logPath); var dirs = log.Root.Element("Files")?.Descendants("Directory").ToList(); if (dirs != null) { //Loop throught dirs and delete the old files in them. foreach (var d in dirs) { foreach (var f in d.Elements("file")) { if (File.Exists(f.Value)) { File.Delete(f.Value); Debug.WriteLine("File delete: " + f.Value); } } } //Delete the empty directories. foreach (var d in dirs) { if (d.Attribute("Path") != null && Directory.Exists(d.Attribute("Path").Value) && !Directory.GetFiles(d.Attribute("Path").Value, "*", SearchOption.AllDirectories).Any()) { Directory.Delete(d.Attribute("Path").Value, true); Debug.WriteLine("Directory delete: " + d.Attribute("Path").Value); } } } //Delete the old install log. We will make a new one so this is not needed anymore. File.Delete(logPath); } var installlog = new XDocument( new XElement("InstalLog", new XAttribute("Project", activeMod.Name), new XAttribute("Build_date", DateTime.Now.ToString()) )); var fileroot = new XElement("Files"); //Copy and log the files. var packedmoddir = activeMod.PackedRootDirectory; if (!Directory.Exists(packedmoddir)) { _loggerService.Error("Failed to install the mod! The packed directory doesn't exist!"); return; } fileroot.Add(Commonfunctions.DirectoryCopy(packedmoddir, _settingsManager.GetRED4GameRootDir(), true)); //var packeddlcdir = Path.Combine(ActiveMod.ProjectDirectory, "packed", "DLC"); //if (Directory.Exists(packeddlcdir)) // fileroot.Add(Commonfunctions.DirectoryCopy(packeddlcdir, MainController.Get().Configuration.CP77GameDlcDir, true)); installlog.Root.Add(fileroot); installlog.Save(logPath); _loggerService.Success($"{activeMod.Name} installed!"); _notificationService.Success($"{activeMod.Name} installed!"); } catch (Exception ex) { //If we screwed up something. Log it. _loggerService.Error(ex); } }
private static void InstallMod() { var ActiveMod = MainController.Get().ActiveMod; var _logger = ServiceLocator.Default.ResolveType <ILoggerService>(); try { //Check if we have installed this mod before. If so do a little cleanup. if (File.Exists(ActiveMod.ProjectDirectory + "\\install_log.xml")) { XDocument log = XDocument.Load(ActiveMod.ProjectDirectory + "\\install_log.xml"); var dirs = log.Root.Element("Files")?.Descendants("Directory"); if (dirs != null) { //Loop throught dirs and delete the old files in them. foreach (var d in dirs) { foreach (var f in d.Elements("file")) { if (File.Exists(f.Value)) { File.Delete(f.Value); Debug.WriteLine("File delete: " + f.Value); } } } //Delete the empty directories. foreach (var d in dirs) { if (d.Attribute("Path") != null) { if (Directory.Exists(d.Attribute("Path").Value)) { if (!(Directory.GetFiles(d.Attribute("Path").Value, "*", SearchOption.AllDirectories).Any())) { Directory.Delete(d.Attribute("Path").Value, true); Debug.WriteLine("Directory delete: " + d.Attribute("Path").Value); } } } } } //Delete the old install log. We will make a new one so this is not needed anymore. File.Delete(ActiveMod.ProjectDirectory + "\\install_log.xml"); } var installlog = new XDocument(new XElement("InstalLog", new XAttribute("Project", ActiveMod.Name), new XAttribute("Build_date", DateTime.Now.ToString()))); var fileroot = new XElement("Files"); //Copy and log the files. if (!Directory.Exists(Path.Combine(ActiveMod.ProjectDirectory, "packed"))) { _logger.LogString("Failed to install the mod! The packed directory doesn't exist! You forgot to tick any of the packing options?", Logtype.Important); return; } var packedmoddir = Path.Combine(ActiveMod.ProjectDirectory, "packed", "Mods"); if (Directory.Exists(packedmoddir)) { fileroot.Add(Commonfunctions.DirectoryCopy(packedmoddir, MainController.Get().Configuration.GameModDir, true)); } var packeddlcdir = Path.Combine(ActiveMod.ProjectDirectory, "packed", "DLC"); if (Directory.Exists(packeddlcdir)) { fileroot.Add(Commonfunctions.DirectoryCopy(packeddlcdir, MainController.Get().Configuration.GameDlcDir, true)); } installlog.Root.Add(fileroot); //Save the log. installlog.Save(ActiveMod.ProjectDirectory + "\\install_log.xml"); _logger.LogString(ActiveMod.Name + " installed!" + "\n", Logtype.Success); } catch (Exception ex) { //If we screwed up something. Log it. _logger.LogString(ex.ToString() + "\n", Logtype.Error); } }