Example #1
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            IDictionary <string, object> dictionary = new Dictionary <string, object>();

            WfMatrixDefinition matrixDefinition = (WfMatrixDefinition)obj;

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Description", matrixDefinition.Description);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Dimensions", matrixDefinition.Dimensions);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Enabled", matrixDefinition.Enabled);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Key", matrixDefinition.Key);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Name", matrixDefinition.Name);

            return(dictionary);
        }
Example #2
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfMatrixDefinition matrixDefinition = new WfMatrixDefinition();

            matrixDefinition.Description = DictionaryHelper.GetValue(dictionary, "Description", string.Empty);
            matrixDefinition.Enabled     = DictionaryHelper.GetValue(dictionary, "Enabled", true);
            matrixDefinition.Key         = DictionaryHelper.GetValue(dictionary, "Key", string.Empty);
            matrixDefinition.Name        = DictionaryHelper.GetValue(dictionary, "Name", string.Empty);

            WfMatrixDimensionDefinitionCollection dimensions = JSONSerializerExecute.Deserialize <WfMatrixDimensionDefinitionCollection>(dictionary["Dimensions"]);

            matrixDefinition.Dimensions.Clear();
            matrixDefinition.Dimensions.CopyFrom(dimensions);

            return(matrixDefinition);
        }
Example #3
0
        private static void FillWorkbook(WfMatrixDefinition definition, WorkbookNode workbook, WfMatrixDefinitionExportOptions options)
        {
            WorksheetNode worksheet = GetWorksheetFromWorkbook(workbook, options);

            worksheet.Names.Clear();
            workbook.Names.Clear();

            worksheet.Table.Rows[1].Cells.Clear();

            int row    = options.StartRow;
            int column = options.StartColumn;

            RowNode titleRow = null;

            if (worksheet.Table.Rows.Count > 0)
            {
                titleRow = worksheet.Table.Rows[1];
            }
            else
            {
                titleRow = new RowNode();
                worksheet.Table.Rows.Add(titleRow);
            }

            foreach (WfMatrixDimensionDefinition dd in definition.Dimensions)
            {
                NamedRangeNode range = new NamedRangeNode();

                range.Name = dd.DimensionKey;

                range.RefersTo = string.Format("={0}!R{1}C{2}", worksheet.Name, row, column);
                workbook.Names.Add(range);

                CellNode cell = new CellNode();

                cell.Data.Value = dd.Name;

                if (options.TitleCellStyleID.IsNotEmpty())
                {
                    cell.StyleID = options.TitleCellStyleID;
                }

                titleRow.Cells.Add(cell);

                column++;
            }
        }
Example #4
0
        private static void SaveWfMatrixDefinition(WfMatrixDefinition def)
        {
            if (def == null)
            {
                return;
            }

            bool defIsExist = true;

            try
            {
                WfMatrixDefinitionAdapter.Instance.Load(def.Key);
            }
            catch (SystemSupportException)
            {
                defIsExist = false;
            }

            if (defIsExist == false)
            {
                WfMatrixDefinitionAdapter.Instance.Update(def);
            }
        }
Example #5
0
        /// <summary>
        /// 从ExcelXml中导入已经存在的矩阵
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="notifier"></param>
        /// <param name="processDescKey"></param>
        public static void ImportNewMatrixFromExcelXml(Stream stream, Action notifier, string processDescKey, WfMatrixDefinition matrixDef)
        {
            WfMatrix matrix = new WfMatrix(matrixDef)
            {
                MatrixID    = Guid.NewGuid().ToString(),
                ProcessKey  = processDescKey,
                CreatorID   = DeluxeIdentity.CurrentUser.ID,
                CreatorName = DeluxeIdentity.CurrentUser.Name
            };

            //ImportFromExcel2007(stream, notifier, processDescKey);
            ImportExcelXml(stream, matrix, notifier);
        }
Example #6
0
        public WfMatrix(WfMatrixDefinition definition)
        {
            definition.NullCheck("definition");

            this._Definition = definition;
        }