Beispiel #1
0
        private static void GetItems()
        {
            string Root = ConfigurationSettings.AppSettings["FARootFolder"].ToString();

            FAWAPI.FAWAPIv2Soap obj    = new FAWAPIv2SoapClient();
            ListItemsResult     result = obj.ListItems2(objAccount.GetLogintoken(), Root + "\\Apttus Connector for SAP VC", 100, 1);
            int i = result.Items.Count();
        }
Beispiel #2
0
 /// <summary>
 /// Share folder
 /// </summary>
 /// <param name="path">eg. Apttus Connector for SAP VC\Apttus Connector - rev7908 - 2017-09-27</param>
 private static SendItemsELinkResponse ShareFolders(string path)
 {
     try
     {
         Console.WriteLine("Creating Share link for " + FAPath + @"\" + Foldername);
         List <ItemDetails>  itemsToshare = new List <ItemDetails>();
         FAWAPI.FAWAPIv2Soap obj          = new FAWAPIv2SoapClient();
         ItemDetails         item         = new ItemDetails()
         {
             Type = "Folder",
             Path = path
         };
         itemsToshare.Add(item);
         string password = PasswordGenerator.CreateRandomPassword(10);
         // creating an object for Sharefile Link request
         SendItemsELinkRequest request = new SendItemsELinkRequest()
         {
             ELinkItems               = itemsToshare.ToArray(),
             ElinkPassWord            = password,
             FolderView               = "F",
             LinkInFileAttachment     = "Y",
             RecipientsEmailAddresses = "[email protected];",
             Token                 = objAccount.GetLogintoken(),
             UserEmailAsSender     = "Y",
             EmailSubject          = "File shared to update",
             EmailBody             = "Created",
             ShareDays             = 14, // no of days for share link to be expired.
             RecordFileHistoryLog  = "Y",
             NotifyDownloadByEmail = "Y",
             SendReadReceipt       = "Y",
             ReadOnlyPermission    = "N",
             DownloadLimit         = 0,
             DisplayWatermark      = "N",
             WatermarkAtBottom     = "",
             WatermarkAtCenter     = ""
         };
         // Send it to share
         SendItemsELinkResponse slresp = obj.SendItemsELink(request);
         if (slresp.SendElinkResult.ELinkURLs.Any())
         {
             Console.WriteLine("Shared Link created..");
             Console.WriteLine("Sending mail with Shared Link and password");
             MailServer.SendHTMLMail(slresp.SendElinkResult.ELinkURLs.First().URL.ToString(), password, path, FAPath, objXMLParser.Get_UploadedFiles_HTML(), Foldername);
             Console.WriteLine("Mail sent." + Environment.NewLine);
             InsertToDB(slresp.SendElinkResult.ELinkURLs.First().URL.ToString(), password, Foldername, SVN_RevisionNo);
         }
         else
         {
             Console.WriteLine("Sharing link failed.");
         }
         return(slresp);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error occurs in creating shared link of uploaded file:- " + ex.Message);
         throw ex;
     }
 }
 /// <summary>
 /// Login to the FAW API account
 /// </summary>
 public bool Login()
 {
     try
     {
         string username = ConfigurationSettings.AppSettings["FAUserName"].ToString();
         string password = ConfigurationSettings.AppSettings["FAPassword"].ToString();
         string apiKey   = ConfigurationSettings.AppSettings["FAAPIKey"].ToString();
         // 50 for a FilesAnywhere WebAdvanced account.
         FAWAPI.AccountLoginRequest lh  = new AccountLoginRequest(apiKey, 50, username, password, "", "");
         FAWAPI.FAWAPIv2Soap        obj = new FAWAPIv2SoapClient();
         _loginResponse = new AccountLoginResponse();
         _loginResponse = obj.AccountLogin(lh);
         return(_loginResponse.LoginResult.ErrorMessage == "");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         throw ex;
     }
 }
Beispiel #4
0
 /// <summary>
 /// Upload a file to RootFolder/Mainfolder+subfolder on Filesanywhere account
 /// </summary>
 /// <param name="MainForlder"></param>
 /// <param name="Subfolder"></param>
 /// <param name="Filepath"></param>
 /// <returns></returns>
 private static bool Upload_File(string MainForlder, string Subfolder, string Filepath)
 {
     try
     {
         // Creating object for uploadFileRequest for uploading a requested file
         UploadFileRequest req = new UploadFileRequest()
         {
             FileData = File.ReadAllBytes(Filepath),
             Path     = objAccount.GetRootFolder() + "/" + MainForlder + "/" + Subfolder + "/" + Path.GetFileName(Filepath),
             Token    = objAccount.GetLogintoken()
         };
         FAWAPI.FAWAPIv2Soap obj       = new FAWAPIv2SoapClient();
         UploadFileResponse  _response = obj.UploadFile(req);
         return(_response.UploadFileResult.Uploaded);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error occured in uploading file " + Path.GetFileName(Filepath) + " :- " + ex.Message);
         throw ex;
     }
 }
Beispiel #5
0
 /// <summary>
 /// Create folder on Filesanywhere
 /// </summary>
 /// <param name="MainForlder"></param>
 /// <param name="Subfolder"></param>
 /// <returns></returns>
 private static bool CreateFolders(string MainForlder, string Subfolder)
 {
     try
     {
         // Get Root Folder on which we are trying to load all files
         string Root                      = ConfigurationSettings.AppSettings["FARootFolder"].ToString();
         FAWAPI.FAWAPIv2Soap obj          = new FAWAPIv2SoapClient();
         CreateFolderResult  folderResult = obj.CreateFolder(objAccount.GetLogintoken(), Root + "/" + MainForlder, Subfolder);
         if (folderResult.FolderCreated == false)
         {
             if (folderResult.ErrorMessage.StartsWith("e2937:"))
             {
                 Console.WriteLine(Subfolder + " folder already exsist on FA. Please use othe folder name.");
             }
         }
         return(folderResult.FolderCreated);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error occurs in Creating Folder on FA (might be because of Mainfolder " + MainForlder + " doesnot exists) :- " + ex.Message);
         throw ex;
     }
 }