Esempio n. 1
0
        private string GetCreateUrl(FileType fileType)
        {
            string title;

            switch (fileType)
            {
            case FileType.Document:
                title = FilesJSResource.TitleNewFileText;
                break;

            case FileType.Spreadsheet:
                title = FilesJSResource.TitleNewFileSpreadsheet;
                break;

            case FileType.Presentation:
                title = FilesJSResource.TitleNewFilePresentation;
                break;

            default:
                return(null);
            }

            Configuration <T> .DocType.TryGetValue(fileType, out var documentType);

            return(BaseCommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.FileHandlerPath)
                   + "?" + FilesLinkUtility.Action + "=create"
                   + "&doctype=" + documentType
                   + "&" + FilesLinkUtility.FileTitle + "=" + HttpUtility.UrlEncode(title));
        }
Esempio n. 2
0
        public string GetFileStreamUrl(File <string> file)
        {
            if (file == null)
            {
                return(string.Empty);
            }

            var fileId = ThirdPartySelector.GetFileId(file.ID);

            Logger.Debug("BoxApp: get file stream url " + fileId);

            var uriBuilder = new UriBuilder(BaseCommonLinkUtility.GetFullAbsolutePath(ThirdPartyAppHandlerService.HandlerPath));

            if (uriBuilder.Uri.IsLoopback)
            {
                uriBuilder.Host = Dns.GetHostName();
            }
            var query = uriBuilder.Query;

            query += FilesLinkUtility.Action + "=stream&";
            query += FilesLinkUtility.FileId + "=" + HttpUtility.UrlEncode(fileId) + "&";
            query += CommonLinkUtility.ParamName_UserUserID + "=" + HttpUtility.UrlEncode(AuthContext.CurrentAccount.ID.ToString()) + "&";
            query += FilesLinkUtility.AuthKey + "=" + EmailValidationKeyProvider.GetEmailKey(fileId + AuthContext.CurrentAccount.ID) + "&";
            query += ThirdPartySelector.AppAttr + "=" + AppAttr;

            return(uriBuilder.Uri + "?" + query);
        }
        public string GetCallbackUrl <T>(T fileId)
        {
            var callbackUrl = BaseCommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.FileHandlerPath
                                                                        + "?" + FilesLinkUtility.Action + "=track"
                                                                        + "&" + FilesLinkUtility.FileId + "=" + HttpUtility.UrlEncode(fileId.ToString())
                                                                        + "&" + FilesLinkUtility.AuthKey + "=" + EmailValidationKeyProvider.GetEmailKey(fileId.ToString()));

            callbackUrl = DocumentServiceConnector.ReplaceCommunityAdress(callbackUrl);
            return(callbackUrl);
        }
Esempio n. 4
0
        public string GetLink <T>(File <T> file, bool withHash = true)
        {
            var url = file.DownloadUrl;

            if (FileUtility.CanWebView(file.Title))
            {
                url = FilesLinkUtility.GetFileWebPreviewUrl(FileUtility, file.Title, file.ID);
            }

            if (withHash)
            {
                var linkParams = CreateKey(file.ID);
                url += "&" + FilesLinkUtility.DocShareKey + "=" + HttpUtility.UrlEncode(linkParams);
            }

            return(BaseCommonLinkUtility.GetFullAbsolutePath(url));
        }
Esempio n. 5
0
        public List <RecentConfig> GetRecent(EntryManager entryManager)
        {
            if (!AuthContext.IsAuthenticated || UserManager.GetUsers(AuthContext.CurrentAccount.ID).IsVisitor(UserManager))
            {
                return(null);
            }
            if (!FilesSettingsHelper.RecentSection)
            {
                return(null);
            }

            var filter = FilterType.FilesOnly;

            switch (_configuration.GetFileType)
            {
            case FileType.Document:
                filter = FilterType.DocumentsOnly;
                break;

            case FileType.Spreadsheet:
                filter = FilterType.SpreadsheetsOnly;
                break;

            case FileType.Presentation:
                filter = FilterType.PresentationsOnly;
                break;
            }

            var folderDao = DaoFactory.GetFolderDao <int>();
            var fileDao   = DaoFactory.GetFileDao <int>();
            var files     = entryManager.GetRecent(folderDao, fileDao, filter, false, Guid.Empty, string.Empty, false);

            var listRecent = from file in files
                             where !Equals(_configuration.Document.Info.File.ID, file.ID)
                             select
                             new RecentConfig
            {
                Folder = folderDao.GetFolder(file.FolderID).Title,
                Title  = file.Title,
                Url    = BaseCommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorUrl(file.ID))
            };

            return(listRecent.ToList());
        }
