コード例 #1
0
		/// <summary>
		/// Evaluates the infix expression using the values in the Hashtable.
		/// </summary>
		/// <remarks>
		/// This is the only publicly available method of the class, it is the entry point into for the user 
		/// into the parser.
		///
		/// Example usage:
		/// 
		/// using info.lundin.Math;
		/// using System;
		/// using System.Collections;
		///
		/// public class Test 
		/// {
		/// 	public static void Main( String[] args )
		/// 	{
		/// 		ExpressionParser parser = new ExpressionParser();
		/// 		Hashtable h = new Hashtable();
		///
		/// 		h.Add( "x", 1.ToString() );
		/// 		h.Add( "y", 2.ToString() );
		///
		///
		/// 		double result = parser.Parse( "xcos(y)", h );
		/// 		Console.WriteLine( “Result: {0}”, result );
		/// 	}
		/// }
		///
		/// </remarks>
		/// <param name="exp">the infix string expression to parse and evaluate.</param>
		/// <returns>a double value</returns>
		public double Parse(String exp, SpreadSheetView view) 
		{
			double ans = 0D;
			String tmp;
			Node tree;

			if( exp == null || exp.Equals("") )
			{
				throw new System.Exception("First argument to method eval is null or empty string");
			}
			else if( view == null )
			{
				throw new ArgumentNullException("View");  
			}
		 
			this.view	= view;

			tmp = skipSpaces( exp );
			//this.sb_init = tmp.Length;

			try
			{
		    
				if( trees.ContainsKey( tmp ) )
				{
					ans = toValue( (Node)trees[ tmp ] );   		
				}
				else
				{
					Syntax( tmp );
					
					//tree = parse( putMult( parseE( tmp ) ) ); 
					tree = parse(  parseE( tmp )  );
			
					ans = toValue( tree );

					trees.Add( tmp , tree );  
				}
	
				return ans;
		  
			}
			catch( Exception e )
			{ 
				throw new System.Exception( e.Message );
			}
		}
コード例 #2
0
        public static SpreadSheetView CreateView(SpreadSheetDocument doc)
        {
            SpreadSheetView view = new SpreadSheetView(doc, 2006, 2006);

            //
//			for (int i = 0; i <  12; i++)
//			{
//				Column col = new Column();
//				col.AllowUserValue = true;
//				col.Id = i.ToString();//String.Format("2006-Q{0}-{1}", (int)((i / 3) + 1), ((i % 12) + 1));
//				col.Name = String.Format("2006-Q{0}-{1}", (int)((i / 3) + 1), ((i % 12) + 1));
//				view.Columns.Add(col);
//			}

//
//			if (_testView == null)
//				_testView = view;

            return(view);
        }
コード例 #3
0
ファイル: ExpressionParser.cs プロジェクト: 0anion0/IBN
        /// <summary>
        /// Evaluates the infix expression using the values in the Hashtable.
        /// </summary>
        /// <remarks>
        /// This is the only publicly available method of the class, it is the entry point into for the user 
        /// into the parser.
        ///
        /// Example usage:
        /// 
        /// using info.lundin.Math;
        /// using System;
        /// using System.Collections;
        ///
        /// public class Test 
        /// {
        /// 	public static void Main( String[] args )
        /// 	{
        /// 		ExpressionParser parser = new ExpressionParser();
        /// 		Hashtable h = new Hashtable();
        ///
        /// 		h.Add( "x", 1.ToString() );
        /// 		h.Add( "y", 2.ToString() );
        ///
        ///
        /// 		double result = parser.Parse( "xcos(y)", h );
        /// 		Console.WriteLine( “Result: {0}”, result );
        /// 	}
        /// }
        ///
        /// </remarks>
        /// <param name="exp">the infix string expression to parse and evaluate.</param>
        /// <returns>a double value</returns>
        public double Parse(String exp, SpreadSheetView view)
        {
            double ans = 0D;
            String tmp;
            Node tree;

            if( exp == null || exp.Equals("") )
            {
                throw new System.Exception("First argument to method eval is null or empty string");
            }
            else if( view == null )
            {
                throw new ArgumentNullException("View");
            }

            this.view	= view;

            tmp = skipSpaces( exp );
            //this.sb_init = tmp.Length;

            try
            {

                if( trees.ContainsKey( tmp ) )
                {
                    ans = toValue( (Node)trees[ tmp ] );
                }
                else
                {
                    Syntax( tmp );

                    //tree = parse( putMult( parseE( tmp ) ) );
                    tree = parse(  parseE( tmp )  );

                    ans = toValue( tree );

                    trees.Add( tmp , tree );
                }

                return ans;

            }
            catch( Exception e )
            {
                throw new System.Exception( e.Message );
            }
        }
