Esempio n. 1
0
        private void GenerateAuditLog(AuditLogInfo auditLogInfo, string fileName)
        {
            Document document = new Document("Templates\\Audit Log File Template.docx");

            //Construct the datatable
            DataTable auditTable = new DataTable("Audit");

            auditTable.Columns.Add("ObjectName");
            auditTable.Columns.Add("Query");
            auditTable.Columns.Add("CheckInDate");
            auditTable.Columns.Add("Description");

            foreach (AuditItem item in auditLogInfo.Items)
            {
                auditTable.Rows.Add(item.ElementName, item.Query, item.Date, item.Description);
            }

            document.MailMerge.MergeField += new MergeFieldEventHandler(HandleMergeField);
            //IFieldMergingCallback
            document.MailMerge.ExecuteWithRegions(auditTable);
            document.Range.Bookmarks["Title"].Text  = auditLogInfo.Title;
            document.Range.Bookmarks["Auther"].Text = auditLogInfo.Author;
            document.Save(textBoxFolder.Text.Trim() + "\\" + fileName);
            //auditTable.Rows.Add(
        }
Esempio n. 2
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();
                }));
            }
        }
Esempio n. 3
0
        private AuditLogInfo GetAuditInfo(DataBus dataBus, string releaseName)
        {
            JSCodeRunner codeRunner = new JSCodeRunner();

            codeRunner.Include("JSCode\\JsonEncode.js");
            codeRunner.Include("JSCode\\GetAuditInfo.js");
            string       codeToRun    = " return GetAuditInfo(\"" + releaseName + "\");";
            AuditLogInfo auditLogInfo = codeRunner.Run <AuditLogInfo>(dataBus, codeToRun);

            return(auditLogInfo);
        }