/// <summary>
        /// Handles Windowed Mode
        /// </summary>
        private void WindowedCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            string[] linesToAppend =
            {
                "FullscreenMode=",
                "LastConfirmedFullscreenMode=",
                "PreferredFullscreenMode=",
            };

            string[] customValues =
            {
                "1",
                "1",
                "1"
            };

            List <string> fileContents = DFile.AppendFileContents(Game.GameUserSettingsINI, linesToAppend, customValues);

            // Remove the Read Only attribute from the GameUserSettings.ini file
            File.SetAttributes(Game.GameUserSettingsINI, FileAttributes.Normal);

            // Overwrite the info in the file
            File.WriteAllLines(Game.GameUserSettingsINI, fileContents);

            // Re-Add the Read Only attribute to the GameUserSettings.ini file
            File.SetAttributes(Game.GameUserSettingsINI, FileAttributes.ReadOnly);
        }
Esempio n. 2
0
        public int GetFilePages(DFile file)
        {
            if (file.Body.Size >= 10 * 1024 * 1024)
            {
                return(0);
            }

            try
            {
                var pages = _store.GetFilePageCount(file.Body.Id);
                if (pages != 0)
                {
                    return(pages);
                }

                var fileContent = _repository.GetFileChunk(_file.Body.Id, 0, (int)_file.Body.Size);
                var count       = _documentRender.RenderPages(fileContent, _store.GetImagesStorageDirectory(file.Body.Id));
                return(count);
            }
            catch (RenderToolNotFoundException ex)
            {
                _logger.Error(ex);
                //todo show error ui
            }
            catch (Exception ex)
            {
                _logger.Error("Unable to generate page for file", ex);
            }

            return(0);
        }
        /// <summary>
        /// Handels Height of the game window (ONLY if Fullscreen is enabled!)
        /// </summary>
        private void HeightTextBox_TextChanged(object sender, EventArgs e)
        {
            string[] linesToAppend =
            {
                "ResolutionSizeY=",
                "LastUserConfirmedResolutionSizeY=",
                "DesiredScreenHeight=",
                "LastUserConfirmedDesiredScreenHeight="
            };

            string[] customValues =
            {
                HeightTextBox.Text,
                HeightTextBox.Text,
                HeightTextBox.Text,
                HeightTextBox.Text
            };

            List <string> fileContents = DFile.AppendFileContents(Game.GameUserSettingsINI, linesToAppend, customValues);

            // Remove the Read Only attribute from the GameUserSettings.ini file
            File.SetAttributes(Game.GameUserSettingsINI, FileAttributes.Normal);

            // Overwrite the info in the file
            File.WriteAllLines(Game.GameUserSettingsINI, fileContents);

            // Re-Add the Read Only attribute to the GameUserSettings.ini file
            File.SetAttributes(Game.GameUserSettingsINI, FileAttributes.ReadOnly);
        }
        /// <summary>
        /// Handles Fullscreen
        /// </summary>
        private void FullscreenCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            // Fix Fullscreen for ini file (0 = Fullscreen, 1 = Windowed Fullscreen)
            bool FullscreenFix = !FullscreenCheckBox.Checked;

            string[] linesToAppend =
            {
                "FullscreenMode=",
                "LastConfirmedFullscreenMode=",
                "PreferredFullscreenMode=",
            };

            string[] customValues =
            {
                Convert.ToInt32(FullscreenFix).ToString(),
                Convert.ToInt32(FullscreenFix).ToString(),
                Convert.ToInt32(FullscreenFix).ToString(),
            };

            List <string> fileContents = DFile.AppendFileContents(Game.GameUserSettingsINI, linesToAppend, customValues);

            // Remove the Read Only attribute from the GameUserSettings.ini file
            File.SetAttributes(Game.GameUserSettingsINI, FileAttributes.Normal);

            // Overwrite the info in the file
            File.WriteAllLines(Game.GameUserSettingsINI, fileContents);

            // Re-Add the Read Only attribute to the GameUserSettings.ini file
            File.SetAttributes(Game.GameUserSettingsINI, FileAttributes.ReadOnly);
        }
Esempio n. 5
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                //_fileData = await DFile.GetData();
                _fileAllData = await DFile.GetAllData();

                _fileTypeData = await DFileType.GetData();

                _violationData = await DViolation.GetData();

                _creatPersonData = await DPerson.GetCreate();

                _creatPlaqueData = await DPlaque.GetCreate();
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message);
                Close();
                return;
            }
            //_fileSearchData = _fileData;
            _fileSearchAllData       = _fileAllData;
            CboFileType.ItemsSource  = _fileTypeData;
            CboViolation.ItemsSource = _violationData;
            DgdFile.ItemsSource      = _fileSearchAllData;
            BtnNew_Click(null, null);
        }