コード例 #4
0
        private void GenerateScaleUpDownScript(SpreadSheetView view)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<script language=JavaScript>");
            sb.Append("function GridScaleUpDown2(newlength2) {  popup_show(); ");
            //Clear TD selection
            sb.Append("var obj = document.getElementById('span-link-month'); if (obj != null) obj.className='dhtmlLink_Passive'; ");
            sb.Append("obj = document.getElementById('span-link-quartal'); if (obj != null) obj.className='dhtmlLink_Passive'; ");
            sb.Append("obj = document.getElementById('span-link-year'); if (obj != null) obj.className='dhtmlLink_Passive'; ");
            sb.Append("obj = document.getElementById('span-link-week'); if (obj != null) obj.className='dhtmlLink_Passive'; ");
            sb.Append("obj = document.getElementById('span-link-project'); if (obj != null) obj.className='dhtmlLink_Passive'; ");

            sb.Append("newColumnLength = newlength2; setTimeout(\"GridScaleUpDown(newColumnLength);\", 100); }");
            sb.Append("function GridScaleUpDown(newlength) { ");

            sb.Append("if (gridScale != null && gridScale != 'undefined') { ");

            #region ShowHideToalForProject
            sb.Append("if (gridScale == -1) {");
            for (int i = 2; i <= view.Columns.Length; i++)
            {
                sb.AppendFormat("mygrid.setColWidth({0},newlength); ", i);
            }
            sb.Append("popup_hide(); return;");
            sb.Append("}");
            #endregion

            #region MonthQuarterYear
            if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
            {
                //Month <-> Quartal
                sb.Append("if((gridScale == 0 && newlength == 0) || (gridScale == 1 && newlength > 0)) { ");
                for (int i = 2; i < view.Columns.Length; i++)
                {
                    int counter = (i - 2) % 17;
                    if ((counter + 1) % 4 == 0 || counter > 14) continue;
                    sb.AppendFormat("mygrid.setColWidth({0},newlength);", i);
                }
                sb.Append("if (newlength == 0) {gridScale++; } else {gridScale--; } popup_hide(); return;}"); // gridScale == 0

                //Quartal <-> Year
                sb.Append("if ((gridScale == 1 && newlength == 0) || (gridScale == 2 && newlength > 0)) {");
                for (int i = 2; i < view.Columns.Length; i++)
                {
                    int counter = (i - 2) % 17;
                    if ((counter + 1) % 4 == 0 || counter < 15)
                        sb.AppendFormat("mygrid.setColWidth({0},newlength); ", i);
                }
                sb.Append("if (newlength == 0) {gridScale++; } else {gridScale=0; } popup_hide(); return;}"); //gridScale == 1

            }
            #endregion

            #region WeekYear
            if (view.Document.DocumentType == SpreadSheetDocumentType.WeekYear)
            {
                sb.Append("if ((gridScale == 0 && newlength == 0) || (gridScale == 1 && newlength > 0)) {");
                for (int i = 2; i < view.Columns.Length; i++)
                {
                    int counter = (i - 2) % 53;
                    if (counter < 52)
                        sb.AppendFormat("mygrid.setColWidth({0},newlength); ", i);
                }
                sb.Append("if (newlength == 0) {gridScale++; } else {gridScale--; }  popup_hide(); return;}");
            }
            #endregion

            #region QuarterYear
            if (view.Document.DocumentType == SpreadSheetDocumentType.QuarterYear)
            {
                sb.Append("if ((gridScale == 0 && newlength == 0) || (gridScale == 1 && newlength > 0)) {");
                for (int i = 2; i < view.Columns.Length; i++)
                {
                    int counter = (i - 2) % 5;
                    if (counter < 4)
                        sb.AppendFormat("mygrid.setColWidth({0},newlength); ", i);
                }
                sb.Append("if (newlength == 0) {gridScale++; } else {gridScale--; } popup_hide(); return;}");
            }
            #endregion

            sb.Append("popup_hide();} "); // gridScale != null

            sb.Append("}"); // function
            sb.Append("</script>");

            Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), sb.ToString());
        }
