private TableCellType CreateHeaderTableCell(ReportColumn field)
        {
            var headerTableCell = new TableCellType();

            headerTableCell.Items = new object[] { CreateHeaderTableCellReportItems(field) };
            return(headerTableCell);
        }
        private ReportItemsType CreateHeaderTableCellReportItems(ReportColumn field)
        {
            var headerTableCellReportItems = new ReportItemsType();

            headerTableCellReportItems.Items = new object[] { CreateHeaderTableCellTextbox(field) };
            return(headerTableCellReportItems);
        }
        public void Constructor_throws_InvalidArgumentException_when_element_name_is_not_ColData()
        {
            var xml = ColDataXML();

            xml.Name = "RowData";
            var column = new ReportColumn(xml);
        }
Exemple #4
0
        public void TestCreateEntity( )
        {
            var c = new Report
            {
                Name = "EDC"
            };

            c.Save( );

            var p = new ReportColumn
            {
                Name            = "Col1",
                ColumnForReport = c
            };

            p.Save( );

            Assert.IsNotNull(c);
            Assert.IsNotNull(p);

            p.Delete( );
            c.Delete( );

            p = (ReportColumn)Entity.Get(p.Id, false);
            c = (Report)Entity.Get(c.Id, false);

            Assert.IsNull(p);
            Assert.IsNull(c);
        }
Exemple #5
0
        public DataResponse <bool> DeleteReportColumn(int ColumnId)
        {
            var response = new DataResponse <bool>();

            try
            {
                base.DBInit();
                ReportColumn reportColumn = DBEntity.ReportColumns.Find(ColumnId);
                try
                {
                    DBEntity.ReportColumns.Remove(reportColumn);
                    if (DBEntity.SaveChanges() > 0)
                    {
                        response.Status  = DataResponseStatus.OK;
                        response.Message = "Successfully Deleted.";
                        response.Model   = true;
                    }
                }
                catch (DbUpdateException ex)
                {
                    response.Status  = DataResponseStatus.InternalServerError;
                    response.Message = "There are some releted item in database, please delete those first.";
                    response.Model   = false;
                }
            }
            catch (Exception ex)
            {
                ex.Log();
            }
            finally
            {
                base.DBClose();
            }
            return(response);
        }
Exemple #6
0
        public void Equals_GivenTwoNotEqualsObjects_EqualsMethodReturnFalse()
        {
            ReportColumn a = null;
            ReportColumn b = null;

            Assert.IsTrue(a == b);

            //compare with null
            Assert.IsFalse(originalColumn.Equals(null));
            Assert.IsFalse(originalColumn == null);
            Assert.IsFalse(null == originalColumn);

            //compare objects with different types.
            Assert.IsFalse(originalColumn.Equals(new object()));
            Assert.IsFalse(originalColumn.Equals("String object"));
            Assert.IsFalse(originalColumn.Equals(42));

            //compare objects with same type
            Assert.IsFalse(originalColumn.Equals(differentColumn));
            Assert.IsFalse(originalColumn.Equals((object)differentColumn));
            Assert.IsFalse(originalColumn == differentColumn);
            Assert.IsTrue(originalColumn != differentColumn);

            //compare objects with different titles
            a = new ReportColumn()
            {
                Title = "ColumnA",
                SqlValueExpression = "Exp"
            };

            b = new ReportColumn()
            {
                Title = "ColumnB",
                SqlValueExpression = "Exp"
            };

            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(b.Equals(a));
            Assert.IsFalse(a == b);
            Assert.IsFalse(b == a);

            //compare objects with different SqlValueExpressions
            a = new ReportColumn()
            {
                Title = "Column",
                SqlValueExpression = "ExpA"
            };

            b = new ReportColumn()
            {
                Title = "Column",
                SqlValueExpression = "ExpB"
            };

            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(b.Equals(a));
            Assert.IsFalse(a == b);
            Assert.IsFalse(b == a);
        }
Exemple #7
0
        public void SqlAlias_GivenSingleWordTitle_ReturnFormattedValue()
        {
            ReportColumn reportColumn = new ReportColumn()
            {
                Title = "Something"
            };

            Assert.That(reportColumn.SqlAlias, Is.EqualTo("Something"));
        }
Exemple #8
0
        public void SqlAlias_GivenMultipleWordsTitle_ReturnFormattedValue()
        {
            ReportColumn reportColumn = new ReportColumn()
            {
                Title = "Column Title"
            };

            Assert.That(reportColumn.SqlAlias, Is.EqualTo("ColumnTitle"));
        }
Exemple #9
0
        public virtual object GetCellItemValue(ReportColumn rdColumn, int rowIndex)
        {
            object toRet = null;

            DataRowView dataRowView = dataView[rowIndex];

            toRet = dataRowView[rdColumn.Name];

            return(toRet);
        }
Exemple #10
0
        public static Type GetRootTable(ReportColumn reportColumn)
        {
            var databindingTable = GetDatabindingTableAttribute(reportColumn);

            if (null == databindingTable)
            {
                return(null);
            }
            return(databindingTable.RootTable);
        }
Exemple #11
0
        public void TestRelationshipEnumeratorForReadableRead( )
        {
            var deleteList = new List <EntityRef>( );

            try
            {
                var edc = new Report
                {
                    Name = "EDC"
                };
                edc.Save( );
                deleteList.Add(edc);

                var jude = new ReportColumn
                {
                    Name            = "Jude",
                    Alias           = "edc:jude",
                    ColumnForReport = edc
                };
                jude.Save( );
                deleteList.Add(jude);

                var pete = new ReportColumn
                {
                    Name            = "Pete",
                    Alias           = "edc:pete",
                    ColumnForReport = edc
                };
                pete.Save( );
                deleteList.Add(pete);

                Assert.AreEqual(2, edc.ReportColumns.Count);

                IEnumerator <ReportColumn> inumerator = edc.ReportColumns.GetEnumerator( );

                var writableEdc = Entity.Get <Report>(edc.Id, true);

                writableEdc.ReportColumns.Clear( );
                writableEdc.Save( );

                int count = 0;
                while (inumerator.MoveNext( ))
                {
                    count++;
                    ReportColumn referenced = inumerator.Current;
                    Assert.IsNotNull(referenced, "The referenced object is still there.");
                }

                Assert.AreEqual(2, count, "We still have two things in the iterator.");
            }
            finally
            {
                Entity.Delete(deleteList);
            }
        }
