void MainPage_Loaded(object sender, RoutedEventArgs e) { // load data from embedded zip resource var ds = new DataSet(); var asm = Assembly.GetExecutingAssembly(); using (var s = asm.GetManifestResourceStream("CustomColumns.nwind.zip")) { var zip = new C1ZipFile(s); using (var zr = zip.Entries[0].OpenReader()) { // load data ds.ReadXml(zr); } } // show sales by country and category var olap = _c1OlapPage.OlapPanel.OlapEngine; olap.BeginUpdate(); olap.Updated += olap_Updated; olap.ValueFields.MaxItems = 3; olap.DataSource = ds.Tables[0].DefaultView; olap.RowFields.Add("Country"); olap.ColumnFields.Add("Category"); olap.ValueFields.Add("Sales"); olap.Fields["Sales"].Format = "n0"; olap.EndUpdate(); }
public MainWindow() { InitializeComponent(); // load data from embedded zip resource var ds = new DataSet(); var asm = Assembly.GetExecutingAssembly(); using (var s = asm.GetManifestResourceStream("OlapQuickStart.nwind.zip")) { var zip = new C1ZipFile(s); using (var zr = zip.Entries[0].OpenReader()) { // load data ds.ReadXml(zr); } } _c1OlapPage.Loaded += (s, ea) => { // bind olap page to data _c1OlapPage.DataSource = ds.Tables[0].DefaultView; // show sales by country and category var olap = _c1OlapPage.OlapPanel.OlapEngine; olap.DataSource = ds.Tables[0].DefaultView; olap.BeginUpdate(); olap.RowFields.Add("Country"); olap.ColumnFields.Add("Category"); olap.ValueFields.Add("Sales"); olap.Fields["Sales"].Format = "n0"; olap.EndUpdate(); }; }
static void Main(String[] args) { String DirectoryToRead = ""; String DirectoryToSave = ""; if (args.Length < 2) { Console.WriteLine("Usage: Zipper \\SourceFolder \\DestinationFile"); return; } if (args.Length > 0) { Console.WriteLine(args[0]); DirectoryToRead = args[0]; } if (args.Length > 1) { DirectoryToSave = args[1] + DateTime.Now.ToString("yyyyMMddHHmm") + ".zip"; Console.WriteLine(args[1] + DateTime.Now.ToString("yyyyMMddHHmm") + ".zip"); } Console.WriteLine(DirectoryToSave); Int32 Depth = 0; C1ZipFile zf = new C1ZipFile(DirectoryToSave, true); FolderLoop(DirectoryToRead, Depth, zf); zf.Close(); //Console.WriteLine("Press any key ..."); //Console.ReadKey(); }
public MainWindow() { InitializeComponent(); // load Invoices data from embedded resource var ds = new DataSet(); var asm = Assembly.GetExecutingAssembly(); using (var s = asm.GetManifestResourceStream("ConditionalFormatting.nwind.zip")) { var zip = new C1ZipFile(s); using (var zr = zip.Entries[0].OpenReader()) { // load data ds.ReadXml(zr); } } // bind olap page to data _c1OlapPage.Loaded += (s, ea) => { // prepare to build view _c1OlapPage.DataSource = ds.Tables[0].DefaultView; var olap = _c1OlapPage.OlapPanel.OlapEngine; olap.BeginUpdate(); // show sales by country and category/product olap.ColumnFields.Add("Country"); olap.RowFields.Add("Category", "Product"); olap.Fields["Product"].Width = 250; var value = olap.Fields["Sales"]; olap.ValueFields.Add(value); value.Format = "n0"; // show values in the top 90% percentile in green var sh = value.StyleHigh; sh.Value = .90; sh.ConditionType = C1.Olap.ConditionType.Percentage; sh.ForeColor = Color.FromArgb(0xff, 0, 50, 0); sh.BackColor = Color.FromArgb(0xff, 200, 250, 200); sh.FontBold = true; // show values in the bottom 2% percentile in red var sl = value.StyleLow; sl.Value = .02; sl.ConditionType = C1.Olap.ConditionType.Percentage; sl.ForeColor = Color.FromArgb(0xff, 50, 0, 0); sl.BackColor = Color.FromArgb(0xff, 250, 200, 200); sl.FontBold = true; // view is ready olap.EndUpdate(); }; }
static void FolderLoop(String DirectoryToRead, Int32 Depth, C1ZipFile zf) { DirectoryInfo di = new DirectoryInfo(DirectoryToRead); ++Depth; foreach (DirectoryInfo diSub in di.GetDirectories()) { Console.WriteLine(DirectoryToRead); DirectoryToRead = diSub.FullName; FolderLoop(DirectoryToRead, Depth, zf); } foreach (FileInfo fi in di.GetFiles()) { Console.WriteLine(fi.FullName); zf.Entries.Add(fi.FullName, Depth); } }
public MainWindow() { InitializeComponent(); // load data from embedded zip resource var ds = new DataSet(); var asm = Assembly.GetExecutingAssembly(); using (var s = asm.GetManifestResourceStream("OlapTemplate.nwind.zip")) { var zip = new C1ZipFile(s); using (var zr = zip.Entries[0].OpenReader()) { // load data ds.ReadXml(zr); } } _c1OlapPage.Loaded += (s, ea) => { // bind olap page to data _c1OlapPage.DataSource = ds.Tables[0].DefaultView; // set columns totals chart _c1OlapPage.ChartType = C1.WPF.Olap.ChartType.Column; _c1OlapPage.ChartTotals = true; // show sales by country and order date var olap = _c1OlapPage.OlapPanel.OlapEngine; olap.DataSource = ds.Tables[0].DefaultView; olap.BeginUpdate(); olap.RowFields.Add("Country"); olap.ColumnFields.Add("OrderDate"); olap.ValueFields.Add("Sales"); olap.Fields["OrderDate"].Format = "MMM"; olap.EndUpdate(); }; }
void MainPage_Loaded(object sender, RoutedEventArgs e) { // load data from embedded zip resource var ds = new DataSet(); var asm = Assembly.GetExecutingAssembly(); using (var s = asm.GetManifestResourceStream("CustomizePage.Resources.nwind.zip")) { var zip = new C1ZipFile(s); using (var zr = zip.Entries[0].OpenReader()) { // load data ds.ReadXml(zr); } } // bind olap page to data _c1OlapPage.DataSource = ds.Tables[0].DefaultView; // view not found in storage, use default var olap = _c1OlapPage.OlapPanel.OlapEngine; olap.DataSource = ds.Tables[0].DefaultView; olap.BeginUpdate(); olap.RowFields.Add("Country"); olap.ColumnFields.Add("Category"); olap.ValueFields.Add("Sales"); olap.Fields["Sales"].Format = "n0"; olap.EndUpdate(); // get predefined views from XML resource var views = new Dictionary<string, string>(); using (var s = asm.GetManifestResourceStream("CustomizePage.Resources.OlapViews.xml")) using (var reader = XmlReader.Create(s)) { // read predefined view definitions while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "C1OlapPage") { var id = reader.GetAttribute("id"); var def = reader.ReadOuterXml(); views[id] = def; } } } // build new menu with predefined views var menuViews = new C1MenuItem(); menuViews.Header = "View"; menuViews.Icon = GetImage("Resources/views.png"); menuViews.VerticalAlignment = VerticalAlignment.Center; ToolTipService.SetToolTip(menuViews, "Select a predefined Olap view."); foreach (var id in views.Keys) { var mi = new C1MenuItem(); mi.Header = id; mi.Tag = views[id]; mi.Click += mi_Click; menuViews.Items.Add(mi); } // add new menu to the page's main menu _c1OlapPage.MainMenu.Items.Insert(6, menuViews); }
public MainWindow() { InitializeComponent(); // load data from embedded zip resource var ds = new DataSet(); var asm = Assembly.GetExecutingAssembly(); using (var s = asm.GetManifestResourceStream("CustomUI.Resources.nwind.zip")) { var zip = new C1ZipFile(s); using (var zr = zip.Entries[0].OpenReader()) { // load data ds.ReadXml(zr); } } // bind olap page to data PivotBuilder.DataSource = ds.Tables[0].DefaultView; var olap = PivotBuilder.OlapEngine; // rename fields in the UI olap.Fields["ExtendedPrice"].Caption = "Sales"; olap.Fields["OrderDate"].Caption = "Order Date"; olap.Fields["PostalCode"].Caption = "Postal Code"; //olap.Fields["Customers_002eCompanyName"].Caption = "Company Name"; olap.Fields["ProductName"].Caption = "Product Name"; olap.Fields["RequiredDate"].Caption = "Required Date"; olap.Fields["ShipAddress"].Caption = "Ship Address"; olap.Fields["ShipCity"].Caption = "Ship City"; olap.Fields["ShipCountry"].Caption = "Ship Country"; olap.Fields["ShipName"].Caption = "Ship Name"; olap.Fields["ShippedDate"].Caption = "Shipped Date"; //olap.Fields["Shippers_002eCompanyName"].Caption = "Shipper"; olap.Fields["ShipPostalCode"].Caption = "Ship Postal Code"; olap.Fields["ShipRegion"].Caption = "Ship Region"; olap.Fields["UnitPrice"].Caption = "Price"; // set formats olap.Fields["OrderDate"].Format = "yyyy"; olap.Fields["RequiredDate"].Format = "yyyy"; olap.Fields["ShippedDate"].Format = "yyyy"; olap.Fields["ExtendedPrice"].Format = "c2"; olap.Fields["UnitPrice"].Format = "c2"; // show sales by country and category olap.DataSource = ds.Tables[0].DefaultView; olap.BeginUpdate(); olap.RowFields.Add("Country"); olap.ColumnFields.Add("OrderDate"); olap.ValueFields.Add("ExtendedPrice"); olap.EndUpdate(); PivotBuilder.OlapEngine.Update(); // initialize printing report options _reportOptions = new ReportOptions() { IncludeGrid = true, IncludeChart = true, IncludeRawData = false, Margin = new Thickness(1), ChartScale = ScaleMode.SinglePage, GridScale = ScaleMode.PageWidth, RawDataScale = ScaleMode.PageWidth, ShowFooterSeparator = true, ShowHeaderSeparator = true, HeaderCenter = "&[ViewTitle]", HeaderRight = "&[Date]", FooterRight = "Page &[Page] of &[PageCount]" }; // initialize undo/redo stack new OlapPanelUndoStack(PivotBuilder, btnUndo, btnRedo); // configure toolbar btnChartType_Bar.IsChecked = true; Application.Current.Resources.MergedDictionaries.Add(C1.WPF.Theming.C1Theme.GetCurrentThemeResources(new C1.WPF.Theming.Office2013.C1ThemeOffice2013White())); }
/// <summary> /// Opens a package from a web instance. /// </summary> /// <param name="fileName"> The package file name.</param> public void OpenPackageWeb(string fileName) { C1ZipFile zipFile = new C1ZipFile(); // package = new ScriptingApplicationPackage(); try { zipFile.Open(fileName); // Application C1ZipEntry entry = zipFile.Entries[0]; // Get entry name and convert to guid // if invalid GUID, throw exception string name = entry.FileName; string applicationXml = string.Empty; string applicationArgumentsXml = string.Empty; // Get Scripting Application Xml. Guid g = new Guid(name); StreamReader reader = new StreamReader(entry.OpenReader(),System.Text.Encoding.UTF8); applicationXml= reader.ReadToEnd(); reader.Close(); if ( zipFile.Entries.Count > 1 ) { // Arguments entry = zipFile.Entries[1]; reader = new StreamReader(entry.OpenReader(),System.Text.Encoding.UTF8); applicationArgumentsXml = reader.ReadToEnd(); if ( applicationArgumentsXml.ToLower() != "none" ) { _arguments = ScriptingApplicationArgs.FromXml(applicationArgumentsXml); } else { _arguments = null; } reader.Close(); } // Get Custom Transforms int start = 2; for ( int i=2;i<zipFile.Entries.Count;i++ ) { entry = zipFile.Entries[i]; if ( entry.FileName == "CustomTransformsSeparator" ) { start = i+1; break; } // Add File References to Application Startup // string location = System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + entry.FileName; // if ( !File.Exists(location) ) // { // zipFile.Entries.Extract(i, location); // } // Add WebTransform Entry in Configuration. // if exists don't add. // RegisterWebTransform(location); // ScriptingApplicationSerializer.UpdateSerializer(); } // Generate scripting application. XmlDocument document = new XmlDocument(); document.LoadXml(applicationXml); _application = ScriptingApplication.Decrypt(document); // _application = ScriptingApplication.FromXml(applicationXml); // // for ( int i=start;i<zipFile.Entries.Count;i++ ) // { // entry = zipFile.Entries[i]; // // // Add File References to Internet Cache // string location = Utils.AppLocation.InternetTemp + Path.DirectorySeparatorChar + _application.Header.ApplicationID + Path.DirectorySeparatorChar + entry.FileName; // if ( File.Exists(location) ) // { // File.Delete(location); // } // zipFile.Entries.Extract(i, location); // } } catch { throw; } finally { zipFile.Close(); } }
/// <summary> /// Reads the application id from the package. /// </summary> /// <param name="packageFile"> The package file.</param> /// <returns> An application id.</returns> public static string ReadApplicationID(string packageFile) { string result = string.Empty; C1ZipFile zipFile = new C1ZipFile(); try { zipFile.Open(packageFile); // Application C1ZipEntry entry = zipFile.Entries[0]; // Get entry name and convert to guid // if invalid GUID, throw exception string name = entry.FileName; Guid g = new Guid(name); result = name; } catch ( Exception ex ) { System.Diagnostics.Debug.Write(ex.ToString()); } finally { zipFile.Close(); } return result; }
void OlapDemo_Loaded(object sender, RoutedEventArgs e) { // load data from embedded zip resource var ds = new DataSet(); var asm = Assembly.GetExecutingAssembly(); using (var s = asm.GetManifestResourceStream("OlapSamples.Resources.nwind.zip")) { var zip = new C1ZipFile(s); using (var zr = zip.Entries[0].OpenReader()) { // load data ds.ReadXml(zr); } } // bind olap page to data olapPage.DataSource = ds.Tables[0].DefaultView; // view not found in storage, use default var olap = olapPage.OlapPanel.OlapEngine; olap.DataSource = ds.Tables[0].DefaultView; // set value field limit to 4 (**default is 1) olap.ValueFields.MaxItems = 4; // create conditional formatting olap.Fields["ExtendedPrice"].StyleHigh.ForeColor = Colors.Green; olap.Fields["ExtendedPrice"].StyleHigh.ConditionType = C1.Olap.ConditionType.Percentage; olap.Fields["ExtendedPrice"].StyleHigh.Value = 0.8; olap.Fields["ExtendedPrice"].StyleLow.ForeColor = Colors.Red; olap.Fields["ExtendedPrice"].StyleLow.ConditionType = C1.Olap.ConditionType.Percentage; olap.Fields["ExtendedPrice"].StyleLow.Value = 0.1; // apply update to view olap.BeginUpdate(); olap.Fields["ExtendedPrice"].Caption = "Sales"; olap.RowFields.Add("Country"); olap.ColumnFields.Add("Salesperson"); olap.ValueFields.Add("ExtendedPrice"); olap.Fields["ExtendedPrice"].Format = "c0"; olap.EndUpdate(); // get predefined views from XML resource var views = new Dictionary<string, string>(); using (var s = asm.GetManifestResourceStream("OlapSamples.Resources.OlapViews.xml")) using (var reader = XmlReader.Create(s)) { // read predefined view definitions while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "C1OlapPage") { var id = reader.GetAttribute("id"); var def = reader.ReadOuterXml(); views[id] = def; } } } // build new menu with predefined views var menuViews = new C1MenuItem(); menuViews.Header = "Views"; menuViews.Icon = GetImage("/Resources/Views.png"); menuViews.VerticalAlignment = VerticalAlignment.Center; ToolTipService.SetToolTip(menuViews, "Select a predefined Olap view."); foreach (var id in views.Keys) { var mi = new C1MenuItem(); mi.Header = id; mi.Padding = new Thickness(5); mi.Tag = views[id]; mi.Click += mi_Click; menuViews.Items.Add(mi); } // add new menu to the page's main menu olapPage.MainMenu.Items.Insert(6, menuViews); }