コード例 #5
0
ファイル: ProjectSpreadSheet.cs プロジェクト: 0anion0/IBN
        public static XmlDocument CreateViewDocForAnalysis(SpreadSheetView view)
        {
            XmlDocument xmlDoc = new XmlDocument();

            XmlNode rows_node = xmlDoc.AppendChild(xmlDoc.CreateElement("rows"));
            //XmlNode head_node = rows_node.AppendChild(xmlDoc.CreateElement("head"));

            for (int index = 0; index < view.Rows.Length; index++)
            {
                Row row = view.Rows[index];

                XmlNode row_node = rows_node.AppendChild(xmlDoc.CreateElement("row"));
                row_node.Attributes.Append(xmlDoc.CreateAttribute("id")).Value = row.Id;

                XmlNode _cellparent = xmlDoc.CreateElement("cell");

                //_cellparent.Attributes.Append(xmlDoc.CreateAttribute("colspan")).Value = "2";

                //XmlNode _cellParentAddImage = null;

                #region Bind block row
                //Generate tree
                if (row is Block)
                {
                    index++;
                    int endIndex = index + row.ChildRows.Count;
                    _cellparent.InnerText = row.Name;

                    for (; index < endIndex; index++) //Row childrow in ((Block)row).ChildRows)
                    {

                        Row childrow = view.Rows[index];

                        //Generate XML for child rows
                        XmlNode rowchild_node = row_node.AppendChild(xmlDoc.CreateElement("row"));
                        //rowchild_node.AppendChild(xmlDoc.CreateCDataSection(String.Format("<a href='alert(1)'>{0}</a>", childrow.Name)));
                        rowchild_node.Attributes.Append(xmlDoc.CreateAttribute("id")).Value = ((Row)childrow).Id;

                        XmlNode cellcaption_node = xmlDoc.CreateElement("cell");
                        //cellcaption_node.InnerText = childrow.Name;

                        //-cellcaption_node.AppendChild(xmlDoc.CreateCDataSection(String.Format("{0} <img border=0 id='{2}_{3}' onclick=\"{2}\" src='{1}'>", childrow.Name, GetAbsolutePath("Layouts/Images/delete.gif"), GenScript_DeleteRow(childrow), childrow.Id, row.ChildRows.Count + 1 ))); //.InnerText = childrow.Name;
                        cellcaption_node.InnerText = childrow.Name;
                        rowchild_node.AppendChild(cellcaption_node);

                        foreach (Column childcolum in view.Columns)
                        {
                            BindCell(view, xmlDoc, rowchild_node, childcolum.Id, childrow.Id);
                            // TODO:
                        }
                    }
                    index--;
                    //row_node.AppendChild(_cellParentAddImage);
                }//if
                #endregion

                if (row.ReadOnly && row.Expression != string.Empty && !(row is Block))
                {
                    _cellparent.InnerText = "<b>" + row.Name + "</b>";
                }
                else
                {
                    _cellparent.InnerText = row.Name;
                }
                row_node.AppendChild(_cellparent);

                #region Bind cells values
                foreach (Column column in view.Columns)
                {
                    BindCell(view, xmlDoc, row_node, column.Id, row.Id);
                }
                #endregion
            }

            return xmlDoc;
        }
コード例 #6
0
        public static SpreadSheetView CreateView(SpreadSheetDocument doc)
        {
            SpreadSheetView view = new SpreadSheetView(doc, 2006, 2006);

            //
            //			for (int i = 0; i <  12; i++)
            //			{
            //				Column col = new Column();
            //				col.AllowUserValue = true;
            //				col.Id = i.ToString();//String.Format("2006-Q{0}-{1}", (int)((i / 3) + 1), ((i % 12) + 1));
            //				col.Name = String.Format("2006-Q{0}-{1}", (int)((i / 3) + 1), ((i % 12) + 1));
            //				view.Columns.Add(col);
            //			}

            //
            //			if (_testView == null)
            //				_testView = view;

            return view;
        }
