public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                int RowCount = 0;
                foreach (DAL.UserDefData udd in UDTTransfer.GetDataFromUDT(e.List))
                {
                    RowData row = new RowData();
                    row.ID = udd.RefID;

                    foreach (string field in e.ExportFields)
                    {
                        if (wizard.ExportableFields.Contains(field))
                        {
                            switch (field)
                            {
                                case "欄位名稱": row.Add(field, udd.FieldName); break;
                                case "值": row.Add(field, udd.Value); break;
                            }
                        }

                    }
                    RowCount++;
                    e.Items.Add(row);
                }
            };
        }
Esempio n. 2
0
        public static void Fill3000(SvodDdr.DdrDataContext dc)
        {
            dc.context.ReportProgress(@"Заполняем форму 3000 ...");

            var ws = ((Worksheet)dc.newDoc.Worksheets[@"стр.5"]);
            ws.Activate();

            var totalRow = new RowData();
            var sqlText = string.Format(@"SELECT
                COUNT(DISTINCT Event.client_id) as CountClients,
                COUNT(DISTINCT IF(Action.MKB != '' AND Action.MKB NOT LIKE 'Z%', Event.id, NULL)) as CountEvents,
                ActionType.code AS ActionTypeCode FROM Event
                INNER JOIN EventType ON (Event.`deleted` = 0) AND (EventType.`code` IN ('dd2013_2'))
                    AND (EventType.`id` = Event.`eventType_id`) AND (EventType.`deleted` = 0)
                INNER JOIN Action ON (Action.`deleted` = 0) /* AND (Action.`status` != 3) */
                    AND (Action.`event_id` = Event.`id`)
                INNER JOIN ActionType ON (ActionType.`deleted` = 0) AND (Action.`actionType_id` = ActionType.`id`)
                INNER JOIN Client ON (Client.`deleted` = 0) AND (Client.`id` = Event.`client_id`)
                WHERE (Event.`execDate` >= '{0}') AND (Event.`execDate` < '{1}')
                    AND (Action.`status` != 3) AND (Action.`status` != 6)
                GROUP BY ActionType.code",
                                    dc.dateEnd.BeginOfYear().SqlStr(),
                                    dc.dateEnd.AddDays(1).SqlStr());

            var sqlData = selectSqlData<SourceData>(dc, sqlText);

            for (int rowIndex = 7; rowIndex <= 19; rowIndex++)
            {
                fillRow(dc, rowIndex, totalRow, ws, sqlData);
            }

            totalRow.FillData(ws, 20);

            dc.context.ProgressSeparator();
        }
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(_ExportList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                // 取得異動代碼
                XElement _UpdateCode=DAL.DALTransfer.GetUpdateCodeList();
                List<string> UpdateCodeList = (from elm in _UpdateCode.Elements("異動") where elm.Element("分類").Value == "新生異動" select elm.Element("代號").Value).ToList();
                // 取得學生新生異動
                List<SHUpdateRecordRecord> updateRecList = (from data in SHUpdateRecord.SelectByStudentIDs(e.List) where UpdateCodeList.Contains(data.UpdateCode) select data).ToList();
            Dictionary<string, string> StudentStatusDict = DAL.FDQuery.GetAllStudentStatus1Dict();

            foreach (SHUpdateRecordRecord rec in updateRecList)
            {
                RowData row = new RowData();
                row.ID = rec.StudentID;
                foreach (string field in e.ExportFields)
                {
                    if (wizard.ExportableFields.Contains(field))
                    {
                        switch(field)
                        {
                            case "學年度":
                                if(rec.SchoolYear.HasValue )
                                    row.Add(field, rec.SchoolYear.Value.ToString ()); break;
                            case "學期":
                                if(rec.Semester.HasValue )
                                    row.Add(field, rec.Semester.Value.ToString ()); break;
                            case "年級": row.Add(field, rec.GradeYear); break;
                            case "異動代碼": row.Add(field, rec.UpdateCode); break;
                            case "原因及事項": row.Add(field, rec.UpdateDescription); break;
                            case "異動日期": row.Add(field, rec.UpdateDate); break;
                            case "備註": row.Add(field, rec.Comment); break;
                            case "班別": row.Add(field, rec.ClassType); break;
                            case "科別": row.Add(field, rec.Department); break;
                            case "特殊身分代碼": row.Add(field, rec.SpecialStatus); break;
                            case "入學資格證明文件": row.Add(field, rec.GraduateDocument); break;
                            case "異動姓名": row.Add(field, rec.StudentName); break;
                            case "異動學號": row.Add(field, rec.StudentNumber); break;
                            case "異動身分證字號": row.Add(field, rec.IDNumber); break;
                            case "異動生日": row.Add(field, rec.Birthdate); break;
                            case "異動身分證註記": row.Add(field, rec.IDNumberComment); break;
                            case "異動性別": row.Add(field, rec.Gender); break;
                            case "畢業國中": row.Add(field, rec.GraduateSchool); break;
                            case "畢業國中所在地代碼": row.Add(field, rec.GraduateSchoolLocationCode); break;
                            case "畢業國中學校代碼": row.Add(field, rec.GraduateSchoolCode); break;
                            case "畢業國中畢業學年度": row.Add(field, rec.GraduateSchoolYear); break;
                            case "畢業國中入學資格註記": row.Add(field, rec.GraduateComment); break;
                            case "核准日期": row.Add(field, rec.ADDate); break;
                            case "核准文號": row.Add(field, rec.ADNumber); break;
                            case "狀態":
                                if(StudentStatusDict.ContainsKey(rec.StudentID))
                                    row.Add(field, StudentStatusDict[rec.StudentID]); break;
                        }
                    }
                }
                e.Items.Add(row);
            }
            };
        }
Esempio n. 4
0
    CSVSheet(string filePath, TextLine textLine)
    {
        Assert.IsTrue(textLine != null);

        this.filePath = filePath;

        using (var lines = textLine.GetEnumerator())
        {
            lines.MoveNext();
            string colNames = lines.Current;
            lines.MoveNext();
            string colTypes = lines.Current;
            this.columnInfo = new ColumnInfo(colNames, colTypes, filePath);

            List<RowData> tempList = new List<RowData>();
            while (lines.MoveNext())
            {
                string line = lines.Current;
                if (!string.IsNullOrEmpty(line))
                {
                    var tokens = line.Split(',');
                    var newRow = new RowData(tokens);
                    Assert.IsTrue(newRow.IsValidInLength(columnInfo), string.Format("tokens.Length={0}, columnInfo.Length={1} in \n{2}", tokens.Length, columnInfo.Length, line));
                    int errIndex;
                    Assert.IsTrue(newRow.IsValidInType(columnInfo, out errIndex), errIndex < 0 ? string.Empty : string.Format("Converting error: [{0}] to {1} in {2}", tokens[errIndex], columnInfo[errIndex].Value, filePath));
                    tempList.Add(newRow);
                }
            }
            rows = tempList;
        }
    }
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                int RowCount = 0;

                List<DAO.UDT_CounselUserDefDataDef> CounselUserDefDataList = _UDTTransfer.GetCounselUserDefineDataByStudentIDList(e.List);

                foreach (DAO.UDT_CounselUserDefDataDef udd in CounselUserDefDataList)
                {
                    RowData row = new RowData();
                    row.ID = udd.StudentID.ToString ();

                    foreach (string field in e.ExportFields)
                    {
                        if (wizard.ExportableFields.Contains(field))
                        {
                            switch (field)
                            {
                                case "欄位名稱": row.Add(field, udd.FieldName); break;
                                case "值": row.Add(field, udd.Value); break;
                                case "狀態":
                                    row.Add(field, udd.StudentStatus);
                                    break;

                            }
                        }

                    }
                    RowCount++;
                    e.Items.Add(row);
                }
            };
        }
Esempio n. 6
0
        private static void fillRow(SvodDdr.DdrDataContext dc, int rowIndex, Worksheet ws, List<SourceData> sqlData, List<SourceData> usedData)
        {
            var row = (Range)ws.Rows[rowIndex];
            string mkbRange = ((Range)row.Cells[1, 52]).Value2;

            var rowData = new RowData();
            rowData.SelectData(sqlData, mkbRange, usedData, false);
            rowData.Fill(ws, rowIndex);
        }
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);

            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                // 學生類別組合
                Dictionary<string, StudentTagEntity> StudTagDict = new Dictionary<string, StudentTagEntity>();

                // 取得學生類別
                foreach (StudentTagRecord studTagRec in StudentTag.SelectByStudentIDs(e.List))
                {
                    if (StudTagDict.ContainsKey(studTagRec.RefStudentID))
                        StudTagDict[studTagRec.RefStudentID].AddPrefixName(studTagRec.Prefix, studTagRec.Name);
                    else
                    {
                        StudentTagEntity stn = new StudentTagEntity();
                        stn.StudentID = studTagRec.RefStudentID;
                        stn.AddPrefixName(studTagRec.Prefix, studTagRec.Name);
                        StudTagDict.Add(studTagRec.RefStudentID, stn);
                    }
                }

                // 讀取組合後的學生類別
                foreach (StudentTagEntity ste in StudTagDict.Values)
                {
                    foreach (KeyValuePair<string, List<string>> data in ste.GetPrefixNameDic())
                    {
                        // 當群組空白
                        string key = string.Empty;
                        if (data.Key != " ")
                            key = data.Key;

                        // 類別名稱
                        foreach (string str in data.Value)
                        {
                            RowData row = new RowData();
                            foreach (string field in e.ExportFields)
                            {
                                row.ID = ste.StudentID;

                                if (field == "群組")
                                    row.Add(field, key);

                                if (field == "類別名稱")
                                    row.Add(field, str);
                            }
                            e.Items.Add(row);
                        }
                    }
                }

                PermRecLogProcess prlp = new PermRecLogProcess();
                prlp.SaveLog("學生.匯出類別", "匯出", "共匯出" + StudTagDict.Values.Count + "筆學生類別資料.");
            };
        }
Esempio n. 8
0
        //ロード処理(暗号化済みファイルから)
        void LoadWWWCriptFile(WWW www)
        {
            byte[] readBytes = www.bytes;
            switch (FileType)
            {
            case AssetFileType.Text:                                    //テキスト
                text = System.Text.Encoding.UTF8.GetString(fileIO.Decode(readBytes));
                break;

            case AssetFileType.Bytes:                                   //バイナリ
                bytes = fileIO.Decode(readBytes);
                break;

            case AssetFileType.Texture:                         //テクスチャ
                fileIO.DecodeNoCompress(readBytes);             //圧縮なしでデコード
                //サイズとTextureFormatはLoadImage後無視される。ミップマップの反映のみ
                texture = new Texture2D(1, 1, TextureFormat.ARGB32, FileInfo.IsTextureMipmap);
                if (texture.LoadImage(readBytes))
                {
                    texture.name     = FileInfo.FilePath;
                    texture.wrapMode = TextureWrapMode.Clamp;
                    //ReadWriteフラグの設定
                    if (RowData != null && RowData.ParseCellOptional("ReadWrite", false))
                    {
                        texture.Apply(false, false);
                    }
                    else
                    {
                        texture.Apply(false, true);
                    }
                }
                else
                {
                    Debug.LogError(" Filed load image " + FileInfo.FilePath);
                }

                break;

            case AssetFileType.Sound:                                   //サウンド
                fileIO.DecodeNoCompress(readBytes);                     //圧縮なしでデコード
                sound      = FileIOManagerBase.ReadAudioFromMem(this.FileName, readBytes);
                sound.name = FileInfo.FilePath;
                break;

            case AssetFileType.Csv:                                     //CSV
                csv = new StringGrid(this.FileName, FileInfo.IsTsv ? CsvType.Tsv : CsvType.Csv, System.Text.Encoding.UTF8.GetString(fileIO.Decode(readBytes)));
                break;

            case AssetFileType.UnityObject:
                Debug.LogError("AssetBundle not support load from utage cript cache file");
                break;

            default:
                break;
            }
        }
        public void ParseRowWithTooManyColumns()
        {
            RowData rowData = new RowData();
            // It will repeat the given string up to 8000 characters nad that
            // will pass the maximum number of columns.
            IFileReader reader    = new FileReaderTestImpl("ABC,", 2000 * 4);
            RowParser   rowParser = new RowParser(",", "\r\n", string.Empty);

            rowParser.ParseNextRow(reader, rowData);
        }
Esempio n. 10
0
 protected virtual void SetCritical()
 {
     for (int i = 0; i < length; i++)
     {
         if (rowCodes[i].CritCheck(i == 0 ? null : (RowData?)rowCodes[i - 1]) != true)
         {
             rowCodes[i] = new RowData('p', 'p', 'p');
         }
     }
 }
Esempio n. 11
0
        public static RowData MapToRowData(Row rowDTO)
        {
            var rowData = new RowData();

            foreach (var cellDTO in rowDTO.Cells)
            {
                rowData.Values.Add(MapToCellData(cellDTO));
            }
            return(rowData);
        }
Esempio n. 12
0
        public static RowData GetEmployeeRowDataByAccount(string account)
        {
            account = BuildAccountDomain(account);
            SectionQuery query = Session.CreateSectionQuery();

            query.ConditionGroup.Conditions.AddNew("AccountName", FieldType.Unistring, ConditionOperation.Equals, account);
            RowData rdEmployee = SessionManager.SecStaffEmployees.FindRows(query.GetXml())[0];

            return(rdEmployee);
        }
Esempio n. 13
0
 public CandleStick(string _RowData)
 {
     RowDataString = _RowData;
     RowData       = _RowData.Split(',');
     Date          = RowData.ElementAt(0);
     Open          = double.Parse(RowData.ElementAt(1));
     High          = double.Parse(RowData.ElementAt(2));
     Low           = double.Parse(RowData.ElementAt(3));
     Close         = double.Parse(RowData.ElementAt(4));
 }
        private static void SetRowDoubleValue(this SectionData self, string fieldValue,
                                              object value, string fieldName = "Name",
                                              FieldType fieldType            = FieldType.Unistring)
        {
            RowData rd = self.FindRow(string.Format("@{0}='{1}'", fieldName, fieldValue));

            rd.SetValue("Value", value, fieldType);
            rd.SetString("DisplayValue", value);
            rd.SetString("TextValue", value);
        }
Esempio n. 15
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            RowData row = item as RowData;

            if (row != null)
            {
                return(row.EvenRow ? EvenRowTemplate : OddRowTemplate);
            }
            return(base.SelectTemplate(item, container));
        }
        public void ResetRowDataTest()
        {
            RowData target = new RowData();

            target.AddColumnData("A");
            target.AddColumnData("B");
            Assert.AreEqual <int>(2, target.ColumnCount);
            target.ResetRowData();
            Assert.AreEqual <int>(0, target.ColumnCount);
        }
Esempio n. 17
0
        public override void ReadLine(System.IO.BinaryReader reader)
        {
            RowData row = new RowData();

            Read <string>(reader, ref row.Comment, stringParse); columnno = 0;
            Read <string>(reader, ref row.Name, stringParse); columnno    = 1;
            Read <int>(reader, ref row.Value, intParse); columnno         = 2;
            Table[lineno] = row;
            columnno      = -1;
        }