Esempio n. 6
0
        public List <TemplatesConfig> GetTemplates(EntryManager entryManager)
        {
            if (!AuthContext.IsAuthenticated || UserManager.GetUsers(AuthContext.CurrentAccount.ID).IsVisitor(UserManager))
            {
                return(null);
            }
            if (!FilesSettingsHelper.TemplatesSection)
            {
                return(null);
            }

            var extension = FileUtility.GetInternalExtension(_configuration.Document.Title).TrimStart('.');
            var filter    = FilterType.FilesOnly;

            switch (_configuration.GetFileType)
            {
            case FileType.Document:
                filter = FilterType.DocumentsOnly;
                break;

            case FileType.Spreadsheet:
                filter = FilterType.SpreadsheetsOnly;
                break;

            case FileType.Presentation:
                filter = FilterType.PresentationsOnly;
                break;
            }

            var folderDao     = DaoFactory.GetFolderDao <int>();
            var fileDao       = DaoFactory.GetFileDao <int>();
            var files         = entryManager.GetTemplates(folderDao, fileDao, filter, false, Guid.Empty, string.Empty, false);
            var listTemplates = from file in files
                                select
                                new TemplatesConfig
            {
                Image = BaseCommonLinkUtility.GetFullAbsolutePath("skins/default/images/filetype/thumb/" + extension + ".png"),
                Name  = file.Title,
                Title = file.Title,
                Url   = BaseCommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorUrl(file.ID))
            };

            return(listTemplates.ToList());
        }
        public string ReplaceDocumentAdress(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(url);
            }

            var uri         = new UriBuilder(url).ToString();
            var externalUri = new UriBuilder(BaseCommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.DocServiceUrl)).ToString();
            var internalUri = new UriBuilder(BaseCommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.DocServiceUrlInternal)).ToString();

            if (uri.StartsWith(internalUri, true, CultureInfo.InvariantCulture) || !uri.StartsWith(externalUri, true, CultureInfo.InvariantCulture))
            {
                return(url);
            }

            uri = uri.Replace(externalUri, FilesLinkUtility.DocServiceUrlInternal);

            return(uri);
        }
 private string GetEcho(string method, bool user = true)
 {
     return(new TwilioResponseHelper(this, BaseCommonLinkUtility.GetFullAbsolutePath("")).GetEcho(method, user));
 }