コード例 #7
0
ファイル: ProjectSpreadSheet.cs プロジェクト: 0anion0/IBN
        // Generate XML for updating cells/rows
        public static XmlDocument CreateDocChangesCompare(SpreadSheetView view1, SpreadSheetView view2)
        {
            XmlDocument xmlDoc = new XmlDocument();

            XmlNode rows_node = xmlDoc.AppendChild(xmlDoc.CreateElement("rows"));
            XmlNode user_node = rows_node.AppendChild(xmlDoc.CreateElement("userdata"));
            user_node.Attributes.Append(xmlDoc.CreateAttribute("name")).Value = "action";
            user_node.InnerText = "update";

            foreach (Cell cell in view1.ChangedCellList)
            {
                XmlNode cell_node = rows_node.AppendChild(xmlDoc.CreateElement("cell"));
                Cell _cell = view1.GetCell(cell.Position.ColumnId, cell.Position.RowId);
                Cell _cell2 = view2.GetCell(cell.Position.ColumnId, cell.Position.RowId);
                string Value = String.Format("{0}/{1}", cell.Value.ToString(), _cell2.Value.ToString());
                if (_cell != null)
                {
                    if (_cell.Type == CellType.AutoCalc)
                        cell_node.Attributes.Append(xmlDoc.CreateAttribute("font")).Value = "Black";
                    else if (_cell.Type == CellType.UserValue)
                        cell_node.Attributes.Append(xmlDoc.CreateAttribute("font")).Value = "#CE3431";
                    if (_cell.ReadOnly)
                        Value = "<div></div>" + Value;
                }
                int colind = view1.GetColumnIndex(cell.Position.ColumnId) + 2;

                cell_node.Attributes.Append(xmlDoc.CreateAttribute("columnindex")).Value = colind.ToString();
                cell_node.Attributes.Append(xmlDoc.CreateAttribute("rowid")).Value = cell.Position.RowId;
                cell_node.InnerText = Value;
            }

            return xmlDoc;
        }