Esempio n. 18
0
    private static void MoveExistEmployee(RowData employeeDocsvision, RowData department)
    {
        var newDepartmentCode     = department[RefStaff.Units.Code];
        var existedDepartmentCode = employeeDocsvision.SubSection.ParentRow[RefStaff.Units.Code];

        if (!newDepartmentCode.Equals(existedDepartmentCode))
        {
            employeeDocsvision.Move(Guid.Empty, department.Id);
        }
    }
Esempio n. 19
0
        public void AddRow(IList <CellData> cellData)
        {
            var rowData = new RowData()
            {
                Values = cellData
            };

            _gridData.RowData.Add(rowData);
            _currentRowIndex++;
        }
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);

            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                // 教師類別組合
                Dictionary<string, TeacherTagEntity> teachTagDict = new Dictionary<string, TeacherTagEntity>();
                // 取得教師類別
                foreach (TeacherTagRecord teachTagRec in TeacherTag.SelectByTeacherIDs(e.List))
                {
                    if (teachTagDict.ContainsKey(teachTagRec.RefTeacherID))
                        teachTagDict[teachTagRec.RefTeacherID].AddPrefixName(teachTagRec.Prefix, teachTagRec.Name);
                    else
                    {
                        TeacherTagEntity stn = new TeacherTagEntity();
                        stn.TeacherID = teachTagRec.RefTeacherID;
                        stn.AddPrefixName(teachTagRec.Prefix, teachTagRec.Name);
                        teachTagDict.Add(teachTagRec.RefTeacherID, stn);
                    }
                }

                // 讀取組合後的教師類別
                foreach (TeacherTagEntity teach in teachTagDict.Values)
                {
                    foreach (KeyValuePair<string, List<string>> data in teach.GetPrefixNameDic())
                    {
                        // 當群組空白
                        string key = string.Empty;
                        if (data.Key != " ")
                            key = data.Key;

                        // 類別名稱
                        foreach (string str in data.Value)
                        {
                            RowData row = new RowData();
                            foreach (string field in e.ExportFields)
                            {
                                row.ID = teach.TeacherID;

                                if (field == "群組")
                                    row.Add(field, key);

                                if (field == "類別名稱")
                                    row.Add(field, str);
                            }
                            e.Items.Add(row);
                        }
                    }
                }

                PermRecLogProcess prlp = new PermRecLogProcess();
                prlp.SaveLog("教師.匯出類別", "匯出", "共匯出" + teachTagDict.Values.Count + "筆教師類別資料.");
            };
        }
        private void btnImport_Click(object sender, EventArgs e)
        {
            var fields = TypeData.ContentFullType.Fields.ToArray();

            BackgroundWorker bw = new BackgroundWorker();

            var newrowcount    = lblNewRows.Text;
            var updaterowcount = lblUpdateRows.Text;

            bw.DoWork += delegate
            {
                SetButtonsEnabledDisabled(false);
                int counter = 1;
                foreach (var row in RowData.Where(p => string.IsNullOrEmpty(p.Value.SysID)))
                {
                    var entry = row.Value.GetDynamicEntry(fields);
                    try
                    {
                        SetImportProgressLabel("Importing new data " + counter + " of " + newrowcount);
                        var result        = Library.ContentFul.Client.Instance.AddContent(entry, TypeData.TypeID);
                        var publishResult = Library.ContentFul.Client.Instance.PublishContent(result.SystemProperties.Id, result.SystemProperties.Version ?? 1);
                        int j             = 0;
                        counter++;
                    }
                    catch (Exception err)
                    {
                        int j = 0;
                        counter++;
                    }
                }
                counter = 1;
                foreach (var row in RowData.Where(p => !string.IsNullOrEmpty(p.Value.SysID)))
                {
                    var entry = row.Value.GetDynamicEntry(fields);
                    try
                    {
                        SetImportProgressLabel("Importing update data " + counter + " of " + updaterowcount);
                        var result = Library.ContentFul.Client.Instance.UpdateContent(entry, TypeData.TypeID);
                        int j      = 0;
                        counter++;
                    }
                    catch (Exception err)
                    {
                        int j = 0;
                        counter++;
                    }
                }
                SetButtonsEnabledDisabled(true);
                Library.ContentFul.Client.Instance.UpdateLanguageCountryVersion();
                ReturnDialogOK();
            };


            bw.RunWorkerAsync();
        }
        /// <summary>
        /// Инициализирует папку заданными значениями.
        /// </summary>
        /// <param name="Device">Прибор.</param>
        /// <param name="CodeID">ID кода СКБ.</param>
        /// <param name="CodeName">Отобразаемое значение кода СКБ.</param>
        /// <param name="DocumentID">ID документа.</param>
        /// <param name="DocumentName">Название документа.</param>
        /// <param name="FolderID">ID папки.</param>
        public DocumentsFolder(Folder ParentFolder, CardData Document, SavedSearchGroup SearchGroup, SavedView View, FolderCard FolderCard)
        {
            this.ParentFolder = ParentFolder;
            this.Document     = Document;
            DocumentID        = Document.Id;

            SectionData Properties = Document.Sections[CardOrd.Properties.ID];

            DocumentType = Properties.FindRow("@Name = '" + RefPropertiesCD.Requisities.FileType + "'").GetString("Value");
            RowData Code = Properties.FindRow("@Name = '" + RefPropertiesCD.Requisities.Code + "'");

            CodeID   = Code.GetGuid("Value").Value;
            CodeName = Code.GetString("DisplayValue");
            RowData Applicable = Properties.FindRow("@Name = '" + RefPropertiesCD.Requisities.Applicable + "'");

            Applicability = Applicable.GetString("DisplayValue");
            RowData Name = Properties.FindRow("@Name = '" + RefPropertiesCD.Requisities.DocumentName + "'");

            string ShortType = DocumentType == "СД - Спецификация (не платы)" || DocumentType == "СП - Спецификация платы" ? "" : DocumentType.Remove(DocumentType.IndexOf(" - "));

            DocumentName = CodeName + " " + ShortType + " " + Name.GetString("Value");

            Folder      = FolderCard.CreateFolder(ParentFolder.Id, DocumentName);
            Folder.Type = FolderTypes.Virtual;

            if (!SearchGroup.Queries.Any(row => row.Name == DocumentName))
            {
                SearchQuery   Query    = FolderCard.Session.CreateSearchQuery();
                CardTypeQuery CardType = Query.AttributiveSearch.CardTypeQueries.AddNew(CardOrd.ID);
                SectionQuery  Section  = CardType.SectionQueries.AddNew(CardOrd.MainInfo.ID);
                Section.Operation = SectionQueryOperation.And;
                Section.ConditionGroup.Operation = ConditionGroupOperation.And;
                Section.ConditionGroup.Conditions.AddNew(CardOrd.MainInfo.Type, FieldType.RefId, ConditionOperation.Equals, MyHelper.RefType_CD);

                Section           = CardType.SectionQueries.AddNew(CardOrd.Properties.ID);
                Section.Operation = SectionQueryOperation.And;
                Section.ConditionGroup.Operation = ConditionGroupOperation.And;
                Section.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Value, FieldType.Unistring, ConditionOperation.Equals, DocumentType);
                Section.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Name, FieldType.Unistring, ConditionOperation.Equals, RefPropertiesCD.Requisities.FileType);

                Section           = CardType.SectionQueries.AddNew(CardOrd.Properties.ID);
                Section.Operation = SectionQueryOperation.And;
                Section.ConditionGroup.Operation = ConditionGroupOperation.And;
                Section.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Value, FieldType.RefId, ConditionOperation.Equals, CodeID);
                Section.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Name, FieldType.Unistring, ConditionOperation.Equals, RefPropertiesCD.Requisities.Code);
                Query.Limit = 0;
                SearchGroup.Queries.AddNew(DocumentName).Import(Query);
            }
            SavedSearchQuery SavedQuery = SearchGroup.Queries.First(row => row.Name == DocumentName);

            Folder.RefId = SavedQuery.Id;

            Folder.CurrentViewId = View.Id;
            Folder.DefaultViewId = View.Id;
        }
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);

            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                // 班級類別組合
                Dictionary<string, CourseTagEntity> courTagDict = new Dictionary<string, CourseTagEntity>();
                // 取得班級類別
                foreach (CourseTagRecord courTagRec in CourseTag.SelectByCourseIDs(e.List))
                {
                    if (courTagDict.ContainsKey(courTagRec.RefCourseID))
                        courTagDict[courTagRec.RefCourseID].AddPrefixName(courTagRec.Prefix, courTagRec.Name);
                    else
                    {
                        CourseTagEntity cou = new CourseTagEntity();
                        cou.ClassID = courTagRec.RefCourseID;
                        cou.AddPrefixName(courTagRec.Prefix, courTagRec.Name);
                        courTagDict.Add(courTagRec.RefCourseID, cou);
                    }
                }

                // 讀取組合後的學生類別
                foreach (CourseTagEntity cour in courTagDict.Values)
                {
                    foreach (KeyValuePair<string, List<string>> data in cour.GetPrefixNameDic())
                    {
                        // 當群組空白
                        string key = string.Empty;
                        if (data.Key != " ")
                            key = data.Key;

                        // 類別名稱
                        foreach (string str in data.Value)
                        {
                            RowData row = new RowData();
                            foreach (string field in e.ExportFields)
                            {
                                row.ID = cour.ClassID;

                                if (field == "群組")
                                    row.Add(field, key);

                                if (field == "類別名稱")
                                    row.Add(field, str);
                            }
                            e.Items.Add(row);
                        }
                    }
                }

                PermRecLogProcess prlp = new PermRecLogProcess();
                prlp.SaveLog("課程.匯出類別", "匯出", "共匯出" + courTagDict.Values.Count + "筆課程類別資料.");
            };
        }
Esempio n. 24
0
        static void Main(string[] args)
        {
            SetLicense();

            string executionDirectory = Path.GetDirectoryName(
                System.Reflection.Assembly.GetExecutingAssembly().Location);

            ViewerConfig viewerConfig = new ViewerConfig();

            viewerConfig.StoragePath = executionDirectory;
            viewerConfig.UsePdf      = true;

            ViewerImageHandler viewerImageHandler = new ViewerImageHandler(viewerConfig);

            string guid = "Resources\\sample.pdf";

            DocumentInfoOptions documentInfoOptions =
                new DocumentInfoOptions(guid);
            DocumentInfoContainer documentInfoContainer =
                viewerImageHandler.GetDocumentInfo(documentInfoOptions);

            foreach (PageData pageData in documentInfoContainer.Pages)
            {
                Console.WriteLine("Page number: " + pageData.Number);

                for (int i = 0; i < pageData.Rows.Count; i++)
                {
                    RowData rowData = pageData.Rows[i];

                    Console.WriteLine("Row: " + (i + 1));
                    Console.WriteLine("Text: " + rowData.Text);
                    Console.WriteLine("Text width: " + rowData.LineWidth);
                    Console.WriteLine("Text height: " + rowData.LineHeight);
                    Console.WriteLine("Distance from left: " + rowData.LineLeft);
                    Console.WriteLine("Distance from top: " + rowData.LineTop);

                    string[] words = rowData.Text.Split(' ');

                    for (int j = 0; j < words.Length; j++)
                    {
                        int coordinateIndex = j == 0 ? 0 : j + 1;

                        Console.WriteLine(string.Empty);
                        Console.WriteLine("Word: '" + words[j] + "'");
                        Console.WriteLine("Word distance from left: " + rowData.TextCoordinates[coordinateIndex]);
                        Console.WriteLine("Word width: " + rowData.TextCoordinates[coordinateIndex + 1]);
                        Console.WriteLine(string.Empty);
                    }
                }

                Console.WriteLine(string.Empty);
            }

            Console.ReadKey();
        }
Esempio n. 25
0
        public VMRowBlock()
        {
            _cellsCollection  = new ObservableCollection <CellBlock>();
            _rowData          = new RowData();
            _facade           = Facade.Down;
            _direction        = Direction.LeftToRight;
            _doorDirection    = DoorDirection.Left;
            _isHitTestVisible = true;

            CellsCollection.CollectionChanged += CellsCollection_CollectionChanged;
        }
Esempio n. 26
0
        public FileRow(RowData row)
        {
            Guid     versionedFileCard_id       = new Guid(row["FileId"].ToString());
            CardData versionedFileCard_cardData = SessionManager.Session.CardManager.GetCardData(versionedFileCard_id);
            RowData  mainInfo_rd = versionedFileCard_cardData.Sections[new Guid("2FDE03C2-FF87-4E42-A8C2-7CED181977FB")].FirstRow;

            this.fileName = mainInfo_rd["Name"].ToString();
            RowData version_rd = versionedFileCard_cardData.Sections[new Guid("F831372E-8A76-4ABC-AF15-D86DC5FFBE12")].Rows.OrderBy(r => int.Parse(r["Version"].ToString())).First();

            this.fileId = version_rd["FileID"].ToString();
        }
        // 實作匯出
        public override void InitializeExport(ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                // 透過學生編號取得UDT兄弟姊妹資訊
                AccessHelper         accessHelper      = new AccessHelper();
                string               qry               = "ref_student_id IN(" + string.Join(",", e.List.ToArray()) + ")";
                List <SiblingRecord> SiblingRecordList = accessHelper.Select <SiblingRecord>(qry);

                // 填入資料
                foreach (SiblingRecord sr in SiblingRecordList)
                {
                    // 填入資料
                    RowData row = new RowData();
                    row.ID = sr.StudnetID.ToString();

                    foreach (string field in e.ExportFields)
                    {
                        // 檢查需要匯出欄位
                        if (wizard.ExportableFields.Contains(field))
                        {
                            switch (field)
                            {
                            case "兄弟姊妹姓名":
                                row.Add(field, sr.SiblingName);
                                break;

                            case "稱謂":
                                row.Add(field, sr.SiblingTitle);
                                break;

                            case "生日":
                                row.Add(field, sr.Birthday.ToShortDateString());
                                break;

                            case "學校名稱":
                                row.Add(field, sr.SchoolName);
                                break;

                            case "班級名稱":
                                row.Add(field, sr.ClassName);
                                break;

                            case "備註":
                                row.Add(field, sr.Remark);
                                break;
                            }
                        }
                    }
                    e.Items.Add(row);
                }
            };
        }
Esempio n. 28
0
    public RowData CreateEmployee(RowData department)
    {
        if (department == null)
        {
            return(null);
        }

        RowDataCollection employeeRows = department.ChildSections[RefStaff.Employees.ID].Rows;

        return(employeeRows.AddNew());
    }
