AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Разработка
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 30.07.2008, 11:51   #1  
AlekseyS is offline
AlekseyS
Участник
 
77 / 13 (1) ++
Регистрация: 30.07.2008
Адрес: Киев
Проблема запуска MS WORD
Добрый день!
Подскажите столкнулся с такой проблемой:
Делаю plug-ins который по событию создания нового account будет создавать документ MS Word)
Code:
using System;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;
using Microsoft.Office.Interop.Word;
using Microsoft;


namespace Microsoft.Crm.Sdk.Walkthrough
{
public class AccountCreateHandler: IPlugin
{
public void Execute(IPluginExecutionContext context)
{
DynamicEntity entity = null;

#region Verify execution context

// Check if the input parameters property bag contains a target
// of the create operation and that target is of type DynamicEntity.
if (context.InputParameters.Properties.Contains("Target") &&
context.InputParameters.Properties["Target"] is DynamicEntity)
{
// Obtain the target business entity from the input parmameters.
entity = (DynamicEntity)context.InputParameters.Properties["Target"];

// Verify that the entity represents an account.
if (entity.Name != EntityName.account.ToString()) { return; }
}
else
{
return;
}

#endregion Verify execution context

try
{
//System.Console.WriteLine("Opening a new Word document...");
MSWord.openDocument();
//System.Console.WriteLine("Writing stuff to the document.");
MSWord.writeStuff("This is a test.");
//System.Console.WriteLine("Saving the document and exiting.");
MSWord.closeDocument(@"c:\done_test.doc");

}
catch (System.Web.Services.Protocols.SoapException ex)
{
throw new Exception(ex.Detail.ToString(), ex);
}
}
}

class MSWord
{
public static ApplicationClass word = new ApplicationClass();
public static Document doc = null;

public static void openDocument()
{
word.Visible = true;

object file = @"C:\template.dot"; // blank path = new document
object newTemplate = false;
object docType = 0;
object isVisible = false;
// add a new document based off of the normal.dot template
doc = word.Documents.Add(ref file, ref newTemplate, ref docType, ref isVisible);
doc.Activate();
}

public static void writeStuff(string what)
{
System.Console.WriteLine("Total bookmoarks: " + doc.Bookmarks.Count);

foreach (Bookmark bk in doc.Bookmarks)
{
if (bk.Name == "testbook")
{
bk.Range.Text = "This is a content of bookmark";
}
}
doc.Tables[1].Rows[1].Cells[1].Range.Text = "Hello word";
//doc.Tables[0].Cell(0, 0).Range.Text = "hello from C#";
word.Selection.TypeText(what);
}

public static void closeDocument(string path)
{
object filePath = (object)path;
object False = false;
object True = true;
object blank = "";
object format = WdOpenFormat.wdOpenFormatAuto;
//object encoder = Office.MsoEncoding.msoEncodingUSASCII;
object unicode = 65001;
object missing = System.Reflection.Missing.Value;
doc.SaveAs(ref filePath, ref format, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

word.Quit(ref missing,
ref missing,
ref missing);
}

}

}

После выполнения лог:
# CRM Tracing Version 2.0
# LocalTime: 2008-07-30 00:20:40.4
# Categories:
# CallStackOn: No
# ComputerName: MOSS
# CRMVersion: 4.0.7333.3
# DeploymentType: OnPremise
# ScaleGroup:
# ServerRole: AppServer, AsyncService, DiscoveryService, WebService, ApiServer, HelpServer, DeploymentService

[2008-07-30 00:20:40.4] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 8(MSCRM:-NotificationManager.NotificationWatcherThreadProc) |Category: Exception |User: 00000000-0000-0000-0000-000000000000 |Level: Error | NotificationManager.NotificationWatcherThreadProc
at NotificationManager.NotificationWatcherThreadProc()
at ThreadHelper.ThreadStart_Context(Object state)
at ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at ThreadHelper.ThreadStart()
>ThreadAbort Exception in NotificationWatcherThreadProc Thread was being aborted.
[2008-07-30 00:20:40.4] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 8(MSCRM:-NotificationManager.NotificationWatcherThreadProc) |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Error | NotificationManager.NotificationWatcherThreadProc
>NotificationWatcherThreadProc Stopped.



Подскажите, в чем может быть проблема. Кучу всего уже пробовал пока 0 решения.

Последний раз редактировалось AlekseyS; 31.07.2008 в 13:05.
Теги
word

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Проблема активации MS Dynamics CRM Likefire Dynamics CRM: Администрирование 27 10.12.2009 14:33
Проблема с MS CRM Asynchronous Processing Service Camena Dynamics CRM: Администрирование 15 03.04.2009 14:51
Проблема при создании мероприятия ShurikEv Dynamics CRM: Функционал 2 03.11.2008 18:26
Microsoft Dynamics CRM Team Blog: MS Word Proposal for CRM Online Blog bot Dynamics CRM: Blogs 0 12.08.2008 04:07
Проблема при установке MS CRM 3.0 Ошибка в версии SQL alexs_ua Dynamics CRM: Администрирование 3 30.01.2006 18:18

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 05:20.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.