Compare commits
10 Commits
feature/cs
...
feature/cs
| Author | SHA1 | Date | |
|---|---|---|---|
| daf2e65da3 | |||
| ef2df8293f | |||
| 10dbe4a130 | |||
| 8eae4d6bcd | |||
| 95e550e2e6 | |||
| bfec02c5bb | |||
| 1eeec4b937 | |||
| 3ca29cd402 | |||
| c398b30e33 | |||
| 8caea9fab0 |
7
.gitignore
vendored
@ -14,6 +14,7 @@
|
||||
/web/documentserver-example/java/target/
|
||||
/web/documentserver-example/csharp/packages
|
||||
/web/documentserver-example/csharp-mvc/packages
|
||||
/web/documentserver-example/csharp-mvc-react/packages
|
||||
/web/documentserver-example/csharp-mvc-react/Scripts/React/node_modules
|
||||
/web/documentserver-example/csharp-mvc-react/Scripts/React/dist
|
||||
/web/documentserver-example/csharp-mvc-angular/packages
|
||||
/web/documentserver-example/csharp-mvc-angular/Scripts/Angular/node_modules
|
||||
/web/documentserver-example/csharp-mvc-angular/Scripts/Angular/public
|
||||
|
||||
|
||||
4
.gitmodules
vendored
@ -30,7 +30,7 @@
|
||||
path = web/documentserver-example/java-spring/src/main/resources/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/csharp-mvc-react/assets"]
|
||||
path = web/documentserver-example/csharp-mvc-react/assets
|
||||
[submodule "web/documentserver-example/csharp-mvc-angular/assets"]
|
||||
path = web/documentserver-example/csharp-mvc-angular/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Change Log
|
||||
|
||||
- added csharp mvc with react
|
||||
- added csharp mvc with angular
|
||||
|
||||
## 1.5.0
|
||||
- nodejs: added wopi putRelativeFile action
|
||||
|
||||
@ -6,13 +6,13 @@
|
||||
<RootDir Condition="$(RootDir)==''">..\..\</RootDir>
|
||||
<DirCSharp>$(RootDir)web\documentserver-example\csharp\</DirCSharp>
|
||||
<DirMvc>$(RootDir)web\documentserver-example\csharp-mvc\</DirMvc>
|
||||
<DirMvcReact>$(RootDir)web\documentserver-example\csharp-mvc-react\</DirMvcReact>
|
||||
<DirMvcAngular>$(RootDir)web\documentserver-example\csharp-mvc-angular\</DirMvcAngular>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectToBuild Include="$(DirCSharp)OnlineEditorsExample.sln"/>
|
||||
<ProjectToBuild Include="$(DirMvc)OnlineEditorsExampleMVC.sln"/>
|
||||
<ProjectToBuild Include="$(DirMvcReact)OnlineEditorsExampleMVCreact.sln"/>
|
||||
<ProjectToBuild Include="$(DirMvcAngular)OnlineEditorsExampleMVCAngular.sln"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="Build">
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
<DirCSharp>$(RootDir)web\documentserver-example\csharp\</DirCSharp>
|
||||
<NameMvc>$(To)DotNet (Csharp MVC) Example</NameMvc>
|
||||
<DirMvc>$(RootDir)web\documentserver-example\csharp-mvc\</DirMvc>
|
||||
<NameMvcReact>$(To)DotNet (Csharp MVC react) Example</NameMvcReact>
|
||||
<DirMvcReact>$(RootDir)web\documentserver-example\csharp-mvc-react\</DirMvcReact>
|
||||
<NameMvcAngular>$(To)DotNet (Csharp MVC Angular) Example</NameMvcAngular>
|
||||
<DirMvcAngular>$(RootDir)web\documentserver-example\csharp-mvc-angular\</DirMvcAngular>
|
||||
<NameJava>$(To)Java Example</NameJava>
|
||||
<DirJava>$(RootDir)web\documentserver-example\java\</DirJava>
|
||||
<NameSpring>$(To)Java Spring Example</NameSpring>
|
||||
@ -28,22 +28,22 @@
|
||||
<RemoveDir Directories="$(To)" ContinueOnError="true" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesCSharp Include="$(DirCSharp)**" Exclude="$(DirCSharp)obj\**;$(DirCSharp)**\.git" />
|
||||
<ZipFilesCSharp Include="$(DirCSharp)**" Exclude="$(DirCSharp).vs\**;$(DirCSharp)bin\*.pdb;$(DirCSharp)bin\*.xml;$(DirCSharp)obj\**;$(DirCSharp)packages\**;$(DirCSharp)**\.git" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(ZipFilesCSharp)" DestinationFiles="@(ZipFilesCSharp->'$(NameCSharp)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameCSharp)" WorkingDirectory="$(To)" ZipFileName="$(NameCSharp).zip" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesMVC Include="$(DirMvc)**" Exclude="$(DirMvc)obj\**;$(DirMvc)**\.git" />
|
||||
<ZipFilesMVC Include="$(DirMvc)**" Exclude="$(DirMvc).vs\**;$(DirMvc)bin\*.pdb;$(DirMvc)bin\*.xml;$(DirMvc)obj\**;$(DirMvc)packages\**;$(DirMvc)**\.git" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(ZipFilesMVC)" DestinationFiles="@(ZipFilesMVC->'$(NameMvc)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameMvc)" WorkingDirectory="$(To)" ZipFileName="$(NameMvc).zip" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesMVCreact Include="$(DirMvcReact)**" Exclude="$(DirMvcReact).vs\**;$(DirMvcReact)bin\*.pdb;$(DirMvcReact)bin\*.xml;$(DirMvcReact)obj\**;$(DirMvcReact)packages\**;$(DirMvcReact)**\.git;$(DirMvcReact)Scripts\React\node_modules\**" />
|
||||
<ZipFilesMVCAngular Include="$(DirMvcAngular)**" Exclude="$(DirMvcAngular).vs\**;$(DirMvcAngular)bin\*.pdb;$(DirMvcAngular)bin\*.xml;$(DirMvcAngular)obj\**;$(DirMvcAngular)packages\**;$(DirMvcAngular)**\.git;$(DirMvcAngular)Scripts\Angular\node_modules\**" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(ZipFilesMVCreact)" DestinationFiles="@(ZipFilesMVCreact->'$(NameMvcReact)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameMvcReact)" WorkingDirectory="$(To)" ZipFileName="$(NameMvcReact).zip" />
|
||||
<Copy SourceFiles="@(ZipFilesMVCAngular)" DestinationFiles="@(ZipFilesMVCAngular->'$(NameMvcAngular)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameMvcAngular)" WorkingDirectory="$(To)" ZipFileName="$(NameMvcAngular).zip" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesJava Include="$(DirJava)**" Exclude="$(DirJava)**\.git" />
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
using System.Web.Optimization;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact
|
||||
namespace OnlineEditorsExampleMVCAngular
|
||||
{
|
||||
public class BundleConfig
|
||||
{
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact
|
||||
namespace OnlineEditorsExampleMVCAngular
|
||||
{
|
||||
public class FilterConfig
|
||||
{
|
||||
@ -19,7 +19,7 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact
|
||||
namespace OnlineEditorsExampleMVCAngular
|
||||
{
|
||||
public class RouteConfig
|
||||
{
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
using System.Web.Http;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact
|
||||
namespace OnlineEditorsExampleMVCAngular
|
||||
{
|
||||
public static class WebApiConfig
|
||||
{
|
||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 781 B After Width: | Height: | Size: 781 B |
|
Before Width: | Height: | Size: 547 B After Width: | Height: | Size: 547 B |
|
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 425 B |
|
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 331 B |
|
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 507 B |
|
Before Width: | Height: | Size: 757 B After Width: | Height: | Size: 757 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 593 B After Width: | Height: | Size: 593 B |
|
Before Width: | Height: | Size: 738 B After Width: | Height: | Size: 738 B |
|
Before Width: | Height: | Size: 477 B After Width: | Height: | Size: 477 B |
|
Before Width: | Height: | Size: 691 B After Width: | Height: | Size: 691 B |
|
Before Width: | Height: | Size: 992 B After Width: | Height: | Size: 992 B |
|
Before Width: | Height: | Size: 1004 B After Width: | Height: | Size: 1004 B |
|
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 379 B |
|
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 832 B After Width: | Height: | Size: 832 B |
|
Before Width: | Height: | Size: 631 B After Width: | Height: | Size: 631 B |
|
Before Width: | Height: | Size: 832 B After Width: | Height: | Size: 832 B |
|
Before Width: | Height: | Size: 488 B After Width: | Height: | Size: 488 B |
|
Before Width: | Height: | Size: 673 B After Width: | Height: | Size: 673 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 790 B After Width: | Height: | Size: 790 B |
|
Before Width: | Height: | Size: 506 B After Width: | Height: | Size: 506 B |
|
Before Width: | Height: | Size: 549 B After Width: | Height: | Size: 549 B |
|
Before Width: | Height: | Size: 438 B After Width: | Height: | Size: 438 B |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
@ -19,10 +19,10 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web.Mvc;
|
||||
using OnlineEditorsExampleMVCreact.Helpers;
|
||||
using OnlineEditorsExampleMVCreact.Models;
|
||||
using OnlineEditorsExampleMVCAngular.Helpers;
|
||||
using OnlineEditorsExampleMVCAngular.Models;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact.Controllers
|
||||
namespace OnlineEditorsExampleMVCAngular.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
@ -1 +1 @@
|
||||
<%@ Application Codebehind="Global.asax.cs" Inherits="OnlineEditorsExampleMVCreact.MvcApplication" Language="C#" %>
|
||||
<%@ Application Codebehind="Global.asax.cs" Inherits="OnlineEditorsExampleMVCAngular.MvcApplication" Language="C#" %>
|
||||
@ -22,7 +22,7 @@ using System.Web.Mvc;
|
||||
using System.Web.Optimization;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact
|
||||
namespace OnlineEditorsExampleMVCAngular
|
||||
{
|
||||
public class MvcApplication : HttpApplication
|
||||
{
|
||||
@ -24,10 +24,10 @@ using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Script.Serialization;
|
||||
using OnlineEditorsExampleMVCreact.Models;
|
||||
using OnlineEditorsExampleMVCAngular.Models;
|
||||
using System.Net;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact.Helpers
|
||||
namespace OnlineEditorsExampleMVCAngular.Helpers
|
||||
{
|
||||
public class DocManagerHelper
|
||||
{
|
||||
@ -26,7 +26,7 @@ using System.Web.Configuration;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact.Helpers
|
||||
namespace OnlineEditorsExampleMVCAngular.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Class service api conversion
|
||||
@ -23,7 +23,7 @@ using JWT.Serializers;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Configuration;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact.Helpers
|
||||
namespace OnlineEditorsExampleMVCAngular.Helpers
|
||||
{
|
||||
public static class JwtManager
|
||||
{
|
||||
@ -26,7 +26,7 @@ using System.Linq;
|
||||
using System.Web;
|
||||
using System.Text;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact.Helpers
|
||||
namespace OnlineEditorsExampleMVCAngular.Helpers
|
||||
{
|
||||
public class TrackManager
|
||||
{
|
||||
@ -128,48 +128,37 @@ namespace OnlineEditorsExampleMVCreact.Helpers
|
||||
|
||||
DocManagerHelper.VerifySSL();
|
||||
|
||||
try
|
||||
var storagePath = DocManagerHelper.StoragePath(newFileName, userAddress); // get the file path
|
||||
var histDir = DocManagerHelper.HistoryDir(storagePath); // get the path to the history directory
|
||||
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
|
||||
|
||||
var versionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir)); // get the path to the file version
|
||||
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); // if the path doesn't exist, create it
|
||||
|
||||
// get the path to the previous file version and move it to the storage directory
|
||||
File.Move(DocManagerHelper.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
|
||||
|
||||
DownloadToFile(downloadUri, storagePath); // save file to the storage directory
|
||||
DownloadToFile((string)fileData["changesurl"], Path.Combine(versionDir, "diff.zip")); // save file changes to the diff.zip archive
|
||||
|
||||
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
|
||||
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
|
||||
{
|
||||
var bytesFile = DownloadFile(downloadUri); // download document file
|
||||
var storagePath = DocManagerHelper.StoragePath(newFileName, userAddress); // get the file path
|
||||
var jss = new JavaScriptSerializer();
|
||||
hist = jss.Serialize(fileData["history"]);
|
||||
}
|
||||
|
||||
var histDir = DocManagerHelper.HistoryDir(storagePath); // get the path to the history directory
|
||||
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
|
||||
|
||||
var versionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir)); // get the path to the file version
|
||||
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); // if the path doesn't exist, create it
|
||||
|
||||
// get the path to the previous file version and move it to the storage directory
|
||||
File.Move(DocManagerHelper.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
|
||||
|
||||
SaveFile(bytesFile, storagePath);// save document file
|
||||
|
||||
byte[] bytesChanges = DownloadFile((string)fileData["changesurl"]); // download changes file
|
||||
SaveFile(bytesChanges, Path.Combine(versionDir, "diff.zip")); // save file changes to the diff.zip archive
|
||||
|
||||
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
|
||||
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
hist = jss.Serialize(fileData["history"]);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(hist))
|
||||
{
|
||||
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist); // write the history changes to the changes.json file
|
||||
}
|
||||
|
||||
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file
|
||||
|
||||
string forcesavePath = DocManagerHelper.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
|
||||
if (!forcesavePath.Equals("")) // if the forcesaved file version exists
|
||||
{
|
||||
File.Delete(forcesavePath); // remove it
|
||||
}
|
||||
|
||||
} catch (Exception)
|
||||
if (!string.IsNullOrEmpty(hist))
|
||||
{
|
||||
return 1;
|
||||
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist); // write the history changes to the changes.json file
|
||||
}
|
||||
|
||||
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file
|
||||
|
||||
string forcesavePath = DocManagerHelper.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
|
||||
if (!forcesavePath.Equals("")) // if the forcesaved file version exists
|
||||
{
|
||||
File.Delete(forcesavePath); // remove it
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -213,51 +202,43 @@ namespace OnlineEditorsExampleMVCreact.Helpers
|
||||
}
|
||||
|
||||
DocManagerHelper.VerifySSL();
|
||||
|
||||
string forcesavePath = "";
|
||||
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
|
||||
|
||||
try
|
||||
if (isSubmitForm) // if the form is submitted
|
||||
{
|
||||
var bytesFile = DownloadFile(downloadUri); // download document file
|
||||
|
||||
string forcesavePath = "";
|
||||
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
|
||||
|
||||
if (isSubmitForm) // if the form is submitted
|
||||
if (newFileName)
|
||||
{
|
||||
if (newFileName)
|
||||
{
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + downloadExt, userAddress); // get the correct file name if it already exists
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + downloadExt, userAddress); // get the correct file name if it already exists
|
||||
} else
|
||||
{
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + curExt, userAddress);
|
||||
}
|
||||
forcesavePath = DocManagerHelper.StoragePath(fileName, userAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newFileName)
|
||||
{
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
|
||||
}
|
||||
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false);
|
||||
if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist
|
||||
{
|
||||
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, true);
|
||||
}
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + curExt, userAddress);
|
||||
}
|
||||
|
||||
SaveFile(bytesFile, forcesavePath);// save document file
|
||||
|
||||
if (isSubmitForm)
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
|
||||
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
|
||||
var user = action["userid"].ToString(); // get the user id
|
||||
DocManagerHelper.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file
|
||||
}
|
||||
} catch (Exception)
|
||||
forcesavePath = DocManagerHelper.StoragePath(fileName, userAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
if (newFileName)
|
||||
{
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
|
||||
}
|
||||
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false);
|
||||
if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist
|
||||
{
|
||||
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, true);
|
||||
}
|
||||
}
|
||||
|
||||
DownloadToFile(downloadUri, forcesavePath);
|
||||
|
||||
if (isSubmitForm)
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
|
||||
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
|
||||
var user = action["userid"].ToString(); // get the user id
|
||||
DocManagerHelper.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -329,30 +310,27 @@ namespace OnlineEditorsExampleMVCreact.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
// save file
|
||||
private static void SaveFile(byte[] data, string path)
|
||||
{
|
||||
using (var fs = File.Open(path, FileMode.Create))
|
||||
{
|
||||
fs.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// save file information from the url to the file specified
|
||||
private static byte[] DownloadFile(string url)
|
||||
private static void DownloadToFile(string url, string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) throw new ArgumentException("url"); // url isn't specified
|
||||
if (string.IsNullOrEmpty(path)) throw new ArgumentException("path"); // file isn't specified
|
||||
|
||||
var req = (HttpWebRequest)WebRequest.Create(url);
|
||||
req.Timeout = 5000;
|
||||
using (var stream = req.GetResponse().GetResponseStream()) // get input stream of the file information from the url
|
||||
{
|
||||
if (stream == null) throw new Exception("stream is null");
|
||||
const int bufferSize = 4096;
|
||||
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
using (var fs = File.Open(path, FileMode.Create))
|
||||
{
|
||||
stream.CopyTo(memoryStream);
|
||||
return memoryStream.ToArray();
|
||||
var buffer = new byte[bufferSize];
|
||||
int readed;
|
||||
while ((readed = stream.Read(buffer, 0, bufferSize)) != 0)
|
||||
{
|
||||
fs.Write(buffer, 0, readed); // write bytes to the output stream
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact.Helpers
|
||||
namespace OnlineEditorsExampleMVCAngular.Helpers
|
||||
{
|
||||
public class Users
|
||||
{
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
using System.Web;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact.Helpers
|
||||
namespace OnlineEditorsExampleMVCAngular.Helpers
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
@ -24,9 +24,9 @@ using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Script.Serialization;
|
||||
using OnlineEditorsExampleMVCreact.Helpers;
|
||||
using OnlineEditorsExampleMVCAngular.Helpers;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact.Models
|
||||
namespace OnlineEditorsExampleMVCAngular.Models
|
||||
{
|
||||
// create file model
|
||||
public class FileModel
|
||||
@ -19,7 +19,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact.Models
|
||||
namespace OnlineEditorsExampleMVCAngular.Models
|
||||
{
|
||||
public static class FileUtility
|
||||
{
|
||||
@ -11,8 +11,8 @@
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OnlineEditorsExampleMVCreact</RootNamespace>
|
||||
<AssemblyName>OnlineEditorsExampleMVCreact</AssemblyName>
|
||||
<RootNamespace>OnlineEditorsExampleMVCAngular</RootNamespace>
|
||||
<AssemblyName>OnlineEditorsExampleMVCAngular</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<MvcBuildViews>false</MvcBuildViews>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
@ -159,6 +159,7 @@
|
||||
<Content Include="favicon.ico" />
|
||||
<Content Include="Global.asax" />
|
||||
<Content Include="LICENSE" />
|
||||
<Content Include="Scripts\Angular\webpack.config.js" />
|
||||
<Content Include="Scripts\jquery-1.8.2.js" />
|
||||
<Content Include="Scripts\jquery-ui.js" />
|
||||
<Content Include="Scripts\jquery.blockUI.js" />
|
||||
@ -166,9 +167,6 @@
|
||||
<Content Include="Scripts\jquery.fileupload.js" />
|
||||
<Content Include="Scripts\jquery.iframe-transport.js" />
|
||||
<Content Include="Scripts\jscript.js" />
|
||||
<Content Include="Scripts\React\src\app.js" />
|
||||
<Content Include="Scripts\React\src\main.js" />
|
||||
<Content Include="Scripts\React\webpack.config.js" />
|
||||
<Content Include="Views\Home\Editor.aspx" />
|
||||
<Content Include="Views\Home\Index.aspx" />
|
||||
<Content Include="Web.config">
|
||||
@ -197,7 +195,18 @@
|
||||
<Content Include="assets\sample\sample.pptx" />
|
||||
<Content Include="assets\sample\sample.xlsx" />
|
||||
<None Include="packages.config" />
|
||||
<Content Include="Scripts\React\package.json" />
|
||||
<Content Include="Scripts\Angular\package.json" />
|
||||
<Content Include="Scripts\Angular\tsconfig.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="Scripts\Angular\src\app\app.component.ts" />
|
||||
<TypeScriptCompile Include="Scripts\Angular\src\app\app.module.ts" />
|
||||
<TypeScriptCompile Include="Scripts\Angular\src\main.ts" />
|
||||
<TypeScriptCompile Include="Scripts\Angular\src\polyfills.ts" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{4A0DDDB5-7A95-4FBF-97CC-616D07737A77}" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">16.0</VisualStudioVersion>
|
||||
@ -227,6 +236,6 @@
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>call "$(ProjectDir)Scripts\React\build.bat"</PreBuildEvent>
|
||||
<PreBuildEvent>call "$(ProjectDir)Scripts\Angular\build.bat"</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@ -1,9 +1,9 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.4.33213.308
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30523.141
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnlineEditorsExampleMVCreact", "OnlineEditorsExampleMVCreact.csproj", "{D2C16047-E658-444A-A45D-23CEE79CB8F3}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnlineEditorsExampleMVCAngular", "OnlineEditorsExampleMVCAngular.csproj", "{D2C16047-E658-444A-A45D-23CEE79CB8F3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -2,11 +2,11 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
[assembly: AssemblyTitle("OnlineEditorsExampleMVCreact")]
|
||||
[assembly: AssemblyTitle("OnlineEditorsExampleMVCAngular")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Ascensio System SIA")]
|
||||
[assembly: AssemblyProduct("OnlineEditorsExampleMVCreact")]
|
||||
[assembly: AssemblyProduct("OnlineEditorsExampleMVCAngular")]
|
||||
[assembly: AssemblyCopyright("Ascensio System SIA 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
@ -0,0 +1,3 @@
|
||||
cd ../Scripts/Angular
|
||||
call npm install
|
||||
npm run build
|
||||
2691
web/documentserver-example/csharp-mvc-angular/Scripts/Angular/package-lock.json
generated
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "csharp-mvc-angular",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"build": "webpack"
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/common": "~14.2.0",
|
||||
"@angular/compiler": "~14.2.0",
|
||||
"@angular/core": "~14.2.0",
|
||||
"@angular/forms": "~14.2.0",
|
||||
"@angular/platform-browser": "~14.2.0",
|
||||
"@angular/platform-browser-dynamic": "~14.2.0",
|
||||
"@angular/router": "~14.2.0",
|
||||
"core-js": "^3.1.3",
|
||||
"rxjs": "^7.4.0",
|
||||
"zone.js": "0.12.0",
|
||||
"@onlyoffice/document-editor-angular": "1.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.7.23",
|
||||
"typescript": "~4.7.2",
|
||||
"webpack-cli": "^5.0.1",
|
||||
"angular2-template-loader": "^0.6.2",
|
||||
"ts-loader": "^9.0.1"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { IConfig } from '@onlyoffice/document-editor-angular';
|
||||
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
template: `<document-editor
|
||||
id="docEditor"
|
||||
[documentServerUrl]="documentServerUrl"
|
||||
[config]="config"
|
||||
></document-editor>`
|
||||
})
|
||||
export class AppComponent {
|
||||
documentServerUrl:string = null;
|
||||
config:any = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.documentServerUrl = this.getDocServerUrl();
|
||||
this.config = this.getConfig();
|
||||
}
|
||||
|
||||
getDocServerUrl = () => {
|
||||
return document.getElementById("root").getAttribute("data-docserverurl");
|
||||
};
|
||||
|
||||
getConfig = () => {
|
||||
return JSON.parse(document.getElementById("root").getAttribute("data-config"));
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { AppComponent } from './app.component';
|
||||
import { DocumentEditorModule } from '@onlyoffice/document-editor-angular';
|
||||
|
||||
@NgModule({
|
||||
imports: [BrowserModule, FormsModule, DocumentEditorModule],
|
||||
declarations: [AppComponent],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
||||
export class AppModule { }
|
||||
@ -0,0 +1,4 @@
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { AppModule } from './app/app.module';
|
||||
const platform = platformBrowserDynamic();
|
||||
platform.bootstrapModule(AppModule);
|
||||
@ -0,0 +1,2 @@
|
||||
import 'core-js';
|
||||
import 'zone.js/dist/zone';
|
||||
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "es2015",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"lib": [ "es2015", "dom" ],
|
||||
"noImplicitAny": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types/"
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
module.exports = {
|
||||
entry: {
|
||||
'polyfills': './src/polyfills.ts',
|
||||
'app': './src/main.ts'
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, './public'),
|
||||
publicPath: '/public/',
|
||||
filename: "[name].js"
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js']
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
options: { configFile: path.resolve(__dirname, 'tsconfig.json') }
|
||||
},
|
||||
'angular2-template-loader'
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.ContextReplacementPlugin(
|
||||
/angular(\|\/)core/,
|
||||
path.resolve(__dirname, 'src'),
|
||||
{}
|
||||
)
|
||||
]
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
<%@ Page Title="ONLYOFFICE" Language="C#" Inherits="System.Web.Mvc.ViewPage<OnlineEditorsExampleMVCreact.Models.FileModel>" %>
|
||||
<%@ Page Title="ONLYOFFICE" Language="C#" Inherits="System.Web.Mvc.ViewPage<OnlineEditorsExampleMVCAngular.Models.FileModel>" %>
|
||||
<%@ Import Namespace="System.IO" %>
|
||||
<%@ Import Namespace="System.Web.Configuration" %>
|
||||
<%@ Import Namespace="OnlineEditorsExampleMVCreact.Helpers" %>
|
||||
<%@ Import Namespace="OnlineEditorsExampleMVCAngular.Helpers" %>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
@ -36,7 +36,9 @@
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="root" data-docServerUrl="<%= WebConfigurationManager.AppSettings["files.docservice.url.site"] %>" data-config='<%= Model.GetDocConfig(Request, Url) %>'></div>
|
||||
<script src='<%= @Url.Content("~/Scripts/React/dist/bundle.js")%>'></script>
|
||||
<my-app id="root" data-docserverurl="<%= WebConfigurationManager.AppSettings["files.docservice.url.site"] %>" data-config='<%= Model.GetDocConfig(Request, Url) %>'></my-app>
|
||||
<script src='<%= @Url.Content("~/Scripts/Angular/public/polyfills.js")%>'></script>
|
||||
<script src='<%= @Url.Content("~/Scripts/Angular/public/app.js")%>'></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
<%@ Import Namespace="System.IO" %>
|
||||
<%@ Import Namespace="System.Web.Configuration" %>
|
||||
<%@ Import Namespace="OnlineEditorsExampleMVCreact.Helpers" %>
|
||||
<%@ Import Namespace="OnlineEditorsExampleMVCreact.Models" %>
|
||||
<%@ Import Namespace="OnlineEditorsExampleMVCAngular.Helpers" %>
|
||||
<%@ Import Namespace="OnlineEditorsExampleMVCAngular.Models" %>
|
||||
<%@ Import Namespace="System.Collections.Generic" %>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
@ -1 +1 @@
|
||||
<%@ WebHandler Language="C#" CodeBehind="WebEditor.ashx.cs" Class="OnlineEditorsExampleMVCreact.WebEditor" %>
|
||||
<%@ WebHandler Language="C#" CodeBehind="WebEditor.ashx.cs" Class="OnlineEditorsExampleMVCAngular.WebEditor" %>
|
||||
@ -26,11 +26,11 @@ using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Web.Services;
|
||||
using System.Web.Configuration;
|
||||
using OnlineEditorsExampleMVCreact.Helpers;
|
||||
using OnlineEditorsExampleMVCreact.Models;
|
||||
using OnlineEditorsExampleMVCAngular.Helpers;
|
||||
using OnlineEditorsExampleMVCAngular.Models;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace OnlineEditorsExampleMVCreact
|
||||
namespace OnlineEditorsExampleMVCAngular
|
||||
{
|
||||
[WebService(Namespace = "http://tempuri.org/")]
|
||||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 144 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 153 KiB After Width: | Height: | Size: 153 KiB |