Esempio n. 29
0
        private void InvDbAnalysis(MySql dbAccess, RowData row)
        {
            var qry = from DataRow record in dbAccess.invLicCombined.Rows
                      where ((record["mr_serial_number"] != DBNull.Value) ? (string)record["mr_serial_number"] : "") == row.mSerNo && ((record["mr_manufacturer"] != DBNull.Value) ? (string)record["mr_manufacturer"] : "") == row.mMfr
                      select new { rec = record, indx = dbAccess.invLicCombined.Rows.IndexOf(record) };

            switch (qry.Count())
            {
            case 0:
                row.mRsult = "No Entry in Inventory or License Database";
                UpdateWSheetRow(rowList.IndexOf(row));
                return;

            case 1:
                break;

            default:
                row.mRsult = "Multiple Entries in Inventory Database - major DB error";
                UpdateWSheetRow(rowList.IndexOf(row));
                return;
            }
            //at this point have only 1 record which is correct and desirable
            DataRow     rowInvTable     = qry.ElementAtOrDefault(0).rec;  //row in license table to be processed
            int         invTableRow     = qry.ElementAtOrDefault(0).indx; //index of that row - needed for later updating of the database after row processing
            Func <bool> testIfActive000 = () => ((sbyte)rowInvTable["active"] & 1) == 0;
            Func <bool> qualified4Nlk00 = () => ((sbyte)rowInvTable["active"] & 2) == 2;
            Func <bool> localW7LicAvail = () => ((sbyte)rowInvTable["inv_flags"] & 4) == 4;
            Func <bool> locW7withKtype0 = () => (string.IsNullOrWhiteSpace((string)rowInvTable["os_product_key_type"])) == false;
            //Func<bool> locW7withlast5c = () => (string.IsNullOrWhiteSpace((string)rowInvTable["os_partial_product_key"])) == false;
            Action errMessageNotActiv = () => { row.mRsult = "Flagged as Not Active System in Inventory database"; };
            Action errMessNotW7Eligab = () => { row.mStatus = "System in Inventory DB, but is not eligible for NLK Win 7 installation"; ProcessNewKeyInv(row, "System Status updated in Inventory DB to allow key download and install", rowInvTable); };
            Action statusPartKeyExist = () => { row.mStatus = "Windows 7, Key Type is " + rowInvTable["os_product_key_type"] + " with last 5 of " + rowInvTable["os_partial_product_key"]; ProcessNewKeyInv(row, "Inventory DB Product Key updated and ready for download", rowInvTable); };
            Action statusWindowsXP000 = () => { row.mStatus = "Windows XP or No data for Windows 7"; ProcessNewKeyInv(row, "Inventory DB Product Key added and is ready for download", rowInvTable); };

            //Action statusNlkEligible0 = () => { row.mStatus = "NLK Eligible"; ProcessNewKeyInv(row, "Product Key added and is ready for download", rowInvTable); };
            LogicTable.Start()
            .Condition(testIfActive000, "TFFF")
            .Condition(qualified4Nlk00, "-F-T")
            .Condition(localW7LicAvail, "-FT-")
            .Condition(locW7withKtype0, "---F")
            .Action(errMessageNotActiv, "X   ")
            .Action(errMessNotW7Eligab, " X  ")       // W7 Home premium will end on this action
            .Action(statusPartKeyExist, "  X ")
            .Action(statusWindowsXP000, "   X");
            dbAccess.invLicCombined.Rows[invTableRow]["active"]         = rowInvTable["active"];
            dbAccess.invLicCombined.Rows[invTableRow]["inv_flags"]      = rowInvTable["inv_flags"];
            dbAccess.invLicCombined.Rows[invTableRow]["os_product_key"] = rowInvTable["os_product_key"];
            UpdateWSheetRow(rowList.IndexOf(row));
            if (sqlQryResultInventory.Length != 0)
            {
                sqlQryResultInventory.Append(" OR ");
            }
            sqlQryResultInventory.Append("(`mr_manufacturer` = " + "'" + row.mMfr + "' AND " + "`mr_serial_number` = " + "'" + row.mSerNo + "')");
        }
Esempio n. 30
0
        private ITabularParameterRow ToRowResult(RowData row, int index)
        {
            var values = Columns.Select(c =>
            {
                var expected = row.Expected != null ? c.GetValue(row.Expected) : ColumnValue.None;
                var actual   = row.Actual.Exception == null && row.Actual.Value != null ? c.GetValue(row.Actual.Value) : ColumnValue.None;
                return(ToColumnValueResult(c, expected, actual));
            });

            return(new TabularParameterRow(index, row.Type, values, row.Actual.Exception));
        }
Esempio n. 31
0
        private static void fillRow(SvodDdr.DdrDataContext dc, int rowIndex,  RowData totalRow, Worksheet ws,  
            List<SourceData> sqlData)
        {
            var rowData = new RowData();
            var row = (Range) ws.Rows[rowIndex];
            string serviceCode = ((Range)row.Cells[1, serviceCodeColumn]).Value2.ToString();

            rowData.Select(sqlData, serviceCode);
            rowData.Fill(ws, rowIndex);
            totalRow.Accumulate(rowData);
        }
        public void ReadColumnNamesTest()
        {
            RowData             rowData = new RowData();
            IFileReader         reader  = FileReaderTest.GetReader("A,B,C\r\n1,2,3");
            DelimitedFileParser parser  = new DelimitedFileParser(",", "\r\n");

            parser.ColumnNameInFirstRow = true;

            parser.ParseNextRow(reader, rowData);
            RowDataTest.VerifyParsedRow(rowData, new string[] { "A", "B", "C" });
        }
Esempio n. 33
0
 private void ResetData(DataGridView dgv, int rowIndex)
 {
     if (dgv != null && dgv.Rows.Count > rowIndex)
     {
         RowData rowData = (RowData)dgv.Rows[rowIndex].Cells[2].Value;
         rowData.IsSelected          = false;
         dgv.Rows[rowIndex].Selected = false;
         this.dgv      = null;
         this.rowIndex = 0;
     }
 }
Esempio n. 34
0
        private void SetData(DataGridView dgv, int rowIndex)
        {
            dgvTmp        = null;
            this.dgv      = dgv;
            this.rowIndex = rowIndex;
            RowData rowData = (RowData)dgv.Rows[rowIndex].Cells[2].Value;

            rowData.IsSelected          = true;
            dgv.Rows[rowIndex].Selected = false;
            dgv.Rows[rowIndex].Selected = true;
        }
        private void InsertRowValue(object rowValue, string displayRowValue, IDataType dataType)
        {
            var currentColumnRowValue = CurrentColumnInfo.RowValues.FirstOrDefault(x => x.DisplayRowValue == displayRowValue);

            if (currentColumnRowValue == null)
            {
                currentColumnRowValue = new RowData(displayRowValue, dataType);
                CurrentColumnInfo.RowValues.Add(currentColumnRowValue);
            }
            currentColumnRowValue.AddRowValue(rowValue);
        }
Esempio n. 36
0
        static void OnRowDataContentChanged(object sender, DependencyObject d)
        {
            RowData rowData = sender as RowData;
            int     index   = ((GridControl)rowData.View.DataControl).GetRowListIndexByRow(rowData.Row);

            if (index == -1)
            {
                return;
            }
            SetIsExpanderExpanded(d, GetExpandedRowsList(rowData.View).Contains(index));
        }
        public void ParseSingleQualifiedColumn()
        {
            RowData     rowData   = new RowData();
            IFileReader reader    = FileReaderTest.GetReader("\"A,B\r\n\",C\r\n1,2,3");
            RowParser   rowParser = new RowParser(string.Empty, "\r\n", "\"");

            rowParser.ParseNextRow(reader, rowData);
            RowDataTest.VerifyParsedRow(rowData, "\"A,B\r\n\",C\r\n", new string[] { "A,B\r\n,C" });
            rowParser.ParseNextRow(reader, rowData);
            RowDataTest.VerifyParsedRow(rowData, "1,2,3", new string[] { "1,2,3" });
        }
Esempio n. 38
0
 private void SetEmployeeStatus(bool?actual, RowData employeeDocsvision)
 {
     if (actual.HasValue && !actual.Value)
     {
         employeeDocsvision[RefStaff.Employees.Status] = StaffEmployeeStatus.Discharged;
     }
     else
     {
         employeeDocsvision[RefStaff.Employees.Status] = StaffEmployeeStatus.Active;
     }
 }
        public void AddColumnDataTest()
        {
            RowData target = new RowData();

            target.AddColumnData("ABC");
            Assert.AreEqual <int>(1, target.ColumnCount);
            target.AddColumnData("DEF");
            Assert.AreEqual <int>(2, target.ColumnCount);
            Assert.AreEqual <string>("ABC", target.GetColumnData(0));
            Assert.AreEqual <string>("DEF", target.GetColumnData(1));
        }
Esempio n. 40
0
        /// <summary>
        /// Adds a BLANK Biffrecord to the internal list
        /// additional the method adds the specific BLANK Data to a data container
        /// </summary>
        /// <param name="number">NUMBER Biffrecord</param>
        public void addBLANK(Blank blank)
        {
            this.BLANKList.Add(blank);
            RowData   rowData = this.getSpecificRow(blank.rw);
            BlankCell cell    = new BlankCell();

            cell.Col        = blank.col;
            cell.Row        = blank.rw;
            cell.TemplateID = blank.ixfe;
            rowData.addCell(cell);
        }
Esempio n. 41
0
        private static void fillRow(SvodDdr.DdrDataContext dc, int rowIndex, Worksheet ws, 
                List<SourceData> sqlData)
        {
            var row = (Range)ws.Rows[rowIndex];
            string propValidValue = ((Range)row.Cells[1, propNameColumn]).Value2;
            propValidValue = propValidValue.Split('=')[1];
            int propTypeId = (int)((Range)row.Cells[1, serviceCodeColumn]).Value2;

            var rowData = new RowData();
            rowData.SelectData(sqlData, propTypeId, propValidValue);
            rowData.Fill(ws, rowIndex);
        }
Esempio n. 42
0
 public bool Get_PriceList(long PriceList_ID, ref int iCount, ref string Err)
 {
     string sql_select_PriceList = @"SELECT
       PriceList.ID,
       PriceList.Name,
       PriceList.Valid,
       PriceList.ValidFrom,
       PriceList.ValidTo,
       PriceList.CreationDate,
       PriceList.Description,
       myOrganisation_Person.ID as myOrganisation_Person_ID
       myOrganisation_PersonData.ID as myOrganisation_PersonData_ID
       myOrganisation_PersonData.UserName,
       myOrganisation_PersonData.FirstName,
       myOrganisation_PersonData.LastName,
       myOrganisation_PersonData.Active,
       myOrganisation_PersonData.Job,
       myOrganisation_PersonData.Description as myOrganisation_Person_Description,
       Currency.ID as Currency_ID,
       Currency.Name as Currency_Name,
       Currency.Abbreviation as Currency_Abbreviation,
       Currency.Symbol as Currency_Symbol,
       Currency.CurrencyCode as Currency_CurrencyCode
     FROM PriceList
     INNER JOIN Currency ON Currency.ID = PriceList.Currency_ID
     LEFT JOIN myOrganisation_Person ON myOrganisation_Person.ID = PriceList.myOrganisation_Person_ID
     LEFT JOIN myOrganisation_PersonData ON myOrganisation_PersonData.ID = myOrganisation_Person.myOrganisation_PersonData_ID
     where PriceList.ID = " + PriceList_ID.ToString();
     dt_xPriceList.Clear();
     if (DBSync.DBSync.ReadDataTable(ref dt_xPriceList, sql_select_PriceList, null, ref Err))
     {
         Count = dt_xPriceList.Rows.Count;
         iCount = Count;
         if (Count > 0)
         {
             RowData rowData = new RowData();
             rowData.GetRowData(dt_xPriceList, 0);
             return true;
         }
         else
         {
             Err = "ERROR:No PriceList data for PriceList_ID = " + PriceList_ID.ToString();
             return false;
         }
     }
     else
     {
         return false;
     }
 }
Esempio n. 43
0
	GameObject GetNewRow(RowData rowData, float width, float height)
	{
		var row = GetEmptyRow(width, height);

		var tileWidth = width / rowData.Count;
		var tileHeight = height;

		foreach (var tileData in rowData)
		{
			var tile = GetNewTile(tileData, tileWidth, tileHeight);
			tile.transform.SetParent(row.transform, false);
		}

		return row;
	}
Esempio n. 44
0
        public static void Manager(String path)
        {


            StreamReader reader = new StreamReader(path);
            Dictionary<String, int> headersIDs = new Dictionary<string, int>();
            String line = reader.ReadLine();
            String[] headers = line.Split(',');

            for (int i = 0; i < headers.Length; i++)
            {
                headersIDs.Add(headers[i], i);
            }
            List<RowData> rowdatalist = new List<RowData>();
            RowData r = new RowData();

            while ((line = reader.ReadLine()) != null)
            {

                String[] fields = line.Split(',');

                r.datetime = DateTime.Parse(fields[headersIDs["DateTime"]].ToString());
                r.ask1 = double.Parse(fields[headersIDs["ask1"]].ToString());
                r.bid1 = double.Parse(fields[headersIDs["bid1"]].ToString());
                r.isTrade = int.Parse(fields[headersIDs["isTrade"]].ToString());
                r.askV = int.Parse(fields[headersIDs["ask1volume"]].ToString());
                r.bidV = int.Parse(fields[headersIDs["bid1Volume"]].ToString());
                r.dir = 0;
                rowdatalist.Add(new RowData(r));
            }
            
            string pathsaved = @"C:\Users\Shiri Miller\Desktop\bin\Test" + cout.ToString() + ".bin";
            Stream s = File.Open(pathsaved, FileMode.Create);
            BinaryFormatter bin = new BinaryFormatter();
            bin.Serialize(s, rowdatalist);
            s.Close();
            Stream ss = File.Open(pathsaved, FileMode.Open);
            BinaryFormatter bbiinn = new BinaryFormatter();

            var lr = (List<RowData>)bbiinn.Deserialize(ss);

            Console.WriteLine(lr.Count);
            cout++;


        }
Esempio n. 45
0
        public static void Fill6000(SvodDdr.DdrDataContext dc)
        {
            dc.context.ReportProgress(@"Заполняем форму 6000 ...");

            var ws = ((Worksheet)dc.newDoc.Worksheets[@"стр.10_12"]);
            ws.Activate();

            var sqlText = string.Format(@"SELECT
                {2} - YEAR(Client.birthDate) as ClientAge,
                Diagnosis.`MKB` AS Mkb,
                Client.`sex` AS Sex,
                COUNT(DISTINCT Event.id) as Kol
                FROM Client
                INNER JOIN EventType ON (EventType.`code` IN ('dd2013_1','dd2013_2'))
                    AND (EventType.`deleted` = 0) AND (Client.`deleted` = 0)
                INNER JOIN Event ON (Event.`eventType_id` = EventType.`id`) AND (Event.`deleted` = 0)
                    AND (Event.`client_id` = Client.`id`)
                INNER JOIN Diagnostic ON (Diagnostic.`event_id` = Event.`id`)
                    AND (Diagnostic.`deleted` = 0)
                INNER JOIN Diagnosis ON (Diagnosis.`id` = Diagnostic.`diagnosis_id`)
                    AND (Diagnosis.`deleted` = 0)
                INNER JOIN rbDiseaseCharacter ON (rbDiseaseCharacter.`id` = Diagnostic.`character_id`)
                    AND (rbDiseaseCharacter.`code` = '5')
                WHERE (Event.`execDate` >= '{0}') AND (Event.`execDate` < '{1}')
                AND COALESCE(Diagnosis.`MKB`, '') <> ''
                AND Diagnosis.`MKB` NOT LIKE 'Z%'
                GROUP BY 1,2,3",
                               dc.dateEnd.BeginOfYear().SqlStr(),
                                dc.dateEnd.AddDays(1).SqlStr(),
                                dc.dateEnd.Year);

            var sqlData = selectSqlData<SourceData>(dc, sqlText);

            var usedData = new List<SourceData>();

            fillSection(dc, ws, sqlData, usedData, 8, 25);
            fillSection(dc, ws, sqlData, usedData, 31, 46);
            fillSection(dc, ws, sqlData, usedData, 52, 68);

            var totalRowData = new RowData();
            totalRowData.SelectData(sqlData, "", usedData, true);
            totalRowData.Fill(ws, 69);

            dc.context.ProgressSeparator();
        }
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                RowData row = new RowData();

                foreach (string field in e.ExportFields)
                {
                    if (wizard.ExportableFields.Contains(field))
                    {
                        switch (field)
                        {
                            case "": break;
                        }
                    }
                }
                e.Items.Add(row);

                // 寫 Log
                // ApplicationLog.Log();
            };
        }
