예제 #1
0
        protected void TestFunction(Expression <Func <ColumnCellDictionary, object> > exp, string expected)
        {
            var convert = new ExpressionConvert(new[] { "One", "Two", "Three", "Four", "Five", "Six" }, 3);
            var ret     = convert.Convert(exp);

            Assert.AreEqual(expected, ret);
        }
예제 #2
0
        public void Day()
        {
            Expression <Func <Dictionary <string, object>, object> > exp = c => DateTime.Now.Day;
            var convert = new ExpressionConvert(new string[] { }, 3);
            var ret     = convert.Convert(exp);

            Assert.AreEqual("DAY(NOW())", ret);
        }
예제 #3
0
        public void EDateWithColumn()
        {
            Expression <Func <Dictionary <string, ColumnValue>, object> > exp = c => ((DateTime)c["Date"]).AddMonths((int)c["Month"]);
            var convert = new ExpressionConvert(new string[] { "Date", "Month" }, 3);
            var ret     = convert.Convert(exp);

            Assert.AreEqual("EDATE(A4,B4)", ret);
        }
예제 #4
0
        public void EDate()
        {
            Expression <Func <Dictionary <string, object>, object> > exp = c => DateTime.Now.AddMonths(3);
            var convert = new ExpressionConvert(new string[] { }, 3);
            var ret     = convert.Convert(exp);

            Assert.AreEqual("EDATE(NOW(),3)", ret);
        }
예제 #5
0
        private static void SetCellValue(ExcelType excelType, ExcelColumn column, ICell cell, string val,
                                         string[] columnTitles)
        {
            if (column.Type == typeof(Uri))
            {
                cell.Hyperlink = Switch <IHyperlink>(
                    excelType,
                    () => new HSSFHyperlink(HyperlinkType.Url)
                {
                    Address = val
                },
                    () => new XSSFHyperlink(HyperlinkType.Url)
                {
                    Address = val
                }
                    );
            }
            else if (column.Type == typeof(Expression))
            {
                var convert = new ExpressionConvert(columnTitles, cell.RowIndex);
                cell.SetCellFormula(convert.Convert(column.Formula));
                if (column.ResultType != null)
                {
                    if (column.ResultType == typeof(DateTime))
                    {
                        cell.CellStyle            = cell.Sheet.Workbook.CreateCellStyle();
                        cell.CellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("m/d/yy");
                    }
                }
                return;
            }
            else if (column.Type == typeof(string))
            {
                cell.SetCellType(CellType.String);
                cell.CellStyle            = cell.Sheet.Workbook.CreateCellStyle();
                cell.CellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("text");
            }

            if (column.Font != null)
            {
                IFont font = cell.Sheet.Workbook.CreateFont();
                font.FontName           = column.Font.FontName;
                font.FontHeightInPoints = column.Font.FontHeightInPoints;
                font.Color = column.Font.Color;
                if (column.Font.IsBold)
                {
                    font.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold;
                }
                cell.CellStyle.SetFont(font);
            }

            //cell.Hyperlink=new HSSFHyperlink

            cell.SetCellValue(val);
        }
예제 #6
0
        private static ActivityView BuildDelayView(Delay source)
        {
            string activityId = ObjectIdManager.GetId(source);

            string duration = ExpressionConvert.ToString(source.Duration);

            var view = new DelayView(activityId)
            {
                ActivityName = source.DisplayName,
                Duration     = duration,
            };

            return(view);
        }
예제 #7
0
        private static ActivityView BuildWriteLineView(WriteLine source)
        {
            string activityId = ObjectIdManager.GetId(source);

            string text = ExpressionConvert.ToString(source.Text);

            var view = new WriteLineView(activityId)
            {
                ActivityName = source.DisplayName,
                Text         = text,
            };

            return(view);
        }
예제 #8
0
        private static ActivityView BuildWhileView(While source)
        {
            string activityId = ObjectIdManager.GetId(source);

            string condition = ExpressionConvert.ToString(source.Condition);

            var view = new WhileView(activityId)
            {
                ActivityName = source.DisplayName,
                Condition    = condition,
            };

            return(view);
        }
예제 #9
0
        private static ActivityView BuildCorrelationScopeView(CorrelationScope source)
        {
            string activityId = ObjectIdManager.GetId(source);

            string correlatesWidth = ExpressionConvert.ToString(source.CorrelatesWith);

            var view = new CorrelationScopeView(activityId)
            {
                ActivityName   = source.DisplayName,
                CorrelatesWith = correlatesWidth,
            };

            return(view);
        }
예제 #10
0
        private static ActivityView BuildAssignView <T>(Assign <T> source)
        {
            string activityId = ObjectIdManager.GetId(source);

            string to    = ExpressionConvert.ToString(source.To);
            string value = ExpressionConvert.ToString(source.Value);

            var view = new AssignView(activityId)
            {
                ActivityName = source.DisplayName,
                To           = to,
                Value        = value,
            };

            return(view);
        }
예제 #11
0
        private static void SetCellValue(ExcelType excelType, ExcelColumn column, ICell cell, string val,
                                         string[] columnTitles)
        {
            if (column.Type == typeof(Uri))
            {
                cell.Hyperlink = Switch <IHyperlink>(
                    excelType,
                    () => new HSSFHyperlink(HyperlinkType.Url)
                {
                    Address = val
                },
                    () => new XSSFHyperlink(HyperlinkType.Url)
                {
                    Address = val
                }
                    );
            }
            else if (column.Type == typeof(Expression))
            {
                var convert = new ExpressionConvert(columnTitles, cell.RowIndex);
                cell.SetCellFormula(convert.Convert(column.Formula));
                if (column.ResultType != null)
                {
                    if (column.ResultType == typeof(DateTime))
                    {
                        cell.CellStyle            = cell.Sheet.Workbook.CreateCellStyle();
                        cell.CellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("m/d/yy");
                    }
                }
                return;
            }
            else if (column.Type == typeof(string))
            {
                cell.SetCellType(CellType.String);
                cell.CellStyle            = cell.Sheet.Workbook.CreateCellStyle();
                cell.CellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("text");
            }

            //cell.Hyperlink=new HSSFHyperlink

            cell.SetCellValue(val);
        }
예제 #12
0
        private static ActivityView BuildParallelForEachView <T>(ParallelForEach <T> source)
        {
            string activityId = ObjectIdManager.GetId(source);

            string values   = ExpressionConvert.ToString(source.Values);
            string argument = string.Empty;

            if (source.Body != null)
            {
                argument = source.Body.Argument.Name;
            }

            var view = new ForEachView(activityId)
            {
                ActivityName = source.DisplayName,
                Values       = values,
                Argument     = argument,
            };

            return(view);
        }