public Document(string number, EDocumentType type) { Number = number; Type = type; Validate(); }
public void SaveDocument( [Parameter("The path to the folder in which to save the document")] string path, [Parameter("The name to give the document")] string name, [Parameter("The description to give the document")] string desc, [Parameter("The document type to save the document as")] EDocumentType documentType, [Parameter("The document file type to save the document as")] EDocumentFileType documentFileType, [Parameter("The content for the new document")] string content, [Parameter("The security class to assign the document", DefaultValue = "[Default]")] string securityClass, [Parameter("If true, the document is saved as a private document; otherwise, it is public", DefaultValue = false)] bool isPrivate, [Parameter("True to overwrite any existing document with the same name in the folder", DefaultValue = true)] bool overwrite) { HFM.Try("Saving document {0} to {1}", name, path, () => _documents.SaveDocument2(path, name, desc, (int)documentType, (int)documentFileType, securityClass, content, isPrivate, (int)EDocumentType.All, overwrite)); // Update cache LoadCache(path, false); }
protected void Repeater_ItemDataBound(object sender, DataListItemEventArgs e) { EDocumentType obj = new EDocumentType(); db.toObject(((DataRowView)e.Item.DataItem).Row, obj); e.Item.FindControl("DeleteItem").Visible = IsAllowEdit & !obj.DocumentTypeIsSystem; if (e.Item.ItemIndex == Repeater.EditItemIndex) { ebinding = new Binding(dbConn, db); ebinding.add((HtmlInputHidden)e.Item.FindControl("DocumentTypeID")); ebinding.add((TextBox)e.Item.FindControl("DocumentTypeCode")); ebinding.add((TextBox)e.Item.FindControl("DocumentTypeDesc")); ebinding.init(Request, Session); Hashtable values = new Hashtable(); db.populate(obj, values); ebinding.toControl(values); } else { e.Item.FindControl("Edit").Visible = IsAllowEdit & !obj.DocumentTypeIsSystem; HtmlInputHidden h = (HtmlInputHidden)e.Item.FindControl("DocumentTypeID"); h.Value = ((DataRowView)e.Item.DataItem)["DocumentTypeID"].ToString(); } HROne.Common.WebUtility.WebControlsLocalization(Session, e.Item.Controls); }
public Document(string number, EDocumentType type) { Number = number; Type = type; AddNotifications(new Contract().Requires().IsTrue(Validate(), "Document.Number", "Invalid document")); }
public byte[] GetDocument( [Parameter("The path to the folder from which to retrieve the docuemnt")] string path, [Parameter("The name of the document to retrieve")] string name, // Multiple documents with the same name, but different document types can exist // within a folder [Parameter("The document type to look for; as names need not be unique within a folder, " + "the document type can be used to disambiguate the actual document required. " + "However, if the document you are after is unique, you can specify a document " + "type of 'All' to retrieve the first document with the specified name.", DefaultValue = EDocumentType.All)] EDocumentType documentType) { string docContent = null; object desc = null, secClass = null; // Find the document in the cache to determine its actual type and file type var doc = FindDocument(path, name, documentType); if (doc != null) { HFM.Try("Retrieving document", () => docContent = (string)_documents.GetDocument(doc.Folder, doc.Name, (int)doc.DocumentType, (int)doc.DocumentFileType, ref desc, ref secClass)); } else { throw new DocumentException("No document named {0} could be found at {1}", name, path); } return(FileUtilities.GetBytes(docContent)); }
/// Determines the document type for Rpt style file protected void ParseXML(string filePath) { using (XmlTextReader xr = new XmlTextReader(filePath)) { xr.WhitespaceHandling = WhitespaceHandling.None; xr.Read(); // Read the XML declaration node, advance to next tag xr.Read(); // Read the root tag switch (xr.Name.ToLower()) { case "linkdoc": DocumentType = EDocumentType.Link; break; case "griddef": DocumentType = EDocumentType.DataGrid; break; case "workspace": DocumentType = EDocumentType.TaskList; break; default: throw new DocumentException("Cannot determine document type for file {0}", filePath); } Name = xr.GetAttribute("doc_name"); Description = xr.GetAttribute("doc_description"); DocumentFileType = EDocumentFileType.XML; // TODO: Fix this... SecurityClass = xr.GetAttribute("doc_secclass"); } }
public SubscriptionHandlerTest() { _firstName = "Daniel"; _lastName = "Negrisoli"; _document = "9999999999"; _email = "*****@*****.**"; _barCode = "123456789"; _boletoNumber = "1234654987"; _paymentNumber = "123121"; _paidDate = DateTime.Now.Date; _expireDate = DateTime.Now.AddMonths(1); _total = 100; _totalPaid = 100; _payer = "Payer"; _payerDocument = "12345678911"; _payerDocumentType = EDocumentType.CPF; _payerEmail = "*****@*****.**"; _street = "Rua Payer"; _number = "1010"; _neighborhood = "Payer"; _city = "São Paulo"; _state = "SP"; _country = "Brasil"; _zipCode = "12345678"; }
public void LoadDocuments( [Parameter("The source path containing the documents to be loaded")] string sourceDir, [Parameter("A file name pattern identifying the documents to be loaded; " + "wildcards may be used. Note that the name pattern does not " + "apply to folder names when IncludeSubDirs is true.", DefaultValue = "*")] string name, [Parameter("The folder in the HFM document repository where the documents should be placed")] string targetFolder, [Parameter("A flag indicating whether sub-directories below the source directory " + "should also be loaded. If true, sub-folders will be created below the " + "target folder with the same names as the sub-directories.", DefaultValue = false)] bool includeSubDirs, [Parameter("The document type(s) to upload", DefaultValue = EDocumentType.All)] EDocumentType documentType, [Parameter("The security class to be assigned to the uploaded documents", DefaultValue = "[Default]")] string securityClass, [Parameter("If true, the documents are created as private documents; otherwise they are public", DefaultValue = false)] bool isPrivate, [Parameter("True to overwrite existing documents, false to leave existing documents unchanged", DefaultValue = false)] bool overwrite, IOutput output) { var files = FileUtilities.FindMatchingFiles(sourceDir, name, includeSubDirs); var loaded = 0; _log.InfoFormat("Loading documents from {0} to {1}", sourceDir, targetFolder); output.InitProgress("Loading documents", files.Count); foreach (var filePath in files) { var file = Path.GetFileName(filePath); var tgtFolder = Path.Combine(targetFolder, FileUtilities.PathDifference(sourceDir, filePath)); CreateFolder(tgtFolder, null, securityClass, isPrivate, EDocumentType.All, false); if (overwrite || !DoesDocumentExist(tgtFolder, file, EDocumentType.All)) { var doc = new DocumentInfo(filePath); if (doc.IsDocumentType(documentType)) { _log.FineFormat("Loading {0} to {1}", file, targetFolder); SaveDocument(targetFolder, doc.Name, doc.Description, doc.DocumentType, doc.DocumentFileType, doc.Content, securityClass, isPrivate, overwrite); loaded++; } } if (output.IterationComplete()) { break; } } output.EndProgress(); _log.InfoFormat("Successfully loaded {0} documents to {1}", loaded, targetFolder); }
/// Determines the document type for Rpt style file protected void ParseRpt(string filePath) { var re = new Regex(@"^(ReportType|ReportLabel|ReportDescription|ReportSecurityClass)=(.*)", RegexOptions.IgnoreCase); using (StreamReader r = new StreamReader(filePath)) { while (r.Peek() >= 0) { var line = r.ReadLine(); var match = re.Match(line); if (match.Success) { switch (match.Groups[1].Value.ToUpper()) { case "REPORTDESCRIPTION": Description = match.Groups[2].Value; break; case "REPORTLABEL": Name = match.Groups[2].Value; break; case "REPORTSECURITYCLASS": // TODO: Fix this... SecurityClass = match.Groups[2].Value; break; case "REPORTTYPE": switch (match.Groups[2].Value.ToUpper()) { case "INTERCOMPANY": DocumentType = EDocumentType.IntercompanyReport; DocumentFileType = EDocumentFileType.ReportDefRPT; break; case "JOURNAL": DocumentType = EDocumentType.JournalReport; DocumentFileType = EDocumentFileType.ReportDefRPT; break; case "WEBFORM": DocumentType = EDocumentType.WebForm; DocumentFileType = EDocumentFileType.WebFormDef; break; case "DATAEXPLORER": DocumentType = EDocumentType.DataExplorerReport; DocumentFileType = EDocumentFileType.XML; break; } break; } } } } if (DocumentType == EDocumentType.Invalid) { DocumentType = EDocumentType.Custom; } _log.TraceFormat("File {0} has document type {1}", filePath, DocumentType); }
public Document(EDocumentType documentType, string documentValue) { DocumentType = documentType; DocumentValue = documentValue; this.ValidTypeDocument(); this.ValidValueDocument(); }
public Document(string Number, EDocumentType type) { this.Number = Number; Type = type; AddNotifications(new Contract(). Requires() .IsTrue(Validate(), "Document", "O documento é inválido")); }
public List <DocumentInfo> EnumDocuments( [Parameter("The document repository folder that contains the documents to return " + @"(note: the root folder is '\')", DefaultValue = @"\")] string path, [Parameter("An optional pattern that document names should match; may include wildcards ? and *", DefaultValue = "*")] string name, [Parameter("If true, recurses into each sub-folder encountered, and returns its content as well", DefaultValue = false)] bool includeSubFolders, [Parameter("The document type(s) to return", DefaultValue = EDocumentType.All)] EDocumentType documentType, [Parameter("A visibility setting used to determine whether public, private or both " + "types of documents should be returned", DefaultValue = EPublicPrivate.Public)] EPublicPrivate visibility, IOutput output) { var nameRE = FileUtilities.ConvertWildcardPatternToRE(name); List <DocumentInfo> docs = new List <DocumentInfo>(); if (_documentCache.ContainsKey(path)) { _log.TraceFormat("Locating matching documents at {0}", path); docs.AddRange(_documentCache[path].Where(doc => nameRE.IsMatch(doc.Name) && doc.IsDocumentType(documentType) && doc.IsVisible(visibility))); if (includeSubFolders) { // Recurse into sub-directory foreach (var folder in GetFolders(path, visibility)) { docs.AddRange(EnumDocuments(AddFolderToPath(path, folder.Name), name, includeSubFolders, documentType, visibility, null)); } } } else { _log.WarnFormat("The path '{0}' does not exist", path); } if (output != null) { // TODO: Add support for outputting any field of DocumentInfo output.SetHeader("Name", 30, "Document Type", "Timestamp", "Description"); foreach (var doc in docs) { output.WriteRecord(doc.Name, doc.DocumentType, doc.Timestamp, doc.Description); } output.End(); } return(docs); }
protected void Repeater_ItemCommand(object source, DataListCommandEventArgs e) { Button b = (Button)e.CommandSource; if (b.ID.Equals("Edit")) { Repeater.EditItemIndex = e.Item.ItemIndex; view = loadData(info, db, Repeater); WebUtils.SetEnabledControlSection(AddPanel, false); } else if (b.ID.Equals("Cancel")) { Repeater.EditItemIndex = -1; view = loadData(info, db, Repeater); WebUtils.SetEnabledControlSection(AddPanel, true); } else if (b.ID.Equals("Save")) { ebinding = new Binding(dbConn, db); ebinding.add((HtmlInputHidden)e.Item.FindControl("DocumentTypeID")); ebinding.add((TextBox)e.Item.FindControl("DocumentTypeCode")); ebinding.add((TextBox)e.Item.FindControl("DocumentTypeDesc")); ebinding.init(Request, Session); EDocumentType obj = new EDocumentType(); Hashtable values = new Hashtable(); PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); ebinding.toValues(values); db.validate(errors, values); if (!errors.isEmpty()) { return; } db.parse(values, obj); if (!AppUtils.checkDuplicate(dbConn, db, obj, errors, "DocumentTypeCode")) { return; } WebUtils.StartFunction(Session, FUNCTION_CODE); db.update(dbConn, obj); WebUtils.EndFunction(dbConn); Repeater.EditItemIndex = -1; view = loadData(info, db, Repeater); WebUtils.SetEnabledControlSection(AddPanel, true); } }
public Document(string number, EDocumentType type) { Number = number; Type = type; AddNotifications(new Contract() .Requires() .IsTrue(Validade(), "Document.Validade", "CPF/CNPJ Invalidos")); }
public Document(string number, EDocumentType type) { Number = number; Type = type; AddNotifications(new Contract() .Requires() .IsTrue(Validate(), "Document.Number", $"{type.ToString()} inválido.")); }
public Document(string number, EDocumentType type) { Number = number; Type = Type; AddNotifications(new Contract() .Requires() .IsTrue(!Validate(), "Documento.Number", "Documento inválido")); }
public Document(string number, EDocumentType type) { Number = number; Type = type; // Biblioteca Flunt AddNotifications(new Flunt.Validations.Contract() .Requires() .IsTrue(Validade(), "Document.Number", "Documento inválido")); }
public Documento(string numeroDocumento, EDocumentType tipoDocumento) { NumeroDocumento = numeroDocumento; TipoDocumento = tipoDocumento; AddNotifications(new Contract() .Requires() .IsTrue(ValidarTipos(), "Documento.TipoDocumento", "Documento invalido") ); }
public void ValidateDocument( string document, EDocumentType type, bool valid ) { var doc = new Document(document, type); Assert.AreEqual(doc.Valid, valid); }
public Document(string number, EDocumentType eDocumentoType) { Number = number; EDocumentoType = eDocumentoType; AddNotifications(new Contract() .Requires() .IsTrue(Validate(), "Document.Number", "Documento inválido.") ); }
public Document(string number, EDocumentType type) { this.Number = number; this.Type = type; AddNotifications(new Contract <Document>() .Requires() .IsTrue(Validate(), "Document.Number", "Documento inválido") ); }
public Document(string number, EDocumentType type) { Number = number; Type = type; AddNotifications(new Contract() .Requires() //.IsTrue(DocumentValidate.validate(Type, Number), "Document.Number", "Documento inválido") ); }
public Document(string number, EDocumentType type) { Number = number; Type = type; AddNotifications(new Contract() .Requires() .IsTrue(Validade(), nameof(Document.Number), "Documento inválido") ); }
public Document(string value, EDocumentType type) { Value = value; Type = type; AddNotifications( new Contract() .Requires() .IsTrue(Validate(), "Document.Value", "Documento inválido")); }
public Document(string number, EDocumentType documentType) { Number = number; DocumentType = documentType; AddNotifications(new Contract() .Requires() .IsTrue(IsValid(), "Document.Number", "Documento inválido!") ); }
protected void Delete_Click(object sender, EventArgs e) { PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); ArrayList list = new ArrayList(); foreach (DataListItem item in Repeater.Items) { CheckBox c = (CheckBox)item.FindControl("DeleteItem"); HtmlInputHidden h = (HtmlInputHidden)item.FindControl("DocumentTypeID"); if (c.Checked) { EDocumentType obj = new EDocumentType(); obj.DocumentTypeID = Int32.Parse(h.Value); list.Add(obj); } } foreach (EDocumentType obj in list) { db.select(dbConn, obj); DBFilter empDocumentTypeFilter = new DBFilter(); empDocumentTypeFilter.add(new Match("DocumentTypeID", obj.DocumentTypeID)); empDocumentTypeFilter.add("empid", true); ArrayList empDocumentTypeList = EEmpDocument.db.select(dbConn, empDocumentTypeFilter); if (empDocumentTypeList.Count > 0) { errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_CODE_USED_BY_EMPLOYEE, new string[] { HROne.Common.WebUtility.GetLocalizedString("DocumentType Code"), obj.DocumentTypeCode })); foreach (EEmpDocument empDocumentType in empDocumentTypeList) { EEmpPersonalInfo empInfo = new EEmpPersonalInfo(); empInfo.EmpID = empDocumentType.EmpID; if (EEmpPersonalInfo.db.select(dbConn, empInfo)) { errors.addError("- " + empInfo.EmpNo + ", " + empInfo.EmpEngFullName); } else { EEmpDocument.db.delete(dbConn, empDocumentType); } } errors.addError(HROne.Translation.PageErrorMessage.ERROR_ACTION_ABORT); view = loadData(info, db, Repeater); return; } else { WebUtils.StartFunction(Session, FUNCTION_CODE); db.delete(dbConn, obj); WebUtils.EndFunction(dbConn); } } view = loadData(info, db, Repeater); }
public Document(string number, EDocumentType type) { Number = number; Type = type; AddNotifications(new Contract() .Requires() .IsDigit(number, "Document.Number", "Inválido (não numérico)") .IsTrue(Validate(), "Document.Number", "Inválido") ); }
public static string ToContentType(this EDocumentType value) { switch (value) { case EDocumentType.Txt: return("text/plain"); default: throw new Exception("Unknown document type"); } }
public int DeleteDocuments( [Parameter("The path to the folder from which to delete documents")] string path, [Parameter("The name of the document(s) to delete; may include wildcards ? and *")] string name, [Parameter("Set to true to delete matching documents in sub-folders as well", DefaultValue = false)] bool includeSubFolders, [Parameter("The document type(s) to delete; use All to include all documents that " + "match the name, path, and any other criteria", DefaultValue = EDocumentType.All)] EDocumentType documentType, [Parameter("Filter documents to be deleted to public, private or both", DefaultValue = EPublicPrivate.Both)] EPublicPrivate visibility, IOutput output) { int count = 0; List <DocumentInfo> docs = EnumDocuments(path, name, includeSubFolders, documentType, visibility, null); docs.Reverse(); // So we delete folder content before folders var paths = new string[1]; var names = new string[1]; if (docs.Count > 1) { output.InitProgress("Deleting documents", docs.Count); } foreach (var doc in docs) { paths[0] = doc.Folder; names[0] = doc.Name; HFM.Try("Deleting document {0}", doc.Name, () => _documents.DeleteDocuments(paths, names, (int)doc.DocumentType, (int)doc.DocumentFileType, false)); count++; if (output.IterationComplete()) { break; } if (doc.DocumentType == EDocumentType.Folder) { _documentCache.Remove(AddFolderToPath(doc.Folder, doc.Name)); } } output.EndProgress(); // Update cache LoadCache(path, includeSubFolders); _log.InfoFormat("Successfully deleted {0} documents", count); return(count); }
public bool DocumentIsValid(string number, EDocumentType documentType = EDocumentType.CPF) { switch (documentType) { case EDocumentType.CPF: return(number.Length == 11); default: AddNotification("DocumentType", "Documento informado não é valido"); return(false); } }