Esempio n. 47
0
        public override void getInfo(RowData r)
        {

            if (ProgramMain.deltaMin(ProgramMain.rowDataToSave.Peek().datetime, borsStart) >= 15)
            {
                int p;
                if (this.firstTime)
                {
                    for (int k = 0; k < paramArr[4]; k++)
                    {
                        this.avgsellsum = 0;
                        this.avgbuysum = 0;
                        for (int i = Convert.ToInt32(paramArr[PlaInArrNumOfRows]) * k; i < Convert.ToInt32(paramArr[PlaInArrNumOfRows]) * k + Convert.ToInt32(paramArr[PlaInArrNumOfRows]); i++)
                        {
                            helper.ToChange(ProgramMain.rowDataToSave.Dequeue());
                            this.avgbuysum += helper.ask1;
                            this.avgsellsum += helper.bid1;
                            saveData1.Enqueue(helper);

                        }


                        this.avgbuy[k] = this.avgbuysum / this.paramArr[PlaInArrNumOfRows];
                        this.avgsell[k] = this.avgsellsum / this.paramArr[PlaInArrNumOfRows];



                    }
                    while (ProgramMain.rowDataToSave.Count != 0)
                    {
                        saveData1.Enqueue(ProgramMain.rowDataToSave.Dequeue());
                    }
                    while (saveData1.Count != 0)
                    {
                        ProgramMain.rowDataToSave.Enqueue(saveData1.Dequeue());
                    }
                    this.firstTime = false;

                }
                else
                {
                    this.avgbuy[0] = (this.avgbuy[0] * this.paramArr[PlaInArrNumOfRows] - ProgramMain.row.ask1 + ProgramMain.toGetPointer[Convert.ToInt32(this.paramArr[PlaInArrNumOfRows]) - 1].ask1) / this.paramArr[PlaInArrNumOfRows];
                    this.avgsell[0] = (this.avgsell[0] * this.paramArr[PlaInArrNumOfRows] - ProgramMain.row.bid1 + ProgramMain.toGetPointer[Convert.ToInt32(this.paramArr[PlaInArrNumOfRows]) - 1].bid1) / this.paramArr[PlaInArrNumOfRows];
                    for (p = 1; p < this.paramArr[4] - 1; p++)
                    {
                        this.avgbuy[p] = (this.avgbuy[p] * this.paramArr[PlaInArrNumOfRows] - ProgramMain.toGetPointer[Convert.ToInt32(this.paramArr[PlaInArrNumOfRows]) * p - 1].ask1 + ProgramMain.toGetPointer[Convert.ToInt32((this.paramArr[PlaInArrNumOfRows]) * (p + 1)) - 1].ask1) / this.paramArr[PlaInArrNumOfRows];
                        this.avgsell[p] = (this.avgsell[p] * this.paramArr[PlaInArrNumOfRows] - ProgramMain.toGetPointer[Convert.ToInt32(this.paramArr[PlaInArrNumOfRows]) * p - 1].bid1 + ProgramMain.toGetPointer[Convert.ToInt32((this.paramArr[PlaInArrNumOfRows]) * (p + 1)) - 1].bid1) / this.paramArr[PlaInArrNumOfRows];

                    }

                }

                //--------------------
                if (!this.inPos)
                {
                    if(miller)
                    {
                        this.isInWait = this.Algo(r,  this.paramArr[1]);
                    }
                    if (isInWait)
                    {
                        miller = false;
                        if (this.timeInWait <= this.paramArr[5])
                        {
                            if (dirForAction)
                            {
                                if (r.ask1 <= this.avgbuy[avgbuy.Length - 1])
                                {
                                    buy(r, 1);
                                    this.isInWait = false;
                                    this.timeInWait = 0;
                                    this.inPos = true;
                                    this.toPass = true;
                                    this.inBuy = true;
                                    this.miller = true;
                                }
                            }

                            if (!dirForAction)
                            {
                                if (r.bid1 >= this.avgsell[avgsell.Length - 1])
                                {
                                    sell(r, 1);
                                    this.isInWait = false;
                                    this.timeInWait = 0;
                                    this.inPos = true;
                                    this.toPass = true;
                                    this.inBuy = false;
                                    this.miller = true;
                                }
                            }
                            if (!this.toPass)
                            {
                                this.toPass = false;
                                this.timeInWait++;
                            }
                        }
                        else
                        {
                            this.isInWait = false;
                            this.miller = true;
                            this.timeInWait = 0;

                        }
                    }


                    //------------------------------------------------------------------
                }
                else
                {
                    if (miller)
                    {
                        this.isInWait = this.Algo2(r, this.paramArr[2], this.getList()[this.getList().Count - 1].getDir());
                    }                 
                    if (isInWait)
                    {
                        this.miller = false;
                        if (this.timeInWait <= this.paramArr[5])
                        {
                            if (dirForAction)
                            {
                                int dir = this.getList()[this.getList().Count - 1].getDir();
                                if (dir == -1)
                                {
                                    if (r.ask1 <= this.avgbuy[avgbuy.Length - 1])
                                    {
                                        buy(r, 1);
                                        this.isInWait = false;
                                        this.timeInWait = 0;
                                        this.inPos = false;
                                        this.toPass = true;
                                        this.inBuy = true;
                                        this.miller = true;
                                    }
                                }
                            }

                            if (!dirForAction)
                            {
                                if (this.getList()[this.getList().Count - 1].getDir() == 1)
                                {
                                    if (r.bid1 >= this.avgsell[avgsell.Length - 1])
                                    {
                                        sell(r, 1);
                                        this.isInWait = false;
                                        this.timeInWait = 0;
                                        this.inPos = false;
                                        this.toPass = true;
                                        this.inBuy = false;
                                        this.miller = true;
                                    }
                                }
                            }
                          
                            
                            if (!this.toPass)
                            {
                                this.toPass = false;
                                this.timeInWait++;
                            }
                        }
                        else
                        {
                            this.miller = true;
                            this.isInWait = false;
                            this.timeInWait = 0;
                        }

                    }
                }
            }
        }
Esempio n. 48
0
        public bool Algo2(RowData r, double pram, int dir)
        {
            bool ok = true;
            int counter = 0;
            int i = 1;
            if (dir == -1)
            {
                
                while (counter <= this.paramArr[3])
                {
                    while (avgbuy[i - 1] < avgbuy[i] && avgbuy[i - 1] / avgbuy[i] >= pram)
                    {
                        if (i == (avgbuy.Length - 1))
                        {

                            this.dirForAction = true;
                            return true;
                        }
                        i++;
                        ok = false;
                    }
                    if (ok)
                    {
                        i++;
                        ok = true;
                    }
                    counter++;
                }

                if (counter <= this.paramArr[3] && i < avgbuy.Length)
                {
                    this.dirForAction = true;
                    return true;
                }

            }
            else
            {

                i = 1;
                ok = true;
                counter = 0;
                while (counter <= this.paramArr[3])
                {
                    while (avgsell[i - 1] < avgsell[i] && avgsell[i - 1] / avgsell[i] >= pram)
                    {
                        if (i == (avgsell.Length - 1))
                        {

                            this.dirForAction = false;
                            return true;

                        }
                        i++;
                        ok = false;
                    }
                    if (ok)
                    {
                        i++;
                        ok = true;
                    }
                    counter++;
                }
                if (counter <= this.paramArr[3] && i < avgsell.Length)
                {
                    this.dirForAction = false;
                    return true;
                }

            }
            return false;
        }
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
               {
               // 依學生ID取得晤談紀錄
                List<DAO.UDT_CounselStudentInterviewRecordDef> _StudentInterviewRecordList = _UDTTransfer.GetCounselStudentInterviewRecordByStudentIDList(e.List);

                // 取得教師ID與名稱對照
                Dictionary<int, string> TeacherNameDict = Utility.GetTeacherIDNameDict();

               Dictionary<string, string> item_AttendessDict = new Dictionary<string, string>();
                Dictionary<string, string> item_CounselTypeDict = new Dictionary<string, string>();
                Dictionary<string, string> item_CounselTypeKindDict = new Dictionary<string, string>();

                // 學生ID List
                List<int> studIdList = (from data in _StudentInterviewRecordList select data.StudentID).ToList();

                // 取得學生名稱log 用
                Dictionary<string, string> StudentNameDict = new Dictionary<string, string>();
                foreach (KeyValuePair<int, string> data in Utility.GetConvertStringDict1fromDB(studIdList))
                    StudentNameDict.Add(data.Key.ToString(), data.Value);

                // 記錄匯出 log 細項用
                Dictionary<string, StringBuilder> logData = new Dictionary<string, StringBuilder>();

                // 匯出總筆數
                int totalCount = 0;

                foreach (DAO.UDT_CounselStudentInterviewRecordDef csir in _StudentInterviewRecordList)
                {

                    // 取得 XML 解析後
                    item_AttendessDict = Utility.GetConvertCounselXMLVal_Attendees(csir.Attendees);
                    item_CounselTypeDict = Utility.GetConvertCounselXMLVal_CounselType(csir.CounselType);
                    item_CounselTypeKindDict = Utility.GetConvertCounselXMLVal_CounselTypeKind(csir.CounselTypeKind);

                    RowData row = new RowData();
                    row.ID = csir.StudentID.ToString();
                     foreach (string field in e.ExportFields)
                     {
                         if (wizard.ExportableFields.Contains(field))
                         {
                             // 參與人員
                             if (item_AttendessDict.ContainsKey(field))
                                 row.Add(field, item_AttendessDict[field]);

                             // 輔導方式
                             if (item_CounselTypeDict.ContainsKey(field))
                                 row.Add(field, item_CounselTypeDict[field]);

                             // 輔導歸類
                             if (item_CounselTypeKindDict.ContainsKey(field))
                                 row.Add(field, item_CounselTypeKindDict[field]);

                             switch (field)
                             {
                                 case "晤談編號":
                                     row.Add(field, csir.InterviewNo);
                                     break;
                                 case "晤談老師":
                                     // 需轉換
                                   if(TeacherNameDict.ContainsKey(csir.TeacherID))
                                       row.Add(field, TeacherNameDict[csir.TeacherID]);
                                     break;
                                 case "晤談方式":
                                     row.Add(field, csir.InterviewType);
                                     break;
                                 case "晤談對象":
                                     row.Add(field, csir.IntervieweeType);
                                     break;
                                 case "日期":
                                     if(csir.InterviewDate.HasValue )
                                        row.Add(field, csir.InterviewDate.Value.ToShortDateString());
                                     break;
                                 case "時間":
                                     row.Add(field, csir.InterviewTime);
                                     break;
                                 case "地點":
                                     row.Add(field, csir.Place);
                                     break;
                                 case "晤談事由":
                                     row.Add(field, csir.Cause);
                                     break;
                                 case "參與人員":
                                     // 解析 XML
                                     row.Add(field,Utility.AttendeesXMLToString(csir.Attendees));
                                     break;
                                 case "輔導方式":
                                     // 解析 XML
                                     row.Add(field, Utility.CounselTypeXMLToString(csir.CounselType));
                                     break;
                                 case "輔導歸類":
                                     // 解析 XML
                                     row.Add(field, Utility.CounselTypeKindXMLToString(csir.CounselTypeKind));
                                     break;
                                 case "內容要點":
                                     row.Add(field, csir.ContentDigest);
                                     break;

                                 case "記錄者":
                                     row.Add(field, csir.AuthorID);
                                     break;

                                 case "記錄者姓名":
                                     row.Add(field, csir.AuthorName);
                                     break;

                                 case "狀態":
                                     row.Add(field, csir.StudentStatus);
                                     break;

                             }
                         }
                     }
                     e.Items.Add(row);
                }
                // 處理 log 細項
                foreach (RowData rd in e.Items)
                {
                    // 收集 log
                    StringBuilder sb = new StringBuilder();
                    if (StudentNameDict.ContainsKey(rd.ID))
                        sb.AppendLine(StudentNameDict[rd.ID]);
                    sb.AppendLine(this.Text);
                    foreach (KeyValuePair<string, string> data in rd)
                        sb.AppendLine(data.Key + ":" + data.Value);

                    // 加入 log
                    if (logData.ContainsKey(rd.ID))
                    {
                        sb.AppendLine();
                        logData[rd.ID].AppendLine(sb.ToString());
                    }
                    else
                        logData.Add(rd.ID, sb);
                }

                // 寫入 log
                DAO.LogTransfer log = new DAO.LogTransfer();
                foreach (KeyValuePair<string, StringBuilder> data in logData)
                    log.SaveLog("輔導系統." + this.Text, "匯出", "student", data.Key, data.Value);

                StringBuilder sbT = new StringBuilder();
                sbT.AppendLine(this.Text);
                sbT.AppendLine("總共匯出" + logData.Keys.Count + "位學生 , 共" + totalCount + "筆");
                sbT.AppendLine("匯出學生名單..");
                foreach (KeyValuePair<string, string> data in StudentNameDict)
                    if (logData.ContainsKey(data.Key))
                        sbT.AppendLine(data.Value);

                log.SaveLog("輔導系統." + this.Text, "匯出", "student", "", sbT);
               };
        }