Exemple #12
0
 /// <summary>
 /// Given a list of columns, returns true if the specified other column is redundant in
 /// terms of specifying a unique index on a table.
 /// </summary>
 protected static bool StartsWith(IEnumerable <ReportColumn> list, ReportColumn key)
 {
     foreach (ReportColumn id in list)
     {
         if (key.Table == id.Table && key.Column.StartsWith(id.Column))
         {
             return(true);
         }
     }
     return(false);
 }
        private static void CheckScriptColumn <TArg>(ReportColumn column, string colName, string script, ReportNode node) where TArg : class, IEntity
        {
            Assert.AreEqual(colName, column.Name, "Col name");
            Assert.IsTrue(column.ColumnIsHidden == false, "Is hidden");
            Assert.IsTrue(column.ColumnExpression.Is <EDC.ReadiNow.Model.ScriptExpression>(), "Is script expr");
            Assert.IsTrue(column.ColumnExpression.ReportExpressionResultType.Is <TArg>());
            var nameExpr = column.ColumnExpression.As <EDC.ReadiNow.Model.ScriptExpression>();

            Assert.IsTrue(nameExpr.ReportScript == script);
            Assert.AreEqual(node.Id, nameExpr.SourceNode.Id);
        }
Exemple #14
0
        public virtual object GetCellItemValue(ReportColumn rdColumn, int rowIndex)
        {
            object toRet = null;

            DataGridViewRow  dgvRow  = dataGridView.Rows[rowIndex];
            DataGridViewCell dgvCell = dgvRow.Cells[rdColumn.Name];

            toRet = dgvCell.Value;

            return(toRet);
        }
 public static ReportColumnName GetColumnName(ReportColumn column)
 {
     for (var i = 0; i < Collection.Count; i++)
     {
         if (Collection[i].Column == column)
         {
             return(Collection[i]);
         }
     }
     return(null);
 }
Exemple #16
0
        public ColumnInfo GetColumnInfo(ReportColumn reportColumn)
        {
            Type   lastTable;
            String columnName;

            Resolve(reportColumn.Table, reportColumn.Column, out lastTable, out columnName);
            ColumnInfo result = GetColumnInfo(lastTable, columnName);

            result.ReportColumn = reportColumn;
            return(result);
        }
        private static void CheckFieldColumn <TArg>(ReportColumn column, string colName, string fieldName, ReportNode node) where TArg : class, IEntity
        {
            Assert.AreEqual(colName, column.Name, "Col name");
            Assert.IsTrue(column.ColumnIsHidden == false, "Is hidden");
            Assert.IsTrue(column.ColumnExpression.Is <FieldExpression>(), "Is field expr");
            Assert.IsTrue(column.ColumnExpression.ReportExpressionResultType.Is <TArg>(), "Correct column type");
            var nameExpr = column.ColumnExpression.As <FieldExpression>();

            Assert.AreEqual(fieldName, nameExpr.FieldExpressionField.Name, "Correct field");
            Assert.AreEqual(node.Id, nameExpr.SourceNode.Id);
        }
        public void Import_Nested_SimplifiedReport( )
        {
            IEntityRepository     repository = Factory.EntityRepository;
            IEntityXmlImporter    importer   = Factory.EntityXmlImporter;
            EntityXmlImportResult result;
            string xml;
            long   entityId;
            Report report;

            // Import
            using (RunAsImportExportRole( ))
                using (Stream stream = GetStream("SimplifiedReport.xml"))
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        xml    = reader.ReadToEnd( );
                        result = importer.ImportXml(xml, EntityXmlImportSettings.Default);
                    }

            // Check
            Assert.That(result, Is.Not.Null);
            Assert.That(result.RootEntities, Is.Not.Null);
            entityId = result.RootEntities.Single( );

            report = repository.Get <Report>(entityId);
            try
            {
                Assert.That(report, Is.Not.Null);
                Assert.That(report.Name, Is.EqualTo("Simple herb"));
                ResourceReportNode rootNode = report.RootNode?.As <ResourceReportNode>( );
                Assert.That(rootNode, Is.Not.Null, "Root node");
                Assert.That(rootNode.ResourceReportNodeType, Is.Not.Null);
                Assert.That(rootNode.ResourceReportNodeType.Alias, Is.EqualTo("test:herb"));
                Assert.That(report.ReportColumns, Has.Count.EqualTo(1), "ReportColumns");
                ReportColumn column = report.ReportColumns.First( );
                Assert.That(column, Is.Not.Null, "Column");
                Assert.That(column.Name, Is.EqualTo("AA_Herb"));
                Assert.That(column.ColumnIsHidden == true, Is.True, "ColumnIsHidden");
                FieldExpression fieldExpr = column.ColumnExpression?.As <FieldExpression>( );
                Assert.That(fieldExpr, Is.Not.Null, "FieldExpression");
                Assert.That(fieldExpr.FieldExpressionField.Alias, Is.EqualTo("core:name"));
                Assert.That(fieldExpr.SourceNode?.Id, Is.EqualTo(rootNode?.Id), "SourceNode");
                Assert.That(column.ColumnGrouping, Has.Count.EqualTo(1), "ColumnGrouping");
                ReportRowGroup grouping = column.ColumnGrouping.First( );
                Assert.That(grouping, Is.Not.Null, "ColumnGrouping");
                Assert.That(grouping.GroupingPriority, Is.EqualTo(1), "GroupingPriority");
            }
            finally
            {
                Entity.Delete(entityId);
            }
        }
