Exemplo n.º 1
0
        public CategoryDialog(Database.DataModelsDataContext DB)
        {
            InitializeComponent();

            this.category = new Database.Category();
            this.newModel = true;
            this.DB       = DB;
        }
Exemplo n.º 2
0
        public CategoryDialog(Database.Category category, Database.DataModelsDataContext DB)
        {
            InitializeComponent();

            this.category = category;
            this.newModel = false;
            this.DB       = DB;
        }
Exemplo n.º 3
0
        private void GridViewBackupFiles_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            if (GridViewBackupFiles.SelectedRowsCount > 0)
            {
                try
                {
                    BackupFile        backupFile = MainWindow.Settings.BackupFiles[GridViewBackupFiles.FocusedRowHandle];
                    Database.Category category   = MainWindow.Database.CategoriesData.GetCategoryById(backupFile.CategoryId);

                    long fileSize = File.Exists(backupFile.LocalPath) ? new FileInfo(backupFile.LocalPath).Length : 0;

                    LabelGameTitle.Text = category.Title;
                    LabelFileName.Text  = backupFile.FileName;
                    LabelFileSize.Text  = File.Exists(backupFile.LocalPath)
                    ? (MainWindow.Settings.ShowFileSizeInBytes ? fileSize.ToString("{0:n}") + " bytes" : fileSize.FormatBytes())
                    : "No File Exists";
                    LabelCreatedOn.Text   = backupFile.CreatedDate.ToLocalTime().ToString();
                    LabelLocalPath.Text   = backupFile.LocalPath;
                    LabelInstallPath.Text = backupFile.InstallPath;


                    if (!File.Exists(backupFile.LocalPath))
                    {
                        XtraMessageBox.Show(
                            $"Local file: {backupFile.FileName} for game: {category.Title} can't be found at path: {backupFile.LocalPath}.\n\nIf you have moved this file then edit the backup and choose the locate the file, otherwise re-install your game update and backup the orginal game file again.",
                            "No Local File");
                    }
                }
                catch
                {
                    // Will throw index out of range if deleting the last item
                }
            }

            ButtonEdit.Enabled        = GridViewBackupFiles.SelectedRowsCount > 0;
            ButtonDelete.Enabled      = GridViewBackupFiles.SelectedRowsCount > 0;
            ButtonDeleteAll.Enabled   = GridViewBackupFiles.SelectedRowsCount > 0;
            ButtonBackupFile.Enabled  = GridViewBackupFiles.SelectedRowsCount > 0 && MainWindow.IsConsoleConnected;
            ButtonRestoreFile.Enabled = GridViewBackupFiles.SelectedRowsCount > 0 && MainWindow.IsConsoleConnected;
        }
Exemplo n.º 4
0
 public void editCategoryDialogShow(Database.Category c)
 {
     CategoryDialogShow(new CustomControls.CategoryDialog(c, DB));
 }
Exemplo n.º 5
0
        static void HandleCategoryLookup(HttpRequest Request, HttpResponse Response, Guid userId)
        {
            try
            {
                Response.ClearContent();
                ClientControlsWriter w = new ClientControlsWriter(Response.OutputStream);

                //Version
                w.Write((int)1);

                //ResultCode
                if (userId == Guid.Empty)
                {
                    w.Write((int)-1);
                    return;
                }

                string categoryName = Request["categoryName"];
                if (categoryName == null)
                {
                    categoryName = string.Empty;
                }
                categoryName = categoryName.Trim();
                if (!Validation.ValidateCategoryName(categoryName))
                {
                    w.Write((int)-2);
                    return;
                }

                w.Write((int)0);
                // } result code.

                Database.MemberDetails details = Database.GetMemberDetails(null, userId);
                Guid existingId       = Database.GetSubCategory(userId, details.HomeCategoryId, categoryName);
                Database.Category cat = null;
                if (existingId != Guid.Empty)
                {
                    cat = Database.GetCategoryInfo(userId, existingId);
                }

                w.Write(existingId != Guid.Empty);
                w.Write(existingId.ToByteArray());
                //canAddPermission
                w.Write(cat != null && cat.CurrentPermission >= Permission.Add);
                //securityPermission
                w.Write(cat != null && cat.CurrentPermission >= Permission.Owner);                 //TODO: shold be securitypermission.
                w.WriteString(cat != null?cat.Name:categoryName);

                //can't send email
                w.Write((byte)0x00);
                //can't share to friends
                w.Write((byte)0x00);

                //Write the permission entries on the category.
                if (existingId == Guid.Empty)
                {
                    w.Write(0);
                }
                else
                {
                    Guid groupId = Database.GetMemberGroup(userId, "$" + existingId);
                    Database.GroupMember[] members = Database.EnumGroupMembers(userId, groupId);
                    w.Write((uint)(members.Length - 1));                   //minus self
                    foreach (Database.GroupMember member in members)
                    {
                        if (member.MemberId == userId)
                        {
                            continue;
                        }
                        Database.MemberDetails md = Database.GetMemberDetails(null, member.MemberId);
                        w.Write((byte)0);
                        w.Write(md.Id.ToByteArray());
                        w.WriteString(md.admin_username);
                        w.WriteString(md.admin_email);
                        w.WriteString(md.Name);

                        w.Write((uint)0);
                        w.Write((uint)0);
                        w.Write((uint)0);
                        w.Write((uint)0);
                    }
                }
            }
            finally
            {
                Response.Flush();
                Response.Close();
                Response.End();
            }
        }