コード例 #8
0
ファイル: ProjectSpreadSheet.cs プロジェクト: 0anion0/IBN
        // Generate XML for compare two views
        public static XmlDocument CreateViewCompareDocForAnalysis(SpreadSheetView view1, SpreadSheetView view2)
        {
            if (view1.Columns.Length != view2.Columns.Length || view1.Rows.Length != view2.Rows.Length)
                throw new ArgumentException("Incorect views", "view1, view2");

            XmlDocument xmlDoc = new XmlDocument();
            XmlNode rows_node = xmlDoc.AppendChild(xmlDoc.CreateElement("rows"));

            for (int index = 0; index < view1.Rows.Length; index++)
            {
                Row row = view1.Rows[index];
                Row row2 = view2.Rows[index];

                XmlNode row_node = rows_node.AppendChild(xmlDoc.CreateElement("row"));
                row_node.Attributes.Append(xmlDoc.CreateAttribute("id")).Value = row.Id;

                XmlNode _cellparent = xmlDoc.CreateElement("cell");
                //_cellparent.Attributes.Append(xmlDoc.CreateAttribute("colspan")).Value = "2";

                //XmlNode _cellParentAddImage = null;
                //Generate tree
                #region Block rows generating
                if (row is Block)
                {
                    _cellparent.InnerText = row.Name;

                    index++;
                    int endIndex = index + row.ChildRows.Count;
                    //_cellparent.AppendChild(xmlDoc.CreateCDataSection(String.Format("{0} <img border=0 onclick=\"{2}\" src='{1}'>", row.Name, GetAbsolutePath("Layouts/Images/listsnew.gif"), GenScript_NewRow(row))));

                    for (; index < endIndex; index++) //Row childrow in ((Block)row).ChildRows)
                    {

                        Row childrow = view1.Rows[index];
                        Row childrow2 = view2.Rows[index];

                        //Generate XML for child rows
                        XmlNode rowchild_node = row_node.AppendChild(xmlDoc.CreateElement("row"));
                        //rowchild_node.AppendChild(xmlDoc.CreateCDataSection(String.Format("<a href='alert(1)'>{0}</a>", childrow.Name)));
                        rowchild_node.Attributes.Append(xmlDoc.CreateAttribute("id")).Value = ((Row)childrow).Id;

                        XmlNode cellcaption_node = xmlDoc.CreateElement("cell");
                        //cellcaption_node.InnerText = childrow.Name;

                        //-cellcaption_node.AppendChild(xmlDoc.CreateCDataSection(String.Format("{0} <img border=0 id='{2}_{3}' onclick=\"{2}\" src='{1}'>", childrow.Name, GetAbsolutePath("Layouts/Images/delete.gif"), GenScript_DeleteRow(childrow), childrow.Id, row.ChildRows.Count + 1 ))); //.InnerText = childrow.Name;
                        cellcaption_node.InnerText = childrow.Name;
                        rowchild_node.AppendChild(cellcaption_node);

                        //XmlNode cellbtn = xmlDoc.CreateElement("cell");
                        //cellbtn.AppendChild(xmlDoc.CreateCDataSection(String.Format("<img border=0 id='{2}_{3}' onclick=\"{2}\" src='{1}'>", childrow.Name, GetAbsolutePath("Layouts/Images/delete.gif"), GenScript_DeleteRow(childrow), childrow.Id, row.ChildRows.Count + 1 )));
                        //rowchild_node.AppendChild(cellbtn);

                        foreach (Column childcolum in view1.Columns)
                        {
                            #region Get cell value
                            string val1, val2;
                            val1 = view1.GetValue(childcolum.Id, childrow.Id);
                            val2 = view2.GetValue(childcolum.Id, childrow2.Id);
                            if (val1.Length > 0 && val2.Length == 0) val2 = "0";
                            if (val1.Length == 0 && val2.Length > 0) val1 = "0";
                            string Value = String.Format("{0}/{1}", val1, val2);
                            if (val1.Length == 0 && val2.Length == 0) Value = string.Empty;
                            #endregion

                            XmlNode cell_node = rowchild_node.AppendChild(xmlDoc.CreateElement("cell"));
                            Cell _cell = view1.GetCell(childcolum.Id, childrow.Id);
                            if (_cell != null)
                            {
                                if (_cell.Type == CellType.AutoCalc)
                                    cell_node.Attributes.Append(xmlDoc.CreateAttribute("class")).Value = "dhtmlxGrid_bold";
                                else if (_cell.Type == CellType.UserValue)
                                    cell_node.Attributes.Append(xmlDoc.CreateAttribute("class")).Value = "dhtmlxGrid_italic";
                                if (_cell.ReadOnly)
                                    Value = "<div></div>" + Value;

                            }
                            cell_node.Attributes.Append(xmlDoc.CreateAttribute("id")).Value = childcolum.Id;

                            cell_node.InnerText = Value;
                            // TODO:
                        }
                    }

                    index--;
                    //row_node.AppendChild(_cellParentAddImage);
                }//if
                #endregion

                if (row.ReadOnly && row.Expression != string.Empty && !(row is Block))
                {
                    _cellparent.InnerText = "<b>" + row.Name + "</b>";
                }
                else
                {
                    _cellparent.InnerText = row.Name;
                }

                row_node.AppendChild(_cellparent);

                #region Bind columns values
                foreach (Column column in view1.Columns)
                {
                    string CellUID = string.Format("{0}:{1}", column.Id, row.Id);

                    #region Get cell value
                    string val1, val2;
                    val1 = view1.GetValue(column.Id, row.Id);
                    val2 = view2.GetValue(column.Id, row2.Id);
                    if (val1.Length > 0 && val2.Length == 0) val2 = "0";
                    if (val1.Length == 0 && val2.Length > 0) val1 = "0";
                    string Value = String.Format("{0}/{1}", val1, val2);
                    if (val1.Length == 0 && val2.Length == 0) Value = string.Empty;
                    #endregion

                    Cell _cell = view1.GetCell(column.Id, row.Id);
                    XmlNode cell_node = row_node.AppendChild(xmlDoc.CreateElement("cell"));

                    if (_cell != null)
                    {
                        if (_cell.Type == CellType.AutoCalc)
                            cell_node.Attributes.Append(xmlDoc.CreateAttribute("class")).Value = "dhtmlxGrid_bold";
                        else if (_cell.Type == CellType.UserValue)
                            cell_node.Attributes.Append(xmlDoc.CreateAttribute("class")).Value = "dhtmlxGrid_italic";
                        if (_cell.ReadOnly)
                            Value = "<div></div>" + Value;

                        if (row.ReadOnly && row.Id.ToLower().Contains("Space"))
                            Value = "<div></div>";

                    }

                    cell_node.Attributes.Append(xmlDoc.CreateAttribute("id")).Value = column.Id;//CellUID;//column.Id;
                    cell_node.InnerText = Value;
                }
                #endregion
            }

            return xmlDoc;
        }