Esempio n. 50
0
        public static void setReportData40(ref MySqlDataReader oDataReader, ref RowData oRawData)
        {
            //oRawData.RowNum = i.ToString();
            oRawData.rowData = new List<string>();
            //Type oType = oRawData.GetType();

            for (int iIndex = 1; iIndex <= oDataReader.FieldCount; iIndex++)
            {
                if (!Convert.IsDBNull(oDataReader[iIndex - 1]))
                {
                    oRawData.rowData.Add(Convert.ToString(oDataReader[iIndex - 1]));
                    //oType.GetProperty("Collumn" + iIndex.ToString()).SetValue(oRawData, Convert.ToString(oDataReader[iIndex - 1]), null);
                }
                else
                {
                    oRawData.rowData.Add("");
                    //oType.GetProperty("Collumn" + iIndex.ToString()).SetValue(oRawData, "", null);
                }

                //if (!Convert.IsDBNull(oDataReader[iIndex - 1]))
                //{
                //    oType.GetProperty("Collumn" + iIndex.ToString()).SetValue(oRawData, Convert.ToString(oDataReader[iIndex - 1]), null);
                //}
                //else
                //{
                //    oType.GetProperty("Collumn" + iIndex.ToString()).SetValue(oRawData, "", null);
                //}
            }
        }
        private void _BKWValidate_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bkw = (BackgroundWorker)sender;
            List<string> selectedFields = (List<string>)((object[])e.Argument)[0];
            Dictionary<string, int> importFields = (Dictionary<string, int>)((object[])e.Argument)[1];
            Workbook wb = (Workbook)((object[])e.Argument)[2];
            wb.Worksheets[0].Comments.Clear();
            wb.Worksheets[0].Hyperlinks.Clear();
            int errorSheetIndex = wb.Worksheets.Add();
            {
                int errc = 0;
                #region 命名
                for (; ; errc++)
                {
                    bool pass = true;
                    string n = "錯誤&警告說明" + (errc == 0 ? "" : "(" + errc + ")");
                    foreach (Aspose.Cells.Worksheet var in wb.Worksheets)
                    {
                        if (n == var.Name)
                        {
                            pass = false;
                            break;
                        }
                    }
                    if (pass) break;
                }
                #endregion
                wb.Worksheets[errorSheetIndex].Name = "錯誤&警告說明" + (errc == 0 ? "" : "(" + errc + ")");
            }
            string errorSheetName = wb.Worksheets[errorSheetIndex].Name;
            Worksheet errorSheet = wb.Worksheets[errorSheetIndex];
            errorSheet.Cells[0, 0].PutValue("行號");
            errorSheet.Cells[0, 1].PutValue("種類");
            errorSheet.Cells[0, 2].PutValue("說明");
            int errorSheetRowIndex = 1;

            Style errorStyle = wb.Styles[wb.Styles.Add()];
            Style warningStyle = wb.Styles[wb.Styles.Add()];
            Style passStyle = wb.Styles[wb.Styles.Add()];

            Style errorStyle2 = wb.Styles[wb.Styles.Add()];
            Style warningStyle2 = wb.Styles[wb.Styles.Add()];

            //errorStyle.Pattern = BackgroundType.Solid;
            //errorStyle.ForegroundColor = Color.Red;
            errorStyle.Font.Color = Color.Red;
            errorStyle.Font.Underline = FontUnderlineType.Single;

            //warningStyle.Pattern = BackgroundType.Solid;
            //warningStyle.ForegroundColor = Color.Yellow;
            warningStyle.Font.Color = wb.GetMatchingColor(Color.Goldenrod);
            warningStyle.Font.Underline = FontUnderlineType.Single;

            //passStyle.Pattern = BackgroundType.Solid;
            //passStyle.ForegroundColor = Color.Green;
            passStyle.Font.Color = Color.Green;

            warningStyle2.Font.Color = wb.GetMatchingColor(Color.Goldenrod);
            errorStyle2.Font.Color = Color.Red;

            int errorCount = 0;
            int warningCount = 0;
            Dictionary<RowData, int> rowDataIndex = new Dictionary<RowData, int>();

            Dictionary<int, string> fieldIndex = new Dictionary<int, string>();
            foreach (string field in selectedFields)
            {
                fieldIndex.Add(importFields[field], field);
            }

            double progress = 0.0;

            // 讀取驗證資料工作表使用
            Dictionary<string, int> checkSameDataDic = new Dictionary<string, int>();
            for (int i = 1; i <= wb.Worksheets[0].Cells.MaxDataRow; i++)
            {
                string chkStr = ImportUtil.GetChekcDataStr(i, wb.Worksheets[0], importFields);

                if (!checkSameDataDic.ContainsKey(chkStr))
                    checkSameDataDic.Add(chkStr, 0);
            }

            #region 產生RowData資料
            if (importFields.ContainsKey("姓名") && importFields.ContainsKey("暱稱"))
            {
                #region 用「姓名+暱稱」驗證資料

                List<K12.Data.TeacherRecord> stus = K12.Data.Teacher.SelectAll();
                K12.Data.TeacherRecord stu = new K12.Data.TeacherRecord();
                for (int i = 1; i <= wb.Worksheets[0].Cells.MaxDataRow; i++)
                {

                    // , "學號", "班級", "座號", "科別", "姓名"
                    string name = GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["姓名"]].StringValue);
                    string nickName = GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["暱稱"]].StringValue);
                    if ((name+nickName) != "")
                    {
                        string rowError = "";

                        // 檢查重複資料
                        string chkStr = ImportUtil.GetChekcDataStr(i, wb.Worksheets[0], importFields);
                        if (checkSameDataDic.ContainsKey(chkStr))
                        {
                            checkSameDataDic[chkStr]++;
                            if (checkSameDataDic[chkStr] > 1)
                                rowError = "有重複資料!";
                        }

                        #region 驗明正身
                        if (stus != null)
                        {
                            if (stus.Where(x => (x.Name.Trim() == name.Trim() && x.Nickname.Trim() == nickName.Trim())).Count() == 0)
                                rowError = "教師不存在於系統中,請先新增教師資料!!";
                        }
                        else
                            rowError = "教師不存在於系統中,請先新增教師資料!!";
                        #endregion
                        if (rowError == "")
                        {
                            stu = stus.Where(x => (x.Name.Trim() == name.Trim() && x.Nickname.Trim() == nickName.Trim())).ElementAt(0);
                            if (!(stu.Status == _StudStatus))
                            {
                                #region 警告非在職教師
                                errorSheet.Cells[errorSheetRowIndex, 0].PutValue(i + 1);
                                errorSheet.Cells[errorSheetRowIndex, 1].PutValue("警告");
                                //errorSheet.Cells[errorSheetRowIndex, 2].PutValue("學生不是在校生。");
                                errorSheet.Cells[errorSheetRowIndex, 2].PutValue("教師不在所選擇狀態內。");
                                errorSheet.Cells[errorSheetRowIndex, 0].Style = warningStyle;
                                errorSheet.Cells[errorSheetRowIndex, 1].Style = warningStyle2;
                                errorSheet.Cells[errorSheetRowIndex, 2].Style = warningStyle2;
                                errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[i, 0].Name);
                                errorSheet.AutoFitRow(errorSheetRowIndex);
                                errorSheetRowIndex++;
                                warningCount++;
                                #endregion
                            }
                            RowData rowdata = new RowData();
                            rowdata.ID = stu.ID;
                            foreach (int index in fieldIndex.Keys)
                            {
                                if (wb.Worksheets[0].Cells[i, index].Type == CellValueType.IsDateTime)
                                {
                                    rowdata.Add(fieldIndex[index], wb.Worksheets[0].Cells[i, index].DateTimeValue.ToString());
                                }
                                else
                                    rowdata.Add(fieldIndex[index], GetTrimText("" + wb.Worksheets[0].Cells[i, index].StringValue));
                            }
                            rowDataIndex.Add(rowdata, i);
                        }
                        else
                        {
                            errorCount++;
                            errorSheet.Cells[errorSheetRowIndex, 0].PutValue(i + 1);
                            errorSheet.Cells[errorSheetRowIndex, 1].PutValue("錯誤");
                            errorSheet.Cells[errorSheetRowIndex, 2].PutValue(rowError);
                            errorSheet.Cells[errorSheetRowIndex, 0].Style = errorStyle;
                            errorSheet.Cells[errorSheetRowIndex, 1].Style = errorStyle2;
                            errorSheet.Cells[errorSheetRowIndex, 2].Style = errorStyle2;
                            errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[i, 0].Name);
                            wb.Worksheets[0].Hyperlinks.Add(i, 0, 1, 1, "'" + errorSheetName + "'!" + errorSheet.Cells[errorSheetRowIndex, 0].Name);
                            errorSheet.AutoFitRow(errorSheetRowIndex);
                            errorSheetRowIndex++;
                            wb.Worksheets[0].Cells[i, 0].Style = errorStyle;
                        }
                    }
                    else
                    {
                        bool isNullRow = true;
                        for (byte c = 0; c < wb.Worksheets[0].Cells.MaxDataColumn; c++)
                        {
                            if (GetTrimText("" + wb.Worksheets[0].Cells[i, c].StringValue) != "")
                                isNullRow = false;
                        }
                        if (!isNullRow)
                        {
                            errorCount++;
                            errorSheet.Cells[errorSheetRowIndex, 0].PutValue(i + 1);
                            errorSheet.Cells[errorSheetRowIndex, 1].PutValue("錯誤");
                            errorSheet.Cells[errorSheetRowIndex, 2].PutValue("驗證欄位(姓名+暱稱)不得空白");
                            errorSheet.Cells[errorSheetRowIndex, 0].Style = errorStyle;
                            errorSheet.Cells[errorSheetRowIndex, 1].Style = errorStyle2;
                            errorSheet.Cells[errorSheetRowIndex, 2].Style = errorStyle2;
                            errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[i, 0].Name);
                            wb.Worksheets[0].Hyperlinks.Add(i, 0, 1, 1, "'" + errorSheetName + "'!" + errorSheet.Cells[errorSheetRowIndex, 0].Name);
                            errorSheet.AutoFitRow(errorSheetRowIndex);
                            errorSheetRowIndex++;
                            wb.Worksheets[0].Cells[i, 0].Style = errorStyle;
                        }
                    }
                    if (bkw.CancellationPending)
                    {
                        e.Cancel = true;
                        _ErrorWB = wb;
                        return;
                    }
                    progress = ((double)i) * 100.0 / 100000;
                    bkw.ReportProgress((int)progress, new int[] { errorCount, warningCount });
                }
                #endregion
            }
            #endregion

            #region 驗證資料
            List<string> list = new List<string>();
            foreach (RowData row in rowDataIndex.Keys)
            {
                if (!list.Contains(row.ID))
                    list.Add(row.ID);
            }
            //_Process.StartValidate(list);
            if (ValidateStart != null)
            {
                SmartSchool.API.PlugIn.Import.ValidateStartEventArgs args = new SmartSchool.API.PlugIn.Import.ValidateStartEventArgs();
                args.List = list.ToArray();
                ValidateStart(this, args);
            }
            double totleCount = (double)rowDataIndex.Count;
            double count = 0.0;
            foreach (RowData row in rowDataIndex.Keys)
            {
                #region 驗證
                string rowError = "";
                Dictionary<string, string> errorFields, warningFields;
                //RowDataValidatedEventArgs args = _Process.ValidateRow(row, selectedFields);
                SmartSchool.API.PlugIn.Import.ValidateRowEventArgs args = new SmartSchool.API.PlugIn.Import.ValidateRowEventArgs();
                args.Data = row;
                args.SelectFields.AddRange(selectedFields);
                if (ValidateRow != null)
                {
                    ValidateRow(this, args);
                }
                errorFields = args.ErrorFields;
                warningFields = args.WarningFields;
                rowError += args.ErrorMessage;
                if (rowError == "" && errorFields.Count == 0 && warningFields.Count == 0)
                {
                    wb.Worksheets[0].Cells[rowDataIndex[row], 0].Style = passStyle;
                }
                else
                {
                    string message = "";
                    bool hasError = false;
                    if (rowError != "" || errorFields.Count != 0)
                    {
                        errorCount++;
                        hasError = true;
                        message = rowError;
                        message += (message == "" ? "" : "\n") + "";
                        foreach (string key in errorFields.Keys)
                        {
                            message += (message == "" ? "" : "\n") + "  " + key + ":" + errorFields[key];
                        }
                        errorSheet.Cells[errorSheetRowIndex, 0].PutValue(rowDataIndex[row] + 1);
                        errorSheet.Cells[errorSheetRowIndex, 1].PutValue(hasError ? "錯誤" : "警告");
                        errorSheet.Cells[errorSheetRowIndex, 2].PutValue(message);
                        errorSheet.Cells[errorSheetRowIndex, 0].Style = errorStyle;
                        errorSheet.Cells[errorSheetRowIndex, 1].Style = errorStyle2;
                        errorSheet.Cells[errorSheetRowIndex, 2].Style = errorStyle2;
                        errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[rowDataIndex[row], 0].Name);
                        wb.Worksheets[0].Hyperlinks.Add(rowDataIndex[row], 0, 1, 1, "'" + errorSheetName + "'!" + errorSheet.Cells[errorSheetRowIndex, 0].Name);
                        errorSheet.AutoFitRow(errorSheetRowIndex);
                        errorSheetRowIndex++;
                    }
                    message = "";
                    if (warningFields.Count != 0)
                    {
                        if (!hasError)
                            warningCount++;
                        message += (message == "" ? "" : "\n") + "";
                        foreach (string key in warningFields.Keys)
                        {
                            message += (message == "" ? "" : "\n") + "  " + key + ":" + warningFields[key];
                        }
                        errorSheet.Cells[errorSheetRowIndex, 0].PutValue(rowDataIndex[row] + 1);
                        errorSheet.Cells[errorSheetRowIndex, 1].PutValue("警告");
                        errorSheet.Cells[errorSheetRowIndex, 2].PutValue(message);
                        errorSheet.Cells[errorSheetRowIndex, 0].Style = warningStyle;
                        errorSheet.Cells[errorSheetRowIndex, 1].Style = warningStyle2;
                        errorSheet.Cells[errorSheetRowIndex, 2].Style = warningStyle2;
                        errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[rowDataIndex[row], 0].Name);
                        if (!hasError)
                            wb.Worksheets[0].Hyperlinks.Add(rowDataIndex[row], 0, 1, 1, "'" + errorSheetName + "'!" + errorSheet.Cells[errorSheetRowIndex, 0].Name);
                        errorSheet.AutoFitRow(errorSheetRowIndex);
                        errorSheetRowIndex++;
                    }
                    wb.Worksheets[0].Cells[rowDataIndex[row], 0].Style = hasError ? errorStyle : warningStyle;
                }
                #endregion
                if (bkw.CancellationPending)
                {
                    e.Cancel = true;
                    _ErrorWB = wb;
                    return;
                }
                count++;
                bkw.ReportProgress((int)(progress + count * (100.0 - progress) / totleCount), new int[] { errorCount, warningCount });
            }

            //_Process.FinishValidate();
            if (ValidateComplete != null)
                ValidateComplete(this, new EventArgs());
            #endregion

            List<RowData> rows = new List<RowData>();
            rows.AddRange(rowDataIndex.Keys);

            bkw.ReportProgress(100, new int[] { errorCount, warningCount });

            errorSheet.AutoFitColumn(0);
            errorSheet.AutoFitColumn(1, 1, 500);
            errorSheet.AutoFitColumn(2, 1, 500);

            e.Result = new object[] { wb, errorCount == 0, rows, selectedFields };
        }
        /// <summary>
        /// Prepare row for rasterize, so that current row always ready to use
        /// </summary>
        /// <param name="startYIndex"></param>
        /// <param name="endYIndex"></param>
        public void PrepareRows(int row)
        {
            if ((Rows == null) || (Rows.Length < DestBufferHeight + 1))
            {
                Rows = new RowData[DestBufferHeight + 1];
            }

            // clip row first
            if (row > ClippingBoxYMax) row = (int)ClippingBoxYMax;
            else if (row < ClippingBoxYMin) row = (int)ClippingBoxYMin;

            // determine min,max y
            if (row < CurrentStartYIndex)
            {
                int oldStartY = CurrentStartYIndex;
                CurrentStartYIndex = row;

                if (row > CurrentEndYIndex)
                {
                    // when the first time drawing, row > current end rowYIndex
                    CurrentEndYIndex = row;
                    Rows[CurrentStartYIndex] = new RowData();
                }
                else
                {
                    // create new from start to old start y
                    for (; row < oldStartY; row++)
                    {
                        Rows[row] = new RowData();
                    }
                }
            }
            else if (row + 1 > CurrentEndYIndex)
            {
                int olfEndY = CurrentEndYIndex;
                CurrentEndYIndex = row + 1;
                if (row < Rows.Length - 1) row++;
                for (; row > olfEndY; row--)
                {
                    Rows[row] = new RowData();
                }
            }
        }