Exemple #19
0
        public bool ContainsColumn(ReportColumn rColumn)
        {
            bool toRet = false;

            foreach (ReportTableGroup rtGroup in this)
            {
                if (rtGroup.ColumnGrouping.Contains(rColumn))
                {
                    toRet = true;
                    break;
                }
            }
            return(toRet);
        }
        /// <summary>
        /// Fill the Members list with VariableMember objects for each variable.
        /// </summary>
        private void FindVariableMembers()
        {
            this.columns = new List <IReportColumn>();

            AddExperimentFactorLevels();

            foreach (string fullVariableName in this.VariableNames)
            {
                if (fullVariableName != string.Empty)
                {
                    this.columns.Add(ReportColumn.Create(fullVariableName, clock, storage.Writer, locator, events));
                }
            }
        }
Exemple #21
0
        // GET: Business/ReportColumns/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReportColumn reportColumn = db.ReportColumns.Find(id);

            if (reportColumn == null)
            {
                return(HttpNotFound());
            }
            return(View(reportColumn));
        }
Exemple #22
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static ReportColumnModel Update(ReportColumnModel model)
        {
            var entity = new ReportColumn();

            // check validate parent column
            if (!ValidateUpdateColumn(model.Id, model.Width, model.ParentId))
            {
                return(null);
            }
            // fill entity
            model.FillEntity(ref entity);

            return(new ReportColumnModel(ReportColumnServices.Update(entity)));
        }
        private static void CheckResourceExprColumn(ReportColumn column, string colName, ReportNode node, string expectedTypeName)
        {
            Assert.AreEqual(colName, column.Name, "Col name");
            Assert.IsTrue(column.ColumnIsHidden == false, "Is hidden");
            Assert.IsTrue(column.ColumnExpression.Is <EDC.ReadiNow.Model.ResourceExpression>(), "Is res expr");
            Assert.IsTrue(column.ColumnExpression.ReportExpressionResultType.Is <ResourceArgument>());
            var nameExpr = column.ColumnExpression.As <EDC.ReadiNow.Model.ResourceExpression>();

            Assert.AreEqual(node.Id, nameExpr.SourceNode.Id);

            var resourceArg = column.ColumnExpression.ReportExpressionResultType.As <ResourceArgument>();

            Assert.IsNotNull(resourceArg.ConformsToType, "Conforms to type");
            Assert.AreEqual(expectedTypeName, resourceArg.ConformsToType.Name, "Conforms to type");
        }
