public static List <SPR_file> Get_SRP_fileList(HssStatus status, bool all_flag = false) { List <SPR_file> list = new List <SPR_file>(); DB_select selt = new DB_select(SPR_file.Get_cmdTP()); selt.IgnoreColumn("FileBinary"); if (!all_flag) { SQL_relation rela = new SQL_relation("Status", RelationalOperator.Equals, (int)status); selt.SetCondition(rela); } DB_reader reader = new DB_reader(selt, Utility.Get_DRWIN_hDB()); while (reader.Read()) { SPR_file sf = new SPR_file(); sf.Init_from_reader(reader); list.Add(sf); } reader.Close(); return(list); }
internal HssUtility.SQLserver.DB_update Get_DBupdate() { if (!this.CheckValueChanges()) { return(null); } else { this.LastModifyAt.Value = DateTime.Now; this.LastModifyBy.Value = Utility.CurrentUser; } HssUtility.SQLserver.DB_update upd = new HssUtility.SQLserver.DB_update(SPR_file.Get_cmdTP()); if (this.FileName.ValueChanged) { upd.AddValue("FileName", this.FileName); /*Optional 2*/ } if (this.CreateTime.ValueChanged) { upd.AddValue("CreateTime", this.CreateTime); /*Optional 3*/ } if (this.CreateBy.ValueChanged) { upd.AddValue("CreateBy", this.CreateBy); /*Optional 5*/ } if (this.Status.ValueChanged) { upd.AddValue("Status", this.Status); /*Optional 6*/ } if (this.CUSIP.ValueChanged) { upd.AddValue("CUSIP", this.CUSIP); /*Optional 7*/ } if (this.RecordDate.ValueChanged) { upd.AddValue("RecordDate", this.RecordDate); /*Optional 8*/ } if (this.SecurityName.ValueChanged) { upd.AddValue("SecurityName", this.SecurityName); /*Optional 9*/ } if (this.LastModifyAt.ValueChanged) { upd.AddValue("LastModifyAt", this.LastModifyAt); /*Optional 10*/ } if (this.LastModifyBy.ValueChanged) { upd.AddValue("LastModifyBy", this.LastModifyBy); /*Optional 11*/ } if (this.LastModifyAction.ValueChanged) { upd.AddValue("LastModifyAction", this.LastModifyAction); /*Optional 12*/ } HssUtility.SQLserver.SQL_relation rela = new HssUtility.SQLserver.SQL_relation("ID", HssUtility.General.RelationalOperator.Equals, this.pk_ID); upd.SetCondition(rela); return(upd); }
public SPR_file GetCopy() { SPR_file newEntity = new SPR_file(); if (!this.FileName.IsNull_flag) { newEntity.FileName.Value = this.FileName.Value; } if (!this.CreateTime.IsNull_flag) { newEntity.CreateTime.Value = this.CreateTime.Value; } if (!this.CreateBy.IsNull_flag) { newEntity.CreateBy.Value = this.CreateBy.Value; } if (!this.Status.IsNull_flag) { newEntity.Status.Value = this.Status.Value; } if (!this.CUSIP.IsNull_flag) { newEntity.CUSIP.Value = this.CUSIP.Value; } if (!this.RecordDate.IsNull_flag) { newEntity.RecordDate.Value = this.RecordDate.Value; } if (!this.SecurityName.IsNull_flag) { newEntity.SecurityName.Value = this.SecurityName.Value; } if (!this.LastModifyAt.IsNull_flag) { newEntity.LastModifyAt.Value = this.LastModifyAt.Value; } if (!this.LastModifyBy.IsNull_flag) { newEntity.LastModifyBy.Value = this.LastModifyBy.Value; } if (!this.LastModifyAction.IsNull_flag) { newEntity.LastModifyAction.Value = this.LastModifyAction.Value; } return(newEntity); }
public static List <SPR_file> SplitRawFile(byte[] rawBytes) { List <SPR_file> sf_list = new List <SPR_file>(); List <List <string> > tempDataList = new List <List <string> >(); MemoryStream ms = new MemoryStream(rawBytes); StreamReader sr = new StreamReader(ms); string headerLine = null, trailerLine = null; string str = null; while ((str = sr.ReadLine()) != null) { if (headerLine == null && str.StartsWith("HDR", StringComparison.OrdinalIgnoreCase)) { headerLine = str; continue; } if (trailerLine == null && str.StartsWith("TRL", StringComparison.OrdinalIgnoreCase)) { trailerLine = str; foreach (List <string> strList in tempDataList) { strList.Add(trailerLine); } break; } if (str.Length < 19) { continue; } char recordType_char = str[18]; if (recordType_char == '1') { List <string> strList = new List <string>(); if (headerLine != null) { strList.Add(headerLine); } strList.Add(str); tempDataList.Add(strList); } else { if (tempDataList.Count < 1) { continue; } List <string> strList = tempDataList[tempDataList.Count - 1]; strList.Add(str); } } foreach (List <string> strList in tempDataList) { SPR_file sf = new SPR_file(); List <byte> byteList = new List <byte>(); foreach (string line in strList) { byte[] arr = Encoding.UTF8.GetBytes(line); byteList.AddRange(arr); arr = Encoding.UTF8.GetBytes(HssStr.WinNextLine); byteList.AddRange(arr); } sf.FileBinary = byteList.ToArray(); sf.Calculate(); sf_list.Add(sf); } return(sf_list); }
/// <summary> /// Button events handler in Action column /// </summary> private void ActionButtonEvent_textEditor(object sender, EditorButtonEventArgs e) { if (e.Context is UltraGridCell == false) { return; } UltraGridCell cell = (UltraGridCell)e.Context; int ID = (int)cell.Row.Cells["ID"].Value; SPR_file sf = new SPR_file(ID); sf.Init_from_DB(); string option = e.Button.Key; if (option.StartsWith("Approve", StringComparison.OrdinalIgnoreCase)) { if (MessageBox.Show("Approve file " + ID + "?", "Happy!", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } Dividend curr_dvd = null; string CUSIP = cell.Row.Cells["CUSIP"].Value.ToString(); List <Dividend> dvdList = Helper_Dividend.Get_DividendList_CUSIP(CUSIP); foreach (Dividend dvd in dvdList) { if (HssDateTime.CompareDateTime_day(sf.RecordDate.Value, dvd.RecordDate_ADR.Value) == 0) { curr_dvd = dvd;//matching Dividend found break; } } if (curr_dvd == null) //CUSIP and Record Date not found record in [Dividend_Control] table, let user to choose { Form_DividendSelector fds = new Form_DividendSelector(); int dvd_index = fds.Init_from_list(dvdList); if (dvd_index > 0) { curr_dvd = new Dividend(dvd_index); } } else //CUSIP and Record Date match record in [Dividend_Control] table { if (MessageBox.Show("Update Dividend " + curr_dvd.DividendIndex + "?", "???", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } } if (curr_dvd != null) { if (!curr_dvd.Insert_DTC_position(sf)) { return; } sf.SetStatus(HssStatus.Approved); sf.LastModifyAction.Value = "Approve"; sf.Update_to_DB(); MessageBox.Show("Dividend #" + curr_dvd.DividendIndex + " DTC position updated!"); this.RefreshData(); } else { MessageBox.Show("Dividend Event not found..."); } } else if (option.StartsWith("ViewData", StringComparison.OrdinalIgnoreCase)) { ViewDataForm vdf = new ViewDataForm(); vdf.Set_notePad_dataSource(sf.FileBinary, ViewDataOption.RawView_strLine); vdf.Show(); } else if (option.StartsWith("Reject", StringComparison.OrdinalIgnoreCase)) { if (MessageBox.Show("Reject file " + ID + "?", "Sad...", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } sf.SetStatus(HssStatus.Rejected); sf.LastModifyAction.Value = "Reject"; sf.Update_to_DB(); this.RefreshData(); } else if (option.StartsWith("Restore", StringComparison.OrdinalIgnoreCase)) { if (MessageBox.Show("Restore file " + ID + "?", "Hero is back!", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } sf.SetStatus(HssStatus.Pending); sf.LastModifyAction.Value = "Restore"; sf.Update_to_DB(); this.RefreshData(); } }
/// <summary> /// Initialize object from DB /// </summary> public bool Init_from_DB() { if (this.ID < 0) { return(false); } HssUtility.SQLserver.DB_select db_sel = new HssUtility.SQLserver.DB_select(SPR_file.Get_cmdTP()); db_sel.tableName = "DTCC_FTP_files"; HssUtility.SQLserver.SQL_relation rela = new HssUtility.SQLserver.SQL_relation("ID", HssUtility.General.RelationalOperator.Equals, this.ID); db_sel.SetCondition(rela); bool res_flag = false; HssUtility.SQLserver.DB_reader reader = new HssUtility.SQLserver.DB_reader(db_sel, Utility.Get_DRWIN_hDB()); if (reader.Read()) { this.Init_from_reader(reader); res_flag = true; } reader.Close(); return(res_flag); }
internal HssUtility.SQLserver.DB_insert Get_DBinsert() { HssUtility.SQLserver.DB_insert dbIns = new HssUtility.SQLserver.DB_insert(SPR_file.Get_cmdTP()); dbIns.AddValue("FileName", this.FileName); /*Optional 2*/ dbIns.AddValue("CreateTime", this.CreateTime); /*Optional 3*/ dbIns.AddValue("FileBinary", this.FileBinary); /*Optional 4*/ dbIns.AddValue("CreateBy", this.CreateBy); /*Optional 5*/ dbIns.AddValue("Status", this.Status); /*Optional 6*/ dbIns.AddValue("CUSIP", this.CUSIP); /*Optional 7*/ dbIns.AddValue("RecordDate", this.RecordDate); /*Optional 8*/ dbIns.AddValue("SecurityName", this.SecurityName); /*Optional 9*/ dbIns.AddValue("LastModifyAt", this.LastModifyAt); /*Optional 10*/ dbIns.AddValue("LastModifyBy", this.LastModifyBy); /*Optional 11*/ dbIns.AddValue("LastModifyAction", this.LastModifyAction); /*Optional 12*/ return(dbIns); }