Esempio n. 53
0
 public void Accumulate(RowData data)
 {
     Man.Accumulate(data.Man);
     Woman.Accumulate(data.Woman);
 }
        /// <summary>
        /// Add a line to result row array.
        /// This method need all coordinate has been scaled ( mean multiply for Pixel Scale)
        /// </summary>
        /// <param name="x1Scaled">x coordinate of point 1 ( x * PixelScale)</param>
        /// <param name="y1Scaled">y coordinate of point 1 ( x * PixelScale)</param>
        /// <param name="x2Scaled">x coordinate of point 2 ( x * PixelScale)</param>
        /// <param name="y2Scaled">y coordinate of point 2 ( x * PixelScale)</param>
        /// <remarks>
        /// double coordinate will be convert by using
        /// method upscale() to convert to int before add to rasterizer
        /// Not implement horizontal lines
        /// </remarks>
        protected virtual void DrawScaledLine(int x1Scaled, int y1Scaled, int x2Scaled, int y2Scaled)
        {
#if DEBUG
            int min = -1;
            if ((x1Scaled < min) || (y1Scaled < min) || (x2Scaled < min) || (y2Scaled < min))
            {
                Log.Warning(string.Format("x1: {0} x2: {1} y1: {2} y2: {3}", x1Scaled, x2Scaled, y1Scaled, y2Scaled));
            }
#endif
            int CurrentRowIndex = 0;
            int currentRasterizeX = 0;
            CellData CurrentCell = null, TempCell = null;

            // calculate some property of line
            int slopeByX = (x2Scaled == x1Scaled) ? 0 : (x2Scaled - x1Scaled) < 0 ? -1 : 1;

            #region make sure always draw from left to right ( equal is kept)
            if (slopeByX < 0)
            {
                // switch x1,y1 with x2,y2
                int tempSwitch = x1Scaled;
                x1Scaled = x2Scaled;
                x2Scaled = tempSwitch;

                tempSwitch = y1Scaled;
                y1Scaled = y2Scaled;
                y2Scaled = tempSwitch;
            }
            #endregion

            #region calculate some know value
            int exactlyX1 = x1Scaled >> PixelShift;
            int exactlyX2 = x2Scaled >> PixelShift;
            int exactlyY1 = y1Scaled >> PixelShift;
            int exactlyY2 = y2Scaled >> PixelShift;
            int firstY1 = y1Scaled & PixelMask;
            int firstY2 = y2Scaled & PixelMask;
            int firstX1 = x1Scaled & PixelMask;
            int firstX2 = x2Scaled & PixelMask;
            #endregion

            #region init value for drawing line
            int slopeByY = 0;
            CurrentRowIndex = exactlyY1;
            currentRasterizeX = exactlyX1;
            // special case for start point, may be out side of prepare range
            if (Rows[CurrentRowIndex] == null) Rows[CurrentRowIndex] = new RowData();
            CurrentCell = Rows[CurrentRowIndex].GoToCell(exactlyX1);
            if (y2Scaled > y1Scaled)
            {
                slopeByY = 1;
            }
            else if (y2Scaled < y1Scaled)
            {
                slopeByY = -1;
            }
            #endregion

            //int slope = slopeByX * slopeByY;
            if (slopeByX * slopeByY == 0) // vertical or horizontal
            {
                #region when vertical line
                // when in same cell
                if (exactlyY1 == exactlyY2)
                {
                    CurrentCell.Coverage += y2Scaled - y1Scaled;
                    CurrentCell.Area += (y2Scaled - y1Scaled) * 2 * firstX1;
                }
                else
                {
                    #region  when top -> bottom
                    if (y2Scaled > y1Scaled)
                    {
                        if (firstX1 == 0) // at the right side
                        {
                            firstX1 = 1;
                        }
                        #region draw first
                        CurrentCell.Coverage += PixelScale - firstY1;
                        CurrentCell.Area += (PixelScale - firstY1) * 2 * firstX1;
                        #endregion
                        #region drawing cells
                        // calculate number of cell
                        int totalRows = exactlyY2 - exactlyY1 - 1;
                        while (totalRows-- > 0)
                        {
                            CurrentCell = Rows[++CurrentRowIndex].GoToCell(currentRasterizeX);
                            CurrentCell.Coverage += PixelScale;
                            CurrentCell.Area += firstX1 << 9;

                        }
                        #endregion
                        #region draw last
                        if (firstY2 > 0)
                        {
                            CurrentCell = Rows[++CurrentRowIndex].GoToCell(currentRasterizeX);
                            CurrentCell.Coverage += firstY2;
                            CurrentCell.Area += firstY2 * 2 * firstX1;
                        }
                        #endregion
                    }
                    #endregion
                    #region bottom ->top
                    else
                    {
                        firstX1 = PixelMask - firstX1;
                        if (firstX1 == 0) // at the right side
                        {
                            firstX1 = 1;
                        }
                        #region draw first
                        if (firstY1 != 0)
                        {
                            CurrentCell.Coverage -= firstY1;
                            CurrentCell.Area -= firstY1 * 2 * (PixelScale - firstX1);
                        }
                        #endregion
                        #region drawing cells
                        // calculate number of cell
                        int totalRows = exactlyY1 - exactlyY2 - 1;
                        while (totalRows-- > 0)
                        {
                            CurrentCell = Rows[--CurrentRowIndex].GoToCell(currentRasterizeX);
                            CurrentCell.Coverage -= PixelScale;
                            CurrentCell.Area -= ((PixelScale - firstX1) << 9);
                        }
                        #endregion
                        #region draw last
                        if (firstY2 < PixelScale)
                        {
                            CurrentCell = Rows[--CurrentRowIndex].GoToCell(currentRasterizeX);
                            CurrentCell.Coverage += firstY2 - PixelScale;
                            CurrentCell.Area += (firstY2 - PixelScale) * 2 * (PixelScale - firstX1);
                        }
                        #endregion
                    }
                    #endregion
                }
                // exist function
                return;
                #endregion
            }
            else
            {
                // draw horizontal lines
                #region when in single cell
                if (exactlyX1 == exactlyX2)
                {
                    if (exactlyY1 == exactlyY2)
                    {
                        CurrentCell.Coverage += slopeByX * (y2Scaled - y1Scaled);
                        CurrentCell.Area += slopeByX * (y2Scaled - y1Scaled) * (firstX1 + firstX2);
                        return;
                    }
                }
                #endregion

                #region else ( NORMAL CASE)
                int xFrom = 0, xTo = 0, yFrom = 0, yTo = 0, xCurrentMax = 0, yCurrentMax = 0;

                #region normal line calculation here
                // using x = ( invAlpha * (y-beta) ) >>LineApproxiateScale;
                double invAlpha = (double)(x2Scaled - x1Scaled) / (y2Scaled - y1Scaled);
                // using y = ((alpha * x ) >> LineApproxiateScale) + beta;
                double alpha = (double)(y2Scaled - y1Scaled) / (x2Scaled - x1Scaled);
                // beta
                double beta = ((double)y1Scaled - ((alpha) * x1Scaled));
                #endregion

                #region draw horizontal lines
                #region when slopeY>0
                if (slopeByY > 0)
                {
                    // from left to right
                    // first cell at all
                    xFrom = x1Scaled;
                    yFrom = y1Scaled;
                    // from the first row
                    yCurrentMax = (exactlyY1) << PixelShift;
                    //while (true)
                    while (true)
                    {
                        #region rendering in row
                        // calculate max X  that current line can be draw to int way
                        yCurrentMax += PixelScale;
                        #region check if end
                        // when current Max Y is greater than last y2=> change it
                        if ((yCurrentMax >= y2Scaled) || (xCurrentMax >= x2Scaled))
                        {
                            // all in one row
                            yCurrentMax = y2Scaled;
                            xCurrentMax = x2Scaled;
                        }
                        else
                        {
                            xCurrentMax = (int)(invAlpha * (yCurrentMax - beta));
                        }
                        #endregion
                        xTo = (exactlyX1) << PixelShift;
                        while (true)
                        {
                            #region calculate xTo,yTo
                            // draw horizontal line from x1,y1 to xCurrentMax,yCurrentMax
                            xTo += PixelScale;
                            // check if max x, calculate need value and break
                            if (xTo >= xCurrentMax)
                            {
                                xTo = xCurrentMax;
                                yTo = yCurrentMax;
                                #region calculate and set coverage + area
                                CurrentCell.Coverage += slopeByX * (yTo - yFrom);
                                CurrentCell.Area += slopeByX * (yTo - yFrom) *
                                (((xFrom & PixelMask) + ((xTo - 1) & PixelMask)) + 1);
                                #endregion
                                // continue to next row
                                break;
                            }
                            else
                            {
                                yTo = (int)((alpha * xTo) + beta);
                            }
                            #endregion

                            #region calculate and set coverage + area
                            CurrentCell.Coverage +=
                            slopeByX * (yTo - yFrom);
                            CurrentCell.Area +=
                            slopeByX * (yTo - yFrom) * ((((xFrom) & PixelMask) + ((xTo - 1) & PixelMask)) + 1);
                            #endregion

                            xFrom = xTo;
                            yFrom = yTo;
                            exactlyX1++;
                            #region increase cell
                            ++currentRasterizeX;
                            if (CurrentCell.Next == null)
                            {
                                CurrentCell.Next = new CellData(currentRasterizeX);
                            }
                            else if (CurrentCell.Next.X > currentRasterizeX)
                            {
                                TempCell = CurrentCell.Next;
                                CurrentCell.Next = new CellData(currentRasterizeX);
                                CurrentCell.Next.Next = TempCell;
                            }
                            CurrentCell = CurrentCell.Next;
                            #endregion
                        }
                        #endregion

                        #region check if end and increase row
                        if (++exactlyY1 > exactlyY2)
                        {
                            break;
                        }
                        //increase yFrom ( in case calculation not correct )
                        yFrom = yCurrentMax;
                        xFrom = xCurrentMax;

                        // when cell is not same as expect
                        if ((xFrom >> PixelShift) - exactlyX1 != 0)
                        {
                            // go to next cell
                            CurrentCell = Rows[++CurrentRowIndex].GoToCell(++currentRasterizeX);
                            exactlyX1++;
                        }
                        else
                        {
                            // go to next cell
                            CurrentCell = Rows[++CurrentRowIndex].GoToCell(currentRasterizeX);
                        }
                        #endregion
                    }

                }
                #endregion
                #region when slopeByY<0 ( bottom to top)
                else
                {
                    // from left to right
                    // first cell at all
                    xFrom = x1Scaled;
                    yFrom = y1Scaled;
                    if (firstY1 == 0)
                    {
                        exactlyY1--;
                        CurrentCell = Rows[--CurrentRowIndex].GoToCell(currentRasterizeX);
                    }
                    yCurrentMax = (exactlyY1 + 1) * PixelScale;
                    while (true)
                    {
                        #region rendering rows
                        // calculate max X  that current line can be draw to int way
                        yCurrentMax -= PixelScale;
                        xCurrentMax = (int)(invAlpha * (yCurrentMax - beta));

                        #region check if end
                        // when current Max Y is greater than last y2=> change it
                        if (xCurrentMax >= x2Scaled)
                        {
                            // all in one row
                            yCurrentMax = y2Scaled;
                            xCurrentMax = x2Scaled;
                        }
                        #endregion

                        xTo = (exactlyX1) * PixelScale;

                        while (true)
                        {
                            #region calculate xTo,yTo
                            // draw horizontal line from x1,y1 to xCurrentMax,yCurrentMax
                            xTo += PixelScale;

                            // get max only
                            if (xTo >= xCurrentMax)
                            {
                                xTo = xCurrentMax;
                                yTo = yCurrentMax;
                                #region calculate and set coverage + area
                                CurrentCell.Coverage += slopeByX * (yTo - yFrom);
                                CurrentCell.Area += slopeByX * (yTo - yFrom) * (((xFrom & PixelMask) + ((xTo - 1) & PixelMask)) + 1);
                                #endregion
                                break;
                            }
                            else
                            {
                                // caculate yTo from xTo
                                yTo = (int)((alpha * xTo) + beta);
                            }
                            #endregion
                            #region calculate and set coverage + area
                            CurrentCell.Coverage += slopeByX * (yTo - yFrom);
                            CurrentCell.Area += slopeByX * (yTo - yFrom) * (((xFrom & PixelMask) + ((xTo - 1) & PixelMask)) + 1);
                            #endregion
                            xFrom = xTo;
                            yFrom = yTo;
                            exactlyX1++;

                            #region increase cell
                            ++currentRasterizeX;
                            if (CurrentCell.Next == null)
                            {
                                CurrentCell.Next = new CellData(currentRasterizeX);
                            }
                            else if (CurrentCell.Next.X > currentRasterizeX)
                            {
                                TempCell = CurrentCell.Next;
                                CurrentCell.Next = new CellData(currentRasterizeX);
                                CurrentCell.Next.Next = TempCell;
                            }
                            CurrentCell = CurrentCell.Next;
                            #endregion
                        }

                        #endregion
                        #region check if end
                        if (--exactlyY1 < exactlyY2)
                        {
                            break;
                        }
                        yFrom = yCurrentMax;
                        xFrom = xCurrentMax;
                        if ((xFrom >> PixelShift) - exactlyX1 != 0)
                        {
                            CurrentCell = Rows[--CurrentRowIndex].GoToCell(++currentRasterizeX);
                            exactlyX1++;
                        }
                        else
                        {
                            CurrentCell = Rows[--CurrentRowIndex].GoToCell(currentRasterizeX);
                        }
                        #endregion
                    }
                }
                #endregion
                #endregion

                #endregion
            }
        }
Esempio n. 55
0
        private static void fillSection(SvodDdr.DdrDataContext dc, Worksheet ws,
            int minAge, int maxAge, int rowIndex, List<SourceData> sourceDataList, RowData itogLine)
        {
            foreach (var age in ddrAges.Where(x => x >= minAge && x <= maxAge))
            {
                var lineData = new RowData();

                lineData.Age = age;
                lineData.Select(sourceDataList, dc);
                lineData.Fill(dc, ws, rowIndex);
                itogLine.Accumulate(lineData);

                rowIndex++;
            }
        }
