Saturday, July 4, 2009
Thursday, June 18, 2009
Sunday, March 1, 2009
Visual vault
Visual vault
Using visual vault sdk api handling document
Following class will help you to handle document with visual vault
public class VaultModule
{
private static VVRuntime.Library.DocumentLibrary _library;
private static Vault _vault;
private static Folder _selectedFolder;
private static Guid _selectedFolderID;
private static Document _selectedDocument;
static string serverURL = ConfigurationManager.AppSettings["vaultServer"];
static string usr = ConfigurationManager.AppSettings["vaultUserName"];
static string usrPwd = ConfigurationManager.AppSettings["vaultPwd"];
static string rootFolder = ConfigurationManager.AppSettings["vaultRootFolder"];
public VaultModule()
{
//
// TODO: Add constructor logic here
//
}
public static string UploadFile(string folderName, string fileNameAndPath, string itemsFolderName, string NEwFileName, string Description, string KeyWord, string Item, string VendorNo)
{
_vault = Authenticate.Login(serverURL, WindowsIdentity.GetCurrent()); //with userID and password
if (_vault == null)
{
_vault = Authenticate.Login(serverURL, usr, usrPwd); //with userID and password
}
if (_vault != null)
{
_library = _vault.DefaultStore.Library;
}
//Guid gFolderID;
if (_vault != null)
{
Folder RootFolder = _vault.DefaultStore.Library.GetTopLevelFolders().get_Item(rootFolder);
if (RootFolder == null)
return null;
Folder VendorFolder = RootFolder.GetChildFolders().get_Item("Vendor");
if (VendorFolder == null)
return null;
Folder folder = null;
try
{
folder = VendorFolder.GetChildFolders().get_Item(FindVendorFolder(VendorNo, VendorFolder.StoreID).Name);//( .GetTopLevelFolders();
}
catch
{
}
if (folder != null)
{
Folder itmFolder = null;
try
{
itmFolder = folder.GetChildFolders().get_Item(FindItemFolder(Item, folder.FolderID ).Name);
// itmFolder= FindItemFolder(Item);
}
catch
{
}
if (itmFolder == null)
{
_selectedFolder = folder.NewChildFolder(itemsFolderName, "Items Folder");
}
else
{
_selectedFolder = itmFolder;
}
}
else
{
try
{
folder = VendorFolder.NewChildFolder(folderName, "Vendor Folder Name");
_selectedFolder = folder.NewChildFolder(itemsFolderName, "Items");
}
catch (Exception)
{
return null;
}
}
string Extension = fileNameAndPath.Substring(fileNameAndPath.LastIndexOf(@"."));
string DID = CreateDocumentInFolder(fileNameAndPath, NEwFileName + Extension, "1", DocumentState.Released, fileNameAndPath, Description, KeyWord).DocumentLink ;
// if (CreateDocumentInFolder(fileNameAndPath, NEwFileName + Extension, "1", DocumentState.Released, fileNameAndPath, Description, KeyWord) != null)
return DID;
}
return null;
}
private static Document CreateDocumentInFolder(string fileNameAndPath, string fileName, string revision, DocumentState documentState, string docID, string description, string KeyWord)
{
System.IO.FileStream fs;
Document document = null;
if (_selectedFolder != null)
{
fs = System.IO.File.Open(fileNameAndPath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
//document is created by calling the NewDocument method on the target VisualVault folder
document = _selectedFolder.NewDocument(fileName, description, revision, fs, fileName, documentState);
document.UpdateKeywords(KeyWord, true);
fs.Close();
}
return document;
}
private static Folder FindItemFolder(string Item, Guid StoreId)
{
VVRuntime.Library.Folders.FolderCollection folderCollection;
_library = _vault.GetStore(StoreId).Library;
folderCollection = _vault.DefaultStore.Library.GetChildFolders(StoreId);
Folder ItemFold = null;
if (folderCollection != null)
{
if (folderCollection.Count > 0)
{
foreach (Folder Fo in folderCollection)
{
string [] matching_item = Fo.Name.Split('-');
if ( matching_item[0].ToLower().Equals(Item.ToLower()))
//Fo.Name.ToLower().IndexOf(Item.ToLower())!=-1)
{
ItemFold = Fo;
return ItemFold;
}
}
}
return null;
}
return null;
}
private static Folder FindVendorFolder(string Vendor, Guid StoreID)
{
VVRuntime.Library.Folders.FolderCollection folderCollection;
_library = _vault.GetStore(StoreID).Library ;
folderCollection = _library.FindFolders(Vendor);
Folder VenFold=null;
if (folderCollection != null)
{
if (folderCollection.Count > 0)
{
foreach (Folder Fo in folderCollection)
{
string matching_vendor = Fo.Name.ToString().Substring(Fo.Name.ToString().LastIndexOf('-') + 1);
if (matching_vendor.Equals(Vendor))
{
VenFold = Fo;
break;
}
}
return VenFold;
}
}
return null;
}
}
Using visual vault sdk api handling document
Following class will help you to handle document with visual vault
public class VaultModule
{
private static VVRuntime.Library.DocumentLibrary _library;
private static Vault _vault;
private static Folder _selectedFolder;
private static Guid _selectedFolderID;
private static Document _selectedDocument;
static string serverURL = ConfigurationManager.AppSettings["vaultServer"];
static string usr = ConfigurationManager.AppSettings["vaultUserName"];
static string usrPwd = ConfigurationManager.AppSettings["vaultPwd"];
static string rootFolder = ConfigurationManager.AppSettings["vaultRootFolder"];
public VaultModule()
{
//
// TODO: Add constructor logic here
//
}
public static string UploadFile(string folderName, string fileNameAndPath, string itemsFolderName, string NEwFileName, string Description, string KeyWord, string Item, string VendorNo)
{
_vault = Authenticate.Login(serverURL, WindowsIdentity.GetCurrent()); //with userID and password
if (_vault == null)
{
_vault = Authenticate.Login(serverURL, usr, usrPwd); //with userID and password
}
if (_vault != null)
{
_library = _vault.DefaultStore.Library;
}
//Guid gFolderID;
if (_vault != null)
{
Folder RootFolder = _vault.DefaultStore.Library.GetTopLevelFolders().get_Item(rootFolder);
if (RootFolder == null)
return null;
Folder VendorFolder = RootFolder.GetChildFolders().get_Item("Vendor");
if (VendorFolder == null)
return null;
Folder folder = null;
try
{
folder = VendorFolder.GetChildFolders().get_Item(FindVendorFolder(VendorNo, VendorFolder.StoreID).Name);//( .GetTopLevelFolders();
}
catch
{
}
if (folder != null)
{
Folder itmFolder = null;
try
{
itmFolder = folder.GetChildFolders().get_Item(FindItemFolder(Item, folder.FolderID ).Name);
// itmFolder= FindItemFolder(Item);
}
catch
{
}
if (itmFolder == null)
{
_selectedFolder = folder.NewChildFolder(itemsFolderName, "Items Folder");
}
else
{
_selectedFolder = itmFolder;
}
}
else
{
try
{
folder = VendorFolder.NewChildFolder(folderName, "Vendor Folder Name");
_selectedFolder = folder.NewChildFolder(itemsFolderName, "Items");
}
catch (Exception)
{
return null;
}
}
string Extension = fileNameAndPath.Substring(fileNameAndPath.LastIndexOf(@"."));
string DID = CreateDocumentInFolder(fileNameAndPath, NEwFileName + Extension, "1", DocumentState.Released, fileNameAndPath, Description, KeyWord).DocumentLink ;
// if (CreateDocumentInFolder(fileNameAndPath, NEwFileName + Extension, "1", DocumentState.Released, fileNameAndPath, Description, KeyWord) != null)
return DID;
}
return null;
}
private static Document CreateDocumentInFolder(string fileNameAndPath, string fileName, string revision, DocumentState documentState, string docID, string description, string KeyWord)
{
System.IO.FileStream fs;
Document document = null;
if (_selectedFolder != null)
{
fs = System.IO.File.Open(fileNameAndPath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
//document is created by calling the NewDocument method on the target VisualVault folder
document = _selectedFolder.NewDocument(fileName, description, revision, fs, fileName, documentState);
document.UpdateKeywords(KeyWord, true);
fs.Close();
}
return document;
}
private static Folder FindItemFolder(string Item, Guid StoreId)
{
VVRuntime.Library.Folders.FolderCollection folderCollection;
_library = _vault.GetStore(StoreId).Library;
folderCollection = _vault.DefaultStore.Library.GetChildFolders(StoreId);
Folder ItemFold = null;
if (folderCollection != null)
{
if (folderCollection.Count > 0)
{
foreach (Folder Fo in folderCollection)
{
string [] matching_item = Fo.Name.Split('-');
if ( matching_item[0].ToLower().Equals(Item.ToLower()))
//Fo.Name.ToLower().IndexOf(Item.ToLower())!=-1)
{
ItemFold = Fo;
return ItemFold;
}
}
}
return null;
}
return null;
}
private static Folder FindVendorFolder(string Vendor, Guid StoreID)
{
VVRuntime.Library.Folders.FolderCollection folderCollection;
_library = _vault.GetStore(StoreID).Library ;
folderCollection = _library.FindFolders(Vendor);
Folder VenFold=null;
if (folderCollection != null)
{
if (folderCollection.Count > 0)
{
foreach (Folder Fo in folderCollection)
{
string matching_vendor = Fo.Name.ToString().Substring(Fo.Name.ToString().LastIndexOf('-') + 1);
if (matching_vendor.Equals(Vendor))
{
VenFold = Fo;
break;
}
}
return VenFold;
}
}
return null;
}
}
Subscribe to:
Posts (Atom)