コード例 #1
0
ファイル: Document.cs プロジェクト: parat-schweiz/Publicus
 public Document(Guid id) : base(id)
 {
     Contact     = new ForeignKeyField <Contact, Document>(this, "contactid", false, null);
     Verifier    = new ForeignKeyField <Contact, Document>(this, "verifierid", true, null);
     CreatedDate = new Field <DateTime>(this, "createddate", DateTime.UtcNow);
     FileName    = new StringField(this, "filename", 512);
     ContentType = new StringField(this, "contenttype", 128);
     Data        = new FieldClass <byte[]>(this, "data", false);
     Type        = new EnumField <DocumentType>(this, "documenttype", DocumentType.Other, DocumentTypeExtensions.Translate);
 }
コード例 #2
0
ファイル: PostStatus.cs プロジェクト: parat-schweiz/Publicus
        public void AssingDataUrlString(string fieldName, FieldClass <byte[]> dataField, StringField contentTypeField, string stringValue, bool required)
        {
            if (!string.IsNullOrEmpty(stringValue))
            {
                var parts = stringValue.Split(new string[] { "data:", ";base64," }, StringSplitOptions.RemoveEmptyEntries);

                if (parts.Length == 2)
                {
                    try
                    {
                        if (!ReferenceEquals(contentTypeField, null))
                        {
                            contentTypeField.Value = parts[0];
                        }

                        dataField.Value = Convert.FromBase64String(parts[1]);
                    }
                    catch
                    {
                        Add(fieldName,
                            "Validation.Upload.Failed",
                            "Validation message on upload failed",
                            "File upload failed");
                        IsSuccess = false;
                    }
                }
                else
                {
                    Add(fieldName,
                        "Validation.Upload.Failed",
                        "Validation message on upload failed",
                        "File upload failed");
                    IsSuccess = false;
                }
            }
            else if (required)
            {
                Add(fieldName,
                    "Validation.Upload.Required",
                    "Validation message on upload required",
                    "File upload required");
                IsSuccess = false;
            }
        }