コード例 #9
0
ファイル: ProjectSpreadSheet.cs プロジェクト: 0anion0/IBN
        private static void BindCell(SpreadSheetView view, XmlDocument doc, XmlNode parent_node, string ColumnId, string RowId)
        {
            XmlNode cell_node = parent_node.AppendChild(doc.CreateElement("cell"));
            Cell _cell = view.GetCell(ColumnId, RowId);
            string Value = view.GetValue(ColumnId, RowId);

            if (_cell != null)
            {
                if (_cell.Type == CellType.AutoCalc)
                {
                    cell_node.Attributes.Append(doc.CreateAttribute("class")).Value = "dhtmlxGrid_bold";
                    //Value = "<span></span>"+Value;
                }
                else if (_cell.Type == CellType.UserValue)
                {
                    cell_node.Attributes.Append(doc.CreateAttribute("class")).Value = "dhtmlxGrid_italic";
                }
                if (_cell.ReadOnly)
                    Value = "<div></div>" + Value;

                //ѕустые р¤ды. Name == string.Empty + ReadOnly
                if (view.Rows[view.GetRowIndex(_cell.Position.RowId)].Name == string.Empty && view.Rows[view.GetRowIndex(_cell.Position.RowId)].ReadOnly)
                {
                    Value = "<div></div>&nbsp;";
                }
            }
            cell_node.Attributes.Append(doc.CreateAttribute("id")).Value = ColumnId;
            cell_node.InnerText = Value;
        }
コード例 #10
0
ファイル: ProjectSpreadSheet.cs プロジェクト: 0anion0/IBN
        internal static void SaveBusinessScore(int ProjectId, int Index, SpreadSheetDocument Document)
        {
            using (DbTransaction tran = DbTransaction.Begin())
            {
                // Delete prev results by ProjectId and Index
                BusinessScoreDataRow.Delete(ProjectId, Index);

                if (Document.Cells.Length != 0)
                {
                    // Fill Business Score Hash
                    BusinessScore[] bsList = BusinessScore.List();
                    Hashtable bsHash = new Hashtable();

                    foreach (BusinessScore bs in bsList)
                    {
                        bsHash.Add(bs.Key, bs.BusinessScoreId);
                    }

                    bool bContainsBusinessScoreRow = false;

                    foreach (Row row in Document.Template.Rows)
                    {
                        if (bsHash.ContainsKey(row.Id))
                        {
                            bContainsBusinessScoreRow = true;
                            break;
                        }
                    }

                    if (bContainsBusinessScoreRow)
                    {
                        SpreadSheetView bsView = new SpreadSheetView(Document);

                        Hashtable businessScoreHash = new Hashtable();
                        List<ExpressionInfo> userValueExpList = new List<ExpressionInfo>();

                        List<string> checkRelaitedList = new List<string>();

                        // Calculate Business Score
                        foreach (Row row in Document.Template.Rows)
                        {
                            if (bsHash.ContainsKey(row.Id))
                            {
                                // Save Business Score
                                foreach (Column column in bsView.Columns)
                                {
                                    Cell dataCell = bsView.GetCell(column.Id, row.Id);

                                    switch (dataCell.Type)
                                    {
                                        case CellType.Common:
                                            BusinessScoreDataRow newRowCommon = new BusinessScoreDataRow();
                                            newRowCommon.BusinessScoreId = (int)bsHash[row.Id];
                                            newRowCommon.ProjectId = ProjectId;
                                            newRowCommon.Index = Index;
                                            newRowCommon.Date = SpreadSheetView.GetDateByColumn(column.Id);
                                            newRowCommon.Value = dataCell.Value;

                                            businessScoreHash.Add(dataCell.Uid, newRowCommon);
                                            break;
                                        case CellType.AutoCalc:
                                            if (column.Id.IndexOf("T") == -1 ||
                                                (Document.DocumentType == SpreadSheetDocumentType.Total) ||
                                                (Document.DocumentType == SpreadSheetDocumentType.Year && column.Id != "TT"))
                                            {
                                                //userValueExpList.Add(dataCell.Expression);
                                                userValueExpList.Add(dataCell.GetExpressionInfo());

                                                BusinessScoreDataRow newRowAutoCalc = new BusinessScoreDataRow();
                                                newRowAutoCalc.BusinessScoreId = (int)bsHash[row.Id];
                                                newRowAutoCalc.ProjectId = ProjectId;
                                                newRowAutoCalc.Index = Index;
                                                newRowAutoCalc.Date = SpreadSheetView.GetDateByColumn(column.Id);
                                                if (newRowAutoCalc.Date == DateTime.MinValue)
                                                    newRowAutoCalc.Date = DateTime.Now;
                                                newRowAutoCalc.Value = dataCell.Value;

                                                businessScoreHash.Add(dataCell.Uid, newRowAutoCalc);
                                            }
                                            break;
                                        case CellType.UserValue:
                                            //userValueExpList.Add(dataCell.Expression);
                                            userValueExpList.Add(dataCell.GetExpressionInfo());
                                            checkRelaitedList.Add(dataCell.Uid);

                                            BusinessScoreDataRow newRowUserValue = new BusinessScoreDataRow();
                                            newRowUserValue.BusinessScoreId = (int)bsHash[row.Id];
                                            newRowUserValue.ProjectId = ProjectId;
                                            newRowUserValue.Index = Index;
                                            newRowUserValue.Date = SpreadSheetView.GetDateByColumn(column.Id);
                                            newRowUserValue.Value = dataCell.Value;

                                            businessScoreHash.Add(dataCell.Uid, newRowUserValue);
                                            break;
                                    }
                                }
                            }
                        }

                        // Check Relaited with checkRelaitedList Items

                        // Remove Common Items by UserValue
                        foreach (ExpressionInfo exInfo in userValueExpList)
                        {
                            //ExpressionInfo exInfo = ExpressionInfo.Parse(Expression);

                            foreach (string CellUID in exInfo.Params)
                            {
                                if (businessScoreHash.ContainsKey(CellUID))
                                {
                                    businessScoreHash.Remove(CellUID);
                                }
                            }
                        }

                        // Save Business Score
                        foreach (BusinessScoreDataRow data in businessScoreHash.Values)
                        {
                            if (data.Value != 0)
                                data.Update();
                        }
                    }
                }

                tran.Commit();
            }
        }
