public ActionResult Load() { HttpRequest request = HttpContext.Current.Request; ActionResult result; try { string value = request.Form["Params"]; dynamic param = JsonConvert.DeserializeObject(value); string appDomainID = param.ID; AddInService addInService = new AddInService(); addInService.InitPath(); List <Common.AddIn> addIn = addInService.GetAddIn(); List <Common.AddIn> list = new List <Common.AddIn>(); foreach (Common.AddIn current in addIn) { if (current.ID == Convert.ToInt32(appDomainID)) { list.Add(current); } } addInService.LoadAddIn(list); SqlHelper sqlHelper = new SqlHelper(); sqlHelper.ExecuteNonQuery("update T_AddIn set F_Status = 1 where F_ID=" + appDomainID); result = this.Json(new { errcode = 0, errmsg = "OK", msgdoc = string.Concat(new object[] { "http://", request.Url.Host, ":", request.Url.Port, "/AddInsDomain/help/doc" }) }, JsonRequestBehavior.DenyGet); } catch (Exception ex) { Log.log(ex.ToString()); result = this.Json(new { errcode = -1, errmsg = ex.Message, msgdoc = string.Concat(new object[] { "http://", request.Url.Host, ":", request.Url.Port, "/AddInsDomain/help/doc" }) }, JsonRequestBehavior.DenyGet); } return(result); }
protected void Application_Start(object sender, EventArgs e) { AddInService addInService = new AddInService(); addInService.InitPath(); List <AddInWebApp.Common.AddIn> addIn = addInService.GetAddIn(); addInService.LoadAddIn(addIn); Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("addindomain", "AddInsDomain"); dictionary.Add("controller", "AddInsService"); dictionary.Add("action", "AddInDomains"); dictionary.Add("id", null); dictionary.Add("namespaces", "AddInWebApp.Controllers"); dictionary.Add("assembly", "AddInWebApp"); RouteTable.Routes.Add("defaultRoute", new Route("{addindomain}/{controller}/{action}/{id}", dictionary, new AddInRouteHandler())); }
/// <summary> /// Refreshes the document command bar button_ click. /// </summary> /// <param name="cmdBarbutton">The CMD barbutton.</param> /// <param name="cancel">if set to <c>true</c> [cancel].</param> private void RefreshDocumentCommandBarButton_Click(CommandBarButton cmdBarbutton, ref bool cancel) { app.ScreenUpdating = false; Microsoft.Office.Interop.Word.Document doc = app.ActiveDocument; // Get the active documents as stream of bytes byte[] input = doc.GetPackageStream(); // Generate document on the Server. AddInService can be a proxy to service, however here it's direct call byte[] output = AddInService.GenerateDocument(input); if (output != null) { using (MemoryStream ms = new MemoryStream()) { ms.Write(output, 0, output.Length); using (WordprocessingDocument wordDocument = WordprocessingDocument.Open(ms, true)) { XDocument xDoc = OPCHelper.OpcToFlatOpc(wordDocument.Package); string openxml = xDoc.ToString(); doc.Range().InsertXML(openxml); // Add CustomXmlPart CustomXmlPartCore customXmlPartCore = new CustomXmlPartCore(DocumentGenerationInfo.NamespaceUri); CustomXmlPart customPart = customXmlPartCore.GetCustomXmlPart(wordDocument.MainDocumentPart); if (customPart != null) { XDocument customPartDoc = null; using (XmlReader reader = XmlReader.Create(customPart.GetStream(FileMode.Open, FileAccess.Read))) { customPartDoc = XDocument.Load(reader); } doc.StoreCustomXmlPart(customPartDoc); } } } } app.ScreenUpdating = true; }
public ActionResult ReloadAll() { HttpRequest request = HttpContext.Current.Request; ActionResult result; try { AddInService addInService = new AddInService(); addInService.InitPath(); List <Common.AddIn> addIn = addInService.GetAddIn(); addInService.LoadAddIn(addIn); result = this.Json(new { errcode = 0, errmsg = "OK", msgdoc = string.Concat(new object[] { "http://", request.Url.Host, ":", request.Url.Port, "/AddInsDomain/help/doc" }) }, JsonRequestBehavior.DenyGet); } catch (Exception ex) { Log.log(ex.ToString()); result = this.Json(new { errcode = -1, errmsg = ex.Message, msgdoc = string.Concat(new object[] { "http://", request.Url.Host, ":", request.Url.Port, "/AddInsDomain/help/doc" }) }, JsonRequestBehavior.DenyGet); } return(result); }