예제 #1
0
        public string GenerateThumb(MediaFileItem mediaFile)
        {
            using (new Tracer(mediaFile))
            {
                try
                {
                    var doc = new Microsoft.Office.Interop.Word.Application().Documents.Open(FileName: mediaFile.MediaLocation, Visible: false, ReadOnly: true);

                    doc.ShowGrammaticalErrors = false;
                    doc.ShowRevisions         = false;
                    doc.ShowSpellingErrors    = false;

                    byte[] bytes = doc.Range().EnhMetaFileBits;

                    Image page = Image.FromStream(new MemoryStream(bytes));

                    doc.Close(WdSaveOptions.wdDoNotSaveChanges);
                    Helper.Helper.GetThumb(page, mediaFile.Width, mediaFile.Height);
                }
                catch (Exception ex)
                {
                }
                return(_wordThumbPath);
            }
        }
예제 #2
0
        public Analysis doAnalysis(string originalFileName, string newFileName)
        {
            log.Info("Starting Document Comparision");
            log.Debug("Original File - " + originalFileName);
            log.Debug("New File - " + newFileName);

            Document wDocNew      = null;
            Document wDocOriginal = null;
            Analysis result       = null;

            try
            {
                log.Info("Loading New File");
                wDocNew = new Microsoft.Office.Interop.Word.Application().Documents.Open(newFileName, ReadOnly: true);
                log.Info("Loading Original File");
                wDocOriginal = new Microsoft.Office.Interop.Word.Application().Documents.Open(originalFileName, ReadOnly: true);
                log.Info("Preparing New File");
                prepareNewDoc(wDocNew);
                log.Info("Preparing Original File");
                prepareOriginalDoc(wDocOriginal);

                result = new Analysis();
                log.Info("Analzing..");
                foreach (KeyValuePair <string, string> new_item in newDocDictionary)
                {
                    if (!originalDocDictionary.ContainsKey(new_item.Key)) // New clause added
                    {
                        result.newClauses.Add(new_item.Key.ToString(), new_item.Value);
                    }
                    else if (!new_item.Value.ToString().Equals(originalDocDictionary[new_item.Key]))
                    {
                        //clause number is present but content is not equal
                        if (new_item.Value.ToString().Trim().Equals(""))
                        {
                            //clause is deleted
                            result.deletedClauses.Add(new_item.Key.ToString(), originalDocDictionary[new_item.Key]);
                        }
                        else
                        {
                            //clause is modified
                            result.modifiedClauses.Add(new_item.Key.ToString(), new_item.Value);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                log.Error("An error occured while processing - " + exception.Message);
                log.Error(exception);
                return(null);
            }
            finally
            {
                log.Info("Analysis Complete");
                wDocNew.Close();
                wDocOriginal.Close();
            }

            return(result);
        }