public static void SaveAsPDFAllAnalyisOuput(ObservableCollection <AnalyticsData> DataList, string fullpathzipcsvhtmfilename) { int imgnamecounter = 0; List <string> filelist = new List <string>(); bool extratags = false; bool fileExists = File.Exists(fullpathzipcsvhtmfilename); double left, top, right, bottom; GetPDFpageMargins(strPDFPageMargin, out left, out top, out right, out bottom); //Creating a PDF doc to which we will add PDFTables MigraDoc.DocumentObjectModel.Document Doc = new MigraDoc.DocumentObjectModel.Document(); MigraDoc.DocumentObjectModel.Tables.Table pdfTable; //Set Page margins from configuration Doc.DefaultPageSetup.LeftMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(left); //left margin Doc.DefaultPageSetup.TopMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(top); //top margin Doc.DefaultPageSetup.RightMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(right); //right margin Doc.DefaultPageSetup.BottomMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(bottom); //bottom margin Doc.AddSection(); //////// looping thru all analysis one by one ////// foreach (AnalyticsData analysisdata in DataList) { //03Aug2012 ICommandAnalyser analyser = CommandAnalyserFactory.GetClientAnalyser(analysisdata); CommandOutput output = analysisdata.Output; // getting refrence of already generated objects. SessionOutput sessionoutput = analysisdata.SessionOutput; //27Nov2013 if there is session output if (output != null) { output.NameOfAnalysis = analysisdata.AnalysisType;//For Parent Node name 02Aug2012 } if (sessionoutput != null) { sessionoutput.NameOfSession = analysisdata.AnalysisType; } /////// dumping output // if (output != null) { ExportOutputPDF(output, Doc, extratags, filelist); } else if (sessionoutput != null) { foreach (CommandOutput cout in sessionoutput) { ExportOutputPDF(cout, Doc, extratags, filelist, true); } } } ////rendering doc MigraDoc.Rendering.PdfDocumentRenderer docrender = new MigraDoc.Rendering.PdfDocumentRenderer(false); docrender.Document = Doc; docrender.RenderDocument(); docrender.PdfDocument.Save(fullpathzipcsvhtmfilename); }
public Writer(Uri dependencyServiceUri, AtlasConfiguration atlasConfiguration, DataFormat dataFormat, string group, IOutputTopic topic, bool enableCache = true) { var httpDependencyClient = new HttpDependencyClient(dependencyServiceUri, group, enableCache); // DependencyClient stores the Data format, Atlas Configuration var dataFormatClient = new DataFormatClient(httpDependencyClient); var atlasConfigurationClient = new AtlasConfigurationClient(httpDependencyClient); var atlasConfigurationId = atlasConfigurationClient .PutAndIdentifyAtlasConfiguration(atlasConfiguration); // Uniq ID created for the AtlasConfiguration var dataFormatId = dataFormatClient.PutAndIdentifyDataFormat(dataFormat); // Uniq ID created for the Data Format TopicName = topic.TopicName; //Init Session session = new SessionTelemetryDataOutput(topic, dataFormatId, dataFormatClient); session.SessionOutput.AddSessionDependency(DependencyTypes.DataFormat, dataFormatId); session.SessionOutput.AddSessionDependency(DependencyTypes.AtlasConfiguration, atlasConfigurationId); SessionOutput = session.SessionOutput; }
public SyntaxEditorWindow() { InitializeComponent(); this.MinWidth = 440;// 384; this.MinHeight = 200; this.Width = 750;// 976; this.Height = 550; this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; SMenu.Items.Add(omh.OutputMenu);///Add Output menu /// inputTextbox.Focus();//set focus inside text box. //opening Graphics device with sytax Editor. //05May2013 // when graphic command executes, we close the device then generate output and finally open the device again. OpenGraphicsDevice(); sessionlst = new SessionOutput(); }
//22Nov2013 for sending session contents to output window. //This gives us control to send output each time "RUN" is clicked and for batch command //this method can be called when last slice contents get appended to sessionlist public void DisplayAllSessionOutput(string sessionheader = "", OutputWindow selectedOW=null)//06May2015 slectedOW param added { sessionlst.NameOfSession = sessionheader; sessionlst.isRSessionOutput = true; //if (sessionheader.Trim().Length > 1) if(sessionlst.Count>0)//07Nov2014 { if (selectedOW == null) { //for dialog batch commads say 'lm' sessionheader will have some dialog title like 'lm' ow.AddSynEdtSessionOutput(sessionlst);//send output to 'Active' marked output window. } else { selectedOW.AddSynEdtSessionOutput(sessionlst);//send output to specific window from where command was executed } } sessionlst = new SessionOutput();//28Nov2013 for creating new instance and not deleting old one }
//AUGrid c1fg = null; /// Read .bso file and create all the displayable objects in allanalysis public List <SessionOutput> html2xml(string fullpathfilename) { #region read html and if (!File.Exists(fullpathfilename)) { MessageBox.Show(BSky.GlobalResources.Properties.Resources.BSkyOutFileNotFound); return(null); } string fulltext = File.ReadAllText(fullpathfilename); string s = Regex.Replace(fulltext, @"\0", ""); //////////////Put <BSKYOUTPUT> check here ////////////// if (Regex.Matches(s, "<bskyoutput>").Count < 1 || Regex.Matches(s, "</bskyoutput>").Count < 1) { MessageBox.Show(BSky.GlobalResources.Properties.Resources.BSkyOutFileBadFormat); return(null); } string r = Regex.Replace(s, @"<head>", ""); string t = r; /// fixing class attribute with quotes string patternh = @"\bclass=h[0-9]+"; string u = Regex.Replace(t, patternh, " class='h'"); string patternc = @"\bclass=c[0-9]+"; string v = Regex.Replace(u, patternc, " class='c'"); List <SessionOutput> allSessions = new List <SessionOutput>(); XmlDocument sessXd = new XmlDocument(); //New Session tag which is parent of bskyanalysis tag ////// No of sessions/// ana is abbrivation for analysis MatchCollection sessmc = Regex.Matches(v, "<sessoutput"); MatchCollection sessmc2 = Regex.Matches(v, "</sessoutput>"); for (int ss = 0; ss < sessmc.Count; ss++) ///loop on number of sessions { /// int sessStart = sessmc[ss].Index; int sessEnd = sessmc2[ss].Index; string onesession = v.Substring(sessStart, sessEnd - sessStart + 14); ////// No of Analysis/// ana is abbrivation for analysis MatchCollection anamc = Regex.Matches(onesession, "<bskyanalysis>"); MatchCollection anamc2 = Regex.Matches(onesession, "</bskyanalysis>"); sessXd.LoadXml(onesession); string sessionheader = sessXd.SelectSingleNode("sessoutput").Attributes["Header"] != null?sessXd.SelectSingleNode("sessoutput").Attributes["Header"].Value : string.Empty; string isRsession = sessXd.SelectSingleNode("sessoutput").Attributes["isRsession"] != null?sessXd.SelectSingleNode("sessoutput").Attributes["isRsession"].Value : "false"; bool isrsessionoutput = false; if (isRsession.ToLower().Trim().Equals("true")) { isrsessionoutput = true; } int anaStart = 0; int anaEnd = 0; XmlDocument anaXd = new XmlDocument(); CommandOutput lst = null; SessionOutput allanalysis = new SessionOutput(); allanalysis.NameOfSession = sessionheader; allanalysis.isRSessionOutput = isrsessionoutput; AUParagraph AUP; //09Jul2013 for (int j = 0; j < anamc.Count; j++) ///loop on number of analysis { lst = new CommandOutput(); ///for treeview. New analysis anaStart = anamc[j].Index; anaEnd = anamc2[j].Index; string oneAnalysis = onesession.Substring(anaStart, anaEnd - anaStart + 15); anaXd.LoadXml(oneAnalysis); lst.NameOfAnalysis = anaXd.SelectSingleNode("bskyanalysis/analysisname").InnerText.Trim(); //For Parent Node name 02Aug2012 int noofaup = anaXd.SelectNodes("bskyanalysis/aup").Count; // should be 2 int leafcount = anaXd.ChildNodes.Item(0).ChildNodes.Count; //29Oct2013 no. of leaves in an analysis string[] contTyp = { "Header", "Dataset" }; // should be 2 int noofnotes = anaXd.SelectNodes("bskyanalysis/bskynotes").Count; //06nov2012 foreach (XmlNode ln in anaXd.ChildNodes.Item(0).ChildNodes) { if (ln.Name.Trim().Equals("analysisname")) { continue; } XmlNode xn = null; switch (ln.Name.Trim()) { case "aup": #region AUPara AUP = createAUPara(ln, "", ""); if (AUP != null) { lst.Add(AUP); } #endregion break; case "bskynotes": #region BSkyNotes if (noofnotes >= 1) { BSkyNotes bsnotes = createBSkyNotes(ln, "", "Notes"); if (bsnotes != null) { lst.Add(bsnotes); } } #endregion break; case "graphic": #region Graphic string tempDir = System.IO.Path.GetDirectoryName(fullpathfilename); string fullpathimgfilename = string.Empty; XmlNode imgxn = ln;//anaXd.SelectSingleNode("bskyanalysis/graphic"); string pathimgfilename = (imgxn != null) ? imgxn.InnerText.Trim() : ""; string imgfileNamewithExt = System.IO.Path.GetFileName(pathimgfilename); string outputDir = tempDir + "\\";// @"\temp2\"; fullpathimgfilename = System.IO.Path.Combine(outputDir + imgfileNamewithExt); if (fullpathimgfilename.Trim().Length > 0) { lst.Add(CreateBSkyGraphicControl(fullpathimgfilename)); } #endregion break; case "auxgrid": #region FlexGrid oneAnalysis = ln.OuterXml; ////// No. of Grids in one analysis: for C1FlexGrid header/footer err/warning generation ////// MatchCollection aux1 = Regex.Matches(oneAnalysis, "<auxgrid>"); MatchCollection aux2 = Regex.Matches(oneAnalysis, "</auxgrid>"); XmlDocument anagrid = new XmlDocument();//this will be used to get contents of auxgrid(excluding flexgrid) ////// No. of FlexGrids in one analysis: for C1FlexGrid generation ////// MatchCollection mc = Regex.Matches(oneAnalysis, "<html>"); MatchCollection mc2 = Regex.Matches(oneAnalysis, "</html>"); int start = 0; int end = 0; XmlDocument xd = new XmlDocument(); for (int k = 0; k < mc.Count; k++) /// loop till all C1FlexGrid in current Analysis get generated { AUXGrid xgrid = new AUXGrid(); AUGrid c1fg = xgrid.Grid;// new C1flexgrid. anagrid.LoadXml(oneAnalysis.Substring(aux1[k].Index, aux2[k].Index - aux1[k].Index + 10)); //flexgrid header xn = anagrid.SelectSingleNode("auxgrid/fgheader[1]"); xgrid.Header.Text = (xn != null) ? xn.InnerText : ""; ///AUXGrid error/warning Dictionary <char, string> Metadata = new Dictionary <char, string>(); char ch = ' '; int erri = 2; string mesg = "", fullmsg = ""; xn = anagrid.SelectSingleNode("auxgrid/errm[1]"); while (xn != null) { /// err msg is like :- "a:. Warning: .... fullmsg = xn.InnerText.ToString().Replace('"', ' ').Trim(); ch = fullmsg.Substring(0, xn.InnerText.ToString().IndexOf(':')).ToCharArray()[0];///extract key char. mesg = fullmsg.Substring(fullmsg.IndexOf(':') + 1); Metadata.Add(ch, mesg); xn = anagrid.SelectSingleNode("auxgrid/errm[" + erri + "]"); erri++; //error index. next line. } xgrid.Metadata = Metadata; /////// AUXGrid Footer ///// bool templatedDialog = false; if (templatedDialog) { Dictionary <char, string> Footer = new Dictionary <char, string>(); erri = 2; xn = anagrid.SelectSingleNode("auxgrid/footermsg[1]"); while (xn != null) { /// err msg is like :- "a:. Warning: .... fullmsg = xn.InnerText.ToString().Replace('"', ' ').Trim(); ch = fullmsg.Substring(0, xn.InnerText.ToString().IndexOf(':')).ToCharArray()[0];///extract key char. mesg = fullmsg.Substring(fullmsg.IndexOf(':') + 1); Footer.Add(ch, mesg); xn = anagrid.SelectSingleNode("auxgrid/errm[" + erri + "]"); erri++; //error index. next line. } xgrid.FootNotes = Footer; } else { //This works for non-templated dialogs xn = anagrid.SelectSingleNode("auxgrid/footermsg[1]"); if (xn != null) { fullmsg = xn.InnerText.ToString().Replace('"', ' ').Trim(); xgrid.StarFootNotes = fullmsg; } } ////////////get index of <html> and </html> ////// start = mc[k].Index; end = mc2[k].Index; //// create xmldoc loaind string from <html> to </html> //// xd.LoadXml(oneAnalysis.Substring(start, end - start + 7)); html2flex(xd, c1fg);//create rows/cols/headers and populate ///////////// find C1Flexgrid Generate it //////E///// xgrid.Margin = new Thickness(10); lst.Add(xgrid); } #endregion break; } //switch } //for each leave allanalysis.Add(lst); } allSessions.Add(allanalysis); }//for session #endregion return(allSessions); }
public void Checkout(SessionOutput output, string refspec = "master") { var checkoutOptions = new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force, }; // Clone repository if it does not exist if (!Repository.IsValid(Source.RepositoryPath)) { output.WriteLine("Cloning Repository...", ConsoleColor.DarkCyan); var cloneOptions = new CloneOptions(); cloneOptions.CredentialsProvider += CredentialsProvider; Repository.Clone(Source.RepositoryUrl, Source.RepositoryPath, cloneOptions); } using (var repo = new Repository(Source.RepositoryPath)) { // Fetch all updated refspecs and tags output.WriteLine("Fetching updated refs...", ConsoleColor.DarkCyan); var fetchSpec = new[] { "+refs/heads/*:refs/remotes/origin/*" }; var fetchOptions = new FetchOptions { TagFetchMode = TagFetchMode.All, }; fetchOptions.CredentialsProvider += CredentialsProvider; LibGit2Sharp.Commands.Fetch(repo, "origin", fetchSpec, fetchOptions, null); // Find local and remote branches var remoteBranchName = $"refs/remotes/origin/{refspec}"; var remoteBranch = repo.Branches[remoteBranchName]; var localBranchName = $"refs/heads/origin/{refspec}"; var localBranch = repo.Branches[localBranchName]; if (remoteBranch == null) { output.Write("Git Refspec ", ConsoleColor.DarkYellow) .Write(refspec, ConsoleColor.Yellow) .WriteLine(" was not found!", ConsoleColor.DarkYellow); throw new ApplicationException($"Git Refspec '{refspec}' was not found!"); } if (localBranch != null) { output.WriteLine($"Found local branch '{localBranch.FriendlyName}'...", ConsoleColor.DarkCyan); // Update tracking branch if not remote branch if (!localBranch.IsTracking || localBranch.TrackedBranch != remoteBranch) { output.WriteLine("Updating local branch tracking reference...", ConsoleColor.DarkCyan); repo.Branches.Update(localBranch, b => b.TrackedBranch = remoteBranch.CanonicalName); } // Checkout local branch if not current if (!localBranch.IsCurrentRepositoryHead) { output.WriteLine($"Checkout local branch '{localBranch.FriendlyName}'...", ConsoleColor.DarkCyan); LibGit2Sharp.Commands.Checkout(repo, localBranch, checkoutOptions); } // Revert to common ancestor commit if diverged var status = localBranch.TrackingDetails; var aheadCount = status.AheadBy ?? 0; if (aheadCount > 0) { output.WriteLine($"Local branch '{localBranch.FriendlyName}' has diverged from the remote tracking branch!", ConsoleColor.DarkYellow); var common = status.CommonAncestor; if (common != null) { output.WriteLine($"Reverting local branch to commit '{common.Sha}'!", ConsoleColor.DarkCyan); repo.Reset(ResetMode.Hard, common, checkoutOptions); } } // Pull latest changes from remote output.WriteLine("Pull changes from remote...", ConsoleColor.DarkCyan); var sign = new Signature("photon", "*****@*****.**", DateTimeOffset.Now); var pullOptions = new PullOptions { FetchOptions = fetchOptions, }; LibGit2Sharp.Commands.Pull(repo, sign, pullOptions); } else { // Create local branch tracking remote output.WriteLine($"No local branch found. Creating local tracking branch '{remoteBranch.FriendlyName}'...", ConsoleColor.DarkCyan); localBranch = repo.CreateBranch(remoteBranch.FriendlyName, remoteBranch.Tip); repo.Branches.Update(localBranch, b => b.TrackedBranch = remoteBranch.CanonicalName); output.WriteLine($"Checkout local tracking branch '{localBranch.FriendlyName}'...", ConsoleColor.DarkCyan); LibGit2Sharp.Commands.Checkout(repo, localBranch, checkoutOptions); } output.WriteLine("Current Commit:", ConsoleColor.DarkBlue) .WriteLine($" {repo.Head.Tip.Sha}", ConsoleColor.Blue) .WriteLine($" {repo.Head.Tip.Author?.Name}", ConsoleColor.Blue) .WriteLine(repo.Head.Tip.Message, ConsoleColor.Cyan); } }