Esempio n. 6
0
 public RenderViewModel(DFile file, IRepository repository, IDocumentRender documentRender, IStore store)
 {
     _file           = file;
     _repository     = repository;
     _documentRender = documentRender;
     _store          = store;
 }
Esempio n. 7
0
        private async void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckSelectDelete())
            {
                return;
            }
            var selectItem = _fileSearchAllData[DgdFile.SelectedIndex];

            if (!CanDelete(selectItem.Id))
            {
                return;
            }
            Utility.MyMessageBox("هشدار", "آیا از حذف اطمینان دارید؟ ", "Warning.png", false);
            if (!Utility.YesNo)
            {
                return;
            }
            try
            {
                if (selectItem.Id != null)
                {
                    var deleteFile = new DFile
                    {
                        DId = (int)selectItem.Id
                    };
                    await Task.Run(() => deleteFile.Delete());
                }
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message);
                return;
            }

            try
            {
                if (selectItem.Id != null)
                {
                    var deleteFilePerson = new DFilePerson
                    {
                        DFileId = (int)selectItem.Id
                    };
                    await Task.Run(() => deleteFilePerson.Delete());


                    var deleteFilePlaque = new DFilePlaque
                    {
                        DFileId = (int)selectItem.Id
                    };
                    await Task.Run(() => deleteFilePlaque.Delete());
                }
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message);
            }

            Window_Loaded(null, null);
            Utility.Message("پیام", "اطلاعات با موفقیت حذف گردید", "Correct.png");
        }
Esempio n. 8
0
        private DChangesetData CreateChangesetData(Guid objectId, Stream stream, string fileName)
        {
            var dBody = CreateFileBody(stream);
            var file  = new DFile
            {
                Body = dBody,
                Name = fileName
            };

            Logger.InfoFormat("Creating new filebody({0})", dBody.Id);

            var change = _objectModifier.EditObject(objectId);

            change = _objectModifier.AddFile(change, file, fileName);

            if (IsSameFileAdded(change))
            {
                Logger.InfoFormat("Update canceled: same file was added");
                return(null);
            }

            var changesetData = new DChangesetData {
                Identity = Guid.NewGuid()
            };

            changesetData.Changes.Add(change);
            changesetData.NewFileBodies.Add(file.Body.Id);

            Logger.InfoFormat("Changeset({0}) created", changesetData.Id);
            return(changesetData);
        }
Esempio n. 9
0
 private void LaunchThreadToGetFileProperties()
 {
     WindowWrapper.Current().Dispatcher.Dispatch(async() =>
     {
         var prop      = await DFile.GetBasicPropertiesAsync();
         FileTimeStamp = prop.ItemDate.ToString("g");
     });
 }
Esempio n. 10
0
 public DChange AddFile(DChange change, DFile file, string fileName)
 {
     if (change.Old.ActualFileSnapshot.Files.Count > 0)
     {
         change = CreateSnapshot(change);
     }
     change.New.ActualFileSnapshot.AddFile(file, _personId);
     return(change);
 }
Esempio n. 11
0
        private void CreateFile(DFile file)
        {
            Logger.InfoFormat("Uploading file {0}", file.Body.Id);
            long pos = 0;

            if (file.Body.Size > MinResumeUploadFileSize)
            {
                //get file position from server
                pos = _fileArchiveApi.GetFilePosition(file.Body.Id);
                if (pos > file.Body.Size)
                {
                    throw new Exception($"File with id {file.Body.Id} is corrupted");
                }
            }

            // change progress
            _uploaded += pos;

            //send file body to server
            _fileStream.Position = 0;
            if (file.Body.Size != _fileStream.Length)
            {
                throw new Exception($"Local file size is incorrect: {file.Body.Id}");
            }

            var fileBody = file.Body;

            const int maxAttemptCount = 5;
            int       attemptCount    = 0;
            bool      succeed         = false;

            do
            {
                UploadData(_fileStream, file.Body.Id, pos);
                try
                {
                    _fileArchiveApi.PutFileInArchive(fileBody);
                    succeed = true;
                }
                catch (Exception e)
                {
                    Logger.Error("Error on uploading file {0}", e);
                    pos       = 0;
                    _uploaded = 0;
                }
                attemptCount++;
            } while (!succeed && attemptCount < maxAttemptCount);

            if (!succeed)
            {
                throw new Exception($"Unable to upload file {file.Body.Id}");
            }
        }
