コード例 #1
0
        //Extended Data Access (XDA) reporting (Freeform SQL or Query Builder).
        private void button2_Click(object sender, EventArgs e)
        {
            string reportGuid = "1ACE8C37484AE0EBD81271BB88B63013";

            try
            {
                MSTRConn con1 = new MSTRConn();

                IDSSSession oSession = con1.getSession();

                IDSSSource oSource = oSession.ObjectSource;

                IDSSReportSource oReportSource = oSession.ReportSource;

                IDSSReportDefinition4 oReportDef = (IDSSReportDefinition4)oSource.FindObject(reportGuid, EnumDSSObjectType.DssTypeReportDefinition,
                                                                                             EnumDSSSourceFlags.DssSourceDefault, null, 0, 0);


                Console.WriteLine(oReportDef.XDAType);

                IDSSTable3 oTable = (IDSSTable3)oReportDef.SourceTable;

                Console.WriteLine(oTable.XDADefinition);

                con1.close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message.ToString());
            }
        }
コード例 #2
0
        //レポートのSQLを表示
        private void button1_Click(object sender, EventArgs e)
        {
            string reportGuid = "796249EE4429B79CD62FC195F59A6764";

            try
            {
                MSTRConn con1 = new MSTRConn();

                IDSSSession oSession = con1.getSession();

                IDSSSource oSource = oSession.ObjectSource;

                IDSSReportSource oReportSource = oSession.ReportSource;

                IDSSReportDefinition oReportDef = (IDSSReportDefinition)oSource.FindObject(reportGuid, EnumDSSObjectType.DssTypeReportDefinition,
                                                                                           EnumDSSSourceFlags.DssSourceDefault, null, 0, 0);


                IDSSReportInstance oReportInstance = oReportSource.ExecuteDefinition(oReportDef, EnumDSSReportActions.DssActionExecuteSQL, EnumDSSReportFlags.DssReportRunSynch, null, 0, 0);

                //IDSSReportInstance oReportInstance = oReportSource.NewInstance(oReportDef);
                //oReportSource.Execute(oReportInstance, EnumDSSReportActions.DssActionGenerateSQL, EnumDSSReportFlags.DssReportLocalOnly,null,0,0);
                //oReportSource.GenerateSQL(oReportInstance,EnumDSSReportFlags.DssReportCacheDefault,null,0,0);

                int i = 0;
                while ((int)(oReportInstance.State & EnumDSSReportStates.DssActionGenerateSQLDone) != 2)
                {
                    Thread.Sleep(100);
                    i++;
                    if (i == 10)
                    {
                        break;
                    }
                }

                Console.WriteLine(i);

                if (i != 10)
                {
                    foreach (IDSSSQL sql in oReportInstance.SQLs)
                    {
                        Console.WriteLine(sql.DisplaySQL);
                    }
                }

                con1.close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message.ToString());
            }
        }
コード例 #3
0
ファイル: Form_Metric.cs プロジェクト: espressojp/mstr
        // メトリックの定義情報の抽出
        private void button1_Click(object sender, EventArgs e)
        {
            string metricGuid = "67407E8F4B7C8EC6791C8D9CC41B8249";

            try
            {
                MSTRConn con1 = new MSTRConn();

                IDSSSession oSession = con1.getSession();

                IDSSSource oSource = oSession.ObjectSource;

                IDSSSearch oSearch = (DSSCOMMasterLib.IDSSSearch)oSource.NewObject(EnumDSSObjectType.DssTypeSearch, EnumDSSSourceFlags.DssSourceDefault, null);

                IDSSObjectInfo oInfo  = oSource.FindObject(metricGuid, EnumDSSObjectType.DssTypeMetric, EnumDSSSourceFlags.DssSourceDefault, null, 0, 0);
                IDSSMetric     metric = (IDSSMetric)oInfo;

                // 1. Expression
                Console.WriteLine("Formula: " + metric.Expression.Text);


                // 2. Filter
                IDSSFilter filter = (IDSSFilter)metric.Conditionality.Filter;
                if (filter != null)
                {
                    Console.WriteLine("Condition: " + metric.Conditionality.Filter.Expression.Text);
                }

                // 3. Level
                string key;

                for (int i = 0; i < metric.Dimensionality.Count(); i++)
                {
                    key = "K" + i.ToString();

                    IDSSDimty ab = metric.Dimensionality;

                    // Base report level
                    if (metric.Dimensionality.Item(key).UnitType.Equals(EnumDSSDimtyUnitType.DssDimtyUnitTypeReportBaseLevel))
                    {
                        Console.WriteLine("Report Level / "
                                          + metric.Dimensionality.Item(key).Filtering.ToString()
                                          + " / "
                                          + metric.Dimensionality.Item(key).GroupBy.ToString());
                    }
                    // attribute
                    else if (metric.Dimensionality.Item(key).UnitType.Equals(EnumDSSDimtyUnitType.DssDimtyUnitTypeAttribute))
                    {
                        Console.WriteLine(((IDSSAttribute)metric.Dimensionality.Item(key).Target).Info.Name
                                          + " / "
                                          + metric.Dimensionality.Item(key).Filtering.ToString()
                                          + " / "
                                          + metric.Dimensionality.Item(key).GroupBy.ToString());
                    }
                    // hierarchy
                    else if (metric.Dimensionality.Item(key).UnitType.Equals(EnumDSSDimtyUnitType.DssDimtyUnitTypeDimension))
                    {
                        Console.WriteLine(((IDSSDimension)metric.Dimensionality.Item(key).Target).Info.Name
                                          + " / "
                                          + metric.Dimensionality.Item(key).Filtering.ToString()
                                          + " / "
                                          + metric.Dimensionality.Item(key).GroupBy.ToString());
                    }
                    else
                    {
                        // DssDimtyUnitTypeRole
                    }
                }


                // 4. Aggregation
                //Console.WriteLine(metric.Subtotals.Count());

                foreach (IDSSMetricSubtotal sub in metric.Subtotals)
                {
                    // Console.WriteLine(sub.Name);
                    switch (sub.Name)
                    {
                    case "合計":
                        Console.WriteLine("Total: " + metric.Subtotals.Item("合計").Implementation.Info.Name);
                        break;

                    case "集計":
                        Console.WriteLine("Aggregation:" + metric.Subtotals.Item("集計").Implementation.Info.Name);
                        break;
                    }
                }

                // 5. Transfomation
                oSearch.Types.Clear();
                oSearch.Types.Add(EnumDSSObjectType.DssTypeRole);
                oSearch.UsedBy.Add(oInfo);
                oSearch.Domain = EnumDSSSearchDomain.DssSearchProject;

                foreach (IDSSRole oRole in oSource.ExecuteSearch(oSearch, 0, null, null, 0, 0))
                {
                    Console.WriteLine("Transformation:" + oRole.Info.Name);
                }

                con1.close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message.ToString());
            }
        }