Exemple #24
0
        public ActionResult DeleteConfirmed(int id)
        {
            ReportColumn reportColumn = db.ReportColumns.Find(id);

            try
            {
                db.ReportColumns.Remove(reportColumn);
                db.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("Error", "There are some releted item in database, please delete those first");
                return(View("Delete", reportColumn));
            }
            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// Fill the Members list with VariableMember objects for each variable.
        /// </summary>
        private void FindVariableMembers()
        {
            this.columns = new List <IReportColumn>();

            AddExperimentFactorLevels();

            foreach (string fullVariableName in this.VariableNames)
            {
                if (fullVariableName != string.Empty)
                {
                    this.columns.Add(ReportColumn.Create(fullVariableName, clock, storage, locator, events));
                }
            }
            columnNames = columns.Select(c => c.Name);
            columnUnits = columns.Select(c => c.Units);
        }
Exemple #26
0
        public void Equals_Symmetric()
        {
            var x = new ReportColumn()
            {
                Title = "Column A",
                SqlValueExpression = "select 1"
            };
            var y = new ReportColumn()
            {
                Title = "Column A",
                SqlValueExpression = "select 1"
            };

            Assert.IsTrue(x.Equals(y) && y.Equals(x));
            Assert.IsTrue(x.GetHashCode() == y.GetHashCode());
        }
Exemple #27
0
        public void GetHashCode_GivenTwoEqualsObject_MethodReturEqualHashCodes()
        {
            var a = new ReportColumn()
            {
                Title = "ColumnA",
                SqlValueExpression = "Exp"
            };

            var b = new ReportColumn()
            {
                Title = "ColumnA",
                SqlValueExpression = "Exp"
            };

            Assert.That(a.GetHashCode(), Is.EqualTo(b.GetHashCode()));
        }
        private void parseHeader(string line)
        {
            string[] headerStrings = line.Split('\t');               // beolvasott header-ek
            numberOfColumns = headerStrings.Length;
            int columnCounter = 0;

            foreach (string headerItem in headerStrings)       // a beolvasott headerek sorban
            {
                ReportColumn rc = new ReportColumn();          // új report oszlop létrehozása
                rc.header = headerItem;                        // a címe a beolvasott címe

                if (headerDict.ContainsKey(headerItem.Trim())) // ha értelmezett a beolvasott header
                {
                    switch (headerDict[headerItem.Trim()])     // az adott oszlop típusa
                    {
                    case "t":
                        rc.type = columnType.Text;
                        break;

                    case "p":
                        rc.type = columnType.Percent;
                        break;

                    case "d":
                        rc.type = columnType.Date;
                        break;

                    case "c":
                        rc.type = columnType.Currency;
                        break;

                    case "n":
                        rc.type = columnType.Number;
                        break;
                    }
                }
                else
                {
                    rc.type = columnType.Unknown;                      // ha nem ismeri az adott oszlopot, akkor szövegként rakja ki
                }

                columns.Add(columnCounter, rc);
                columnCounter++;
            }

            Log.AddLog("A fejléc beolvasása kész. Oszlopok száma: " + columns.Count);
        }
Exemple #29
0
        public static List <ReportColumn> SelectReportDataYearly(string program, int semester, int year, bool semesterReport)
        {
            SqlConnection conn = DbConn.GetConnection();

            List <ReportColumn> reportData = new List <ReportColumn>();

            try
            {
                conn.Open();
                SqlCommand selectCommand = new SqlCommand("mcftacademics.dbo.SelectReportData2", conn);
                selectCommand.CommandType = System.Data.CommandType.StoredProcedure;
                selectCommand.Parameters.AddWithValue("@program", program);
                selectCommand.Parameters.AddWithValue("@semester", semester);
                selectCommand.Parameters.AddWithValue("@year", year);
                SqlDataReader reader = selectCommand.ExecuteReader();

                //loop through the resultset
                while (reader.Read())
                {
                    var studentId    = (int)reader["studentId"];
                    var firstName    = (string)reader["firstName"];
                    var lastName     = (string)reader["lastName"];
                    var grade        = (decimal)reader["grade"];
                    var supplemental = (bool)reader["isSupplemental"];
                    var courseId     = (int)reader["courseId"];
                    var name         = (string)reader["name"];
                    var prog         = (string)reader["program"];
                    var courseCode   = (string)reader["courseCode"];
                    var startDate    = (DateTime)reader["startDate"];
                    var endDate      = (DateTime)reader["endDate"];

                    ReportColumn reportRecord = new ReportColumn(studentId, firstName, lastName, grade, supplemental, courseId, name, prog, courseCode, startDate, endDate, semester, semesterReport);

                    reportData.Add(reportRecord);
                }
                return(reportData);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
            }
            return(reportData);
        }
Exemple #30
0
        /// <summary>
        /// Create DataTable for visible columns of DataGridView
        /// </summary>
        /// <param name="dgv"></param>
        private void CreateHeaders()
        {
            //add columns to table
            for (int colIndex = 0; colIndex < Columns.Count; colIndex++)
            {
                ReportColumn rColumn    = Columns[colIndex];
                Type         columnType = rColumn.ValueType;

                if (rColumn is ReportDataColumn)
                {
                    ReportDataColumn rdColumn = rColumn as ReportDataColumn;

                    //Replace True/False to "+/-"
                    if (rdColumn.ValueType == typeof(bool) || rdColumn.ValueType == null)
                    {
                        columnType = typeof(string);
                    }
                    else if (rdColumn.ValueType == typeof(System.Drawing.Image) || rdColumn.ValueType == typeof(System.Drawing.Bitmap))
                    {
                        columnType = typeof(byte[]);
                    }

                    else if (!String.IsNullOrEmpty(rdColumn.DefaultCellStyle.Format))
                    {
                        columnType = typeof(string);
                    }
                }
                else if (rColumn is ReportHyperlinkColumn)
                {
                    if (rColumn.ValueType == typeof(Uri))
                    {
                        columnType = typeof(string);
                    }
                    else if (rColumn.ValueType != typeof(string))
                    {
                        throw new ApplicationException("HyperLinkColumn should have content type System.String or System.Uri.");
                    }
                }
                else
                {
                    throw new ApplicationException("Unknown ReportColumn type.");
                }

                _report.ExportedTable.Columns.Add(rColumn.Name, columnType);
            }
        }
        //public decimal GetTotalProfit()
        //{
        //    decimal retVal = 0;
        //    foreach (ReportSection section in sections)
        //    {
        //        for (int i = 0; i < section.NumRows(); i++)
        //        {
        //            string rowName = section.GetRow(i).Name;
        //            if (!rowName.Equals(section.Type.Name))
        //            {
        //                retVal += GetValue("Total Profit", rowName);
        //            }
        //        }
        //    }
        //    return retVal;
        //}
        //public string GetMostProfitableItem()
        //{
        //    string retVal = "";
        //    decimal highestProfit = -1;
        //    foreach (ReportSection section in sections)
        //    {
        //        for (int i = 0; i < section.NumRows(); i++)
        //        {
        //            string rowName = section.GetRow(i).Name;
        //            if (!rowName.Equals(section.Type.Name))
        //            {
        //                decimal thisProfit = GetValue("Total Profit", rowName);
        //                if (thisProfit > highestProfit)
        //                {
        //                    highestProfit = thisProfit;
        //                    retVal = section.GetRow(i).Text;
        //                }
        //            }
        //        }
        //    }
        //    return retVal.Trim();
        //}
        /// <summary>
        /// Initialise column array, set names and header text, etc.
        /// </summary>
        /// <param name="parameters"></param>
        public override void InitColumns(Dictionary<string, object> parameters)
        {
            bool[] columnsVisible = null;
            int totColumns = 0;
            bool paramsOk = true;

            // Extract parameters...
            try
            {
                for (int i = 0; i < _expectedParams.Length; i++)
                {
                    object paramValue = null;
                    paramsOk = paramsOk && parameters.TryGetValue(_expectedParams[i], out paramValue);
                    if (_expectedParams[i].Equals("StartDate")) _startDate = (DateTime)paramValue;
                    if (_expectedParams[i].Equals("EndDate")) _endDate = (DateTime)paramValue;
                    if (_expectedParams[i].Equals("RegionIDs")) _regionIDs = (List<long>)paramValue;
                    if (_expectedParams[i].Equals("StationIDs")) _stationIDs = (List<long>)paramValue;
                    if (_expectedParams[i].Equals("ItemIDs")) _itemIDs = (List<int>)paramValue;
                    if (_expectedParams[i].Equals("ColumnsVisible")) columnsVisible = (bool[])paramValue;
                    if (_expectedParams[i].Equals("UseMostRecentBuyPrice")) _useMostRecentBuyPrice = (bool)paramValue;
                    if (_expectedParams[i].Equals("RestrictedCostCalc")) _restrictedCostCalc = (bool)paramValue;
                    if (_expectedParams[i].Equals("FinanceAccessParams"))
                        _financeAccessParams = (List<FinanceAccessParams>)paramValue;
                    if (_expectedParams[i].Equals("AssetAccessParams"))
                        _assetAccessParams = (List<AssetAccessParams>)paramValue;
                    if (_expectedParams[i].Equals("TradedItemsOnly")) _tradedItemsOnly = (bool)paramValue;
                }
            }
            catch (Exception)
            {
                paramsOk = false;
            }

            if (!paramsOk)
            {
                // If parameters are wrong in some way then throw an exception.
                string message = "Unable to parse parameters for report '" +
                    _title + "'.\r\nExpected";
                for (int i = 0; i < _expectedParams.Length; i++)
                {
                    message = message + " " + _expectedParams[i] + (i == _expectedParams.Length - 1 ? "." : ",");
                }
                UpdateStatus(0, 0, "Error", message, false);
                throw new EMMAReportingException(ExceptionSeverity.Error, message);
            }

            _subtitle = "Between " + _startDate.ToShortDateString() + " " + _startDate.ToShortTimeString() +
                " and " + _endDate.ToShortDateString() + " " + _endDate.ToShortTimeString();

            totColumns = 0;
            for (int i = 0; i < columnsVisible.Length; i++)
            {
                if (columnsVisible[i]) totColumns++;
            }

            try
            {
                _columns = new ReportColumn[totColumns];

                UpdateStatus(0, totColumns, "", "Building Report Columns...", false);

                // Iterate through the columnsVisible array. Add any columns marked as visible to the report.
                int colNum = 0;
                for (int i = 0; i < columnsVisible.Length; i++)
                {
                    if (columnsVisible[i])
                    {
                        _columns[colNum] = new ReportColumn(_allColumnNames[i], _allColumnNames[i]);
                        if (_allColumnNames[i].Contains("%"))
                        {
                            _columns[colNum].DataType = ReportDataType.Percentage;
                            _columns[colNum].SectionRowBehavior = SectionRowBehavior.Average;
                        }
                        else if (_allColumnNames[i].Equals("Units Bought") ||
                            _allColumnNames[i].Equals("Units Sold"))
                        {
                            _columns[colNum].DataType = ReportDataType.Number;
                            _columns[colNum].SectionRowBehavior = SectionRowBehavior.Blank;
                        }
                        else if (_allColumnNames[i].Contains("Fees") || _allColumnNames[i].Contains("Costs") ||
                            _allColumnNames[i].Contains("Profit"))
                        {
                            _columns[colNum].DataType = ReportDataType.ISKAmount;
                            _columns[colNum].SectionRowBehavior = SectionRowBehavior.Sum;
                        }
                        else
                        {
                            _columns[colNum].DataType = ReportDataType.ISKAmount;
                            _columns[colNum].SectionRowBehavior = SectionRowBehavior.Average;
                        }
                        colNum++;
                        UpdateStatus(colNum, totColumns, "", "", false);
                    }
                }

                UpdateStatus(0, 0, "", "Columns Complete", false);
            }
            catch (Exception ex)
            {
                throw new EMMAReportingException(ExceptionSeverity.Error, "Problem creating columns: " + ex.Message, ex);
            }
        }
        /*        public decimal TotalBuyValue()
        {
            decimal retVal = 0;

            foreach (ReportSection section in sections)
            {
                for (int i = 0; i < section.NumRows(); i++)
                {
                    string rowName = section.GetRow(i).Name;
                    if (!rowName.Equals(section.Type.Name))
                    {
                        retVal += GetValue("Total Units", rowName) * GetValue("Average Buy Price", rowName);
                    }
                }
            }

            return retVal;
        }
        */
        /// <summary>
        /// Initialise column array, set names and header text, etc.
        /// </summary>
        /// <param name="parameters"></param>
        public override void InitColumns(Dictionary<string, object> parameters)
        {
            bool[] columnsVisible = null;
            int totColumns = 0;
            bool paramsOk = true;

             // Extract parameters...
            try
            {
                for (int i = 0; i < _expectedParams.Length; i++)
                {
                    object paramValue = null;
                    paramsOk = paramsOk && parameters.TryGetValue(_expectedParams[i], out paramValue);
                    if (_expectedParams[i].Equals("ColumnsVisible")) columnsVisible = (bool[])paramValue;
                    if (_expectedParams[i].Equals("ValueRegion")) _valueRegionID = (int)paramValue;
                    if (_expectedParams[i].Equals("StationIDs")) _stationsIDs = (List<long>)paramValue;
                    if (_expectedParams[i].Equals("RegionIDs")) _regionIDs = (List<long>)paramValue;
                    if (_expectedParams[i].Equals("IncludeInTransit")) _includeInTransit = (bool)paramValue;
                    if (_expectedParams[i].Equals("IncludeContainers")) _includeContainers = (bool)paramValue;
                    if (_expectedParams[i].Equals("AssetAccessParams")) _assetAccessParams =
                        (List<AssetAccessParams>)paramValue;
                    if (_expectedParams[i].Equals("FinanceAccessParams")) _financeAccessParams =
                        (List<FinanceAccessParams>)paramValue;
                }
            }
            catch (Exception)
            {
                paramsOk = false;
            }

            if (!paramsOk)
            {
                // If parameters are wrong in some way then throw an exception.
                string message = "Unable to parse parameters for report '" +
                    _title + "'.\r\nExpected";
                for (int i = 0; i < _expectedParams.Length; i++)
                {
                    message = message + " " + _expectedParams[i] + (i == _expectedParams.Length - 1 ? "." : ",");
                }
                UpdateStatus(0, 0, "Error", message, false);
                throw new EMMAReportingException(ExceptionSeverity.Error, message);
            }

            _subtitle = "Sell prices based upon data for " + Regions.GetRegionName(_valueRegionID);
            totColumns = 0;
            for (int i = 0; i < columnsVisible.Length; i++)
            {
                if(columnsVisible[i]) totColumns++;
            }

            try
            {
                _columns = new ReportColumn[totColumns];

                UpdateStatus(0, totColumns, "", "Building Report Columns...", false);

                // Iterate through the columnsVisible array. Add any columns marked as visible to the report.
                int colNum = 0;
                for (int i = 0; i < columnsVisible.Length; i++)
                {
                    if (columnsVisible[i])
                    {
                        _columns[colNum] = new ReportColumn(_allColumnNames[i], _allColumnNames[i]);
                        if (_allColumnNames[i].Contains("Units"))
                        {
                            _columns[colNum].DataType = ReportDataType.Number;
                            _columns[colNum].SectionRowBehavior = SectionRowBehavior.Sum;
                        }
                        else if (_allColumnNames[i].Equals("Average Buy Price") ||
                            _allColumnNames[i].Equals("Est. Sell Price"))
                        {
                            _columns[colNum].DataType = ReportDataType.ISKAmount;
                            _columns[colNum].SectionRowBehavior = SectionRowBehavior.Blank;
                        }
                        else
                        {
                            _columns[colNum].DataType = ReportDataType.ISKAmount;
                            _columns[colNum].SectionRowBehavior = SectionRowBehavior.Sum;
                        }
                        colNum++;
                        UpdateStatus(colNum, totColumns, "", "", false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new EMMAReportingException(ExceptionSeverity.Error, "Problem creating columns: " + ex.Message, ex);
            }
        }
 public static Type GetRootTable(ReportColumn reportColumn)
 {
     var databindingTable = GetDatabindingTableAttribute(reportColumn);
     if (null == databindingTable)
     {
         return null;
     }
     return databindingTable.RootTable;
 }
Exemple #34
0
 public ColumnInfo GetColumnInfo(ReportColumn identifier)
 {
     return ColumnInfos[_columnIndexes[identifier]];
 }
 protected bool Equals(ReportColumn other)
 {
     return string.Equals(Name, other.Name) && string.Equals(Format, other.Format);
 }
Exemple #36
0
 private static void fillReportColumn(Worksheet ws, ReportColumn reportColumn, int columnIndex)
 {
     var colData = ws.Columns[columnIndex];
     var rowIndex = 12;
     ((Range) colData.Cells[rowIndex++, 1]).Value2 = reportColumn.Man;
     ((Range) colData.Cells[rowIndex++, 1]).Value2 = reportColumn.Woman;
 }
        private static string ExtractValue(ReportColumn reportColumn, Proposal proposal, bool forExport)
        {
            var result = string.Empty;

            if (!reportColumn.IsProperty)
            {
                var answer = proposal.Answers.Where(a => a.Question.Name == reportColumn.Name).FirstOrDefault();

                if (answer != null)
                {
                    result = answer.Answer;
                }
            }
            else
            {
                if (reportColumn.Name == StaticValues.Report_Submitted)
                {
                    result = proposal.IsSubmitted.ToString();
                }
                else if (reportColumn.Name == StaticValues.Report_Approved)
                {
                    result = proposal.IsApproved.ToString();
                }
                else if(reportColumn.Name == StaticValues.Report_Sequence)
                {
                    result = proposal.Sequence.ToString();
                }

                else if (reportColumn.Name == StaticValues.Report_Investigators)
                {
                    var sb = new StringBuilder();
                    foreach (var investigator in proposal.Investigators.OrderByDescending(a => a.IsPrimary))
                    {
                        var temp = new List<string>();
                        if(!forExport)
                        {
                            temp.Add(investigator.Name.Replace(" ", "&nbsp;"));
                        }
                        else
                        {
                            temp.Add(investigator.Name);
                        }
                        if(!string.IsNullOrEmpty(investigator.Position))
                        {
                            if (!forExport)
                            {
                                temp.Add(investigator.Position.Replace(" ", "&nbsp;"));
                            }
                            else
                            {
                                temp.Add(investigator.Position);
                            }
                        }
                        if(!string.IsNullOrEmpty(investigator.Institution))
                        {
                            if (!forExport)
                            {
                                temp.Add(investigator.Institution.Replace(" ", "&nbsp;"));
                            }
                            else
                            {
                                temp.Add(investigator.Institution);
                            }
                        }
                        if(investigator.IsPrimary)
                        {
                            temp.Add("Primary");
                        }

                        if (forExport)
                        {
                            sb.AppendLine(string.Join("/", temp));
                        }
                        else
                        {
                            sb.AppendLine(string.Join("/", temp));
                        }

                    }
                    result = sb.ToString();
                }
                else if (reportColumn.Name == StaticValues.Report_Denied)
                {
                    result = proposal.IsDenied.ToString();
                }
                else if (reportColumn.Name == StaticValues.Report_RequestedAmount)
                {
                    result = proposal.RequestedAmount.ToString();
                }
                else if (reportColumn.Name == StaticValues.Report_AwardedAmount)
                {
                    result = proposal.ApprovedAmount.ToString();
                }
                else if(reportColumn.Name == StaticValues.Report_Comments)
                {
                    var comments = proposal.Comments.FirstOrDefault();
                    if (comments != null)
                    {
                        result = comments.Text;
                    }
                }
            }

            return result;
        }
Exemple #38
0
 public Object GetValue(int rowIndex, ReportColumn identifier)
 {
     return GetValue(rowIndex, _columnIndexes[identifier]);
 }
 public static DatabindingTableAttribute GetDatabindingTableAttribute(ReportColumn reportColumn)
 {
     return (DatabindingTableAttribute)TypeDescriptor.GetAttributes(reportColumn.Table)[typeof(DatabindingTableAttribute)];
 }
Exemple #40
0
 /// <summary>
 /// Given a list of columns, returns true if the specified other column is redundant in
 /// terms of specifying a unique index on a table.
 /// </summary>
 protected static bool StartsWith(IEnumerable<ReportColumn> list, ReportColumn key)
 {
     foreach (ReportColumn id in list)
     {
         if (key.Table == id.Table && key.Column.StartsWith(id.Column))
         {
             return true;
         }
     }
     return false;
 }
Exemple #41
0
 public ColumnInfo GetColumnInfo(ReportColumn reportColumn)
 {
     Type lastTable;
     String columnName;
     Resolve(reportColumn.Table, reportColumn.Column, out lastTable, out columnName);
     ColumnInfo result = GetColumnInfo(lastTable, columnName);
     result.ReportColumn = reportColumn;
     return result;
 }
Exemple #42
0
        public static void BuildSvedProf(IBackgroundContext context, MonthAccountParams args)
        {
            var dateBegin = args.DateBegin;
            var dateEnd = args.DateEnd;
            var miacCode = args.LpuCode;
            using (var dataConext = new VistaMedDataContext(context))
            {
                var smpBills = (from b in dataConext.VistaMed.Accounts
                                where b.Date >= args.DateBegin.AddDays(15) && b.Date < args.NextMonthBegin.AddDays(15)
                                && b.Contract != null && b.Contract.RbFinance != null
                                && b.Contract.RbFinance.Name.ToLower() == "омс"
                                    && (from a in b.AccountItems
                                        from s in dataConext.VistaMed.RbServices
                                        where a.ServiceId == s.Id
                                        && s.Code.StartsWith("062")
                                        select a).Any()
                                select b).ToList();

                smpBills = smpBills.Where(x => args.IsValidAccountNumber(x.Number)
                    && !x.Number.StartsWith(PlanExecution.ReserveAccountName)).ToList();

               if (smpBills.Count == 0)
                    context.ReportError(@"Счета ДД за период с {0} по {1} не найдены", dateBegin, dateEnd);
                else
                {
                    var excel = new Application();
                    excel.Visible = true;

                    var plans = loadPlans(excel);
                    var templateName = Utils.GetReportFileName(@"SvedProf.xls");

                    if (File.Exists(templateName))
                    {
                        var newDoc = excel.Workbooks.Add(templateName);
                        excel.ScreenUpdating = false;

                        var ws = ((Worksheet) newDoc.Worksheets[1]);
                        newDoc.Names.Item(@"ДатаНачала").RefersToRange.Value2 = dateBegin;
                        newDoc.Names.Item(@"ДатаКонца").RefersToRange.Value2 = dateEnd;
                        newDoc.Names.Item(@"ДатаОтчета").RefersToRange.Value2 = DateTime.Today;
                        newDoc.Names.Item(@"ОтчетныйПериод").RefersToRange.Value2 = Utils.GetPeriodName(dateBegin, dateEnd);

                        var lpu = dataConext.VistaMed.Organisations.FirstOrDefault(x => x.MiacCode == miacCode);
                        if (lpu != null)
                        {
                            newDoc.Names.Item("ЛПУ").RefersToRange.Value2 = lpu.FullName;
                            newDoc.Names.Item("ФИОРуководителя").RefersToRange.Value2 = lpu.Chief;
                            newDoc.Names.Item("ФИОГлавбуха").RefersToRange.Value2 = lpu.Accountant;
                        }

                        var reportColumn = new ReportColumn();
                        reportColumn.Man = plans.Sum(x => x.Man);
                        reportColumn.Woman = plans.Sum(x => x.Woman);
                        fillReportColumn(ws, reportColumn, 3);

                        reportColumn = new ReportColumn();
                        reportColumn.Man = plans.Where(y => y.Month == dateEnd.Month).Sum(x => x.Man);
                        reportColumn.Woman = plans.Where(y => y.Month == dateEnd.Month).Sum(x => x.Woman);
                        fillReportColumn(ws, reportColumn, 7);

                        var allevents = (from b in smpBills
                            from a in b.AccountItems
                            where !a.Deleted && a.Event != null && a.Event.Client != null
                            group a by a.Event
                            into e
                            select new {Event = e.Key, Client = e.Key.Client, Summa = e.Sum(x => x.Sum)}).ToList();

                        var man = (from e in allevents where e.Client.Sex == 1 select e).ToList();
                        var woman = (from e in allevents where e.Client.Sex == 2 select e).ToList();

                        reportColumn = new ReportColumn();
                        reportColumn.Man = man.Sum(x => x.Summa);
                        reportColumn.Woman = woman.Sum(x => x.Summa);
                        fillReportColumn(ws, reportColumn, 8);

                        reportColumn = new ReportColumn();
                        reportColumn.Man = man.Count();
                        reportColumn.Woman = woman.Count();
                        fillReportColumn(ws, reportColumn, 9);

                        excel.ScreenUpdating = true;
                        ws.Activate();
                    }
                }
            }
        }
        /// <summary>
        /// Initialise column array, set names and header text, etc.
        /// </summary>
        /// <param name="parameters"></param>
        public override void InitColumns(Dictionary<string, object> parameters)
        {
            bool[] columnsVisible = null;
            int totColumns = 0;
            bool paramsOk = true;

             // Extract parameters...
            try
            {
                for (int i = 0; i < _expectedParams.Length; i++)
                {
                    object paramValue = null;
                    paramsOk = paramsOk && parameters.TryGetValue(_expectedParams[i], out paramValue);
                    if (_expectedParams[i].Equals("ColumnsVisible")) columnsVisible = (bool[])paramValue;
                    if (_expectedParams[i].Equals("ReportGroupID")) _reportGroupID = (int)paramValue;
                }
            }
            catch (Exception)
            {
                paramsOk = false;
            }

            if (!paramsOk)
            {
                // If parameters are wrong in some way then throw an exception.
                string message = "Unable to parse parameters for report '" +
                    _title + "'.\r\nExpected";
                for (int i = 0; i < _expectedParams.Length; i++)
                {
                    message = message + " " + _expectedParams[i] + (i == _expectedParams.Length - 1 ? "." : ",");
                }
                UpdateStatus(0, 0, "Error", message, false);
                throw new EMMAReportingException(ExceptionSeverity.Error, message);
            }

            totColumns = 0;
            for (int i = 0; i < columnsVisible.Length; i++)
            {
                if(columnsVisible[i]) totColumns++;
            }

            try
            {
                _columns = new ReportColumn[totColumns];

                UpdateStatus(0, totColumns, "", "Building Report Columns...", false);

                // Iterate through the columnsVisible array. Add any columns marked as visible to the report.
                int colNum = 0;
                for (int i = 0; i < columnsVisible.Length; i++)
                {
                    if (columnsVisible[i])
                    {
                        _columns[colNum] = new ReportColumn(_allColumnNames[i], _allColumnNames[i]);
                        if (_allColumnNames[i].Contains("%"))
                        {
                            _columns[colNum].DataType = ReportDataType.Percentage;
                        }
                        else if (_allColumnNames[i].Contains("Units"))
                        {
                            _columns[colNum].DataType = ReportDataType.Number;
                        }
                        else
                        {
                            _columns[colNum].DataType = ReportDataType.ISKAmount;
                        }

                        if (_allColumnNames[i].Contains("Total") || _allColumnNames[i].Equals("Profit"))
                        {
                            _columns[colNum].SectionRowBehavior = SectionRowBehavior.Sum;
                        }
                        else
                        {
                            _columns[colNum].SectionRowBehavior = SectionRowBehavior.Blank;
                        }
                        colNum++;
                        UpdateStatus(colNum, totColumns, "", "", false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new EMMAReportingException(ExceptionSeverity.Error, "Problem creating columns: " + ex.Message, ex);
            }
        }
 private ColumnSpec ConvertReportColumn(ReportColumn reportColumn)
 {
     var identifierPath = PropertyPath.Root;
     var databindingTableAttribute = GetDatabindingTableAttribute(reportColumn);
     var component = reportColumn.Table;
     string oldCaption = null;
     foreach (string part in reportColumn.Column.Parts)
     {
         PropertyPath propertyPath;
         if (part.StartsWith(AnnotationDef.ANNOTATION_PREFIX))
         {
             string annotationName = AnnotationDef.GetColumnDisplayName(part);
             if (component == typeof (DbProteinResult))
             {
                 propertyPath = PropertyPath.Root.Property("Replicate").Property(AnnotationDef.ANNOTATION_PREFIX + annotationName); // Not L10N
             }
             else
             {
                 propertyPath = PropertyPath.Root.Property(AnnotationDef.ANNOTATION_PREFIX + annotationName);
             }
             oldCaption = annotationName;
             component = typeof (string);
         }
         else if (RatioPropertyAccessor.IsRatioOrRdotpProperty(part))
         {
             propertyPath = null;
             if (component == typeof (DbPeptideResult))
             {
                 const string prefixPeptideRatio = "ratio_Ratio"; // Not L10N
                 string labelName, standardName;
                 if (part.StartsWith(prefixPeptideRatio))
                 {
                     if (TryParseLabelNames(part.Substring(prefixPeptideRatio.Length), out labelName, out standardName))
                     {
                         propertyPath = PropertyPath.Root.Property(RatioPropertyDescriptor.MakePropertyName(
                             RatioPropertyDescriptor.RATIO_PREFIX, labelName, standardName));
                     }
                 }
                 const string prefixPeptideRdotp = "rdotp_DotProduct"; // Not L10N
                 if (part.StartsWith(prefixPeptideRdotp))
                 {
                     if (TryParseLabelNames(part.Substring(prefixPeptideRdotp.Length), out labelName, out standardName))
                     {
                         propertyPath = PropertyPath.Root.Property(RatioPropertyDescriptor.MakePropertyName(
                             RatioPropertyDescriptor.RDOTP_PREFIX, labelName, standardName));
                     }
                 }
             }
             else if (component == typeof (DbPrecursorResult))
             {
                 const string prefixPrecursorRatio = "ratio_TotalAreaRatioTo"; // Not L10N
                 const string prefixPrecursorRdotp = "rdotp_DotProductTo"; // Not L10N
                 if (part.StartsWith(prefixPrecursorRatio))
                 {
                     propertyPath = PropertyPath.Root.Property(
                         RatioPropertyDescriptor.MakePropertyName(RatioPropertyDescriptor.RATIO_PREFIX, part.Substring(prefixPrecursorRatio.Length)));
                 }
                 else if (part.StartsWith(prefixPrecursorRdotp))
                 {
                     propertyPath = PropertyPath.Root.Property(
                         RatioPropertyDescriptor.MakePropertyName(RatioPropertyDescriptor.RDOTP_PREFIX,
                             part.Substring(prefixPrecursorRdotp.Length)));
                 }
             }
             else if (component == typeof (DbTransitionResult))
             {
                 const string prefixTransitionRatio = "ratio_AreaRatioTo"; // Not L10N
                 if (part.StartsWith(prefixTransitionRatio))
                 {
                     propertyPath = PropertyPath.Root.Property(
                         RatioPropertyDescriptor.MakePropertyName(RatioPropertyDescriptor.RATIO_PREFIX,
                         part.Substring(prefixTransitionRatio.Length)));
                 }
             }
             component = typeof (double);
             oldCaption = null;
             if (null == propertyPath)
             {
                 Trace.TraceWarning("Unable to parse ratio property {0}", part); // Not L10N
                 propertyPath = PropertyPath.Root.Property(part);
             }
         }
     //                else if (component == typeof (DbProteinResult) && part == "ResultFile")
     //                {
     //                    propertyPath = PropertyPath.Parse("Results!*.Value");
     //                }
         else
         {
             PropertyInfo property = component.GetProperty(part);
             if (null == property)
             {
                 Trace.TraceWarning("Could not find property {0}", part); // Not L10N
                 continue;
             }
             propertyPath = PropertyPath.Root.Property(part);
             foreach (DatabindingColumnAttribute databindingColumn in
                 property.GetCustomAttributes(typeof (DatabindingColumnAttribute), true))
             {
                 if (null != databindingColumn.Name)
                 {
                     propertyPath = PropertyPath.Parse(databindingColumn.Name);
                     break;
                 }
             }
             oldCaption = property.Name;
             foreach (QueryColumn attr in property.GetCustomAttributes(typeof (QueryColumn), true))
             {
                 oldCaption = attr.FullName ?? oldCaption;
             }
             component = property.PropertyType;
         }
         identifierPath = identifierPath.Concat(propertyPath);
     }
     var columnDescriptor = GetColumnDescriptor(databindingTableAttribute, identifierPath);
     if (null == columnDescriptor)
     {
         return new ColumnSpec(identifierPath);
     }
     var columnSpec = new ColumnSpec(columnDescriptor.PropertyPath);
     var newCaption = DataSchema.GetColumnCaption(columnDescriptor).InvariantCaption;
     if (oldCaption != newCaption)
     {
         columnSpec = columnSpec.SetCaption(oldCaption);
     }
     return columnSpec;
 }