Esempio n. 12
0
        public static void SaveFile(string dir, string[] fileNames, string username, bool locked, string privacy, string[] usernames)
        {
            using (TransactionScope sc = new TransactionScope())
                using (boxEntities box = new boxEntities())
                {
                    if (privacy == "Global")
                    {
                        dir = ProjectClass.GetConfigString("GlobalDir", "Global");
                    }
                    var id = Profile.getUserID(username);
                    var d  = dir.Split('/');
                    foreach (var t in fileNames)
                    {
                        DFile file = new DFile();
                        file.Filename  = t;
                        file.Directory = dir;
                        file.UpFolder  = d[d.Length - 1];
                        file.DateAdded = DateTime.Now;
                        file.Privacy   = privacy;
                        file.FullName  = dir + "/" + t;
                        file.Locked    = locked;
                        file.Creator   = id;

                        box.DFiles.AddObject(file);


                        if (privacy == "Public")
                        {
                            foreach (var user in usernames)
                            {
                                FilePrivacy fileP = new FilePrivacy();
                                fileP.UserID = id;
                                fileP.FileID = file.ID;
                                fileP.CanSee = true;

                                box.FilePrivacies.AddObject(fileP);
                            }

                            box.SaveChanges();
                        }
                    }
                    box.SaveChanges();

                    // save file in the
                    sc.Complete();
                }
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                _fileAllData = await DFile.GetAllData();

                _creatPersonData = await DPerson.GetCreate();

                _creatPlaqueData = await DPlaque.GetCreate();
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message);
                Close();
                return;
            }
            _fileSearchAllData  = _fileAllData;
            DgdFile.ItemsSource = _fileSearchAllData;
            FileId = 0;
            New();
        }
Esempio n. 14
0
    public static void w(String o)
    {
        try {
            string logDir = System.Web.HttpContext.Current.Server.MapPath("~");
            if (logDir == "")
            {
                logDir = "C://log/";
            }
            else
            {
                logDir = logDir + "/log/";
            }
            string currentDataTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            string logFilePath = logDir + currentDataTime.Substring(0, 7) + "/" + currentDataTime.Substring(0, 10) + ".log";

            DFile f = new DFile(logFilePath, currentDataTime.Substring(11) + "\t" + o + "-------\r\n");
            f.ReadWriteFile();
        }
        catch {
        }
    }
Esempio n. 15
0
        public int GetFilePages(DFile file)
        {
            if (file.Body.Size >= 10 * 1024 * 1024)
            {
                return(0);
            }

            try
            {
                var pages = _store.GetFilePageCount(file.Body.Id);
                if (pages != 0)
                {
                    return(pages);
                }

                var fileContent = _repository.GetFileChunk(_file.Body.Id, 0, (int)_file.Body.Size);
                var contents    = _documentRender.RenderPages(fileContent).ToList();

                for (var i = 0; i < contents.Count; i++)
                {
                    var content = contents[i];
                    var page    = i + 1;
                    _store.PutImageFileAsync(_file.Body.Id, content, page);
                }

                return(contents.Count);
            }
            catch (RenderToolNotFoundException ex)
            {
                _logger.Error(ex);
                //todo show error ui
            }
            catch (Exception ex)
            {
                _logger.Error("Unable to generate page for file", ex);
            }

            return(0);
        }
        /// <summary>
        /// Handles Framerate cap (ONLY if V-Sync is disabled!)
        /// </summary>
        private void FramerateTextBox_TextChanged(object sender, EventArgs e)
        {
            string[] linesToAppend =
            {
                "FrameRateLimit=",
            };

            string[] customValues =
            {
                FramerateTextBox.Text,
            };

            List <string> fileContents = DFile.AppendFileContents(Game.GameUserSettingsINI, linesToAppend, customValues);

            // Remove the Read Only attribute from the GameUserSettings.ini file
            File.SetAttributes(Game.GameUserSettingsINI, FileAttributes.Normal);

            // Overwrite the info in the file
            File.WriteAllLines(Game.GameUserSettingsINI, fileContents);

            // Re-Add the Read Only attribute to the GameUserSettings.ini file
            File.SetAttributes(Game.GameUserSettingsINI, FileAttributes.ReadOnly);
        }
        /// <summary>
        /// Handles V-Sync
        /// </summary>
        private void VSyncCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            string[] linesToAppend =
            {
                "bUseVSync="
            };

            string[] customValues =
            {
                VsyncCheckBox.Checked.ToString(),
            };

            List <string> fileContents = DFile.AppendFileContents(Game.GameUserSettingsINI, linesToAppend, customValues);

            // Remove the Read Only attribute from the Engine.ini file
            File.SetAttributes(Game.GameUserSettingsINI, FileAttributes.Normal);

            // Overwrite the info in the file
            File.WriteAllLines(Game.GameUserSettingsINI, fileContents);

            // Re-Add the Read Only attribute to the Engine.ini file
            File.SetAttributes(Game.GameUserSettingsINI, FileAttributes.ReadOnly);
        }