Esempio n. 9
0
 public static string GetFullAbsolutePath(string virtualPath)
 {
     return(BaseCommonLinkUtility.GetFullAbsolutePath(virtualPath));
 }
 public static string GetFullAbsolutePath(HttpContext context, string virtualPath)
 {
     return(BaseCommonLinkUtility.GetFullAbsolutePath(context, virtualPath));
 }
        public void CheckDocServiceUrl()
        {
            if (!string.IsNullOrEmpty(FilesLinkUtility.DocServiceHealthcheckUrl))
            {
                try
                {
                    if (!Web.Core.Files.DocumentService.HealthcheckRequest(FilesLinkUtility.DocServiceHealthcheckUrl))
                    {
                        throw new Exception("bad status");
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("Healthcheck DocService check error", ex);
                    throw new Exception("Healthcheck url: " + ex.Message);
                }
            }

            if (!string.IsNullOrEmpty(FilesLinkUtility.DocServiceConverterUrl))
            {
                string convertedFileUri;
                try
                {
                    const string fileExtension = ".docx";
                    var          toExtension   = FileUtility.GetInternalExtension(fileExtension);
                    var          url           = PathProvider.GetEmptyFileUrl(fileExtension);

                    var fileUri = ReplaceCommunityAdress(url);

                    var key = GenerateRevisionId(Guid.NewGuid().ToString());
                    Web.Core.Files.DocumentService.GetConvertedUri(FileUtility, FilesLinkUtility.DocServiceConverterUrl, fileUri, fileExtension, toExtension, key, null, false, FileUtility.SignatureSecret, out convertedFileUri);
                }
                catch (Exception ex)
                {
                    Logger.Error("Converter DocService check error", ex);
                    throw new Exception("Converter url: " + ex.Message);
                }

                try
                {
                    var request = (HttpWebRequest)WebRequest.Create(convertedFileUri);
                    using var response = (HttpWebResponse)request.GetResponse();
                    if (response.StatusCode != HttpStatusCode.OK)
                    {
                        throw new Exception("Converted url is not available");
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("Document DocService check error", ex);
                    throw new Exception("Document server: " + ex.Message);
                }
            }

            if (!string.IsNullOrEmpty(FilesLinkUtility.DocServiceCommandUrl))
            {
                try
                {
                    var key = GenerateRevisionId(Guid.NewGuid().ToString());
                    Web.Core.Files.DocumentService.CommandRequest(FileUtility, FilesLinkUtility.DocServiceCommandUrl, CommandMethod.Version, key, null, null, null, FileUtility.SignatureSecret, out var version);
                }
                catch (Exception ex)
                {
                    Logger.Error("Command DocService check error", ex);
                    throw new Exception("Command url: " + ex.Message);
                }
            }

            if (!string.IsNullOrEmpty(FilesLinkUtility.DocServiceDocbuilderUrl))
            {
                try
                {
                    var storeTemplate = GlobalStore.GetStoreTemplate();
                    var scriptUri     = storeTemplate.GetUri("", "test.docbuilder");
                    var scriptUrl     = BaseCommonLinkUtility.GetFullAbsolutePath(scriptUri.ToString());
                    scriptUrl = ReplaceCommunityAdress(scriptUrl);

                    Web.Core.Files.DocumentService.DocbuilderRequest(FileUtility, FilesLinkUtility.DocServiceDocbuilderUrl, null, scriptUrl, false, FileUtility.SignatureSecret, out var urls);
                }
                catch (Exception ex)
                {
                    Logger.Error("DocService check error", ex);
                    throw new Exception("Docbuilder url: " + ex.Message);
                }
            }
        }
Esempio n. 12
0
 private string GetEcho(string method, bool user = true)
 {
     return(new TwilioResponseHelper(this, BaseCommonLinkUtility.GetFullAbsolutePath(""), AuthContext, TenantUtil, SecurityContext).GetEcho(method, user));
 }
Esempio n. 13
0
        private string CreateEnvelope(string accountId, Document document, DocuSignData docuSignData, DocuSign.eSign.Client.Configuration configuration)
        {
            var eventNotification = new EventNotification
            {
                EnvelopeEvents = new List <EnvelopeEvent>
                {
                    //new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Sent.ToString()},
                    //new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Delivered.ToString()},
                    new EnvelopeEvent {
                        EnvelopeEventStatusCode = DocuSignStatus.Completed.ToString()
                    },
                    new EnvelopeEvent {
                        EnvelopeEventStatusCode = DocuSignStatus.Declined.ToString()
                    },
                    new EnvelopeEvent {
                        EnvelopeEventStatusCode = DocuSignStatus.Voided.ToString()
                    },
                },
                IncludeDocumentFields = "true",
                //RecipientEvents = new List<RecipientEvent>
                //    {
                //        new RecipientEvent {RecipientEventStatusCode = "Sent"},
                //        new RecipientEvent {RecipientEventStatusCode = "Delivered"},
                //        new RecipientEvent {RecipientEventStatusCode = "Completed"},
                //        new RecipientEvent {RecipientEventStatusCode = "Declined"},
                //        new RecipientEvent {RecipientEventStatusCode = "AuthenticationFailed"},
                //        new RecipientEvent {RecipientEventStatusCode = "AutoResponded"},
                //    },
                Url = BaseCommonLinkUtility.GetFullAbsolutePath(DocuSignHandlerService.Path(FilesLinkUtility) + "?" + FilesLinkUtility.Action + "=webhook"),
            };

            Log.Debug("DocuSign hook url: " + eventNotification.Url);

            var signers = new List <Signer>();

            docuSignData.Users.ForEach(uid =>
            {
                try
                {
                    var user = UserManager.GetUsers(uid);
                    signers.Add(new Signer
                    {
                        Email       = user.Email,
                        Name        = user.DisplayUserName(false, DisplayUserSettingsHelper),
                        RecipientId = user.ID.ToString(),
                    });
                }
                catch (Exception ex)
                {
                    Log.Error("Signer is undefined", ex);
                }
            });

            var envelopeDefinition = new EnvelopeDefinition
            {
                CustomFields = new CustomFields
                {
                    TextCustomFields = new List <TextCustomField>
                    {
                        new TextCustomField {
                            Name = UserField, Value = AuthContext.CurrentAccount.ID.ToString()
                        },
                    }
                },
                Documents = new List <Document> {
                    document
                },
                EmailBlurb        = docuSignData.Message,
                EmailSubject      = docuSignData.Name,
                EventNotification = eventNotification,
                Recipients        = new Recipients
                {
                    Signers = signers,
                },
                Status = "created",
            };

            var envelopesApi    = new EnvelopesApi(configuration);
            var envelopeSummary = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

            Log.Debug("DocuSign createdEnvelope: " + envelopeSummary.EnvelopeId);

            var envelopeId = envelopeSummary.EnvelopeId;
            var url        = envelopesApi.CreateSenderView(accountId, envelopeId, new ReturnUrlRequest
            {
                ReturnUrl = BaseCommonLinkUtility.GetFullAbsolutePath(DocuSignHandlerService.Path(FilesLinkUtility) + "?" + FilesLinkUtility.Action + "=redirect")
            });

            Log.Debug("DocuSign senderView: " + url.Url);

            return(url.Url);
        }