Exemple #1
0
        private void CreatePackage()
        {
            try
            {
                if (currentConnectionInfo != null)
                {
                    SessionCache      sessionCache      = new SessionCache();
                    ConnectionSession connectionSession = sessionCache[currentConnectionInfo];
                    DataBus           dataBus           = connectionSession.GetDataBus();
                    if (needCreateAuditlog)
                    {
                        //Generate audit log file.
                        AuditLogInfo auditInfo = GetAuditInfo(dataBus, releaseManagerName);
                        auditInfo.Author = currentConnectionInfo.UserName;
                        auditInfo.Title  = auditFileTitle;
                        GenerateAuditLog(auditInfo, auditFileName);
                    }

                    //Create unload record
                    if (needCreateUnloadRecord)
                    {
                        CreateUnloadFile(dataBus, releaseManagerName, unloadName);
                    }
                    //Generate move instruction doc.
                    if (needCreateMoveInstruction)
                    {
                        dataBus = connectionSession.GetDataBus();
                        //Generate unload script file
                        UnloadScriptFile unloadScriptFile = new UnloadScriptFile();
                        unloadScriptFile.FileLocation     = fileDir;
                        unloadScriptFile.UnloadScriptName = unloadName;
                        unloadScriptFile.GenerateUnloadScript(dataBus);

                        //Create move instruction.
                        MoveInstructionInfo moveInstructionInfo = new MoveInstructionInfo();
                        moveInstructionInfo.UnloadFileLocation = unloadScriptFile.FileLocation;
                        moveInstructionInfo.Title  = textBoxMoveInstructionLocation.Text.Trim();
                        moveInstructionInfo.Author = currentConnectionInfo.UserName;
                        moveInstructionInfo.Entity = GetUnloadEntity(connectionSession.GetDataBus(), unloadScriptFile.UnloadScriptName);
                        GenerateMoveInstructions(moveInstructionInfo, moveInstructionFileLocation);
                    }
                }

                Invoke(new UpdateUI(delegate()
                {
                    MessageBox.Show("Package Created");
                    EnableControls();
                }));
            }
            catch
            {
                Invoke(new UpdateUI(delegate()
                {
                    MessageBox.Show("Create Package Failed, please try again");
                    EnableControls();
                }));
            }
        }
Exemple #2
0
        private void GenerateMoveInstructions(MoveInstructionInfo moveInstructionInfo, string fileName)
        {
            Document document = new Document("Templates\\Move Instructions Template.docx");

            document.Range.Bookmarks["Title"].Text  = moveInstructionInfo.Title;
            document.Range.Bookmarks["Author"].Text = moveInstructionInfo.Author;
            //document. Range. Bookmarks["Date"]. Text = moveInstructionInfo;
            document.Range.Bookmarks["UnlName"].Text = moveInstructionInfo.Entity.Name;


            //Insert the html format screeshot
            string          htmlString = CreateHtmlForScreenShot(moveInstructionInfo.Entity);
            DocumentBuilder docBuilder = new DocumentBuilder(document);

            docBuilder.MoveToBookmark("ScreenShot");
            Image        screenShot  = CreateUnloadImage(moveInstructionInfo.Entity);
            MemoryStream imageStream = new MemoryStream();

            screenShot.Save(imageStream, ImageFormat.Jpeg);
            imageStream.Position = 0;
            Collection <byte> imageData = new Collection <byte>();

            byte[] bufferData = new byte[1024];
            int    readLength = imageStream.Read(bufferData, 0, 1024);

            while (readLength > 0)
            {
                //Copy the data.
                for (int i = 0; i < readLength; i++)
                {
                    imageData.Add(bufferData[i]);
                }
                readLength = imageStream.Read(bufferData, 0, 1024);
            }

            imageStream.Dispose();

            docBuilder.InsertImage(imageData.ToArray());
            //docBuilder. InsertHtml(htmlString);
            document.Save(textBoxFolder.Text.Trim() + "\\" + fileName);
            //Insert the unload file to doc.
            InsertUnloadFileToDocument("FileObject", textBoxFolder.Text.Trim() + "\\" + fileName, moveInstructionInfo.UnloadFileLocation);
        }