コード例 #11
0
ファイル: ProjectSpreadSheet.cs プロジェクト: 0anion0/IBN
        /// <summary>
        /// Saves the view.
        /// </summary>
        /// <param name="ProjectId">The project id.</param>
        /// <param name="Index">The index.</param>
        /// <param name="view">The view.</param>
        public static void SaveView(int ProjectId, int Index, SpreadSheetView view)
        {
            using (DbTransaction tran = DbTransaction.Begin())
            {
                // Update User Rows
                ProjectSpreadSheetRow prjSpreadSheetRow = null;
                ProjectSpreadSheetRow[] SpreadSheets = ProjectSpreadSheetRow.List(ProjectId);

                if (SpreadSheets.Length == 0)
                {
                    //TODO:
                    throw new NotImplementedException();
                }
                else
                {
                    prjSpreadSheetRow = SpreadSheets[0];
                }

                prjSpreadSheetRow.UserRows = view.Document.Template.GetUserRowXml();
                prjSpreadSheetRow.Update();

                // Update Cell Data
                foreach (Cell cell in view.ChangedCellList)
                {
                    if (cell.Type != CellType.AutoCalc)
                    {
                        ProjectSpreadSheetDataRow.Update(prjSpreadSheetRow.ProjectSpreadSheetId,
                            Index,
                            cell.Position.ColumnId,
                            cell.Position.RowId,
                            cell.Value,
                            (int)cell.Type);
                    }
                    else
                    {
                        if (cell.Tag is int)
                        {
                            ProjectSpreadSheetDataRow.Delete((int)cell.Tag);
                        }
                    }
                }

                // Delete cell from removed rows
                foreach (Cell cell in view.Document.DeletedCells)
                {
                    if (cell.Tag is int)
                    {
                        ProjectSpreadSheetDataRow.Delete((int)cell.Tag);
                    }
                }
                view.Document.DeletedCells.Clear();

                //Clean Up Actual Finances
                foreach (string RowId in view.Document.Template.DeletedUserRows)
                {
                    ActualFinancesRow.Delete(RowId);
                }

                // Save business score
                if (Index >= 0)
                    SaveBusinessScore(ProjectId, Index, view.Document);

                tran.Commit();
            }
        }
