Exemplo n.º 1
0
        private void UpdateRecentList()
        {
            RecentList.Items.Clear();
            EditorFile[] history = FileHistory.GenerateList();

            if (history.Length == 0)
            {
                ListBoxItem disabled = new ComboBoxItem();
                disabled.Content    = "File history is empty";
                disabled.Background = new SolidColorBrush(Colors.Gainsboro);
                disabled.HorizontalContentAlignment = HorizontalAlignment.Center;
                disabled.VerticalContentAlignment   = VerticalAlignment.Center;
                disabled.Height    = 200;
                disabled.IsEnabled = false;
                RecentList.Items.Add(disabled);
                return;
            }

            foreach (EditorFile entry in history)
            {
                ListBoxItem listEntry = new ComboBoxItem();
                listEntry.Content             = $"[{FileHistory.GetEditorName(entry.Editor)}]\t    {entry.Path.Split('\\').Last()}";
                listEntry.ToolTip             = entry.Path;
                listEntry.MouseDoubleClick   += ListBoxItemOnMouseDoubleClick;
                listEntry.MouseRightButtonUp += ListEntryOnRightUp;
                listEntry.DataContext         = entry;
                RecentList.Items.Add(listEntry);
            }
        }
 private void OnNodeExported(object sender, NodeExportEventArgs e)
 {
     ConfigurationList.Instance.CurrentConfiguration?.SaveTextureDatabase();
     mCurrentlyOpenFilePath = e.FilePath;
     FileHistory.Add(e.FilePath);
     SetTitle();
 }
        private void lstFiles_MouseUp(object sender, MouseEventArgs e)
        {
            selectedDocuments.Clear();
            int count = lstDocuments.SelectedItems.Count;

            if (count > 0)
            {
                gpbSignatures.Enabled = true;
            }
            int i = 0;

            for (i = 0; i < count; i++)
            {
                FileHistory fh = new FileHistory(lstDocuments.SelectedItems[i].SubItems[3].Text, lstDocuments.SelectedItems[i].SubItems[2].Text);
                selectedDocuments.Add(fh);
            }

            lblSelected.Text = i.ToString();
            loadSigners();

            if ((e.Button == MouseButtons.Right) && (selectedDocuments.Count == 1))
            {
                ctxArquivo.Show(lstDocuments, e.Location);
            }
        }
Exemplo n.º 4
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            if (chkCopyDocuments.Checked)
            {
                LastBackedUpFolder.SetValue("LastBackUpFolder", txtPath.Text, RegistryValueKind.String);
            }

            removeSignatures();
            viewReport(documentsRemoveSignStatus);

            List <FileHistory> files = new List <FileHistory>();

            foreach (FileStatus fs in documentsRemoveSignStatus)
            {
                FileHistory file = new FileHistory(fs.OldPath, fs.Path);
                files.Add(file);
            }
            string formOwner = this.Owner.ToString();
            int    start     = formOwner.IndexOf('.');
            int    end       = formOwner.IndexOf(',');

            formOwner = formOwner.Substring(start + 1, end - start - 1);
            if (formOwner == "frmSelectDigitalSignatureToRemove")
            {
                ((frmSelectDigitalSignatureToRemove)this.Owner).listFiles(files);
            }
            if (formOwner == "frmManageDigitalSignature")
            {
                ((frmManageDigitalSignature)this.Owner).listFiles(files);
            }
            this.Close();
        }
