RemFileImport Method (ObjectID, String, String, Boolean, String, Boolean, Int32) |
Namespace: Paperwork.Connect
public a_GenericResult Import( ObjectID objectId, string fileName, string aOriginalFormat, bool isCompress, string compressFormat, bool aIsBitonal, int aDpi )
ObservableCollection<LookupItem> acls = p.rLookup.GetACLs(string.Empty);
ObservableCollection<LookupItem> types = p.rLookup.GetTypes(string.Empty, string.Empty);
ObservableCollection<LookupItem> forms = p.rLookup.GetForms(false, string.Empty);
public LookupItem getACLByName(string name)
{
foreach (LookupItem acl in acls)
if (acl.Title == name)
return acl;
return null;
}
public LookupItem getTypeByTitle(string title)
{
foreach (LookupItem typ in types)
if (typ.Title == title)
return typ;
return null;
}
public LookupItem getFormByTitle(string title)
{
foreach (LookupItem frm in forms)
if (frm.Title == title)
return frm;
return null;
}
public string createFolder(string path, string acl_id)
{
a_PathInfo pth = p.rNavigation.CreateFolderByPath(path, new ObjectID(acl_id), false);
return pth.ObjectList[pth.ObjectList.Count - 1];
}
public void Import()
{
foreach (string filename in Directory.GetFiles(@"C:\"))
{
string type_name = getTypeByTitle("Egitim").Name;
string form_name = getFormByTitle("Egitim").Name;
string acl_id = getACLByName("Default Acl").ObjectId;
string save_path = @"TR_CABINETS\Deneme\Egitim";
string folder_id = createFolder(save_path, acl_id);
string object_name = Path.GetFileName(filename);
string file_ext = Path.GetExtension(filename).Replace(".", "").ToUpper().Replace("İ", "I");
ITypes fobject = p.rDocument.getDocument(ObjectID.Empty, type_name);
fobject.setAttribute("ACL_ID", acl_id);
fobject.setAttribute("OBJECT_TYPE", type_name);
fobject.setAttribute("FOLDER_ID", folder_id);
fobject.setAttribute("FORM_NAME", form_name);
fobject.setAttribute("FORM_VERSION", "1");
fobject.setAttribute("OBJECT_NAME", object_name);
fobject.setAttribute("FILE_FORMAT", file_ext);
fobject.setAttribute("DENEME", "12345");
a_GenericResult res = p.rDocument.SetDocument(fobject);
if (res.ErrorCode != 0)
throw new Exception(res.Message);
string obj_id = res.Result;
Console.WriteLine("Dosya kaydedildi. ObjectID:{0}", obj_id);
byte[] content = System.IO.File.ReadAllBytes(filename);
a_GenericResult ires = p.rFile.Import(new ObjectID(obj_id), filename, file_ext, false, "ZIP", false, 0);
if (ires.ErrorCode != 0)
throw new Exception(ires.Message);
}
Console.WriteLine("Dosya içerigi kaydedildi.");
}