コード例 #12
0
ファイル: ProjectSpreadSheet.cs プロジェクト: 0anion0/IBN
        /// <summary>
        /// Loads the view.
        /// </summary>
        /// <param name="ProjectId">The project id.</param>
        /// <param name="Index">The index.</param>
        /// <param name="FromYear">From year.</param>
        /// <param name="ToYear">To year.</param>
        /// <returns></returns>
        public static SpreadSheetView LoadView(int ProjectId, int Index, int FromYear, int ToYear)
        {
            // Load Document
            int ProjectSpreadSheetId;
            SpreadSheetDocument document = InitProjectDocument(ProjectId, out ProjectSpreadSheetId);

            if (document == null)
                return null;

            if (Index >= 0)
            {
                foreach (ProjectSpreadSheetDataRow row in
                    ProjectSpreadSheetDataRow.List(ProjectSpreadSheetId, Index))
                {
                    if (((CellType)row.CellType) != CellType.AutoCalc)
                    {
                        Cell cellItem = document.AddCell(row.ColumnId, row.RowId, (CellType)row.CellType, row.Value);
                        cellItem.Tag = row.ProjectSpreadSheetDataId;
                    }
                }
            }
            else
            {
                #region LoadFact View
                foreach (ActualFinances finance in ActualFinances.List(ProjectId, ObjectTypes.Project))
                {
                    string ColumnId = SpreadSheetView.GetColumnByDate(document.DocumentType, finance.Date);
                    string RowId = finance.RowId;

                    Cell cell = document.GetCell(ColumnId, RowId);
                    if (cell == null)
                    {
                        cell = document.AddCell(ColumnId, RowId, CellType.Common, 0);
                    }

                    cell.Value += finance.Value;
                }
                #endregion
            }

            // Create View and return
            SpreadSheetView retVal = new SpreadSheetView(document, FromYear, ToYear);

            return retVal;
        }
コード例 #13
0
        /// <summary>
        /// Saves the specified Active Data by Project to Base Plan Slot.
        /// </summary>
        /// <param name="ProjectId">The project id.</param>
        /// <param name="BasePlanSlotId">The base plan slot id.</param>
        public static void Save(int ProjectId, int BasePlanSlotId)
        {
            using (DbTransaction tran = DbTransaction.Begin())
            {
                // Step. Create or Update ProjectBasePlanInfoRow


                ProjectBasePlanInfoRow infoRow = new ProjectBasePlanInfoRow();

                ProjectBasePlanInfoRow[] activeInfoRowList = ProjectBasePlanInfoRow.List(ProjectId);

                foreach (ProjectBasePlanInfoRow activeInfoRow in activeInfoRowList)
                {
                    if (activeInfoRow.BasePlanSlotId == BasePlanSlotId)
                    {
                        infoRow = activeInfoRow;
                        break;
                    }
                }

                infoRow.BasePlanSlotId = BasePlanSlotId;
                infoRow.ProjectId      = ProjectId;
                infoRow.Created        = DateTime.UtcNow;

                infoRow.Update();
                //DV. Fix Exception, when finances are not active!
                if (ProjectSpreadSheet.IsActive(ProjectId))
                {
                    // Step 1. Save Spread Sheet View from Currency
                    ProjectSpreadSheetDataRow.Delete(ProjectId, BasePlanSlotId);

                    ProjectSpreadSheetDataRow[] srcRowList = ProjectSpreadSheetDataRow.ListCurrentByProjectId(ProjectId);

                    foreach (ProjectSpreadSheetDataRow srcRow in srcRowList)
                    {
                        ProjectSpreadSheetDataRow newRow = new ProjectSpreadSheetDataRow();

                        newRow.Index = BasePlanSlotId;

                        newRow.ProjectSpreadSheetId = srcRow.ProjectSpreadSheetId;

                        newRow.ColumnId = srcRow.ColumnId;
                        newRow.RowId    = srcRow.RowId;

                        newRow.CellType = srcRow.CellType;

                        newRow.Value = srcRow.Value;

                        newRow.Update();
                    }

                    SpreadSheetView view = ProjectSpreadSheet.LoadView(ProjectId, BasePlanSlotId, 2001, 2001);
                    ProjectSpreadSheet.SaveBusinessScore(ProjectId, BasePlanSlotId, view.Document);
                }

                // Step 2. Save Tasks
                ProjectTaskBasePlanRow.Fill(ProjectId, BasePlanSlotId);

                tran.Commit();
            }
        }