Esempio n. 56
0
        public static void Fill1000(SvodDdr.DdrDataContext dc)
        {
            dc.context.ReportProgress(@"Заполняем форму 1000 ...");

            var ws = ((Worksheet)dc.newDoc.Worksheets[@"стр.2_3"]);
            ws.Activate();

            var itogLine = new RowData();

            var sqlText = String.Format(@"SELECT
            COUNT(DISTINCT IF(ClientAttach.id, Client.id, NULL)) as TotalClients,
            COUNT(DISTINCT IF(ClientAttach.id AND Client.sex = 1, Client.id, NULL)) as TotalMen,
            COUNT(DISTINCT IF(ClientAttach.id AND Client.sex = 2, Client.id, NULL)) as TotalWomen,
            COUNT(DISTINCT IF(Event.id AND 1, Client.id, NULL)) as ProcessedClients,
            COUNT(DISTINCT IF(Event.id AND Client.sex = 1 AND 1, Client.id, NULL)) as ProcessedMen,
            COUNT(DISTINCT IF(Event.id AND Client.sex = 2 AND 1, Client.id, NULL)) as ProcessedWomen,
            {2} - YEAR(Client.birthDate) as age
            FROM Client LEFT JOIN EventType ON (EventType.`deleted` = 0)
            AND (EventType.`code` IN ('dd2013_1','dd2013_2'))
            LEFT JOIN Event ON (EventType.`id` = Event.`eventType_id`) AND (Event.`client_id` = Client.`id`)
            AND (Event.`deleted` = 0) AND (Event.`execDate` >= '{0}')
            AND (Event.`execDate` < '{1}')
            LEFT JOIN ClientAttach ON (ClientAttach.`client_id` = Client.`id`)
            AND (ClientAttach.`deleted` = 0) AND (ClientAttach.`LPU_id` = {3})
            AND (ClientAttach.`attachType_id` = 1)
            WHERE (Client.`deleted` = 0) AND
            ({2} - YEAR(Client.birthDate) IN (21, 24, 27, 30, 33, 36, 39, 42,
            45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99))
            GROUP BY {2} - YEAR(Client.birthDate)",
                                    dc.dateEnd.BeginOfYear().SqlStr(),
                                    dc.dateEnd.AddDays(1).SqlStr(),
                                    dc.dateEnd.Year,
                                    dc.LpuId);

            var sqlData = selectSqlData<SourceData>(dc, sqlText);

            var ddVetSql = string.Format(@"SELECT {2} - YEAR(c.birthDate) AS Age, c.Sex AS Sex
            FROM Event e
            JOIN EventType et ON e.eventType_id = et.id AND e.deleted = 0 AND et.deleted = 0 AND et.code = 'ДДвет'
            JOIN Client c ON e.client_id = c.id
            WHERE e.execDate >= '{0}' AND e.execDate < '{1}'",
               dc.dateEnd.BeginOfYear().SqlStr(),
               dc.dateEnd.AddDays(1).SqlStr(),
               dc.dateEnd.Year);

            var vetList = selectSqlData<DdVetEventData>(dc, ddVetSql);
            foreach (var idData in vetList)
            {
                if (!ddrAges.Contains(idData.Age))
                {
                    var validAge = (from a in ddrAges orderby Math.Abs(a - idData.Age) select a).FirstOrDefault();
                    if (validAge != 0)
                        idData.Age = validAge;
                }
            }

            sqlData.ForEach(x =>
            {
                x.ProcessedMen += vetList.Count(y => y.Age == x.Age && y.Sex == 1);
                x.ProcessedWomen += vetList.Count(y => y.Age == x.Age && y.Sex == 2);
            });

            fillSection(dc, ws, 21, 57, 8, sqlData, itogLine);
            fillSection(dc, ws, 60, 99, 26, sqlData, itogLine);

            itogLine.Fill(dc, ws, 40);

            dc.context.ProgressSeparator();
        }
