profile letter
This commit is contained in:
parent
7b8473faef
commit
dc29f2f17c
|
@ -28,6 +28,18 @@
|
||||||
<Compile Remove="Process\NotificationProcess.cs" />
|
<Compile Remove="Process\NotificationProcess.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<COMReference Include="Microsoft.Office.Interop.Word">
|
||||||
|
<WrapperTool>tlbimp</WrapperTool>
|
||||||
|
<VersionMinor>7</VersionMinor>
|
||||||
|
<VersionMajor>8</VersionMajor>
|
||||||
|
<Guid>00020905-0000-0000-c000-000000000046</Guid>
|
||||||
|
<Lcid>0</Lcid>
|
||||||
|
<Isolated>false</Isolated>
|
||||||
|
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||||
|
</COMReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Ease.Core\Ease.Core.csproj" />
|
<ProjectReference Include="..\Ease.Core\Ease.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -1,230 +1,230 @@
|
||||||
//using System;
|
using System;
|
||||||
//using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
//using System.Text;
|
using System.Text;
|
||||||
//using System.Collections;
|
using System.Collections;
|
||||||
//using System.Data;
|
using System.Data;
|
||||||
//using System.IO;
|
using System.IO;
|
||||||
////using Microsoft.Office.Interop;
|
//using Microsoft.Office.Interop;
|
||||||
//using Microsoft.Office.Interop.Word;
|
using Microsoft.Office.Interop.Word;
|
||||||
//using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
//namespace HRM.BO
|
namespace HRM.BO
|
||||||
//{
|
{
|
||||||
// public class MSWord
|
public class MSWord
|
||||||
// {
|
{
|
||||||
// private Hashtable _Pair;
|
private Hashtable _Pair;
|
||||||
// private string _OriginalFile;
|
private string _OriginalFile;
|
||||||
// private string _PreparedFile;
|
private string _PreparedFile;
|
||||||
// private Application _wordapp;
|
private Application _wordapp;
|
||||||
// public MSWord()
|
public MSWord()
|
||||||
// {
|
{
|
||||||
// //_wordapp = null;
|
//_wordapp = null;
|
||||||
// }
|
}
|
||||||
// public Hashtable Pair
|
public Hashtable Pair
|
||||||
// {
|
{
|
||||||
// get
|
get
|
||||||
// {
|
{
|
||||||
// return _Pair;
|
return _Pair;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public string OriginalFile
|
public string OriginalFile
|
||||||
// {
|
{
|
||||||
// get
|
get
|
||||||
// {
|
{
|
||||||
// return _OriginalFile;
|
return _OriginalFile;
|
||||||
// }
|
}
|
||||||
// set
|
set
|
||||||
// {
|
{
|
||||||
// _OriginalFile = value;
|
_OriginalFile = value;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public string PreparedFile
|
public string PreparedFile
|
||||||
// {
|
{
|
||||||
// get
|
get
|
||||||
// {
|
{
|
||||||
// return _PreparedFile;
|
return _PreparedFile;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public void DeleteFile()
|
public void DeleteFile()
|
||||||
// {
|
{
|
||||||
// try
|
try
|
||||||
// {
|
{
|
||||||
// File.Delete(_PreparedFile);
|
File.Delete(_PreparedFile);
|
||||||
// }
|
}
|
||||||
// catch
|
catch
|
||||||
// {
|
{
|
||||||
|
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// private void CreateCopy()
|
private void CreateCopy()
|
||||||
// {
|
{
|
||||||
// string sRoot = Path.GetDirectoryName(_OriginalFile);
|
string sRoot = Path.GetDirectoryName(_OriginalFile);
|
||||||
// string sFileName = Path.GetFileNameWithoutExtension(_OriginalFile);
|
string sFileName = Path.GetFileNameWithoutExtension(_OriginalFile);
|
||||||
// string sExtention = Path.GetExtension(_OriginalFile);
|
string sExtention = Path.GetExtension(_OriginalFile);
|
||||||
|
|
||||||
// string sNewFileName = sRoot + "\\" + sFileName + DateTime.Now.ToString("hhmmss") + " " + new Random().Next().ToString()
|
string sNewFileName = sRoot + "\\" + sFileName + DateTime.Now.ToString("hhmmss") + " " + new Random().Next().ToString()
|
||||||
// + sExtention;
|
+ sExtention;
|
||||||
|
|
||||||
// _PreparedFile = sNewFileName;
|
_PreparedFile = sNewFileName;
|
||||||
|
|
||||||
// if (File.Exists(OriginalFile) == true)
|
if (File.Exists(OriginalFile) == true)
|
||||||
// {
|
{
|
||||||
// File.Copy(OriginalFile, PreparedFile);
|
File.Copy(OriginalFile, PreparedFile);
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
// throw new Exception("File Not Found : " + "File Path : " + _OriginalFile);
|
throw new Exception("File Not Found : " + "File Path : " + _OriginalFile);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// private void CreateCopy(string destFileName)
|
private void CreateCopy(string destFileName)
|
||||||
// {
|
{
|
||||||
// _PreparedFile = destFileName;
|
_PreparedFile = destFileName;
|
||||||
|
|
||||||
// if (File.Exists(OriginalFile) == true)
|
if (File.Exists(OriginalFile) == true)
|
||||||
// {
|
{
|
||||||
// File.Copy(OriginalFile, PreparedFile, true);
|
File.Copy(OriginalFile, PreparedFile, true);
|
||||||
// FileInfo fi = new FileInfo(PreparedFile);
|
FileInfo fi = new FileInfo(PreparedFile);
|
||||||
// if (fi.IsReadOnly)
|
if (fi.IsReadOnly)
|
||||||
// fi.IsReadOnly = false;
|
fi.IsReadOnly = false;
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
// throw new Exception("File Not Found : " + "File Path : " + _OriginalFile);
|
throw new Exception("File Not Found : " + "File Path : " + _OriginalFile);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public void OpenWordApplication()
|
public void OpenWordApplication()
|
||||||
// {
|
{
|
||||||
// _wordapp = new Microsoft.Office.Interop.Word.Application();
|
_wordapp = new Microsoft.Office.Interop.Word.Application();
|
||||||
// }
|
}
|
||||||
// public void CloseWordApplication()
|
public void CloseWordApplication()
|
||||||
// {
|
{
|
||||||
// object SaveChanges = true;
|
object SaveChanges = true;
|
||||||
// object Missing = System.Reflection.Missing.Value;
|
object Missing = System.Reflection.Missing.Value;
|
||||||
|
|
||||||
// if (_wordapp != null)
|
if (_wordapp != null)
|
||||||
// _wordapp.Quit(ref SaveChanges, ref Missing, ref Missing);
|
_wordapp.Quit(ref SaveChanges, ref Missing, ref Missing);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public void PrintWordDoc(object[] argValues, String[] argNames)
|
public void PrintWordDoc(object[] argValues, String[] argNames)
|
||||||
// {
|
{
|
||||||
// object Missing = System.Reflection.Missing.Value;
|
object Missing = System.Reflection.Missing.Value;
|
||||||
|
|
||||||
// object wb = _wordapp.WordBasic;
|
object wb = _wordapp.WordBasic;
|
||||||
|
|
||||||
// //first arg is a printer name
|
//first arg is a printer name
|
||||||
// wb.GetType().InvokeMember("FilePrintSetup", BindingFlags.InvokeMethod, null,
|
wb.GetType().InvokeMember("FilePrintSetup", BindingFlags.InvokeMethod, null,
|
||||||
// wb, argValues, null, null, argNames);
|
wb, argValues, null, null, argNames);
|
||||||
|
|
||||||
|
|
||||||
// object myTrue = true; // Print in background
|
object myTrue = true; // Print in background
|
||||||
// object myFalse = false;
|
object myFalse = false;
|
||||||
|
|
||||||
// _wordapp.PrintOutOld(ref myTrue,
|
_wordapp.PrintOutOld(ref myTrue,
|
||||||
// ref myFalse, ref Missing, ref Missing, ref Missing,
|
ref myFalse, ref Missing, ref Missing, ref Missing,
|
||||||
// ref Missing, ref Missing,
|
ref Missing, ref Missing,
|
||||||
// ref Missing, ref Missing, ref Missing, ref myFalse,
|
ref Missing, ref Missing, ref Missing, ref myFalse,
|
||||||
// ref Missing, ref Missing, ref Missing, ref Missing);
|
ref Missing, ref Missing, ref Missing, ref Missing);
|
||||||
|
|
||||||
// while (_wordapp.BackgroundPrintingStatus > 0)
|
while (_wordapp.BackgroundPrintingStatus > 0)
|
||||||
// {
|
{
|
||||||
// System.Threading.Thread.Sleep(250);
|
System.Threading.Thread.Sleep(250);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// }
|
}
|
||||||
// public void ReplaceWords(string destFileName, Hashtable tagValueHashTable)
|
public void ReplaceWords(string destFileName, Hashtable tagValueHashTable)
|
||||||
// {
|
{
|
||||||
// object SaveChanges = true;
|
object SaveChanges = true;
|
||||||
// // if (_wordapp == null) OpenWordApplication();
|
// if (_wordapp == null) OpenWordApplication();
|
||||||
|
|
||||||
// object Missing = System.Reflection.Missing.Value;
|
object Missing = System.Reflection.Missing.Value;
|
||||||
|
|
||||||
// CreateCopy(destFileName);
|
CreateCopy(destFileName);
|
||||||
// Microsoft.Office.Interop.Word.Document oDoc = null;
|
Microsoft.Office.Interop.Word.Document oDoc = null;
|
||||||
// try
|
try
|
||||||
// {
|
{
|
||||||
// object FileName = _PreparedFile;
|
object FileName = _PreparedFile;
|
||||||
// object ReadOnly = false;
|
object ReadOnly = false;
|
||||||
// object TrueBool = true;
|
object TrueBool = true;
|
||||||
// object FalseBool = false;
|
object FalseBool = false;
|
||||||
// object IsVisible = true;
|
object IsVisible = true;
|
||||||
// object FindText = "";
|
object FindText = "";
|
||||||
// object ReplaceText = "";
|
object ReplaceText = "";
|
||||||
|
|
||||||
|
|
||||||
// oDoc = _wordapp.Documents.Open(ref FileName, ref Missing, ref ReadOnly, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref IsVisible, ref Missing, ref Missing, ref Missing, ref Missing);
|
oDoc = _wordapp.Documents.Open(ref FileName, ref Missing, ref ReadOnly, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref IsVisible, ref Missing, ref Missing, ref Missing, ref Missing);
|
||||||
// oDoc.Activate();
|
oDoc.Activate();
|
||||||
|
|
||||||
// object FindContinue = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
|
object FindContinue = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
|
||||||
// object ReplaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
|
object ReplaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
|
||||||
// object MatchCase = true;
|
object MatchCase = true;
|
||||||
// _Pair = (tagValueHashTable != null) ? tagValueHashTable : new Hashtable();
|
_Pair = (tagValueHashTable != null) ? tagValueHashTable : new Hashtable();
|
||||||
// foreach (string sKey in _Pair.Keys)
|
foreach (string sKey in _Pair.Keys)
|
||||||
// {
|
{
|
||||||
// FindText = sKey;
|
FindText = sKey;
|
||||||
// ReplaceText = tagValueHashTable[sKey];
|
ReplaceText = tagValueHashTable[sKey];
|
||||||
// _wordapp.Selection.Find.Execute(ref FindText, ref MatchCase, ref TrueBool, ref Missing, ref Missing, ref Missing, ref TrueBool, ref FindContinue, ref Missing,
|
_wordapp.Selection.Find.Execute(ref FindText, ref MatchCase, ref TrueBool, ref Missing, ref Missing, ref Missing, ref TrueBool, ref FindContinue, ref Missing,
|
||||||
// ref ReplaceText, ref ReplaceAll, ref Missing, ref Missing, ref Missing, ref Missing);
|
ref ReplaceText, ref ReplaceAll, ref Missing, ref Missing, ref Missing, ref Missing);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// }
|
}
|
||||||
// catch (Exception ex)
|
catch (Exception ex)
|
||||||
// {
|
{
|
||||||
// throw new Exception("Error: Could not read file from disk. Original error: " + ex.Message);
|
throw new Exception("Error: Could not read file from disk. Original error: " + ex.Message);
|
||||||
// }
|
}
|
||||||
// finally
|
finally
|
||||||
// {
|
{
|
||||||
// if (oDoc != null) _wordapp.Documents.Close(ref SaveChanges, ref Missing, ref Missing);
|
if (oDoc != null) _wordapp.Documents.Close(ref SaveChanges, ref Missing, ref Missing);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public void printDoc()
|
public void printDoc()
|
||||||
// {
|
{
|
||||||
// Microsoft.Office.Interop.Word.Application ac = new Microsoft.Office.Interop.Word.Application();
|
Microsoft.Office.Interop.Word.Application ac = new Microsoft.Office.Interop.Word.Application();
|
||||||
// Microsoft.Office.Interop.Word.Application app = ac.Application;
|
Microsoft.Office.Interop.Word.Application app = ac.Application;
|
||||||
|
|
||||||
// // I'm setting all of the alerts to be off as I am trying to get
|
// I'm setting all of the alerts to be off as I am trying to get
|
||||||
// // this to print in the background
|
// this to print in the background
|
||||||
// app.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
|
app.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
|
||||||
|
|
||||||
// // Open the document to print...
|
// Open the document to print...
|
||||||
// object filename = "myFile.rtf";
|
object filename = "myFile.rtf";
|
||||||
// object missingValue = Type.Missing;
|
object missingValue = Type.Missing;
|
||||||
|
|
||||||
// // Using OpenOld so as to be compatible with other versions of Word
|
// Using OpenOld so as to be compatible with other versions of Word
|
||||||
// Microsoft.Office.Interop.Word.Document document = app.Documents.OpenOld(ref filename,
|
Microsoft.Office.Interop.Word.Document document = app.Documents.OpenOld(ref filename,
|
||||||
// ref missingValue, ref missingValue,
|
ref missingValue, ref missingValue,
|
||||||
// ref missingValue, ref missingValue, ref missingValue,
|
ref missingValue, ref missingValue, ref missingValue,
|
||||||
// ref missingValue, ref missingValue, ref missingValue, ref missingValue);
|
ref missingValue, ref missingValue, ref missingValue, ref missingValue);
|
||||||
|
|
||||||
// // Set the active printer
|
// Set the active printer
|
||||||
// app.ActivePrinter = "My Printer Name";
|
app.ActivePrinter = "My Printer Name";
|
||||||
|
|
||||||
// object myTrue = true; // Print in background
|
object myTrue = true; // Print in background
|
||||||
// object myFalse = false;
|
object myFalse = false;
|
||||||
|
|
||||||
// //// Using PrintOutOld to be version independent
|
//// Using PrintOutOld to be version independent
|
||||||
// //m_App.ActiveDocument.PrintOutOld(ref myTrue,
|
//m_App.ActiveDocument.PrintOutOld(ref myTrue,
|
||||||
// //ref myFalse, ref missingValue, ref missingValue, ref missingValue,
|
//ref myFalse, ref missingValue, ref missingValue, ref missingValue,
|
||||||
// // missingValue, ref missingValue,
|
// missingValue, ref missingValue,
|
||||||
// //ref missingValue, ref missingValue, ref missingValue, ref myFalse,
|
//ref missingValue, ref missingValue, ref missingValue, ref myFalse,
|
||||||
// // ref missingValue, ref missingValue, ref m_MissingValue);
|
// ref missingValue, ref missingValue, ref m_MissingValue);
|
||||||
|
|
||||||
// //document.Close(ref missingValue, ref missingValue, ref missingValue);
|
//document.Close(ref missingValue, ref missingValue, ref missingValue);
|
||||||
|
|
||||||
// //// Make sure all of the documents are gone from the queue
|
//// Make sure all of the documents are gone from the queue
|
||||||
// //while(m_App.BackgroundPrintingStatus > 0)
|
//while(m_App.BackgroundPrintingStatus > 0)
|
||||||
// //{
|
//{
|
||||||
// //System.Threading.Thread.Sleep(250);
|
//System.Threading.Thread.Sleep(250);
|
||||||
// //}
|
//}
|
||||||
|
|
||||||
// //app.Quitref missingValue, ref missingValue, ref missingValue);
|
//app.Quitref missingValue, ref missingValue, ref missingValue);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// }
|
}
|
||||||
//}
|
}
|
|
@ -3611,23 +3611,24 @@ namespace HRM.Report
|
||||||
|
|
||||||
if (table != null)
|
if (table != null)
|
||||||
{
|
{
|
||||||
//MSWord file = new MSWord();
|
MSWord file = new MSWord();
|
||||||
//FileInfo ossInfo = null;
|
FileInfo ossInfo = null;
|
||||||
////file.OriginalFile = letterTemplte.FilePath.Trim();
|
|
||||||
//file.OriginalFile = System.IO.Path.Combine(System.Environment.CurrentDirectory + "\\Documents\\LetterTempFolder\\" + lFileName);
|
|
||||||
|
|
||||||
//ossInfo = new FileInfo(sFilePath);
|
|
||||||
//if (ossInfo.Exists)
|
|
||||||
//{
|
|
||||||
// ossInfo.Delete();
|
|
||||||
//}
|
|
||||||
//File.Copy(file.OriginalFile, sFilePath, true);
|
|
||||||
//file = new MSWord();
|
|
||||||
//file.OpenWordApplication();
|
|
||||||
//file.OriginalFile = letterTemplte.FilePath.Trim();
|
//file.OriginalFile = letterTemplte.FilePath.Trim();
|
||||||
//file.ReplaceWords(sFilePath, table);
|
file.OriginalFile = System.IO.Path.Combine(System.Environment.CurrentDirectory + "\\Documents\\LetterTempFolder\\" + lFileName);
|
||||||
|
|
||||||
//file.CloseWordApplication();
|
ossInfo = new FileInfo(sFilePath);
|
||||||
|
if (ossInfo.Exists)
|
||||||
|
{
|
||||||
|
ossInfo.Delete();
|
||||||
|
}
|
||||||
|
File.Copy(file.OriginalFile, sFilePath, true);
|
||||||
|
file = new MSWord();
|
||||||
|
file.OpenWordApplication();
|
||||||
|
//file.OriginalFile = letterTemplte.FilePath.Trim();
|
||||||
|
file.OriginalFile = System.IO.Path.Combine(System.Environment.CurrentDirectory + "\\Documents\\LetterTempFolder\\" + lFileName);
|
||||||
|
file.ReplaceWords(sFilePath, table);
|
||||||
|
|
||||||
|
file.CloseWordApplication();
|
||||||
|
|
||||||
}
|
}
|
||||||
return sFilePath;
|
return sFilePath;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user