public Document(string number, EDocumentType type)
        {
            Number = number;
            Type   = type;

            Validate();
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
    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);
    }
Ejemplo n.º 4
0
        public Document(string number, EDocumentType type)
        {
            Number = number;
            Type   = type;

            AddNotifications(new Contract().Requires().IsTrue(Validate(), "Document.Number", "Invalid document"));
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
            /// 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");
                }
            }
Ejemplo n.º 7
0
 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";
 }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
            /// 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);
            }
Ejemplo n.º 10
0
        public Document(EDocumentType documentType, string documentValue)
        {
            DocumentType  = documentType;
            DocumentValue = documentValue;

            this.ValidTypeDocument();
            this.ValidValueDocument();
        }
Ejemplo n.º 11
0
 public Document(string Number, EDocumentType type)
 {
     this.Number = Number;
     Type        = type;
     AddNotifications(new Contract().
                      Requires()
                      .IsTrue(Validate(), "Document", "O documento é inválido"));
 }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
    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);
        }
    }
Ejemplo n.º 14
0
        public Document(string number, EDocumentType type)
        {
            Number = number;
            Type   = type;

            AddNotifications(new Contract()
                             .Requires()
                             .IsTrue(Validade(), "Document.Validade", "CPF/CNPJ Invalidos"));
        }
Ejemplo n.º 15
0
        public Document(string number, EDocumentType type)
        {
            Number = number;
            Type   = type;

            AddNotifications(new Contract()
                             .Requires()
                             .IsTrue(Validate(), "Document.Number", $"{type.ToString()} inválido."));
        }
Ejemplo n.º 16
0
        public Document(string number, EDocumentType type)
        {
            Number = number;
            Type   = Type;

            AddNotifications(new Contract()
                             .Requires()
                             .IsTrue(!Validate(), "Documento.Number", "Documento inválido"));
        }
Ejemplo n.º 17
0
        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"));
        }
Ejemplo n.º 18
0
        public Documento(string numeroDocumento, EDocumentType tipoDocumento)
        {
            NumeroDocumento = numeroDocumento;
            TipoDocumento   = tipoDocumento;

            AddNotifications(new Contract()
                             .Requires()
                             .IsTrue(ValidarTipos(), "Documento.TipoDocumento", "Documento invalido")
                             );
        }
Ejemplo n.º 19
0
        public void ValidateDocument(
            string document,
            EDocumentType type,
            bool valid
            )
        {
            var doc = new Document(document, type);

            Assert.AreEqual(doc.Valid, valid);
        }
Ejemplo n.º 20
0
        public Document(string number, EDocumentType eDocumentoType)
        {
            Number         = number;
            EDocumentoType = eDocumentoType;

            AddNotifications(new Contract()
                             .Requires()
                             .IsTrue(Validate(), "Document.Number", "Documento inválido.")
                             );
        }
Ejemplo n.º 21
0
        public Document(string number, EDocumentType type)
        {
            this.Number = number;
            this.Type   = type;

            AddNotifications(new Contract <Document>()
                             .Requires()
                             .IsTrue(Validate(), "Document.Number", "Documento inválido")
                             );
        }
Ejemplo n.º 22
0
        public Document(string number, EDocumentType type)
        {
            Number = number;
            Type   = type;

            AddNotifications(new Contract()
                             .Requires()
                             //.IsTrue(DocumentValidate.validate(Type, Number), "Document.Number", "Documento inválido")
                             );
        }
Ejemplo n.º 23
0
        public Document(string number, EDocumentType type)
        {
            Number = number;
            Type   = type;

            AddNotifications(new Contract()
                             .Requires()
                             .IsTrue(Validade(), nameof(Document.Number), "Documento inválido")
                             );
        }
Ejemplo n.º 24
0
        public Document(string value, EDocumentType type)
        {
            Value = value;
            Type  = type;

            AddNotifications(
                new Contract()
                .Requires()
                .IsTrue(Validate(), "Document.Value", "Documento inválido"));
        }
Ejemplo n.º 25
0
        public Document(string number, EDocumentType documentType)
        {
            Number       = number;
            DocumentType = documentType;

            AddNotifications(new Contract()
                             .Requires()
                             .IsTrue(IsValid(), "Document.Number", "Documento inválido!")
                             );
        }
Ejemplo n.º 26
0
    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);
    }
Ejemplo n.º 27
0
        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")
                             );
        }
Ejemplo n.º 28
0
        public static string ToContentType(this EDocumentType value)
        {
            switch (value)
            {
            case EDocumentType.Txt:
                return("text/plain");

            default:
                throw new Exception("Unknown document type");
            }
        }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 30
0
        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);
            }
        }