Esempio n. 57
0
 }// sets the buy/sell arr
 public override void getInfo(RowData r)
 {
     setPointer();
     if (ProgramMain.deltaMin(ProgramMain.lr[lastPoint].datetime, ProgramMain.lr[firstPoint].datetime) >= this.paramArr[1] - (this.paramArr[1])/10)
     {
         if (!buybool && !sellbool)
         {
             avgOrg();
             if (!inPosition)
             {
                 algo();
             }
             else
             {
                 algoExit();
             }
         }
         else 
         {
             if (ProgramMain.deltaMin(r.datetime, ProgramMain.lr[pointerForArr].datetime) < this.paramArr[2])
             {
                 ifAction(r);
             }
             else 
             {
                 sellbool = false;
                 buybool = false;
             }
         }
         //firstPoint++;
     }
 }
        /// <summary>
        /// Appends the row.
        /// </summary>
        /// <param name="rowData">The row data.</param>
        /// <param name="json">The json.</param>
        private void AppendRow(RowData rowData, StringBuilder json)
        {
            string[] textCoordinates = new string[rowData.TextCoordinates.Count];
            for (int i = 0; i < rowData.TextCoordinates.Count; i++)
                textCoordinates[i] = rowData.TextCoordinates[i].ToString(_defaultCulture);

            string[] characterCoordinates = new string[rowData.CharacterCoordinates.Count];
            for (int i = 0; i < rowData.CharacterCoordinates.Count; i++)
                characterCoordinates[i] = rowData.CharacterCoordinates[i].ToString(_defaultCulture);

            json.Append(String.Format("{{\"l\":{0},\"t\":{1},\"w\":{2},\"h\":{3},\"c\":[{4}],\"s\":\"{5}\",\"ch\":[{6}]}}",
                rowData.LineLeft.ToString(_defaultCulture),
                rowData.LineTop.ToString(_defaultCulture),
                rowData.LineWidth.ToString(_defaultCulture),
                rowData.LineHeight.ToString(_defaultCulture),
                string.Join(",", textCoordinates),
                JsonEncode(rowData.Text),
                string.Join(",", characterCoordinates)));
        }
        private void _BKWValidate_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bkw = (BackgroundWorker)sender;
            List<string> selectedFields = (List<string>)((object[])e.Argument)[0];
            Dictionary<string, int> importFields = (Dictionary<string, int>)((object[])e.Argument)[1];
            Workbook wb = (Workbook)((object[])e.Argument)[2];
            wb.Worksheets[0].Comments.Clear();
            wb.Worksheets[0].Hyperlinks.Clear();
            int errorSheetIndex = wb.Worksheets.Add();
            {
                int errc = 0;
                #region 命名
                for (; ; errc++)
                {
                    bool pass = true;
                    string n = "錯誤&警告說明" + (errc == 0 ? "" : "(" + errc + ")");
                    foreach (Aspose.Cells.Worksheet var in wb.Worksheets)
                    {
                        if (n == var.Name)
                        {
                            pass = false;
                            break;
                        }
                    }
                    if (pass) break;
                }
                #endregion
                wb.Worksheets[errorSheetIndex].Name = "錯誤&警告說明" + (errc == 0 ? "" : "(" + errc + ")");
            }
            string errorSheetName = wb.Worksheets[errorSheetIndex].Name;
            Worksheet errorSheet = wb.Worksheets[errorSheetIndex];
            errorSheet.Cells[0, 0].PutValue("行號");
            errorSheet.Cells[0, 1].PutValue("種類");
            errorSheet.Cells[0, 2].PutValue("說明");
            int errorSheetRowIndex = 1;

            Style errorStyle = wb.Styles[wb.Styles.Add()];
            Style warningStyle = wb.Styles[wb.Styles.Add()];
            Style passStyle = wb.Styles[wb.Styles.Add()];

            Style errorStyle2 = wb.Styles[wb.Styles.Add()];
            Style warningStyle2 = wb.Styles[wb.Styles.Add()];

            //errorStyle.Pattern = BackgroundType.Solid;
            //errorStyle.ForegroundColor = Color.Red;
            errorStyle.Font.Color = Color.Red;
            errorStyle.Font.Underline = FontUnderlineType.Single;

            //warningStyle.Pattern = BackgroundType.Solid;
            //warningStyle.ForegroundColor = Color.Yellow;
            warningStyle.Font.Color = wb.GetMatchingColor(Color.Goldenrod);
            warningStyle.Font.Underline = FontUnderlineType.Single;

            //passStyle.Pattern = BackgroundType.Solid;
            //passStyle.ForegroundColor = Color.Green;
            passStyle.Font.Color = Color.Green;

            warningStyle2.Font.Color = wb.GetMatchingColor(Color.Goldenrod);
            errorStyle2.Font.Color = Color.Red;

            int errorCount = 0;
            int warningCount = 0;
            Dictionary<RowData, int> rowDataIndex = new Dictionary<RowData, int>();

            Dictionary<int, string> fieldIndex = new Dictionary<int, string>();
            foreach (string field in selectedFields)
            {
                fieldIndex.Add(importFields[field], field);
            }

            double progress = 0.0;

            // 讀取驗證資料工作表使用
            Dictionary<string, int> checkSameDataDic = new Dictionary<string, int>();
            for (int i = 1; i <= wb.Worksheets[0].Cells.MaxDataRow; i++)
            {
                string chkStr = ImportUtil.GetChekcDataStr(i, wb.Worksheets[0], importFields);

                if (!checkSameDataDic.ContainsKey(chkStr))
                    checkSameDataDic.Add(chkStr, 0);
            }

            #region 產生RowData資料
            if (importFields.ContainsKey("學生系統編號"))
            {
                #region 用編號驗證資料
                for (int i = 1; i <= wb.Worksheets[0].Cells.MaxDataRow; i++)
                {

                    // , "學號", "班級", "座號", "科別", "姓名"
                    string id = GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["學生系統編號"]].StringValue);
                    if (id != "")
                    {
                        string rowError = "";

                        // 檢查重複資料
                        string chkStr = ImportUtil.GetChekcDataStr(i, wb.Worksheets[0], importFields);
                        if (checkSameDataDic.ContainsKey(chkStr))
                        {
                            checkSameDataDic[chkStr]++;
                            if (checkSameDataDic[chkStr] > 1)
                                rowError =chkStr+",有重複資料!";
                        }

                        #region 驗明正身
                        StudentRecord stu = Student.SelectByID(id);
                        if (stu != null)
                        {
                            if (importFields.ContainsKey("學號") && GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["學號"]].StringValue) != stu.StudentNumber)
                            {
                                //rowError = "學號與系統內學生資料不同!!";
                                rowError += (rowError == "" ? "" : "、\n") + "系統內學生學號為\"" + stu.StudentNumber + "\"";
                            }
                            if (importFields.ContainsKey("姓名") && GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["姓名"]].StringValue) != stu.Name)
                            {
                                //rowError = "姓名與系統內學生資料不同!!";
                                rowError += (rowError == "" ? "" : "、\n") + "系統內學生姓名為\"" + stu.Name + "\"";
                            }
                        }
                        else
                        {
                            rowError += "學生不存在!!";
                        }
                        #endregion
                        if (rowError == "")
                        {
                            if (!(stu.Status == _StudStatus))
                            {
                                #region 警告非在校生
                                errorSheet.Cells[errorSheetRowIndex, 0].PutValue(i + 1);
                                errorSheet.Cells[errorSheetRowIndex, 1].PutValue("警告");
                                //errorSheet.Cells[errorSheetRowIndex, 2].PutValue("學生不是在校生。");
                                errorSheet.Cells[errorSheetRowIndex, 2].PutValue("學生不在所選擇狀態內。");
                                errorSheet.Cells[errorSheetRowIndex, 0].Style = warningStyle;
                                errorSheet.Cells[errorSheetRowIndex, 1].Style = warningStyle2;
                                errorSheet.Cells[errorSheetRowIndex, 2].Style = warningStyle2;
                                errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[i, 0].Name);
                                errorSheet.AutoFitRow(errorSheetRowIndex);
                                errorSheetRowIndex++;
                                warningCount++;
                                #endregion
                            }
                            RowData rowdata = new RowData();
                            rowdata.ID = id;
                            foreach (int index in fieldIndex.Keys)
                            {
                                if (wb.Worksheets[0].Cells[i, index].Type == CellValueType.IsDateTime)
                                {
                                    rowdata.Add(fieldIndex[index], wb.Worksheets[0].Cells[i, index].DateTimeValue.ToString());
                                }
                                else
                                    rowdata.Add(fieldIndex[index], GetTrimText("" + wb.Worksheets[0].Cells[i, index].StringValue));
                            }
                            rowDataIndex.Add(rowdata, i);
                        }
                        else
                        {
                            errorCount++;
                            errorSheet.Cells[errorSheetRowIndex, 0].PutValue(i + 1);
                            errorSheet.Cells[errorSheetRowIndex, 1].PutValue("錯誤");
                            errorSheet.Cells[errorSheetRowIndex, 2].PutValue(rowError);
                            errorSheet.Cells[errorSheetRowIndex, 0].Style = errorStyle;
                            errorSheet.Cells[errorSheetRowIndex, 1].Style = errorStyle2;
                            errorSheet.Cells[errorSheetRowIndex, 2].Style = errorStyle2;
                            errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[i, 0].Name);
                            wb.Worksheets[0].Hyperlinks.Add(i, 0, 1, 1, "'" + errorSheetName + "'!" + errorSheet.Cells[errorSheetRowIndex, 0].Name);
                            errorSheet.AutoFitRow(errorSheetRowIndex);
                            errorSheetRowIndex++;
                            wb.Worksheets[0].Cells[i, 0].Style = errorStyle;
                        }
                    }
                    else
                    {
                        bool isNullRow = true;
                        for (byte c = 0; c < wb.Worksheets[0].Cells.MaxDataColumn; c++)
                        {
                            if (GetTrimText("" + wb.Worksheets[0].Cells[i, c].StringValue) != "")
                                isNullRow = false;
                        }
                        if (!isNullRow)
                        {
                            errorCount++;
                            errorSheet.Cells[errorSheetRowIndex, 0].PutValue(i + 1);
                            errorSheet.Cells[errorSheetRowIndex, 1].PutValue("錯誤");
                            errorSheet.Cells[errorSheetRowIndex, 2].PutValue("驗證欄位(學生系統編號)不得空白");
                            errorSheet.Cells[errorSheetRowIndex, 0].Style = errorStyle;
                            errorSheet.Cells[errorSheetRowIndex, 1].Style = errorStyle2;
                            errorSheet.Cells[errorSheetRowIndex, 2].Style = errorStyle2;
                            errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[i, 0].Name);
                            wb.Worksheets[0].Hyperlinks.Add(i, 0, 1, 1, "'" + errorSheetName + "'!" + errorSheet.Cells[errorSheetRowIndex, 0].Name);
                            errorSheet.AutoFitRow(errorSheetRowIndex);
                            errorSheetRowIndex++;
                            wb.Worksheets[0].Cells[i, 0].Style = errorStyle;
                        }
                    }
                    if (bkw.CancellationPending)
                    {
                        e.Cancel = true;
                        _ErrorWB = wb;
                        return;
                    }
                    progress = ((double)i) * 100.0 / 100000;
                    bkw.ReportProgress((int)progress, new int[] { errorCount, warningCount });
                }
                #endregion
            }
            else if (importFields.ContainsKey("學號"))
            {
                #region 用學號驗證資料
                Dictionary<string, List<StudentRecord>> studentNumberStudents = new Dictionary<string, List<StudentRecord>>();
                #region 整理學號對應學生清單(如索引欄不試系統編號時用)
                foreach (StudentRecord stu in Student.SelectAll())
                {
                    if (stu.Status == _StudStatus)
                    {
                        if (!studentNumberStudents.ContainsKey(stu.StudentNumber))
                            studentNumberStudents.Add(stu.StudentNumber, new List<StudentRecord>(new StudentRecord[] { stu }));
                        else
                            studentNumberStudents[stu.StudentNumber].Add(stu);
                    }
                }
                #endregion

                for (int i = 1; i <= wb.Worksheets[0].Cells.MaxDataRow; i++)
                {
                    string num = GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["學號"]].StringValue);
                    //wb.Worksheets[0].Cells.
                    if (num != "")
                    {
                        string rowError = "";

                        // 檢查重複資料
                        string chkStr = ImportUtil.GetChekcDataStr(i, wb.Worksheets[0], importFields);
                        if (checkSameDataDic.ContainsKey(chkStr))
                        {
                            checkSameDataDic[chkStr]++;
                            if (checkSameDataDic[chkStr] > 1)
                                rowError = chkStr+",有重複資料!";
                        }

                        #region 驗明正身
                        StudentRecord stu = null;
                        if (studentNumberStudents.ContainsKey(num))
                        {
                            if (studentNumberStudents[num].Count > 1)
                            {
                                #region 必需要其他欄位做索引
                                bool err = true;
                                foreach (string validateKey in new string[] { "班級", "科別", "座號", "姓名" })
                                {
                                    if (importFields.ContainsKey(validateKey))
                                    {
                                        err = false;
                                        foreach (StudentRecord var in studentNumberStudents[num])
                                        {
                                            bool pass = true;
                                            //if (importFields.ContainsKey("班級") && GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["班級"]].StringValue) != (var.Class != null ? var.Class.Name : ""))
                                            //{
                                            //    if (studentNumberStudents[num].Count == 1)
                                            //        rowError += (rowError == "" ? "" : "、\n") + "系統內學生班級為\"" + (var.Class != null ? var.Class.Name : "") + "\"";
                                            //    pass &= false;
                                            //}
                                            //if (importFields.ContainsKey("座號") && GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["座號"]].StringValue) != "" + var.SeatNo)
                                            //{
                                            //    if (studentNumberStudents[num].Count == 1)
                                            //        rowError += (rowError == "" ? "" : "、\n") + "系統內學生座號為\"" + var.SeatNo + "\"";
                                            //    pass &= false;
                                            //}
                                            if (importFields.ContainsKey("姓名") && GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["姓名"]].StringValue) != var.Name)
                                            {
                                                if (studentNumberStudents[num].Count == 1)
                                                    rowError += (rowError == "" ? "" : "、\n") + "系統內學生姓名為\"" + var.Name + "\"";
                                                pass &= false;
                                            }
                                            if (pass)
                                            {
                                                stu = var;
                                                break;
                                            }
                                        }
                                    }
                                    break;
                                }
                                if (err)
                                {
                                    rowError = "系統內發現多名相同學號學生且皆為在校學生,\n需要其他學生欄位進行識別。";
                                }
                                #endregion
                            }
                            if (studentNumberStudents[num].Count == 1)
                            {
                                StudentRecord var = studentNumberStudents[num][0];
                                bool pass = true;
                                //if (importFields.ContainsKey("班級") && GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["班級"]].StringValue) != (var.Class != null ? var.Class.Name : ""))
                                //{
                                //    if (studentNumberStudents[num].Count == 1)
                                //        rowError += (rowError == "" ? "" : "、\n") + "系統內學生班級為\"" + (var.Class != null ? var.Class.Name : "") + "\"";
                                //    pass &= false;
                                //}
                                //if (importFields.ContainsKey("座號") && GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["座號"]].StringValue) != "" + var.SeatNo)
                                //{
                                //    if (studentNumberStudents[num].Count == 1)
                                //        rowError += (rowError == "" ? "" : "、\n") + "系統內學生座號為\"" + var.SeatNo + "\"";
                                //    pass &= false;
                                //}
                                if (importFields.ContainsKey("姓名") && GetTrimText("" + wb.Worksheets[0].Cells[i, importFields["姓名"]].StringValue) != var.Name)
                                {
                                    if (studentNumberStudents[num].Count == 1)
                                        rowError += (rowError == "" ? "" : "、\n") + "系統內學生姓名為\"" + var.Name + "\"";
                                    pass &= false;
                                }
                                if (pass)
                                {
                                    stu = var;
                                }
                            }
                        }
                        else
                        {
                            rowError += "學生不存在所選擇狀態內!!";
                        }
                        if (rowError == "" && stu == null)
                            rowError = "學生資料有誤!!";
                        #endregion
                        if (rowError == "")
                        {
                            RowData rowdata = new RowData();
                            rowdata.ID = stu.ID;
                            foreach (int index in fieldIndex.Keys)
                            {
                                if (wb.Worksheets[0].Cells[i, index].Type == CellValueType.IsDateTime)
                                {
                                    rowdata.Add(fieldIndex[index], wb.Worksheets[0].Cells[i, index].DateTimeValue.ToString());
                                }
                                else
                                    rowdata.Add(fieldIndex[index], GetTrimText("" + wb.Worksheets[0].Cells[i, index].StringValue));
                            }
                            rowDataIndex.Add(rowdata, i);
                        }
                        else
                        {
                            errorCount++;
                            errorSheet.Cells[errorSheetRowIndex, 0].PutValue(i + 1);
                            errorSheet.Cells[errorSheetRowIndex, 1].PutValue("錯誤");
                            errorSheet.Cells[errorSheetRowIndex, 2].PutValue(rowError);
                            errorSheet.Cells[errorSheetRowIndex, 0].Style = errorStyle;
                            errorSheet.Cells[errorSheetRowIndex, 1].Style = errorStyle2;
                            errorSheet.Cells[errorSheetRowIndex, 2].Style = errorStyle2;
                            errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[i, 0].Name);
                            wb.Worksheets[0].Hyperlinks.Add(i, 0, 1, 1, "'" + errorSheetName + "'!" + errorSheet.Cells[errorSheetRowIndex, 0].Name);
                            errorSheet.AutoFitRow(errorSheetRowIndex);
                            errorSheetRowIndex++;
                            wb.Worksheets[0].Cells[i, 0].Style = errorStyle;
                        }
                    }
                    else
                    {
                        bool isNullRow = true;
                        for (byte c = 0; c < wb.Worksheets[0].Cells.MaxDataColumn; c++)
                        {
                            if (GetTrimText("" + wb.Worksheets[0].Cells[i, c].StringValue) != "")
                                isNullRow = false;
                        }
                        if (!isNullRow)
                        {
                            errorCount++;
                            errorSheet.Cells[errorSheetRowIndex, 0].PutValue(i + 1);
                            errorSheet.Cells[errorSheetRowIndex, 1].PutValue("錯誤");
                            errorSheet.Cells[errorSheetRowIndex, 2].PutValue("驗證欄位(學號)不得空白");
                            errorSheet.Cells[errorSheetRowIndex, 0].Style = errorStyle;
                            errorSheet.Cells[errorSheetRowIndex, 1].Style = errorStyle2;
                            errorSheet.Cells[errorSheetRowIndex, 2].Style = errorStyle2;
                            errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[i, 0].Name);
                            wb.Worksheets[0].Hyperlinks.Add(i, 0, 1, 1, "'" + errorSheetName + "'!" + errorSheet.Cells[errorSheetRowIndex, 0].Name);
                            errorSheet.AutoFitRow(errorSheetRowIndex);
                            errorSheetRowIndex++;
                            wb.Worksheets[0].Cells[i, 0].Style = errorStyle;
                        }
                    }

                    if (bkw.CancellationPending)
                    {
                        e.Cancel = true;
                        _ErrorWB = wb;
                        return;
                    }
                    progress = ((double)i) * 100.0 / 100000;
                    bkw.ReportProgress((int)progress, new int[] { errorCount, warningCount });
                }
                #endregion
            }
            #endregion

            #region 驗證資料
            List<string> list = new List<string>();
            foreach (RowData row in rowDataIndex.Keys)
            {
                if (!list.Contains(row.ID))
                    list.Add(row.ID);
            }
            //_Process.StartValidate(list);
            if (ValidateStart != null)
            {
                SmartSchool.API.PlugIn.Import.ValidateStartEventArgs args = new SmartSchool.API.PlugIn.Import.ValidateStartEventArgs();
                args.List = list.ToArray();
                ValidateStart(this, args);
            }
            double totleCount = (double)rowDataIndex.Count;
            double count = 0.0;
            foreach (RowData row in rowDataIndex.Keys)
            {
                #region 驗證
                string rowError = "";
                Dictionary<string, string> errorFields, warningFields;
                //RowDataValidatedEventArgs args = _Process.ValidateRow(row, selectedFields);
                SmartSchool.API.PlugIn.Import.ValidateRowEventArgs args = new SmartSchool.API.PlugIn.Import.ValidateRowEventArgs();
                args.Data = row;
                args.SelectFields.AddRange(selectedFields);
                if (ValidateRow != null)
                {
                    ValidateRow(this, args);
                }
                errorFields = args.ErrorFields;
                warningFields = args.WarningFields;
                rowError += args.ErrorMessage;
                if (rowError == "" && errorFields.Count == 0 && warningFields.Count == 0)
                {
                    wb.Worksheets[0].Cells[rowDataIndex[row], 0].Style = passStyle;
                }
                else
                {
                    string message = "";
                    bool hasError = false;
                    if (rowError != "" || errorFields.Count != 0)
                    {
                        errorCount++;
                        hasError = true;
                        message = rowError;
                        message += (message == "" ? "" : "\n") + "";
                        foreach (string key in errorFields.Keys)
                        {
                            message += (message == "" ? "" : "\n") + "  " + key + ":" + errorFields[key];
                        }
                        errorSheet.Cells[errorSheetRowIndex, 0].PutValue(rowDataIndex[row] + 1);
                        errorSheet.Cells[errorSheetRowIndex, 1].PutValue(hasError ? "錯誤" : "警告");
                        errorSheet.Cells[errorSheetRowIndex, 2].PutValue(message);
                        errorSheet.Cells[errorSheetRowIndex, 0].Style = errorStyle;
                        errorSheet.Cells[errorSheetRowIndex, 1].Style = errorStyle2;
                        errorSheet.Cells[errorSheetRowIndex, 2].Style = errorStyle2;
                        errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[rowDataIndex[row], 0].Name);
                        wb.Worksheets[0].Hyperlinks.Add(rowDataIndex[row], 0, 1, 1, "'" + errorSheetName + "'!" + errorSheet.Cells[errorSheetRowIndex, 0].Name);
                        errorSheet.AutoFitRow(errorSheetRowIndex);
                        errorSheetRowIndex++;
                    }
                    message = "";
                    if (warningFields.Count != 0)
                    {
                        if (!hasError)
                            warningCount++;
                        message += (message == "" ? "" : "\n") + "";
                        foreach (string key in warningFields.Keys)
                        {
                            message += (message == "" ? "" : "\n") + "  " + key + ":" + warningFields[key];
                        }
                        errorSheet.Cells[errorSheetRowIndex, 0].PutValue(rowDataIndex[row] + 1);
                        errorSheet.Cells[errorSheetRowIndex, 1].PutValue("警告");
                        errorSheet.Cells[errorSheetRowIndex, 2].PutValue(message);
                        errorSheet.Cells[errorSheetRowIndex, 0].Style = warningStyle;
                        errorSheet.Cells[errorSheetRowIndex, 1].Style = warningStyle2;
                        errorSheet.Cells[errorSheetRowIndex, 2].Style = warningStyle2;
                        errorSheet.Hyperlinks.Add(errorSheetRowIndex, 0, 1, 1, "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[rowDataIndex[row], 0].Name);
                        if (!hasError)
                            wb.Worksheets[0].Hyperlinks.Add(rowDataIndex[row], 0, 1, 1, "'" + errorSheetName + "'!" + errorSheet.Cells[errorSheetRowIndex, 0].Name);
                        errorSheet.AutoFitRow(errorSheetRowIndex);
                        errorSheetRowIndex++;
                    }
                    wb.Worksheets[0].Cells[rowDataIndex[row], 0].Style = hasError ? errorStyle : warningStyle;
                }
                #endregion
                if (bkw.CancellationPending)
                {
                    e.Cancel = true;
                    _ErrorWB = wb;
                    return;
                }
                count++;
                bkw.ReportProgress((int)(progress + count * (100.0 - progress) / totleCount), new int[] { errorCount, warningCount });
            }

            //_Process.FinishValidate();
            if (ValidateComplete != null)
                ValidateComplete(this, new EventArgs());
            #endregion

            List<RowData> rows = new List<RowData>();
            rows.AddRange(rowDataIndex.Keys);

            bkw.ReportProgress(100, new int[] { errorCount, warningCount });

            errorSheet.AutoFitColumn(0);
            errorSheet.AutoFitColumn(1, 1, 500);
            errorSheet.AutoFitColumn(2, 1, 500);

            e.Result = new object[] { wb, errorCount == 0, rows, selectedFields };
        }
        /// <summary>
        /// Append rows into current row data. This method should be call as second approach.
        /// ( mean using Begin and Finish function)
        /// But before using this method must call Prepare row
        ///
        /// This optimize for append text from left to right,
        /// so that row data ALWAYS append to end of current row data
        /// </summary>
        /// <param name="rows">rows</param>
        /// <param name="offsetX">offset x</param>
        /// <param name="offsetY">offset y</param>
        public void AppendRowDataAfter(RowData[] rows, double offsetX, double offsetY)
        {
            // first this will cast to integer value,
            // need more implementation to make sure that these value will change the coverage
            // when out side clipping box
            if ((offsetY < ClippingBoxYMax)
            && (offsetX < ClippingBoxXMax))
            {
                int roundedOffsetY = (int)offsetY;
                int roundedOffsetX = (int)offsetX;
                #region start and end row
                double startY =
                roundedOffsetY < ClippingBoxYMin ?
                ClippingBoxYMin : roundedOffsetY; // max of two values
                int startRowIndex = (int)startY - (int)roundedOffsetY;

                double endY = roundedOffsetY + rows.Length > ClippingBoxYMax ?
                ClippingBoxYMax : roundedOffsetY + rows.Length;
                int endRowIndex = (int)endY - roundedOffsetY;
                #endregion

                int startClippingX = (int)ClippingBoxXMin;
                int endClippingX = (int)ClippingBoxXMax;

                int startArea = (PixelScale - (int)(ClippingBoxXMin * PixelScale) & PixelMask) << PixelShift;
                int endArea = ((int)(ClippingBoxXMax * PixelScale) & PixelMask) << PixelShift;

                RowData currentRow = null;
                CellData cellData = null;

                int calculatedX = 0;
                int currentDestIndex = (int)startY;
                for (int row = startRowIndex; row < endRowIndex; row++)
                {
                    if (rows[row] != null)
                    {
                        currentRow = Rows[currentDestIndex];
                        cellData = rows[row].First;
                        while (cellData != null)
                        {
                            calculatedX = cellData.X + roundedOffsetX;
                            CurrentXPosition = calculatedX;
                            #region determine minx,maxy
                            if (CurrentXPosition < CurrentStartXIndex)
                            {
                                CurrentStartXIndex = (int)CurrentXPosition;
                            }
                            if (CurrentXPosition > CurrentEndXIndex)
                            {
                                CurrentEndXIndex = (int)CurrentXPosition + 1;
                            }
                            #endregion
                            if (calculatedX < startClippingX)
                            {
                                currentRow.SetCell(startClippingX, cellData.Coverage, 0);
                            }
                            else if (calculatedX > endClippingX)
                            {
                                currentRow.SetCell(endClippingX, cellData.Coverage, 0);
                            }
                            else
                            {
                                //currentRow.SetCell(calculatedX, cellData.Coverage, cellData.Area);
                                if (currentRow.First == null)
                                {
                                    currentRow.First = new CellData(calculatedX, cellData.Coverage, cellData.Area);
                                    currentRow.CurrentCell = currentRow.First;
                                }
                                else
                                {
                                    currentRow.CurrentCell.Next = new CellData(calculatedX, cellData.Coverage, cellData.Area);
                                    currentRow.CurrentCell = currentRow.CurrentCell.Next;
                                }
                            }
                            cellData = cellData.Next;
                        }
                    }
                    currentDestIndex++;
                }
            }
        }