Exemplo n.º 5
0
 void LoadRecentFiles()
 {
     AppData.Init();
     FileHistory.Load();
     FileHistory.FileHistoryChanged += UpdateRecentList;
     UpdateRecentList();
 }
        public async Task <IActionResult> Create(IFormFile file, [Bind("FileId,Name,FileUrl,Description,FileStart,FileEnd,FileFinished,TaskTypeId")] FileHistory fileHistory)
        {
            fileHistory.FileFinished = false;
            //if (file == null || file.Length == 0)
            //    return Content("Файл танланмади");
            if (file != null)
            {
                string type = Path.GetExtension(file.FileName);
                if ((type != ".docx") && (type != ".doc") && (type != ".pdf"))
                {
                    return(Content("Нотогри файл тури танланди"));
                }
                //return View("~/Views/Shared/_UnsupportedMediatype.cshtml");
                fileHistory.FileUrl = file.FileName;
            }
            if (ModelState.IsValid)
            {
                _context.Add(fileHistory);
                await _context.SaveChangesAsync();

                if (file != null)
                {
                    var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files", file.FileName);

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await file.CopyToAsync(stream);
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TaskTypeId"] = new SelectList(_context.Task_Types, "TaskTypeID", "NameType", fileHistory.TaskTypeId);
            return(View(fileHistory));
        }
Exemplo n.º 7
0
        public void EnableControls()
        {
            SaveExtractedDocs.CheckState = Properties.Settings.Default.SaveDocs ? CheckState.Checked : CheckState.Unchecked;
            LibraryGen.CheckState        = Properties.Settings.Default.GenLib ? CheckState.Checked : CheckState.Unchecked;
            Verbose.CheckState           = Properties.Settings.Default.Verbose ? CheckState.Checked : CheckState.Unchecked;

            LibraryGen.Enabled = true;
            LibraryGen.Update();
            SaveExtractedDocs.Enabled = true;
            SaveExtractedDocs.Update();
            Verbose.Enabled = true;
            Verbose.Update();
            FileHistory.Enabled = true;
            FileHistory.Update();
            button1.Enabled = true;
            button1.Update();
            SelectSource.Enabled = true;
            SelectSource.Update();
            CleanUp.Enabled = true;
            CleanUp.Update();
            LaunchPCBNew.Enabled = (PcbnewLocation != "" && FileHistory.Items.Count != 0)?true:false;
            LaunchPCBNew.Update();
            Edit.Enabled = (TextEditorLoc != "" && FileHistory.Items.Count != 0) ? true : false;
            Edit.Update();
            ClearHistory.Enabled = FileHistory.Items.Count != 0;
            ClearHistory.Update();
        }
Exemplo n.º 8
0
        private void fill_ads(TimeSpan ts1, TimeSpan ts2, VideoFile v1, VideoFile v2, DailyVideoFiles[] list)
        {
            TimeSpan diff = ts2.Subtract(ts1);

            FileHistory fileHistory = new FileHistory();

            fileHistory = XMLReader.ReadFileHistory("ad_log.xml");
            VideoFile[] vf = new VideoFile[1024];

            TimeSpan[] lengths = new TimeSpan[vf.Count()];
            fileHistory.VideoFileList.CopyTo(vf);

            TimeSpan max = lengths[0];

            VideoFile ad = new VideoFile();

            for (int i = 0; vf[i] != null; i++)
            {
                //MessageBox.Show(vf[i].Col.ToString());
                String[] length = vf[i].Length.Split(':');
                lengths[i] = new TimeSpan(int.Parse(length[0]), int.Parse(length[1]), int.Parse(length[2]));
                if (lengths[i] > max && lengths[i] < diff)
                {
                    max = lengths[i];
                    ad  = vf[i];
                }
            }
            MessageBox.Show(max.ToString());
        }
        public async Task <IActionResult> Edit(int id, [Bind("FileId,Name,FileUrl,Description,FileStart,FileEnd,FileFinished,TaskTypeId")] FileHistory fileHistory)
        {
            if (id != fileHistory.FileId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fileHistory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FileHistoryExists(fileHistory.FileId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TaskTypeId"] = new SelectList(_context.Task_Types, "TaskTypeID", "TaskTypeID", fileHistory.TaskTypeId);
            return(View(fileHistory));
        }
Exemplo n.º 10
0
        }// end ProductList()

        #endregion


        #region Generate PDF

        /// <summary>
        /// Generating the PDF files in "wwwroot/documents/" directory
        /// </summary>
        /// <returns></returns>
        public IActionResult GenerateProductPDF()
        {
            var prodList     = _db.Products.ToList();
            var fileName     = $"Product-{DateTime.Now.ToFileTimeUtc()}.pdf";
            var fileBasePath = $"{_hostingEnvironment.WebRootPath}\\documents";
            var filePath     = $"{fileBasePath}\\{fileName}";

            /// Checking the directory
            if (!Directory.Exists(fileBasePath))
            {
                Directory.CreateDirectory(fileBasePath);
            }

            _pdf.GenerateProductTemplate(filePath, prodList);
            // _pdf.Test(filePath);

            /// Preparing the instance to add to db
            var fileHistoryToAdd = new FileHistory();

            fileHistoryToAdd.FileName = fileName;
            fileHistoryToAdd.FilePath = filePath;

            /// Adding to db
            _db.FileHistories.Add(fileHistoryToAdd);
            _db.SaveChanges();

            return(RedirectToAction("ProductList"));
        }// end GenerateProductPDF()
Exemplo n.º 11
0
        private void btnSign_Click(object sender, EventArgs e)
        {
            if (chkCopyDocuments.Checked)
            {
                LastBackedUpFolder.SetValue("LastBackUpFolder", txtPath.Text, RegistryValueKind.String);
            }
            compatibleDocuments.Clear();
            if (compatibleDocumentsList.Count < 1)
            {
                compatibleDocuments = FileOperations.ListAllowedFilesAndSubfolders(documentsToSign, true, chkIncludeSubfolders.Checked);
                foreach (string str in compatibleDocuments)
                {
                    FileHistory fh = new FileHistory(str, str);
                    compatibleDocumentsList.Add(fh);
                }
            }
            else
            {
                compatibleDocuments = FileOperations.ListAllowedFilesAndSubfolders(compatibleDocumentsList, true, chkIncludeSubfolders.Checked);
            }

            if (compatibleDocuments.Count > 0)
            {
                string[] signedDocuments = signDocuments();

                List <string>      docs     = new List <string>();
                List <FileHistory> docsHist = new List <FileHistory>();
                foreach (FileStatus fs in documentsSignStatus)
                {
                    docs.Add(fs.Path);

                    FileHistory fh = new FileHistory(fs.OldPath, fs.Path);
                    docsHist.Add(fh);
                }

                if (signedDocuments != null)
                {
                    if (!chkViewDocuments.Visible)
                    {
                        ((frmManageDigitalSignature)this.Owner).listFiles(docsHist);
                    }
                    if (chkViewDocuments.Checked)
                    {
                        frmViewDigitalSignature FormViewDigitalSignature = new frmViewDigitalSignature(docs.ToArray());
                        FormViewDigitalSignature.Show();
                    }

                    this.Visible = false;

                    frmReport FormReport = new frmReport(documentsSignStatus, "sign");
                    FormReport.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("Os arquivos selecionados não são pacotes válidos.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Exemplo n.º 12
0
        public ProgramState()
        {
            //if (s_programState != null)
            //    throw new InvalidOperationException("Instance of this class was already created");

            TextStyle = new TextStyleSettings();
            History = new FileHistory();
        }
            public static FileHistory CreateNew(string userId, string fileId)
            {
                var newState = new FileHistory
                {
                    RowKey = $"{userId},{fileId}"
                };

                return(newState);
            }
Exemplo n.º 14
0
        private void ClearHistory_Click(object sender, EventArgs e)
        {
            busy.Select();
            FileHistory.Items.Clear();
            FileHistory.ResetText();
//            FileHistory.Items.Insert(0, FileHistory.Text);
            FileHistory.SelectedIndex = -1;
            SaveFileHistory();
        }
Exemplo n.º 15
0
        /// <summary>
        ///     Updates the History Log file.
        /// </summary>
        /// <param name="write">Write new log history to file.</param>
        public static void ManageHistoryLog(bool write = false)
        {
            // Create a history log file if it don't exist
            if (!File.Exists(FileHistoryLocation))
            {
                File.Create(FileHistoryLocation).Close();
            }

            // Check for duplicates
            if (FileHistory.Count != 0)
            {
                FileHistory = FileHistory.Distinct().ToList();
            }

            // Write from memory to history file
            if (write)
            {
                // Hold a history max count to prevent memory leaks
                if (File.ReadAllLines(FileHistoryLocation).Length <= Properties.Settings.Default.MaxRecentProjects)
                {
                    // Add file path to memory
                    FileHistory.Add(WorkingFilePath);

                    // Overwrite the file
                    File.WriteAllLines(FileHistoryLocation, FileHistory);
                }
                else
                {
                    // Truncate first line when limit reached
                    while (FileHistory.Count > Properties.Settings.Default.MaxRecentProjects)
                    {
                        File.WriteAllLines(FileHistoryLocation, File.ReadAllLines(FileHistoryLocation).Skip(1).ToArray());
                    }


                    // Add file path to memory
                    FileHistory.Add(WorkingFilePath);

                    // Overwrite the file
                    File.WriteAllLines(FileHistoryLocation, FileHistory);
                }
            }
            else
            {
                // Read the settings only once from file, to prevent adding multiple items to list
                if (_readSettings)
                {
                    _readSettings = false;

                    var lines = File.ReadLines(FileHistoryLocation);
                    foreach (string line in lines)
                    {
                        FileHistory.Add(line);
                    }
                }
            }
        }
        private string GetFilepath(HttpContext context)
        {
            StringBuilder sbJsonResult   = new StringBuilder();
            string        fileHistoryId  = context.Request.Params["fileHistoryId"];
            FileHistory   fileHistory    = fileHistoryBll.GetModel(fileHistoryId);
            string        fileCategoryId = fileHistory.PARENTID;
            FileCategory  category       = fcBll.GetModel(fileCategoryId);
            string        folderName     = category.FOLDERNAME;

            string taskNo         = string.Empty;
            string returnFileName = string.Empty;
            // 根据任务ID获取任务编号和员工编号,如果有记录说明任务已分配,则需要到员工目录下寻找该文件
            DataTable dtTaskNoAndEmpNo = fileHistoryBll.GetTaskNoAndEmpNoByPrjId(category.PROJECTID).Tables[0];

            // 任务已分配
            if (dtTaskNoAndEmpNo != null && dtTaskNoAndEmpNo.Rows.Count > 0)
            {
                string rootPath = ConfigurationManager.AppSettings["employeePath"].ToString();

                string empNo         = dtTaskNoAndEmpNo.AsEnumerable().Select(item => Convert.ToString(item["employeeNo"])).FirstOrDefault();
                string empNoFullPath = Path.Combine(rootPath, empNo);

                taskNo = dtTaskNoAndEmpNo.AsEnumerable().Select(item => Convert.ToString(item["taskNo"])).FirstOrDefault();
                string taskNoFinalFolder = Directory.GetFiles(empNoFullPath, taskNo, SearchOption.AllDirectories).FirstOrDefault();
                if (!string.IsNullOrEmpty(taskNoFinalFolder))
                {
                    returnFileName = Path.Combine(rootPath, empNo, taskNo, folderName);
                }
            }
            // 任务未分配
            else
            {
                Project prj = prjBll.GetModel(category.PROJECTID);
                taskNo = prj.TASKNO;
                string rootPath          = ConfigurationManager.AppSettings["taskAllotmentPath"];
                string taskNoFinalFolder = Directory.GetFiles(rootPath, taskNo, SearchOption.TopDirectoryOnly).FirstOrDefault();
                if (!string.IsNullOrEmpty(taskNoFinalFolder))
                {
                    returnFileName = Path.Combine(rootPath, taskNo, folderName);
                }
            }
            using (var output = new StringWriter())
            {
                JSON.Serialize(
                    new
                {
                    code     = 0,
                    msg      = "success",
                    filename = returnFileName
                },
                    output
                    );
                sbJsonResult.Append(output.ToString());
            }
            return(sbJsonResult.ToString());
        }
Exemplo n.º 17
0
        private void SaveHistory(Guid fileId, string userId, StatusTypes type)
        {
            FileHistory history = new FileHistory();

            history.FileId       = fileId;
            history.ActionTime   = DateTime.Now;
            history.UserId       = userId;
            history.StatusTypeId = (byte)type;
            fileRepository.AddHistory(history);
        }
Exemplo n.º 18
0
        public JsonResult FileManagerUploadExcel(HttpPostedFileBase files)
        {
            var calculatedData = new List <FileCalculationViewModel>();

            try
            {
                DateTime fileDate;
                var      splitFileName = files.FileName.Split('_').ToList();
                if (splitFileName != null && splitFileName.Count > 1)
                {
                    string fileDateStr = String.Join("", splitFileName.ElementAt(0).Where(char.IsDigit)) + "00";
                    string format      = "yyyyMMddHH";
                    fileDate = DateTime.ParseExact(fileDateStr, format, CultureInfo.InvariantCulture);
                    if (fileDate == DateTime.MinValue)
                    {
                        return(Json(new { Success = false, Message = "Error! file name sholud be in formate MarketRisk_20180630-0331.xls or MarketRisk_20180630-0331.xlsx" }));
                    }
                }
                else
                {
                    return(Json(new { Success = false, Message = "Error! file name sholud be in formate MarketRisk_20180630-0331.xls or MarketRisk_20180630-0331.xlsx" }));
                }
                var setting = analyticsRepo.GetImportSetting(fileType.Excel);
                if (setting != null && !string.IsNullOrWhiteSpace(setting.FileSavePath))
                {
                    if (!Directory.Exists(setting.FileSavePath))
                    {
                        Directory.CreateDirectory(setting.FileSavePath);
                    }
                    string targetPath = Path.Combine(setting.FileSavePath, files.FileName);
                    files.SaveAs(targetPath);

                    //Read excel file
                    FileHistory fileHistory = new FileHistory();
                    fileHistory.FileName    = files.FileName;
                    fileHistory.FilePath    = targetPath;
                    fileHistory.CreatedDate = DateTime.Now;
                    fileHistory.FileDate    = fileDate;
                    marketRRepo.Add <FileHistory>(fileHistory);
                    marketRRepo.UnitOfWork.SaveChanges();

                    var calculation = marketRRepo.Find <FileCalculation>(x => x.FileID == fileHistory.FileID).ToList();
                    calculatedData = AutoMapper.Mapper.Map <List <FileCalculation>, List <FileCalculationViewModel> >(calculation);
                }
                else
                {
                    return(Json(new { Success = false, Message = "Import setting is not configured properly!" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Success = false, Message = "Could not read file!" }));
            }
            return(Json(new { calculatedData = calculatedData, Success = true }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 19
0
        private void CleanUpAll()
        {
            ConvertPCBDoc.OutputString("Removing generated content");

            for (var i = 0; i < FileHistory.Items.Count; i++)
            {
                CleanOutput(FileHistory.GetItemText(FileHistory.Items[i]));
            }
            ConvertPCBDoc.OutputString("Finished");
            CheckOutputDir();
        }
Exemplo n.º 20
0
 List <FileHistoryEntry> ISessionAdapter.GetFileHistoryEntries(ReviewRevision revision)
 {
     if (FileHistory.TryGetValue(revision, out var history))
     {
         return(history);
     }
     else
     {
         return(new List <FileHistoryEntry>());
     }
 }
Exemplo n.º 21
0
        private async void deleteItem_Click(object sender, RoutedEventArgs e)
        {
            EntryInfo info = ((FrameworkElement)sender).DataContext as EntryInfo;
            await FileHistory.DeleteFromHistory(info.Key);

            if (Windows.UI.StartScreen.SecondaryTile.Exists(info.Key))
            {
                SecondaryTile st = new SecondaryTile(info.Key);
                await st.RequestDeleteAsync();
            }
            _history.Entries = await FileHistory.GetHistoryEntriesInfo();
        }
Exemplo n.º 22
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FileHistory DataRowToModel(DataRow row)
        {
            FileHistory model = new FileHistory();

            if (row != null)
            {
                if (row["ID"] != null)
                {
                    model.ID = row["ID"].ToString();
                }
                if (row["PARENTID"] != null)
                {
                    model.PARENTID = row["PARENTID"].ToString();
                }
                if (row["FILENAME"] != null)
                {
                    model.FILENAME = row["FILENAME"].ToString();
                }
                if (row["FILEEXTENSION"] != null)
                {
                    model.FILEEXTENSION = row["FILEEXTENSION"].ToString();
                }
                if (row["FILEFULLNAME"] != null)
                {
                    model.FILEFULLNAME = row["FILEFULLNAME"].ToString();
                }
                if (row["DESCRIPTION"] != null)
                {
                    model.DESCRIPTION = row["DESCRIPTION"].ToString();
                }
                if (row["OPERATEDATE"] != null && row["OPERATEDATE"].ToString() != "")
                {
                    model.OPERATEDATE = DateTime.Parse(row["OPERATEDATE"].ToString());
                }
                if (row["OPERATEUSER"] != null)
                {
                    model.OPERATEUSER = row["OPERATEUSER"].ToString();
                }
                if (row["ISDELETED"] != null && row["ISDELETED"].ToString() != "")
                {
                    if ((row["ISDELETED"].ToString() == "1") || (row["ISDELETED"].ToString().ToLower() == "true"))
                    {
                        model.ISDELETED = true;
                    }
                    else
                    {
                        model.ISDELETED = false;
                    }
                }
            }
            return(model);
        }
Exemplo n.º 23
0
        private void ListEntryOnRightUp(object sender, MouseButtonEventArgs e)
        {
            ListBoxItem target = sender as ListBoxItem;

            EditorFile entry = (EditorFile)target.DataContext;

            if (MessageBox.Show(
                    "Do you want to remove \"" + entry.Path.Split('\\').Last() + "\" from the recently opened files?",
                    "Remove from history", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                FileHistory.Remove(entry);
            }
        }
Exemplo n.º 24
0
        private void SelectSource_Click(object sender, EventArgs e)
        {
            busy.Select();
            OpenFileDialog openFileDialog1 = new OpenFileDialog
            {
                InitialDirectory = @"D:\",
                Title            = "Browse Altium PCBDoc Files",
                CheckFileExists  = true,
                CheckPathExists  = true,

                DefaultExt       = "pcbdoc",
                Filter           = "Altium PCB files (*.pcbdoc, *.cmpcbdoc)|*.pcbdoc; *.cmpcbdoc",
                FilterIndex      = 2,
                RestoreDirectory = true,

                ReadOnlyChecked = true,
                ShowReadOnly    = true
            };

            openFileDialog1.Multiselect = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileHistory.Text = openFileDialog1.FileName;
                FileHistory.Items.AddRange(openFileDialog1.FileNames);
                // only add to history if not already there
                bool found = false;
                foreach (var l in FileHistory.Items)
                {
                    if ((String)l == FileHistory.Text)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    FileHistory.Items.Insert(0, FileHistory.Text);
                    FileHistory.SelectedIndex = 0;
                    FileHistory.Select(FileHistory.Text.Length, 0); // scroll to make filename visible
                    Properties.Settings.Default.LastFile = FileHistory.Text;
                    Properties.Settings.Default.Save();
                }
                SaveFileHistory();
                FileHistory.SelectedItem = 0;
                FileHistory.Select(FileHistory.Text.Length, 0); // scroll to make filename visible
            }
            CheckOutputDir();
        }
Exemplo n.º 25
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(FileHistory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update filehistory set ");
            strSql.Append("PARENTID=@PARENTID,");
            strSql.Append("FILENAME=@FILENAME,");
            strSql.Append("FILEEXTENSION=@FILEEXTENSION,");
            strSql.Append("FILEFULLNAME=@FILEFULLNAME,");
            strSql.Append("DESCRIPTION=@DESCRIPTION,");
            strSql.Append("OPERATEDATE=@OPERATEDATE,");
            strSql.Append("OPERATEUSER=@OPERATEUSER,");
            strSql.Append("ISDELETED=@ISDELETED");
            strSql.Append(" where ID=@ID ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@PARENTID",      MySqlDbType.VarChar,    36),
                new MySqlParameter("@FILENAME",      MySqlDbType.VarChar,   255),
                new MySqlParameter("@FILEEXTENSION", MySqlDbType.VarChar,    20),
                new MySqlParameter("@FILEFULLNAME",  MySqlDbType.VarChar,   255),
                new MySqlParameter("@DESCRIPTION",   MySqlDbType.VarChar,   255),
                new MySqlParameter("@OPERATEDATE",   MySqlDbType.DateTime),
                new MySqlParameter("@OPERATEUSER",   MySqlDbType.VarChar,    36),
                new MySqlParameter("@ISDELETED",     MySqlDbType.Bit),
                new MySqlParameter("@ID",            MySqlDbType.VarChar, 36)
            };
            parameters[0].Value = model.PARENTID;
            parameters[1].Value = model.FILENAME;
            parameters[2].Value = model.FILEEXTENSION;
            parameters[3].Value = model.FILEFULLNAME;
            parameters[4].Value = model.DESCRIPTION;
            parameters[5].Value = model.OPERATEDATE;
            parameters[6].Value = model.OPERATEUSER;
            parameters[7].Value = model.ISDELETED;
            parameters[8].Value = model.ID;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 添加一条文件记录
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="fileName">文件名</param>
        /// <param name="fileNameRelativeToTaskRoot">相对于任务目录的文件名(从任务编号的目录之后开始取)</param>
        /// <param name="description"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool AddFileHistory(string parentId, string fileName, string fileNameRelativeToTaskRoot, string description, string userId)
        {
            FileHistory fileHistory = new FileHistory();

            fileHistory.ID            = Guid.NewGuid().ToString();
            fileHistory.PARENTID      = parentId;
            fileHistory.FILENAME      = fileName;
            fileHistory.FILEFULLNAME  = fileNameRelativeToTaskRoot;
            fileHistory.FILEEXTENSION = Path.GetExtension(fileName);
            fileHistory.DESCRIPTION   = description;
            fileHistory.OPERATEDATE   = DateTime.Now;
            fileHistory.OPERATEUSER   = userId;
            fileHistory.ISDELETED     = false;
            bool addFileHisFlag = this.Add(fileHistory);

            return(addFileHisFlag);
        }
Exemplo n.º 27
0
        private void ListBoxItemOnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ListBoxItem item       = sender as ListBoxItem;
            EditorFile  editorFile = item.DataContext as EditorFile;
            Type        type       = editorFile.GetEditorType();

            if (!typeof(IEditorControl).IsAssignableFrom(type))
            {
                if (MessageBox.Show("Invalid entry in history!\nDo you want to remove it from recently opened files?", "Invalid entry", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    FileHistory.Remove(editorFile);
                }
                return;
            }
            if (!File.Exists(editorFile.Path))
            {
                if (MessageBox.Show("The file does not exist anymore!\nDo you want to remove it from recently opened files?", "Missing file", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    FileHistory.Remove(editorFile);
                }
                return;
            }

            // TODO Check if file type is supported by editor before calling this part

            /*
             * if (FileChecker.IsBinary(editorFile.Path))
             * {
             *  if (MessageBox.Show("Binary files are not supported at this time.\nDo you want to remove it from recently opened files?", "File is binary", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
             *      FileHistory.Remove(editorFile);
             *  return;
             * }
             */

            if (FileChecker.IsTooBig(editorFile.Path))
            {
                if (MessageBox.Show("Files with a size over 10MB are not supported.\nOpen anyways? (Program may freeze or stop working)", "File too big", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            new MainWindow(editorFile.Path, type).Show();
            Close();
        }
        private void lstFiles_KeyDown(object sender, KeyEventArgs e)
        {
            selectedDocuments.Clear();
            int count = lstDocuments.SelectedItems.Count;

            if (count > 0)
            {
                gpbSignatures.Enabled = true;
            }
            for (int i = 0; i < count; i++)
            {
                FileHistory fh = new FileHistory(lstDocuments.SelectedItems[i].SubItems[3].Text, lstDocuments.SelectedItems[i].SubItems[2].Text);
                selectedDocuments.Add(fh);
            }

            lblSelected.Text = count.ToString();
            loadSigners();
        }
Exemplo n.º 29
0
        public Form1()
        {
            AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
            {
                string resourceName = new AssemblyName(args.Name).Name + ".dll";
                string resource     = Array.Find(this.GetType().Assembly.GetManifestResourceNames(), element => element.EndsWith(resourceName));

                using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
                {
                    Byte[] assemblyData = new Byte[stream.Length];
                    stream.Read(assemblyData, 0, assemblyData.Length);
                    return(Assembly.Load(assemblyData));
                }
            };

            Screen scrn = Screen.FromControl(this);

            InitializeComponent();
            MaximisedSize = new Size(0, 0);

            OutputList_Initialize();
            FileHistory_Initialize();
            SaveExtractedDocs.CheckState = Properties.Settings.Default.SaveDocs ? CheckState.Checked : CheckState.Unchecked;
            LibraryGen.CheckState        = Properties.Settings.Default.GenLib ? CheckState.Checked : CheckState.Unchecked;
            Verbose.CheckState           = Properties.Settings.Default.Verbose ? CheckState.Checked : CheckState.Unchecked;
            FileHistory.Text             = Properties.Settings.Default.LastFile;
            FileHistory.Select(FileHistory.Text.Length, 0); // scroll to make filename visible

            ComboboxItems = Properties.Settings.Default.ComboboxItems;
            string[] Items = ComboboxItems.Split(';');
            foreach (var item in Items)
            {
                if (item != "")
                {
                    FileHistory.Items.Insert(0, item);
                }
            }
            FileHistory.SelectedIndex = (ComboboxItems == "")?-1:Properties.Settings.Default.ComboBoxIndex;
            Properties.Settings.Default.ComboBoxIndex = FileHistory.SelectedIndex;
            Properties.Settings.Default.Save();
            PcbnewLocation = "";
            TextEditorLoc  = "";
        }
        private void btnSelectAll_Click(object sender, EventArgs e)
        {
            selectedDocuments.Clear();
            int count = lstDocuments.Items.Count;

            for (int i = 0; i < count; i++)
            {
                lstDocuments.Items[i].Selected = true;
                FileHistory fh = new FileHistory(lstDocuments.SelectedItems[i].SubItems[3].Text, lstDocuments.SelectedItems[i].SubItems[2].Text);
                selectedDocuments.Add(fh);
            }
            if (lstDocuments.Items.Count > 0)
            {
                lstDocuments.Items[0].Focused = true;
            }
            lblSelected.Text = count.ToString();

            loadSigners();
        }
Exemplo n.º 31
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(FileHistory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into filehistory(");
            strSql.Append("ID,PARENTID,FILENAME,FILEEXTENSION,FILEFULLNAME,DESCRIPTION,OPERATEDATE,OPERATEUSER,ISDELETED)");
            strSql.Append(" values (");
            strSql.Append("@ID,@PARENTID,@FILENAME,@FILEEXTENSION,@FILEFULLNAME,@DESCRIPTION,@OPERATEDATE,@OPERATEUSER,@ISDELETED)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ID",            MySqlDbType.VarChar,    36),
                new MySqlParameter("@PARENTID",      MySqlDbType.VarChar,    36),
                new MySqlParameter("@FILENAME",      MySqlDbType.VarChar,   255),
                new MySqlParameter("@FILEEXTENSION", MySqlDbType.VarChar,    20),
                new MySqlParameter("@FILEFULLNAME",  MySqlDbType.VarChar,   255),
                new MySqlParameter("@DESCRIPTION",   MySqlDbType.VarChar,   255),
                new MySqlParameter("@OPERATEDATE",   MySqlDbType.DateTime),
                new MySqlParameter("@OPERATEUSER",   MySqlDbType.VarChar,    36),
                new MySqlParameter("@ISDELETED",     MySqlDbType.Bit)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.PARENTID;
            parameters[2].Value = model.FILENAME;
            parameters[3].Value = model.FILEEXTENSION;
            parameters[4].Value = model.FILEFULLNAME;
            parameters[5].Value = model.DESCRIPTION;
            parameters[6].Value = model.OPERATEDATE;
            parameters[7].Value = model.OPERATEUSER;
            parameters[8].Value = model.ISDELETED;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 32
0
        public Application()
        {
            this.commandManager = new CommandManager();

            this.configurationManager = new ConfigurationManager();
            this.configurationManager.Load(this.GetType().Module.FullyQualifiedName);

            this.fileHistory = new FileHistory();
            this.fileHistory.Configuration = this.configurationManager["FileHistory"];

            this.ftpConfiguration = new FtpConfiguration();
            this.ftpConfiguration.Configuration = this.configurationManager["FtpConfiguration"];

            this.applicationWindow = new ApplicationWindow();
            this.applicationWindow.Closed += new EventHandler(this.ApplicationWindow_Closed);
            this.applicationWindow.Closing += new CancelEventHandler(this.ApplicationWindow_Closing);
            this.applicationWindow.Activated += new EventHandler(this.ApplicationWindowActivated);

            // Toolbar
            CommandBar toolBar = this.applicationWindow.ToolBar;

            this.commandManager.Add("File.New", toolBar.Items.AddButton(CommandBarImageResource.New, "&New", null, Keys.Control | Keys.N));
            this.commandManager.Add("File.Open", toolBar.Items.AddButton(CommandBarImageResource.Open, "&Open...", null, Keys.Control | Keys.O));
            this.commandManager.Add("File.Save", toolBar.Items.AddButton(CommandBarImageResource.Save, "&Save", null, Keys.Control | Keys.S));
            toolBar.Items.AddSeparator();
            this.commandManager.Add("Edit.Cut", toolBar.Items.AddButton(CommandBarImageResource.Cut, "Cu&t", null, Keys.Control | Keys.X));
            this.commandManager.Add("Edit.Copy", toolBar.Items.AddButton(CommandBarImageResource.Copy, "&Copy", null, Keys.Control | Keys.C));
            this.commandManager.Add("Edit.Paste", toolBar.Items.AddButton(CommandBarImageResource.Paste, "&Paste", null, Keys.Control | Keys.V));
            this.commandManager.Add("Edit.Delete", toolBar.Items.AddButton(CommandBarImageResource.Delete, "&Delete", null, Keys.Delete));
            toolBar.Items.AddSeparator();
            this.commandManager.Add("Edit.Undo", toolBar.Items.AddButton(CommandBarImageResource.Undo, "&Undo", null, Keys.Control | Keys.Z));
            this.commandManager.Add("Edit.Redo", toolBar.Items.AddButton(CommandBarImageResource.Redo, "&Redo", null, Keys.Control | Keys.Y));
            toolBar.Items.AddSeparator();
            this.commandManager.Add("Format.Font", toolBar.Items.AddComboBox("Font", new FontComboBox()));
            this.commandManager.Add("Format.FontSize", toolBar.Items.AddComboBox("Font Size", new FontSizeComboBox()));
            toolBar.Items.AddSeparator();
            this.commandManager.Add("Format.Bold", toolBar.Items.AddCheckBox(FormatResource.Bold, "&Bold", Keys.Control | Keys.B));
            this.commandManager.Add("Format.Italic", toolBar.Items.AddCheckBox(FormatResource.Italic, "&Italic", Keys.Control | Keys.I));
            this.commandManager.Add("Format.Underline", toolBar.Items.AddCheckBox(FormatResource.Underline, "U&nderline", Keys.Control | Keys.U));
            toolBar.Items.AddSeparator();
            this.commandManager.Add("Format.UnorderedList", toolBar.Items.AddCheckBox(FormatResource.UnorderedList, "&Bullets"));
            this.commandManager.Add("Format.OrderedList", toolBar.Items.AddCheckBox(FormatResource.OrderedList, "&Numbering"));
            this.commandManager.Add("Format.Unindent", toolBar.Items.AddButton(FormatResource.Unindent, "Unind&ent", null, Keys.Shift | Keys.Tab));
            this.commandManager.Add("Format.Indent", toolBar.Items.AddButton(FormatResource.Indent, "In&dent", null, Keys.Tab));
            toolBar.Items.AddSeparator();

            CommandBarMenu foreColorMenu = toolBar.Items.AddMenu(FormatResource.ForeColor, "Foreground Color");
            this.commandManager.Add("Format.ForeColor.Black", foreColorMenu.Items.AddButton(FormatResource.Black, "Blac&k", null));
            this.commandManager.Add("Format.ForeColor.Yellow", foreColorMenu.Items.AddButton(FormatResource.Yellow, "&Yellow", null));
            this.commandManager.Add("Format.ForeColor.Red", foreColorMenu.Items.AddButton(FormatResource.Red, "&Red", null));
            this.commandManager.Add("Format.ForeColor.Green", foreColorMenu.Items.AddButton(FormatResource.Green, "&Green", null));
            this.commandManager.Add("Format.ForeColor.Blue", foreColorMenu.Items.AddButton(FormatResource.Blue, "&Blue", null));
            this.commandManager.Add("Format.ForeColor.White", foreColorMenu.Items.AddButton(FormatResource.White, "&White", null));

            CommandBarMenu backColorMenu = toolBar.Items.AddMenu(FormatResource.BackColor, "Background Color");
            this.commandManager.Add("Format.BackColor.Black", backColorMenu.Items.AddButton(FormatResource.Black, "Blac&k", null));
            this.commandManager.Add("Format.BackColor.Yellow", backColorMenu.Items.AddButton(FormatResource.Yellow, "&Yellow", null));
            this.commandManager.Add("Format.BackColor.Red", backColorMenu.Items.AddButton(FormatResource.Red, "&Red", null));
            this.commandManager.Add("Format.BackColor.Green", backColorMenu.Items.AddButton(FormatResource.Green, "&Green", null));
            this.commandManager.Add("Format.BackColor.Blue", backColorMenu.Items.AddButton(FormatResource.Blue, "&Blue", null));
            this.commandManager.Add("Format.BackColor.White", backColorMenu.Items.AddButton(FormatResource.White, "&White", null));

            // Menu
            CommandBar menuBar = this.applicationWindow.MenuBar;

            CommandBarMenu fileMenu = menuBar.Items.AddMenu("&File");
            this.commandManager.Add("File.New", fileMenu.Items.AddButton(CommandBarImageResource.New, "&New", null, Keys.Control | Keys.N));
            this.commandManager.Add("File.Open", fileMenu.Items.AddButton(CommandBarImageResource.Open, "&Open...", null, Keys.Control | Keys.O));
            this.commandManager.Add("File.Save", fileMenu.Items.AddButton(CommandBarImageResource.Save, "&Save", null, Keys.Control | Keys.S));
            this.commandManager.Add("File.SaveAs", fileMenu.Items.AddButton("Save &As...", null));
            CommandBarMenu publishToWebMenu = fileMenu.Items.AddMenu("Publish to &Web");
            this.commandManager.Add("File.FtpSetting", publishToWebMenu.Items.AddButton("&Settings...", null));
            this.commandManager.Add("File.Publish", publishToWebMenu.Items.AddButton("&Publish", null));
            fileMenu.Items.AddSeparator();
            this.commandManager.Add("File.PrintPreview", fileMenu.Items.AddButton(CommandBarImageResource.Preview, "Print Pre&view", null));
            this.commandManager.Add("File.Print", fileMenu.Items.AddButton(CommandBarImageResource.Print, "&Print", null, Keys.Control | Keys.P));
            fileMenu.Items.AddSeparator();
            CommandBarMenu fileHistoryMenu = fileMenu.Items.AddMenu("Recent &Files");
            this.commandManager.Add("File.History.0", fileHistoryMenu.Items.AddButton("&1", null));
            this.commandManager.Add("File.History.1", fileHistoryMenu.Items.AddButton("&2", null));
            this.commandManager.Add("File.History.2", fileHistoryMenu.Items.AddButton("&3", null));
            this.commandManager.Add("File.History.3", fileHistoryMenu.Items.AddButton("&4", null));
            fileMenu.Items.AddSeparator();
            this.commandManager.Add("Application.Exit", fileMenu.Items.AddButton("E&xit", null));

            CommandBarMenu editMenu = menuBar.Items.AddMenu("&Edit");
            this.commandManager.Add("Edit.Undo", editMenu.Items.AddButton(CommandBarImageResource.Undo, "&Undo", null, Keys.Control | Keys.Z));
            this.commandManager.Add("Edit.Redo", editMenu.Items.AddButton(CommandBarImageResource.Redo, "&Redo", null, Keys.Control | Keys.Y));
            editMenu.Items.AddSeparator();
            this.commandManager.Add("Edit.Cut", editMenu.Items.AddButton(CommandBarImageResource.Cut, "Cu&t", null, Keys.Control | Keys.X));
            this.commandManager.Add("Edit.Copy", editMenu.Items.AddButton(CommandBarImageResource.Copy, "&Copy", null, Keys.Control | Keys.C));
            this.commandManager.Add("Edit.Paste", editMenu.Items.AddButton(CommandBarImageResource.Paste, "&Paste", null, Keys.Control | Keys.V));
            this.commandManager.Add("Edit.Delete", editMenu.Items.AddButton(CommandBarImageResource.Delete, "&Delete", null, Keys.Delete));
            editMenu.Items.AddSeparator();
            this.commandManager.Add("Edit.SelectAll", editMenu.Items.AddButton("Select &All", null, Keys.Control | Keys.A));
            editMenu.Items.AddSeparator();
            this.commandManager.Add("Edit.Find", editMenu.Items.AddButton(CommandBarImageResource.Search, "&Find...", null, Keys.Control | Keys.F));
            this.commandManager.Add("Edit.FindNext", editMenu.Items.AddButton("Find &Next", null, Keys.F3));
            this.commandManager.Add("Edit.Replace", editMenu.Items.AddButton("&Replace...", null, Keys.Control | Keys.H));

            CommandBarMenu insertMenu = menuBar.Items.AddMenu("&Insert");
            this.commandManager.Add("Edit.InsertHyperlink", insertMenu.Items.AddButton(FormatResource.Hyperlink, "Insert &Hyperlink", null, Keys.Control | Keys.K));
            this.commandManager.Add("Edit.InsertPicture", insertMenu.Items.AddButton(FormatResource.Picture, "Insert &Picture...", null));
            this.commandManager.Add("Edit.InsertDateTime", insertMenu.Items.AddButton("Insert &Date and Time...", null));

            CommandBarMenu formatMenu = menuBar.Items.AddMenu("F&ormat");
            this.commandManager.Add("Format.Bold", formatMenu.Items.AddCheckBox(FormatResource.Bold, "&Bold", Keys.Control | Keys.B));
            this.commandManager.Add("Format.Italic", formatMenu.Items.AddCheckBox(FormatResource.Italic, "&Italic", Keys.Control | Keys.I));
            this.commandManager.Add("Format.Underline", formatMenu.Items.AddCheckBox(FormatResource.Underline, "U&nderline", Keys.Control | Keys.U));
            this.commandManager.Add("Format.Superscript", formatMenu.Items.AddCheckBox(FormatResource.Superscript, "&Superscript"));
            this.commandManager.Add("Format.Subscript", formatMenu.Items.AddCheckBox(FormatResource.Subscript, "Subscri&pt"));
            this.commandManager.Add("Format.Strikethrough", formatMenu.Items.AddCheckBox(FormatResource.Strikethrough, "Stri&ke"));
            formatMenu.Items.AddSeparator();
            this.commandManager.Add("Format.ForeColor", formatMenu.Items.AddButton(FormatResource.ForeColor, "&Fore Color", null));
            this.commandManager.Add("Format.BackColor", formatMenu.Items.AddButton(FormatResource.BackColor, "B&ack Color", null));
            formatMenu.Items.AddSeparator();
            this.commandManager.Add("Format.AlignLeft", formatMenu.Items.AddCheckBox(FormatResource.AlignLeft, "Align &Left"));
            this.commandManager.Add("Format.AlignCenter", formatMenu.Items.AddCheckBox(FormatResource.AlignCenter, "Align &Center"));
            this.commandManager.Add("Format.AlignRight", formatMenu.Items.AddCheckBox(FormatResource.AlignRight, "Align &Right"));
            formatMenu.Items.AddSeparator();
            this.commandManager.Add("Format.OrderedList", formatMenu.Items.AddCheckBox(FormatResource.OrderedList, "&Numbering"));
            this.commandManager.Add("Format.UnorderedList", formatMenu.Items.AddCheckBox(FormatResource.UnorderedList, "B&ullets"));
            this.commandManager.Add("Format.Unindent", formatMenu.Items.AddButton(FormatResource.Unindent, "Unind&ent", null, Keys.Shift | Keys.Tab));
            this.commandManager.Add("Format.Indent", formatMenu.Items.AddButton(FormatResource.Indent, "In&dent", null, Keys.Tab));

            CommandBarMenu helpMenu = menuBar.Items.AddMenu("&Help");
            this.commandManager.Add("Application.About", helpMenu.Items.AddButton("&About Writer...", null));

            this.commandManager.AddTarget(this);

            this.FileNew();

            CommandLine commandLine = new CommandLine();
            string[] fileNames = commandLine.GetArguments(string.Empty);
            if ((fileNames != null) && (fileNames.Length > 0))
            {
                this.LoadFile(fileNames[0]);
            }
        }
Exemplo n.º 33
0
 public FileVersionInfo[] GetFileHistory(string vcsFile)
 {
     if (string.IsNullOrEmpty(vcsFile))
         throw new ArgumentException("vcsFile");
     var fileHistory = new FileHistory(vcsFile, Service);
     var result = new List<FileVersionInfo>(fileHistory.Count);
     result.AddRange(fileHistory);
     result.Reverse();
     return result.ToArray();
 }