Esempio n. 18
0
 public async Task DownloadFilesAsync(DFile dFile)
 {
     MessageBox.Show("下载成功!");
 }
Esempio n. 19
0
        private async void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckEmpty())
            {
                return;
            }
            var fileId = 0;

            #region AddFile

            try
            {
                var addFile = new DFile
                {
                    DMainId      = MainId,
                    DMarlik      = int.Parse(TxtMarlik.Text),
                    DFileTypeId  = CboFileType.SelectedIndex == -1 ? (byte?)null : ((tblFileType)CboFileType.SelectedItem).Id,
                    DViolationId = CboViolation.SelectedIndex == -1 ? (byte?)null : ((tblViolation)CboViolation.SelectedItem).Id,
                    DFileNum     = string.IsNullOrEmpty(TxtFileNum.Text) ? (int?)null : int.Parse(TxtFileNum.Text),
                    DFileYear    = string.IsNullOrEmpty(TxtFileYear.Text) ? (byte?)null : byte.Parse(TxtFileYear.Text),
                    DPermitNum   = string.IsNullOrEmpty(TxtPermitNum.Text) ? (int?)null : int.Parse(TxtPermitNum.Text),
                    DPermitYear  = string.IsNullOrEmpty(TxtPermitYear.Text) ? (byte?)null : byte.Parse(TxtPermitYear.Text),
                    DMantaghe    = string.IsNullOrEmpty(TxtMantaghe.Text) ? (int?)null : int.Parse(TxtMantaghe.Text),
                    DNahie       = string.IsNullOrEmpty(TxtNahie.Text) ? (int?)null : int.Parse(TxtNahie.Text),
                    DMahaleh     = string.IsNullOrEmpty(TxtMahaleh.Text) ? (int?)null : int.Parse(TxtMahaleh.Text),
                    DBlock       = string.IsNullOrEmpty(TxtBlock.Text) ? (int?)null : int.Parse(TxtBlock.Text),
                    DMelk        = string.IsNullOrEmpty(TxtMelk.Text) ? (int?)null : int.Parse(TxtMelk.Text),
                    DRadif       = string.IsNullOrEmpty(TxtRadif.Text) ? (int?)null : int.Parse(TxtRadif.Text),
                    DAddress     = string.IsNullOrEmpty(TxtAddress.Text) ? null : TxtAddress.Text,
                    DPostalCode  = string.IsNullOrEmpty(TxtPostalCode.Text) ? null : TxtPostalCode.Text,
                    DVoteNum     = string.IsNullOrEmpty(TxtVoteNum.Text) ? null : TxtVoteNum.Text,
                    DInArchives  = CheckBox.IsChecked,
                    DSeparation  = null,
                    DAggregation = null,
                    DDateInsert  = string.IsNullOrEmpty(TxtDate.Text) ? null : Utility.CurrectDate(TxtDate.Text),
                    DDescription = string.IsNullOrEmpty(TxtDescription.Text) ? null : TxtDescription.Text
                };
                fileId       = Convert.ToInt32(await addFile.Add());
                _fileAllData = null;
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ثبت اطلاعات\n" + exception.Message);
            }

            try
            {
                var addFilePerson = new DFilePerson();
                foreach (var variable in _createPersons)
                {
                    addFilePerson.DFileId   = fileId;
                    addFilePerson.DPersonId = variable.Id;
                    await Task.Run(() => addFilePerson.Add());
                }
                var addFilePlaque = new DFilePlaque();
                foreach (var variable in _createPlaque)
                {
                    addFilePlaque.DFileId   = fileId;
                    addFilePlaque.DPlaqueId = variable.Id;
                    await Task.Run(() => addFilePlaque.Add());
                }
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ثبت اطلاعات\n" + exception.Message);
            }


            Window_Loaded(null, null);
            Utility.Message("پیام", "اطلاعات با موفقیت ثبت گردید", "Correct.png");

            #endregion
        }
Esempio n. 20
0
        private async void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckSelectEdit() || !CheckEmpty())
            {
                return;
            }

            var selectItem = _fileSearchAllData[DgdFile.SelectedIndex];

            try
            {
                if (selectItem.Id != null)
                {
                    var editFile = new DFile
                    {
                        DId          = (int)selectItem.Id,
                        DMainId      = MainId,
                        DMarlik      = int.Parse(TxtMarlik.Text),
                        DFileTypeId  = CboFileType.SelectedIndex == -1 ? (byte?)null : ((tblFileType)CboFileType.SelectedItem).Id,
                        DViolationId = CboViolation.SelectedIndex == -1 ? (byte?)null : ((tblViolation)CboViolation.SelectedItem).Id,
                        DFileNum     = string.IsNullOrEmpty(TxtFileNum.Text) ? (int?)null : int.Parse(TxtFileNum.Text),
                        DFileYear    = string.IsNullOrEmpty(TxtFileYear.Text) ? (byte?)null : byte.Parse(TxtFileYear.Text),
                        DPermitNum   = string.IsNullOrEmpty(TxtPermitNum.Text) ? (int?)null : int.Parse(TxtPermitNum.Text),
                        DPermitYear  = string.IsNullOrEmpty(TxtPermitYear.Text) ? (byte?)null : byte.Parse(TxtPermitYear.Text),
                        DMantaghe    = string.IsNullOrEmpty(TxtMantaghe.Text) ? (int?)null : int.Parse(TxtMantaghe.Text),
                        DNahie       = string.IsNullOrEmpty(TxtNahie.Text) ? (int?)null : int.Parse(TxtNahie.Text),
                        DMahaleh     = string.IsNullOrEmpty(TxtMahaleh.Text) ? (int?)null : int.Parse(TxtMahaleh.Text),
                        DBlock       = string.IsNullOrEmpty(TxtBlock.Text) ? (int?)null : int.Parse(TxtBlock.Text),
                        DMelk        = string.IsNullOrEmpty(TxtMelk.Text) ? (int?)null : int.Parse(TxtMelk.Text),
                        DRadif       = string.IsNullOrEmpty(TxtRadif.Text) ? (int?)null : int.Parse(TxtRadif.Text),
                        DAddress     = string.IsNullOrEmpty(TxtAddress.Text) ? null : TxtAddress.Text,
                        DPostalCode  = string.IsNullOrEmpty(TxtPostalCode.Text) ? null : TxtPostalCode.Text,
                        DVoteNum     = string.IsNullOrEmpty(TxtVoteNum.Text) ? null : TxtVoteNum.Text,
                        DInArchives  = CheckBox.IsChecked,
                        DSeparation  = selectItem.Separation,
                        DAggregation = selectItem.Aggregation,
                        DDateInsert  = string.IsNullOrEmpty(TxtDate.Text) ? PersianDate.Today.ToString() : Utility.CurrectDate(TxtDate.Text),
                        DDescription = string.IsNullOrEmpty(TxtDescription.Text) ? null : TxtDescription.Text
                    };
                    await Task.Run(() => editFile.Edit());
                }
                _fileAllData = null;
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ویرایش اطلاعات پزشک\n" + exception.Message);
                return;
            }
            try
            {
                if (selectItem.Id != null)
                {
                    var deleteFilePerson = new DFilePerson
                    {
                        DFileId = (int)selectItem.Id
                    };
                    await Task.Run(() => deleteFilePerson.Delete());


                    var deleteFilePlaque = new DFilePlaque
                    {
                        DFileId = (int)selectItem.Id
                    };
                    await Task.Run(() => deleteFilePlaque.Delete());
                }
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message);
            }
            try
            {
                var addFilePerson = new DFilePerson();
                foreach (var variable in _createPersons)
                {
                    if (selectItem.Id != null)
                    {
                        addFilePerson.DFileId = (int)selectItem.Id;
                    }
                    addFilePerson.DPersonId = variable.Id;
                    await Task.Run(() => addFilePerson.Add());
                }
                var addFilePlaque = new DFilePlaque();
                foreach (var variable in _createPlaque)
                {
                    if (selectItem.Id != null)
                    {
                        addFilePlaque.DFileId = (int)selectItem.Id;
                    }
                    addFilePlaque.DPlaqueId = variable.Id;
                    await Task.Run(() => addFilePlaque.Add());
                }
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ثبت اطلاعات\n" + exception.Message);
            }

            Window_Loaded(null, null);
            Utility.Message("پیام", "اطلاعات با موفقیت ویرایش گردید", "Correct.png");
        }