protected override void Prepare (MiscUtil.IO.EndianBinaryWriter w) { w.Write (Position.X); w.Write (Position.Y); w.Write (Position.Z); w.Write ((byte)OnGround); }
public LoginRequestClient (MiscUtil.IO.EndianBinaryReader reader) { ProtocolVersion = reader.ReadInt32 (); Username = ReadString16 (reader); Unused1 = reader.ReadInt64 (); Unused2 = reader.ReadInt32 (); Unused3 = reader.ReadSByte (); Unused4 = reader.ReadSByte (); Unused5 = reader.ReadSByte (); Unused6 = reader.ReadSByte (); }
protected override void Send (MiscUtil.IO.EndianBinaryWriter writer) { writer.Write ((int)ProtocolVersion); WriteString16 (writer, Username); writer.Write ((long)Unused1); writer.Write ((int)Unused2); writer.Write ((sbyte)Unused3); writer.Write ((sbyte)Unused4); writer.Write ((sbyte)Unused5); writer.Write ((sbyte)Unused6); }
void EventAggregator_PortraitFound(object sender, MiscUtil.EventArgs<Damany.Imaging.Common.Portrait> e) { var msg = new Damany.RemoteImaging.Net.Messages.Portrait(); msg.FaceImage = e.Value.GetIpl().ToBitmap(); msg.CaptureTime = e.Value.CapturedAt; if (Bus != null) { try { Bus.Publish(msg); } catch (Exception) { throw; } } }
private HREmployeeLoanApplicationEntity BuildHREmployeeLoanApplicationEntity() { HREmployeeLoanApplicationEntity hREmployeeLoanApplicationEntity = CurrentHREmployeeLoanApplicationEntity; if (ddlLoanCategoryID.Items.Count > 0) { if (ddlLoanCategoryID.SelectedValue == "0") { } else { hREmployeeLoanApplicationEntity.LoanCategoryID = Int64.Parse(ddlLoanCategoryID.SelectedValue); } } if (!txtAppliedLoanAmount.Text.Trim().IsNullOrEmpty()) { hREmployeeLoanApplicationEntity.AppliedLoanAmount = Decimal.Parse(txtAppliedLoanAmount.Text.Trim()); } if (ddlCurrencyID.Items.Count > 0) { if (ddlCurrencyID.SelectedValue == "0") { } else { hREmployeeLoanApplicationEntity.CurrencyID = Int64.Parse(ddlCurrencyID.SelectedValue); } } if (txtLoanPaymentStartDate.Text.Trim().IsNotNullOrEmpty()) { hREmployeeLoanApplicationEntity.LoanPaymentStartDate = MiscUtil.ParseToDateTime(txtLoanPaymentStartDate.Text); } else { hREmployeeLoanApplicationEntity.LoanPaymentStartDate = null; } if (txtLoanPaymentEndDate.Text.Trim().IsNotNullOrEmpty()) { hREmployeeLoanApplicationEntity.LoanPaymentEndDate = MiscUtil.ParseToDateTime(txtLoanPaymentEndDate.Text); } else { hREmployeeLoanApplicationEntity.LoanPaymentEndDate = null; } if (!txtNumberOfInstallment.Text.Trim().IsNullOrEmpty()) { hREmployeeLoanApplicationEntity.NumberOfInstallment = Decimal.Parse(txtNumberOfInstallment.Text.Trim()); } else { hREmployeeLoanApplicationEntity.NumberOfInstallment = null; } hREmployeeLoanApplicationEntity.Description = txtDescription.Text.Trim(); if (ddlEmployeeLoanApprovalStatusID.Items.Count > 0) { if (ddlEmployeeLoanApprovalStatusID.SelectedValue == "0") { } else { hREmployeeLoanApplicationEntity.EmployeeLoanApprovalStatusID = Int64.Parse(ddlEmployeeLoanApprovalStatusID.SelectedValue); } } hREmployeeLoanApplicationEntity.Remarks = txtRemarks.Text.Trim(); return(hREmployeeLoanApplicationEntity); }
/// <summary> /// Update HK-GEMSS.xls file and create HK-GEMSS.xml /// </summary> /// <param name="gemTradingInfo">the GEM trading News Info.</param> public void UpdateGemssFileAndGenerateXMLFile(TradingInfo gemTradingInfo) { string gemssFilePath = MiscUtil.BackUpFileWithDateFolder(configObj.HKGEMSS_Workbook, false); using (ExcelApp app = new ExcelApp(false, false)) { var workbook = ExcelUtil.CreateOrOpenExcelFile(app, gemssFilePath); var worksheet = ExcelUtil.GetWorksheet(configObj.HKGEMSS_Worksheet, workbook); if (worksheet == null) { LogMessage(string.Format("Cannot get worksheet {0} from workbook {1}", configObj.HKGEMSS_Worksheet, workbook.Name)); } using (ExcelLineWriter writer = new ExcelLineWriter(worksheet, 1, 1, ExcelLineWriter.Direction.Down)) { // Allocate spaces ExcelUtil.InsertBlankRows(ExcelUtil.GetRange("A1", worksheet), 24); writer.PlaceNext(1, 1); // Form 1st line and write string line = string.Empty; writer.WriteLine(gemTradingInfo.DateStr); // Copy 2nd and 3rd line from line 26 and line 27 writer.WriteLine(worksheet.Cells[writer.Row + 24, writer.Col]); writer.WriteLine(worksheet.Cells[writer.Row + 24, writer.Col]); if (gemTradingInfo.StockList == null) { writer.WriteLine("NIL"); while (writer.Row < 19) { writer.WriteLine(" "); } } else { // Fill stock info foreach (StockInfo stockInfo in gemTradingInfo.StockList) { StringBuilder sb = new StringBuilder(); sb.Append(stockInfo.Ric.PadRight(12)); sb.Append(stockInfo.StockName.PadRight(27)); sb.Append(stockInfo.Shares.PadLeft(15)); sb.Append(stockInfo.Turnover.PadLeft(20)); line = sb.ToString(); writer.WriteLine(line); } while (writer.Row < 19) { writer.WriteLine(" "); } //Fill non-designated securities summary if non-designated securities exist writer.PlaceNext(19, 1); if (!string.IsNullOrEmpty(gemTradingInfo.NonDesignatedSecuritiesRecordingSum) && gemTradingInfo.NonDesignatedSecuritiesRecordingSum != "0") { writer.WriteLine(gemTradingInfo.NonDesignatedSecuritiesRecordingSum.PadLeft(recordAlignrightLength)); writer.WriteLine(gemTradingInfo.NonDesignatedSharesShortSoldSum.PadLeft(recordAlignrightLength)); writer.WriteLine(gemTradingInfo.NonDesignatedShortSellTransactionSum.PadLeft(recordAlignrightLength)); } // Fill designated securities summary writer.WriteLine(gemTradingInfo.DesignatedSecuritiesRecordingSum.PadLeft(recordAlignrightLength)); writer.WriteLine(gemTradingInfo.DesignatedSharesShortSoldSum.PadLeft(recordAlignrightLength)); writer.WriteLine(gemTradingInfo.DesignatedShortSellTurnoverShares.PadLeft(recordAlignrightLength)); writer.WriteLine(gemTradingInfo.DesignatedShortSellTurnoverValue.PadLeft(recordAlignrightLength)); if (!string.IsNullOrEmpty(gemTradingInfo.HKDTurnoverValue)) { writer.WriteLine(gemTradingInfo.HKDTurnoverValue.PadLeft(recordAlignrightLength)); } } for (int page = 1; page <= 25; page++) { string id = "HK/GEMSS" + page.ToString("D2"); int upRow = 24 * (page - 1) + 1; int downRow = upRow + 23; writer.PlaceNextAndWriteLine(upRow, 3, id); writer.PlaceNextAndWriteLine(downRow, 3, id); } //Fill color for C columns Range range = ExcelUtil.GetRange(1, 3, 24, 3, worksheet); range.Interior.Color = ExcelUtil.GetRange(49, 3, worksheet).Interior.Color; ProductionXmlFileTemplate xmlFileTem = GetGemssXmlFileContent(worksheet); ConfigUtil.WriteXml(configObj.HKGEMSS_XmlPath, xmlFileTem); TaskResultList.Add(new TaskResultEntry("XML file for HK-GEMSS", "", configObj.HKGEMSS_XmlPath)); if (File.Exists(configObj.HKGEMSS_Workbook)) { File.Delete(configObj.HKGEMSS_Workbook); } //Save files as a copy workbook.SaveCopyAs(configObj.HKGEMSS_Workbook); TaskResultList.Add(new TaskResultEntry("HK-GEMSS", "", configObj.HKGEMSS_Workbook)); //Close current opend excel file workbook.Close(false, gemssFilePath, false); } } }
private void GenerateMAINSSExcelAndXmlFile(string xlsFilePath, TradingInfo tradingInfo) { xlsFilePath = MiscUtil.BackUpFileWithDateFolder(xlsFilePath, false); //MiscUtil.BackupFileWithNewName(xlsFilePath); List <string> linesToWrite = new List <string>(); foreach (StockInfo stockInfo in tradingInfo.StockList) { linesToWrite.Add(stockInfo.ToSingleLine()); } linesToWrite.Add(""); if (!string.IsNullOrEmpty(tradingInfo.DesignatedSecuritiesRecordingSum)) { linesToWrite.Add(tradingInfo.DesignatedSecuritiesRecordingSum.PadLeft(recordAlignrightLength)); } if (!string.IsNullOrEmpty(tradingInfo.DesignatedSharesShortSoldSum)) { linesToWrite.Add(tradingInfo.DesignatedSharesShortSoldSum.PadLeft(recordAlignrightLength)); } if (!string.IsNullOrEmpty(tradingInfo.DesignatedShortSellTurnoverShares)) { linesToWrite.Add(tradingInfo.DesignatedShortSellTurnoverShares.PadLeft(recordAlignrightLength)); } if (!string.IsNullOrEmpty(tradingInfo.DesignatedShortSellTurnoverValue)) { linesToWrite.Add(tradingInfo.DesignatedShortSellTurnoverValue.PadLeft(recordAlignrightLength)); } if (!string.IsNullOrEmpty(tradingInfo.HKDTurnoverValue)) { linesToWrite.Add(tradingInfo.HKDTurnoverValue.PadLeft(recordAlignrightLength)); } using (ExcelApp app = new ExcelApp(false, false)) { var workbook = ExcelUtil.CreateOrOpenExcelFile(app, xlsFilePath); var worksheet = ExcelUtil.GetWorksheet(configObj.HKMAINSS_CONFIG_Worksheet, workbook); if (worksheet == null) { LogMessage(string.Format("Cannot get worksheet {0} from workbook {1}", configObj.HKGEMSS_Worksheet, workbook.Name)); } //Generate MAINSSExcelFile using (ExcelLineWriter writer = new ExcelLineWriter(worksheet, 1, 1, ExcelLineWriter.Direction.Down)) { // Allocate spaces int startOffset = (configObj.HKMAINSS_CONFIG_StartPage - 1) * configObj.HKMAINSS_CONFIG_LineNum; int startRow = startOffset + 1; int curLineNum = 0; int insertBlankPageNum = (linesToWrite.Count - 1) / configObj.HKMAINSS_CONFIG_LineEach + 1; ExcelUtil.InsertBlankRows(ExcelUtil.GetRange(startRow, 1, worksheet), insertBlankPageNum * 24); writer.PlaceNext(startRow, 1); // Form 1st line and write string line = string.Empty; List <string> headerLineList = new List <string>(); headerLineList.Add(tradingInfo.DateStr); line = "RIC STOCK NAME SHARES TURNOVER ($)"; headerLineList.Add(line); line = "========= ==================== =============== ==============="; headerLineList.Add(line); for (int i = 0; i < insertBlankPageNum; i++) { int curStartRow = startOffset + i * configObj.HKMAINSS_CONFIG_LineNum + 1; int nextStartRow = curStartRow + 24; writer.WriteLine(headerLineList[0]); writer.WriteLine(headerLineList[1]); writer.WriteLine(headerLineList[2]); //keep a line without text. writer.MoveNext(); while (writer.Row < nextStartRow && curLineNum < linesToWrite.Count) { writer.WriteLine(linesToWrite[curLineNum]); curLineNum++; } writer.PlaceNext(nextStartRow, 1); } // Fill designated securities summary with page no. and background color. for (int page = configObj.HKMAINSS_CONFIG_StartPage; page <= configObj.HKMAINSS_CONFIG_TotalPage; page++) { string id = "HK/MAINSS" + page.ToString("D2"); int upRow = configObj.HKMAINSS_CONFIG_LineNum * (page - 1) + 1; int downRow = upRow + (configObj.HKMAINSS_CONFIG_LineNum - 1); writer.PlaceNextAndWriteLine(upRow, 2, id); writer.PlaceNextAndWriteLine(downRow, 2, id); Range pageRange = ExcelUtil.GetRange(upRow, 2, downRow, 2, worksheet); if (page % 2 == 0) { pageRange.Interior.Color = 16777164.0; } else { pageRange.Interior.Color = 10092543.0; } } Range rangToRemove = ExcelUtil.GetRange(writer.Row, 1, writer.Row + 24 * insertBlankPageNum, 2, worksheet); rangToRemove.Clear(); } //Generate MAINSSXmlFile ProductionXmlFileTemplate xmlFileTem = GetHKMAINSSXmlFileContent(worksheet); ConfigUtil.WriteXml(configObj.HKMAINSS_CONFIG_XmlPath, xmlFileTem); TaskResultList.Add(new TaskResultEntry("XML file for HKMAINSS", "", configObj.HKMAINSS_CONFIG_XmlPath)); if (File.Exists(configObj.HKMAINSS_CONFIG_Workbook)) { File.Delete(configObj.HKMAINSS_CONFIG_Workbook); } workbook.SaveCopyAs(configObj.HKMAINSS_CONFIG_Workbook); TaskResultList.Add(new TaskResultEntry("HKMAINSS", "", configObj.HKMAINSS_CONFIG_Workbook)); workbook.Close(false, xlsFilePath, true); } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int overload; string exception = null; //while(true) //{ Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); } return; } //TODO byte[] data = null; Hashtable removeResult = null; try { NCache nCache = clientManager.CmdExecuter as NCache; Notifications cbEnrty = null; if (cmdInfo.DsItemsRemovedId != -1) { cbEnrty = new Notifications(clientManager.ClientID, -1, -1, -1, -1, cmdInfo.DsItemsRemovedId , Runtime.Events.EventDataFilter.None, Runtime.Events.EventDataFilter.None); //DataFilter not required } OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID); operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout); operationContext.CancellationToken = CancellationToken; removeResult = (Hashtable)nCache.Cache.Remove(cmdInfo.Keys, cmdInfo.FlagMap, cbEnrty, cmdInfo.ProviderName, operationContext); stopWatch.Stop(); BulkRemoveResponseBuilder.BuildResponse(removeResult, cmdInfo.CommandVersion, cmdInfo.RequestId, _serializedResponsePackets, command.commandID, command.requestID, nCache.Cache, clientManager); } catch (OperationCanceledException ex) { exception = ex.ToString(); Dispose(); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; exception = exc.ToString(); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.REMOVEBULK.ToLower()); // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo); log.GenerateBulkDeleteAPILogItem(cmdInfo.Keys.Length, cmdInfo.FlagMap, cmdInfo.ProviderName, cmdInfo.DsItemsRemovedId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } if (removeResult?.Count > 0) { foreach (DictionaryEntry removeEntry in removeResult) { if (removeEntry.Value is CompressedValueEntry compressedValueEntry) { MiscUtil.ReturnEntryToPool(compressedValueEntry.Entry, clientManager.CacheTransactionalPool); MiscUtil.ReturnCompressedEntryToPool(compressedValueEntry, clientManager.CacheTransactionalPool); } } } } } finally { cmdInfo.FlagMap.MarkFree(NCModulesConstants.SocketServer); } //} }
public ValueFormatter() { BeautifyGeneric = MiscUtil.GetMethod <ValueFormatter>(v => v.Beautify <object>(FormatType.DEFAULT, null)); }
protected override void Parse(MiscUtil.IO.EndianBinaryReader r) { MaxSize = ReadVarInt(r); }
void l_Stopped(object sender, MiscUtil.EventArgs<Exception> e) { IPortraitHandler handler = sender as IPortraitHandler; this.RemoveListener(handler); if (e.Value != null) { System.Diagnostics.Debug.WriteLine(handler.Name + " Exception:" + e.Value.Message); } }
protected override void Prepare(MiscUtil.IO.EndianBinaryWriter w) { WriteVarInt(w, MaxSize); }
private void PrepareInitialView() { BuildDropDownList(); txtExpectedStartDate.Text = System.DateTime.Now.AddDays(-30).ToString(UIConstants.SHORT_DATE_FORMAT); txtExpectedEndDate.Text = System.DateTime.Now.ToString(UIConstants.SHORT_DATE_FORMAT); if (this.Page.User.Identity.IsAuthenticated == true) { if (this.Page.User.Identity.Name.Equals("17.466") == true || this.Page.User.Identity.Name.Equals("17.042") == true || this.Page.User.Identity.Name.Equals("17.1127") == true || this.Page.User.Identity.Name.Equals("17.605") == true || this.Page.User.Identity.Name.Equals("17.599") == true || this.Page.User.Identity.Name.Equals("17.1000") == true || this.Page.User.Identity.Name.Equals("17.979") == true || this.Page.User.Identity.Name.Equals("17.687") == true || this.Page.User.Identity.Name.Equals("17.788") == true || this.Page.User.Identity.Name.Equals("17.1116") == true || this.Page.User.Identity.Name.Equals("17.799") == true || this.Page.User.Identity.Name.Equals("17.780") == true) { //String fe1 = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeSupervisorMapEntity.FLD_NAME_SupervisorEmployeeID, MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember).ToString(), SQLMatchType.Equal); //String fe2 = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeSupervisorMapEntity.FLD_NAME_SessionCategoryID, "1", SQLMatchType.Equal); //String fe = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2); //IList<HREmployeeSupervisorMapEntity> lst = FCCHREmployeeSupervisorMap.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression); //IList<HREmployeeSupervisorMap_DetailedEntity> lst = FCCHREmployeeSupervisorMap_Detailed.GetFacadeCreate().GetIL(null, null, String.Empty, fe)lblMessage //if (lst != null && lst.Count > 0) //{ // ddlEmployeeID.Items.Clear(); // foreach (HREmployeeSupervisorMapEntity ent in lst) // { // ListItem lstItem = new ListItem(); // lstItem.Text = ent.EmployeeCode + " - " + ent.EmployeeCode; // lstItem.Value = ent.EmployeeID.ToString(); // ddlEmployeeID.Items.Add(lstItem); // } //} String fe_session = SqlExpressionBuilder.PrepareFilterExpression(HRSessionEntity.FLD_NAME_EvaluationSessionStatusID, MasterDataConstants.MDEvaluationSessionStatus.OPEN.ToString(), SQLMatchType.Equal); IList <HRSessionEntity> lstHRSessionEntity = FCCHRSession.GetFacadeCreate().GetIL(null, null, String.Empty, fe_session, DatabaseOperationType.LoadWithFilterExpression); if (lstHRSessionEntity != null && lstHRSessionEntity.Count > 0) { String fe1 = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeSupervisorMap_DetailedEntity.FLD_NAME_SupervisorEmployeeID, MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember).ToString(), SQLMatchType.Equal); String fe2 = SqlExpressionBuilder.PrepareFilterExpression("HREmployeeSupervisorMap." + HREmployeeSupervisorMap_DetailedEntity.FLD_NAME_SessionCategoryID, lstHRSessionEntity[0].SessionID.ToString(), SQLMatchType.Equal); String fe = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2); IList <HREmployeeSupervisorMap_DetailedEntity> lst = FCCHREmployeeSupervisorMap_Detailed.GetFacadeCreate().GetIL(100000, 1, String.Empty, fe); if (lst != null && lst.Count > 0) { ddlEmployeeID.Items.Clear(); foreach (HREmployeeSupervisorMap_DetailedEntity ent in lst) { ListItem lstItem = new ListItem(); lstItem.Text = ent.EmployeeCode + " - " + ent.EmployeeFullName + "(" + ent.SessionCategoryName.ToString() + ")"; lstItem.Value = ent.EmployeeID.ToString(); ddlEmployeeID.Items.Add(lstItem); } } ddlEmployeeID.Enabled = true; } } else { ddlEmployeeID.SelectedValue = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember).ToString(); ddlEmployeeID.Enabled = false; } } }
protected virtual void OnStopped( MiscUtil.EventArgs<Exception> args) { if (this.Stopped!=null) { this.Stopped(this, args); } }
void threadPool_WorkerException(MiscUtil.Threading.CustomThreadPool pool, MiscUtil.Threading.ThreadPoolWorkItem workItem, Exception e, ref bool handled) { //log.Error(e.Message); }
protected override void Prepare (MiscUtil.IO.EndianBinaryWriter w) { w.Write ((float)(Yaw * 180 / Math.PI)); w.Write ((float)(Pitch * 180 / Math.PI)); w.Write (OnGround); }
public override void DeserializePayload(MiscUtil.IO.EndianBinaryReader reader, ushort length) { byte data_len = reader.ReadByte(); data = reader.ReadBytes(data_len); }
public override void SerializePayload(MiscUtil.IO.EndianBinaryWriter writer) { writer.Write(slaveAddress); writer.Write((byte) writeLen); writer.Write(readLen); writer.Write(writeData, 0, writeLen); }
//Get all the newly generated ISIN for goverment bond //http://www.chinaclear.cn/isin/user/userApplyLogin.do?m=enter //http://www.chinaclear.cn/isin/user/userApplyLogin.do?m=queryFast public List <RicISINInfo> GetAllISINForGoverBond() { AdvancedWebClient wc = new AdvancedWebClient(); string postData = "loginName=&password=&securitiesName=%BC%C7%D5%CB%CA%BD%B8%BD%CF%A2&securitiesCode="; string url = "http://www.chinaclear.cn/isin/user/userApplyLogin.do?m=enter"; string pageSource = WebClientUtil.GetPageSource(wc, url, 18000, postData); pageSource = WebClientUtil.GetPageSource(wc, "http://www.chinaclear.cn/isin/user/userApplyLogin.do?m=queryFast", 18000, "", Encoding.GetEncoding("gb2312")); HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument(); htmlDoc.LoadHtml(pageSource); var nodeList = htmlDoc.DocumentNode.SelectNodes("//tr[@class='td5']"); return(nodeList.Select(node => new RicISINInfo { ISIN = MiscUtil.GetCleanTextFromHtml(node.ChildNodes[1 * 2 + 1].InnerText), Name = MiscUtil.GetCleanTextFromHtml(node.ChildNodes[2 * 2 + 1].InnerText) }).ToList()); }
public override IEnumerable <CommandDTOBase?> Execute(string[] args) { // adapted from @djhohnstein's EventLogParser project // https://github.com/djhohnstein/EventLogParser/blob/master/EventLogParser/EventLogHelpers.cs // combined with scraping from https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands WriteVerbose($"Searching script block logs (EID 4104) for sensitive data.\n"); var context = 3; // number of lines around the match to display string[] powershellLogs = { "Microsoft-Windows-PowerShell/Operational", "Windows PowerShell" }; // Get our "sensitive" cmdline regexes from a common helper function. var powershellRegex = MiscUtil.GetProcessCmdLineRegex(); foreach (var logName in powershellLogs) { var query = "*[System/EventID=4104]"; var eventLogQuery = new EventLogQuery(logName, PathType.LogName, query) { ReverseDirection = true }; var logReader = new EventLogReader(eventLogQuery); for (var eventDetail = logReader.ReadEvent(); eventDetail != null; eventDetail = logReader.ReadEvent()) { var scriptBlock = eventDetail.Properties[2].Value.ToString(); foreach (var reg in powershellRegex) { var m = reg.Match(scriptBlock); if (!m.Success) { continue; } var contextLines = new List <string>(); var scriptBlockParts = scriptBlock.Split('\n'); for (var i = 0; i < scriptBlockParts.Length; i++) { if (!scriptBlockParts[i].Contains(m.Value)) { continue; } var printed = 0; for (var j = 1; i - j > 0 && printed < context; j++) { if (scriptBlockParts[i - j].Trim() == "") { continue; } contextLines.Add(scriptBlockParts[i - j].Trim()); printed++; } printed = 0; contextLines.Add(m.Value.Trim()); for (var j = 1; printed < context && i + j < scriptBlockParts.Length; j++) { if (scriptBlockParts[i + j].Trim() == "") { continue; } contextLines.Add(scriptBlockParts[i + j].Trim()); printed++; } break; } var contextJoined = string.Join("\n", contextLines.ToArray()); yield return(new PowerShellEventsDTO( eventDetail.TimeCreated, eventDetail.Id, $"{eventDetail.UserId}", m.Value, contextJoined )); } } } }
protected void odsOTIssue_Detailed_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { String fe = String.Empty; switch (PageAPType) { case MasterDataConstants.IssuePageType.ADHOC_ISSUE: fe = SqlExpressionBuilder.PrepareFilterExpression("OTIssue." + OTIssueEntity.FLD_NAME_IssueIdentityCategoryID, MasterDataConstants.IssueIdentityCategory.ADHOC_ISSUE.ToString(), SQLMatchType.Equal); lblIssueList.Text = "Adhoc Issue List"; break; case MasterDataConstants.IssuePageType.PROJECT_ADHOC_ISSUE: fe = SqlExpressionBuilder.PrepareFilterExpression("OTIssue." + OTIssueEntity.FLD_NAME_IssueIdentityCategoryID, MasterDataConstants.IssueIdentityCategory.PROJECT_ADHOC_ISSUE.ToString(), SQLMatchType.Equal); lblIssueList.Text = "Project Issue List"; break; case MasterDataConstants.IssuePageType.MY_ISSUE_LIST: fe = SqlExpressionBuilder.PrepareFilterExpression("OTIssue." + OTIssueEntity.FLD_NAME_CreatedByMemberID, CurrentMember.MemberID.ToString(), SQLMatchType.Equal); Int64 employeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember); if (employeeID > 0) { String fe_assignToEmployee = SqlExpressionBuilder.PrepareFilterExpression("OTIssue." + OTIssueEntity.FLD_NAME_AssignedToEmployeeID, employeeID.ToString(), SQLMatchType.Equal); fe = SqlExpressionBuilder.PrepareFilterExpression(fe, SQLJoinType.OR, fe_assignToEmployee); String fe_resource1 = SqlExpressionBuilder.PrepareFilterExpression(ResourceEntity.FLD_NAME_ResourceCategoryID, MasterDataConstants.ResourceCategory.EMPLOYEE.ToString(), SQLMatchType.Equal); String fe_resource2 = SqlExpressionBuilder.PrepareFilterExpression(ResourceEntity.FLD_NAME_ReferenceID, employeeID.ToString(), SQLMatchType.Equal); String fe_resource = SqlExpressionBuilder.PrepareFilterExpression(fe_resource1, SQLJoinType.AND, fe_resource2); IList <ResourceEntity> lstResource = FCCResource.GetFacadeCreate().GetIL(null, null, String.Empty, fe_resource, DatabaseOperationType.LoadWithFilterExpression); if (lstResource != null && lstResource.Count > 0) { String fe_Assigned_Issue = SqlExpressionBuilder.PrepareFilterExpression(OTIssueAssignedResourceEntity.FLD_NAME_ResourceID, lstResource[0].ResourceID.ToString(), SQLMatchType.Equal); IList <OTIssueAssignedResourceEntity> lstIssueAssignedResource = FCCOTIssueAssignedResource.GetFacadeCreate().GetIL(null, null, String.Empty, fe_Assigned_Issue, DatabaseOperationType.LoadWithFilterExpression); if (lstIssueAssignedResource != null && lstIssueAssignedResource.Count > 0) { String compositeIssueID = String.Empty; foreach (OTIssueAssignedResourceEntity ent in lstIssueAssignedResource) { compositeIssueID += ent.IssueID + ","; } if (compositeIssueID.IsNotNullOrEmpty()) { compositeIssueID = compositeIssueID.Substring(0, compositeIssueID.Length - 1); String fe_issue = "OTIssue.IssueID in(" + compositeIssueID + ")"; fe = SqlExpressionBuilder.PrepareFilterExpression(fe, SQLJoinType.OR, fe_issue); } } } } lblIssueList.Text = "My Issue List"; break; default: fe = SqlExpressionBuilder.PrepareFilterExpression("OTIssue." + OTIssueEntity.FLD_NAME_IssueIdentityCategoryID, MasterDataConstants.IssueIdentityCategory.PROJECT_ADHOC_ISSUE.ToString(), SQLMatchType.Equal); break; } if (chbxFilter.Checked) { String fe1 = SqlExpressionBuilder.PrepareFilterExpression("OTIssue.Title", txtSearchText.Text.ToString(), SQLMatchType.LikeWithBothMath); String fe2 = SqlExpressionBuilder.PrepareFilterExpression("MDIssuePriority.Name", txtSearchText.Text.ToString(), SQLMatchType.LikeWithSuffixMath); String fe3 = SqlExpressionBuilder.PrepareFilterExpression("MDIssueStatus.Name", txtSearchText.Text.ToString(), SQLMatchType.LikeWithSuffixMath); Int64 issueID; Int64.TryParse(txtSearchText.Text.Trim().ToString(), out issueID); String fe6 = SqlExpressionBuilder.PrepareFilterExpression("OTIssue.IssueID", issueID.ToString(), SQLMatchType.Equal); String fe4 = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.OR, fe2); String fe5 = SqlExpressionBuilder.PrepareFilterExpression(fe3, SQLJoinType.OR, fe4); String fe7 = SqlExpressionBuilder.PrepareFilterExpression(fe5, SQLJoinType.OR, fe6); fe = SqlExpressionBuilder.PrepareFilterExpression(fe, SQLJoinType.AND, fe7); } e.InputParameters["filterExpression"] = fe; }
private void BuildDropDownList() { // MiscUtil.PopulatePRMWorkOrderItemMap(ddlWorkOrderItemMapID, false); MiscUtil.PopulateMDUnit(ddlUnitID, true); }
private void BuildDropDownList() { MiscUtil.PopulateMDIssueCategoryByIssueIdentityCategory(ddlIssueCategoryID, false, MasterDataConstants.IssueIdentityCategory.ADHOC_ISSUE); MiscUtil.PopulateHREmployee(ddlEmployeeID, true); }
/// <summary> /// Reads a block of bytes from the file stream. /// </summary> /// <param name="stream">The stream to read from.</param> /// <param name="length">The lenght of the data to be read.</param> /// <returns>Returns the string representation of the read block of bytes.</returns> public static string Read(MiscUtil.IO.EndianBinaryReader stream, long length) { int theLength = (int) length; string result = null; try { byte[] bytes = new byte[length]; int readBytes = stream.Read(bytes, 0, theLength); if (readBytes > 0) result = System.Text.Encoding.ASCII.GetString(bytes, 0, readBytes); } catch { } return result; }
private void BuildDropDownList() { MiscUtil.PopulateHREmployee(ddlSendToEmployeeID, false); MiscUtil.PopulateHREmployeeNoticeTemplate(ddlTemplateID, false); }
void _eventAggregator_PortraitFound(object sender, MiscUtil.EventArgs<Portrait> e) { var bmp = e.Value.GetIpl().ToBitmap(); this.BeginInvoke(new Action(()=> { if (this.pictureBox1.Image != null) { var save = this.pictureBox1.Image; this.pictureBox1.Image = null; save.Dispose(); } if (_autoSizePicture) { this.pictureBox1.ClientSize = bmp.Size; MovePictureBox(); } this.pictureBox1.Image = bmp; this.pictureBox1.Visible = true; })); }
private void BuildDropDownList() { MiscUtil.PopulateMDScheduleIdentityCategory(ddlScheduleIdentityCategoryID, false); }
private void BuildDropDownList() { MiscUtil.PopulateCMContractor(ddlContractorID, false); MiscUtil.PopulateBDProject(ddlProjectID, false); MiscUtil.PopulateCMWorkAreaStatus(ddlWorkAreaStatusID, false); }
private void BuildDropDownList() { MiscUtil.PopulateCMNApprovalProcess(ddlApprovalProcessID, false); MiscUtil.PopulateHREmployee(ddlEmployeeID, false); MiscUtil.PopulateMDApprovalPanelStatus(ddlApprovalPanelStatusID, false); }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int dataLength = 0; int overload; string exception = null; System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (ArgumentOutOfRangeException arEx) { if (SocketServer.Logger.IsErrorLogsEnabled) { SocketServer.Logger.NCacheLog.Error("GetCommand", "command: " + command + " Error" + arEx); } _getResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(arEx, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } catch (Exception exc) { _getResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } Alachisoft.NCache.Common.Protobuf.GetResponse getResponse = null; CompressedValueEntry flagValueEntry = null; OperationContext operationContext = null; NCache nCache = clientManager.CmdExecuter as NCache; try { object lockId = cmdInfo.LockId; ulong version = cmdInfo.CacheItemVersion; DateTime lockDate = new DateTime(); operationContext = _operationContext; operationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); if (cmdInfo.LockAccessType == LockAccessType.ACQUIRE) { operationContext.Add(OperationContextFieldName.ClientThreadId, clientManager.ClientID); operationContext.Add(OperationContextFieldName.ClientThreadId, cmdInfo.ThreadId); operationContext.Add(OperationContextFieldName.IsRetryOperation, command.isRetryCommand); } flagValueEntry = nCache.Cache.GetGroup(cmdInfo.Key, cmdInfo.FlagMap, null, null, ref version, ref lockId, ref lockDate, cmdInfo.LockTimeout, cmdInfo.LockAccessType, operationContext); stopWatch.Stop(); UserBinaryObject ubObj = null; getResponse = _getResponse; if (flagValueEntry != null) { if (flagValueEntry.Value is UserBinaryObject) { ubObj = (UserBinaryObject)flagValueEntry.Value; } else { var flag = flagValueEntry.Flag; ubObj = (UserBinaryObject)nCache.Cache.SocketServerDataService.GetClientData(flagValueEntry.Value, ref flag, LanguageContext.DOTNET); } if (flagValueEntry.Value != null) { getResponse.itemType = MiscUtil.EntryTypeToProtoItemType(flagValueEntry.Type);// (Alachisoft.NCache.Common.Protobuf.CacheItemType.ItemType)flagValueEntry.Type; } } if (ubObj != null) { dataLength = ubObj.Length; } if (clientManager.ClientVersion >= 5000) { if (lockId != null) { getResponse.lockId = lockId.ToString(); } getResponse.requestId = cmdInfo.RequestId; getResponse.commandID = command.commandID; getResponse.lockTime = lockDate.Ticks; getResponse.version = version; if (ubObj == null) { // response.get = getResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(getResponse, Common.Protobuf.Response.Type.GET)); } else { //_dataPackageArray = ubObj.Data; getResponse.flag = flagValueEntry.Flag.Data; getResponse.data.AddRange(ubObj.DataList); // response.get = getResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(getResponse, Common.Protobuf.Response.Type.GET)); } } else { Alachisoft.NCache.Common.Protobuf.Response response = Stash.ProtobufResponse; response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.commandID = command.commandID; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET; if (lockId != null) { getResponse.lockId = lockId.ToString(); } getResponse.lockTime = lockDate.Ticks; getResponse.version = version; if (ubObj == null) { response.get = getResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } else { getResponse.flag = flagValueEntry.Flag.Data; getResponse.data.AddRange(ubObj.DataList); response.get = getResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } } catch (Exception exc) { exception = exc.ToString(); _getResult = OperationResult.Failure; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { operationContext?.MarkFree(NCModulesConstants.SocketServer); TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { int resutlt = 0; if (getResponse != null) { resutlt = dataLength; } string methodName = null; if (cmdInfo.LockAccessType == LockAccessType.ACQUIRE) { methodName = MethodsName.GET.ToLower(); } else { methodName = MethodsName.GET.ToLower(); } APILogItemBuilder log = new APILogItemBuilder(methodName); log.GenerateGetCommandAPILogItem(cmdInfo.Key, null, null, (long)cmdInfo.CacheItemVersion, cmdInfo.LockAccessType, cmdInfo.LockTimeout, cmdInfo.LockId, cmdInfo.ProviderName, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), resutlt); } } catch { } if (flagValueEntry != null) { MiscUtil.ReturnCompressedEntryToPool(flagValueEntry, clientManager.CacheTransactionalPool); MiscUtil.ReturnEntryToPool(flagValueEntry.Entry, clientManager.CacheTransactionalPool); } } //} //if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("GetCmd.Exec", "cmd executed on cache"); }
private void BuildDropDownList() { MiscUtil.PopulateMDDesignation(ddlDesignationID, false); }
public List <RicInfo> GetRicList() { List <RicInfo> warrantRicList = new List <RicInfo>(); RicChineseList = GetRicChineseInfo(); HtmlAgilityPack.HtmlNodeCollection ricNodeList = GetNewlyWarrantRicNode(warrantMainPageUri); int endPos = ricNodeList.Count < parent.WarrantEndPos ? ricNodeList.Count : parent.WarrantEndPos; for (int i = parent.WarrantStartPos - 1; i < endPos; i++) { HtmlAgilityPack.HtmlNode ricNode = ricNodeList[i]; RicInfo ricInfo = new RicInfo(); ricInfo.Code = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 1 + 1].InnerText); ricInfo.Underlying = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 4 + 1].InnerText); string id = ricNode.ChildNodes[2 * 1 + 1].ChildNodes[0].Attributes["href"].Value; id = id.Substring(id.IndexOf('=') + 1); id = id.Substring(0, id.IndexOf("'")); //id = id.Substring(id.IndexOf('=') + 1, 5); string[] arr = GetUnderlyingForStockAndIssuePrice(id); if (Char.IsDigit(ricInfo.Underlying, 0)) { ricInfo.UnderlyingNameForStock = arr[0]; } ricInfo.IssuerPrice = arr[1]; ricInfo.Name = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 2 + 1].InnerText); ricInfo.Issuer = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 3 + 1].InnerText); ricInfo.BullBear = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 5 + 1].InnerText); ricInfo.BoardLot = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 6 + 1].InnerText); ricInfo.StrikeLevel = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 7 + 1].InnerText); ricInfo.EntitlementRatio = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 8 + 1].InnerText); ricInfo.TotalIssueSize = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 9 + 1].InnerText); ricInfo.LauntchDate = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 10 + 1].InnerText); ricInfo.ClearingCommencementDate = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 11 + 1].InnerText); ricInfo.ListingDate = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 12 + 1].InnerText); ricInfo.MaturityDate = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 13 + 1].InnerText); //Get Chinese name information foreach (RicInfo ric in RicChineseList) { if (ric.Code == ricInfo.Code) { ricInfo.ChineseName = ric.ChineseName; break; } else { continue; } } //Get Gear and Premium from PDF if (parent.yesOrNo.Equals("Yes"))//if download pdf { parent.PDFAnalysis(ricInfo, FMType.Warrant); } warrantRicList.Add(ricInfo); } return(warrantRicList); }
private void BuildDropDownList() { MiscUtil.PopulateMDOperatorStatus(ddlOperatorStatusID, false); }
private HREmployeeSalaryDeducationInfoEntity BuildHREmployeeSalaryDeducationInfoEntity() { HREmployeeSalaryDeducationInfoEntity hREmployeeSalaryDeducationInfoEntity = CurrentHREmployeeSalaryDeducationInfoEntity; if (ddlSalaryDeducationCategoryID.Items.Count > 0) { if (ddlSalaryDeducationCategoryID.SelectedValue == "0") { } else { hREmployeeSalaryDeducationInfoEntity.SalaryDeducationCategoryID = Int64.Parse(ddlSalaryDeducationCategoryID.SelectedValue); } } if (ddlSalarySessionID.Items.Count > 0) { if (ddlSalarySessionID.SelectedValue == "0") { } else { hREmployeeSalaryDeducationInfoEntity.SalarySessionID = Int64.Parse(ddlSalarySessionID.SelectedValue); } } if (ddlFiscalYearID.Items.Count > 0) { if (ddlFiscalYearID.SelectedValue == "0") { } else { hREmployeeSalaryDeducationInfoEntity.FiscalYearID = Int64.Parse(ddlFiscalYearID.SelectedValue); } } if (ddlEmployeeID.Items.Count > 0) { if (ddlEmployeeID.SelectedValue == "0") { } else { hREmployeeSalaryDeducationInfoEntity.EmployeeID = Int64.Parse(ddlEmployeeID.SelectedValue); } } if (!txtDeductionAmount.Text.Trim().IsNullOrEmpty()) { hREmployeeSalaryDeducationInfoEntity.DeductionAmount = Decimal.Parse(txtDeductionAmount.Text.Trim()); } if (!txtPercentageOfBasicSalary.Text.Trim().IsNullOrEmpty()) { hREmployeeSalaryDeducationInfoEntity.PercentageOfBasicSalary = Decimal.Parse(txtPercentageOfBasicSalary.Text.Trim()); } if (ddlPayCycleID.Items.Count > 0) { if (ddlPayCycleID.SelectedValue == "0") { } else { hREmployeeSalaryDeducationInfoEntity.PayCycleID = Int64.Parse(ddlPayCycleID.SelectedValue); } } if (txtEffectiveDate.Text.Trim().IsNotNullOrEmpty()) { hREmployeeSalaryDeducationInfoEntity.EffectiveDate = MiscUtil.ParseToDateTime(txtEffectiveDate.Text); } if (txtEndDate.Text.Trim().IsNotNullOrEmpty()) { hREmployeeSalaryDeducationInfoEntity.EndDate = MiscUtil.ParseToDateTime(txtEndDate.Text); } else { hREmployeeSalaryDeducationInfoEntity.EndDate = null; } if (!txtNumberOfPayments.Text.Trim().IsNullOrEmpty()) { hREmployeeSalaryDeducationInfoEntity.NumberOfPayments = Decimal.Parse(txtNumberOfPayments.Text.Trim()); } hREmployeeSalaryDeducationInfoEntity.Note = txtNote.Text.Trim(); hREmployeeSalaryDeducationInfoEntity.IsRemoved = chkIsRemoved.Checked; hREmployeeSalaryDeducationInfoEntity.NextInstallMent = Decimal.Parse(txtNextInstallment.Text); return(hREmployeeSalaryDeducationInfoEntity); }
/// <summary> /// Generate the HKMAIN01_10Excel file and the HKMAIN01_10Xml file. /// </summary> /// <param name="main01_10TradingInfo">the Main01_10 trading News Info.</param> public void GenerateMain01_10ExcelAndXMLFile(TradingInfo main01_10TradingInfo) { string main01_10FilePath = MiscUtil.BackUpFileWithDateFolder(configObj.HKMAIN01_10_Workbook, false); //MiscUtil.BackupFileWithNewName(configObj.HKMAIN01_10_Workbook); using (ExcelApp app = new ExcelApp(true, false)) { var workbook = ExcelUtil.CreateOrOpenExcelFile(app, main01_10FilePath); var worksheet = ExcelUtil.GetWorksheet(configObj.HKMAIN01_10_Worksheet, workbook); if (worksheet == null) { LogMessage(string.Format("Cannot get worksheet {0} from workbook {1}", configObj.HKMAIN01_10_Worksheet, workbook.Name)); } using (ExcelLineWriter writer = new ExcelLineWriter(worksheet, 1, 1, ExcelLineWriter.Direction.Right)) { // Update the date string line = string.Empty; writer.WriteLine(main01_10TradingInfo.DateStr); //Copy from line 4 writer.PlaceNext(4, 1); foreach (StockInfo stock in main01_10TradingInfo.StockList) { writer.WriteLine(stock.Ric); writer.WriteLine(stock.StockName); writer.WriteLine(stock.Shares); writer.WriteLine(stock.Turnover); writer.PlaceNext(writer.Row + 1, 1); } int lastUsedRow = worksheet.UsedRange.Row + worksheet.UsedRange.Rows.Count - 1; ExcelUtil.GetRange(writer.Row, writer.Col, lastUsedRow, writer.Col + 4, worksheet).Clear(); writer.PlaceNext(writer.Row + 2, 1); writer.WriteLine(main01_10TradingInfo.DesignatedSecuritiesRecordingSum); writer.PlaceNext(writer.Row + 1, 1); writer.WriteLine(main01_10TradingInfo.DesignatedSharesShortSoldSum); writer.PlaceNext(writer.Row + 1, 1); writer.WriteLine(main01_10TradingInfo.DesignatedShortSellTurnoverShares); writer.PlaceNext(writer.Row + 1, 1); writer.WriteLine(main01_10TradingInfo.DesignatedShortSellTurnoverValue); writer.PlaceNext(writer.Row + 1, 1); writer.WriteLine(main01_10TradingInfo.HKDTurnoverValue); ExcelUtil.GetRange(1, 1, writer.Row - 1, 4, worksheet).Borders.LineStyle = 0; } ProductionXmlFileTemplate xmlFileTem = GetHKMAINXmlFileContent(worksheet); ConfigUtil.WriteXml(configObj.HKMAIN01_10_XmlPath, xmlFileTem); TaskResultList.Add(new TaskResultEntry("XML file for HK-MAIN01-10", "", configObj.HKMAIN01_10_XmlPath)); //Save the HK-MAIN01-10 file as a copy if (File.Exists(configObj.HKMAIN01_10_Workbook)) { File.Delete(configObj.HKMAIN01_10_Workbook); } app.ExcelAppInstance.AlertBeforeOverwriting = false; workbook.SaveCopyAs(configObj.HKMAIN01_10_Workbook); TaskResultList.Add(new TaskResultEntry("HKMAINSS01-10", "", configObj.HKMAIN01_10_Workbook)); workbook.Close(false, main01_10FilePath, true); } }
private void BuildDropDownList() { MiscUtil.PopulateMDItem(ddlItemID, false); }
public void ThreadPoolCallback(Object o) { var arg = o as SearchArgs; var top_points = new SortableData[knn + 1]; for (int i = 0; i <= knn; i++) { top_points[i] = SortableData.Minimum; } foreach (var grp in this._Groups) { string grp_name = grp.Item1; foreach (var kvp_file in grp.Item2) { var top_point_file = SortableData.Minimum; // Find best for each file foreach (var data in kvp_file.Value) { int lens = Math.Min(data._Data.Length, arg.current_norm.Length); float running_sum_norm = 0; float running_sum_flip = 0; int compare_black = 0; for (int i = 0; i < lens; i++) { // char - 48 converts char 1 or 0 to the int value of 1 or 0 // 49 - char converts char 1 or 0 to the int value of 0 or 1 int read = (49 - data._Data[i]); if (read == 1) { compare_black++; } running_sum_norm += arg.current_norm[i] * read; running_sum_flip += arg.current_flip[i] * read; } running_sum_norm /= Math.Max(compare_black, arg.current_black); running_sum_flip /= Math.Max(compare_black, arg.current_black); if (running_sum_norm > top_point_file._Sum) { top_point_file = new SortableData( grp_name, kvp_file.Key, data, running_sum_norm, false); } if (running_sum_flip > top_point_file._Sum) { top_point_file = new SortableData( grp_name, kvp_file.Key, data, running_sum_flip, true); } } // Each file only gets one best if (top_point_file._Data != null) { top_points[0] = top_point_file; for (int offset = 0; // Bubble Sort (offset < knn) && (top_points[offset]._Sum > top_points[offset + 1]._Sum); offset++) { MiscUtil.Swap( ref top_points[offset], ref top_points[offset + 1]); } } } } this._Data = top_points.SubArray(1, knn); _DoneEvent.Set(); }
protected void btnAddToProject_Click(object sender, EventArgs e) { if (ddlProjectID.Items.Count > 0 && ddlProjectID.SelectedValue != "0") { Int64 itemID = 0; if (ViewState["LastUpdatedItemID"] != null) { itemID = (Int64)ViewState["LastUpdatedItemID"]; } if (itemID > 0) { String fe_itemDefault = SqlExpressionBuilder.PrepareFilterExpression(MDItemDefaultEntity.FLD_NAME_ItemID, itemID.ToString(), SQLMatchType.Equal); IList <MDItemDefaultEntity> lstmDItemDefaultEntity = FCCMDItemDefault.GetFacadeCreate().GetIL(null, null, String.Empty, fe_itemDefault, DatabaseOperationType.LoadWithFilterExpression); String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQEntity.FLD_NAME_ProjectID, ddlProjectID.SelectedValue.ToString(), SQLMatchType.Equal); IList <PRMPreBOQEntity> preBOQList = FCCPRMPreBOQ.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression); if (preBOQList != null && preBOQList.Count > 0) { Int64 preBOQID = preBOQList[0].PreBOQID; Decimal totalQty = 0; Decimal.TryParse(txtQty.Text.Trim().ToString(), out totalQty); Decimal currentPrice = MiscUtil.GetCurrentPrice(itemID, lstmDItemDefaultEntity[0].BrandID, lstmDItemDefaultEntity[0].SupplierID, lstmDItemDefaultEntity[0].RegionID, lstmDItemDefaultEntity[0].CountryID); switch (preBOQList[0].IsLocked) { case true: #region Add Item to BOQ try { String fe_boq = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQEntity.FLD_NAME_ProjectID, ddlProjectID.SelectedValue.ToString(), SQLMatchType.Equal); IList <PRMBOQEntity> lstPRMBOQ = FCCPRMBOQ.GetFacadeCreate().GetIL(null, null, String.Empty, fe_boq, DatabaseOperationType.LoadWithFilterExpression); if (lstPRMBOQ != null && lstPRMBOQ.Count > 0) { PRMBOQDetailEntity pRMBOQDeatEntity = new PRMBOQDetailEntity(); pRMBOQDeatEntity.BOQID = lstPRMBOQ[0].BOQID; pRMBOQDeatEntity.ItemID = itemID; pRMBOQDeatEntity.BrandID = lstmDItemDefaultEntity[0].BrandID; pRMBOQDeatEntity.RegionID = lstmDItemDefaultEntity[0].RegionID; pRMBOQDeatEntity.CountryID = lstmDItemDefaultEntity[0].CountryID; pRMBOQDeatEntity.SupplierID = lstmDItemDefaultEntity[0].SupplierID; pRMBOQDeatEntity.Remarks = "Directly Added From Item"; pRMBOQDeatEntity.IsRemoved = false; pRMBOQDeatEntity.Rate = currentPrice; pRMBOQDeatEntity.EntryDate = System.DateTime.Now; pRMBOQDeatEntity.TotalQty = totalQty; Int64 result_boq = -1; result_boq = FCCPRMBOQDetail.GetFacadeCreate().Add(pRMBOQDeatEntity, DatabaseOperationType.Add, TransactionRequired.No); if (result_boq > 0) { PRMAvailableBOQQtyForRequisitionEntity pRMAvailableBOQQtyForRequisitionEntity = new PRMAvailableBOQQtyForRequisitionEntity(); pRMAvailableBOQQtyForRequisitionEntity.IsBOQ = true; pRMAvailableBOQQtyForRequisitionEntity.PreBOQOrBOQDetailID = result_boq; pRMAvailableBOQQtyForRequisitionEntity.ItemID = itemID; pRMAvailableBOQQtyForRequisitionEntity.Qty = totalQty; pRMAvailableBOQQtyForRequisitionEntity.CreateDate = DateTime.Now; pRMAvailableBOQQtyForRequisitionEntity.CreatedByEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember); pRMAvailableBOQQtyForRequisitionEntity.ProjectID = Int64.Parse(ddlProjectID.SelectedValue); Int64 result_available = -1; result_available = FCCPRMAvailableBOQQtyForRequisition.GetFacadeCreate().Add(pRMAvailableBOQQtyForRequisitionEntity, DatabaseOperationType.Add, TransactionRequired.No); MiscUtil.ShowMessage(lblMessage, "Qty Added Successfully to Project Cost.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, "Some Error Occured.", true); } #endregion break; case false: #region Add Item to Pre-BOQ try { String fe_preBOQ = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQEntity.FLD_NAME_ProjectID, ddlProjectID.SelectedValue.ToString(), SQLMatchType.Equal); IList <PRMPreBOQEntity> lstPRMPreBOQ = FCCPRMPreBOQ.GetFacadeCreate().GetIL(null, null, String.Empty, fe_preBOQ, DatabaseOperationType.LoadWithFilterExpression); if (lstPRMPreBOQ != null && lstPRMPreBOQ.Count > 0) { PRMPreBOQDetailEntity pRMPreBOQDeatEntity = new PRMPreBOQDetailEntity(); pRMPreBOQDeatEntity.PreBOQID = lstPRMPreBOQ[0].PreBOQID; pRMPreBOQDeatEntity.ItemID = itemID; pRMPreBOQDeatEntity.BrandID = lstmDItemDefaultEntity[0].BrandID; pRMPreBOQDeatEntity.RegionID = lstmDItemDefaultEntity[0].RegionID; pRMPreBOQDeatEntity.CountryID = lstmDItemDefaultEntity[0].CountryID; pRMPreBOQDeatEntity.SupplierID = lstmDItemDefaultEntity[0].SupplierID; pRMPreBOQDeatEntity.TotalQty = totalQty; pRMPreBOQDeatEntity.Remarks = "Directly Added From Item"; pRMPreBOQDeatEntity.IsRemoved = false; pRMPreBOQDeatEntity.Rate = currentPrice; pRMPreBOQDeatEntity.EntryDate = System.DateTime.Now; Int64 result_preboq = -1; result_preboq = FCCPRMPreBOQDetail.GetFacadeCreate().Add(pRMPreBOQDeatEntity, DatabaseOperationType.Add, TransactionRequired.No); if (result_preboq > 0) { PRMAvailableBOQQtyForRequisitionEntity pRMAvailableBOQQtyForRequisitionEntity = new PRMAvailableBOQQtyForRequisitionEntity(); pRMAvailableBOQQtyForRequisitionEntity.IsBOQ = false; pRMAvailableBOQQtyForRequisitionEntity.PreBOQOrBOQDetailID = result_preboq; pRMAvailableBOQQtyForRequisitionEntity.ItemID = itemID; pRMAvailableBOQQtyForRequisitionEntity.Qty = totalQty; pRMAvailableBOQQtyForRequisitionEntity.CreateDate = DateTime.Now; pRMAvailableBOQQtyForRequisitionEntity.CreatedByEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember); pRMAvailableBOQQtyForRequisitionEntity.ProjectID = Int64.Parse(ddlProjectID.SelectedValue); Int64 result_available = -1; result_available = FCCPRMAvailableBOQQtyForRequisition.GetFacadeCreate().Add(pRMAvailableBOQQtyForRequisitionEntity, DatabaseOperationType.Add, TransactionRequired.No); MiscUtil.ShowMessage(lblMessage, "Qty Added Successfully to BOQ.", false); } } } catch (Exception) { MiscUtil.ShowMessage(lblMessage, "Some Error Occured.", true); } #endregion break; default: break; } } } } }
protected void btnForward_Click(object sender, EventArgs e) { //if (chbxAutoForwardTo.Checked) //{ // APApprovalProcessEntity aPApprovalProcessEntity = APRobot.GetApprovalProcessByTypeAndReference(MasterDataConstants.APType.BILL, CMBillID); // IList<APMemberFeedbackEntity> feedbackList = APRobot.GetAllMemberFeedbacks(aPApprovalProcessEntity.APApprovalProcessID); // IList<APMemberFeedbackEntity> ordered_list = feedbackList.OrderBy(x => x.SequenceNo).ToList(); // APPanelForwardMemberEntity aPPanelForwardMemberEntity = APRobot.GetAPPanelForwardMemberByID(Int64.Parse(ddlForwardTo.SelectedValue)); // var existsInfo = (from s in ordered_list // where s.EmployeeID.ToString() == aPPanelForwardMemberEntity.EmployeeID.ToString() // select s); // if (existsInfo != null && existsInfo.Count() > 0) // { // MiscUtil.ShowMessage(lblMessage, "Member Already Exists in the Approval Panel", true); // return; // } // APMemberFeedbackEntity currentEmployeeInfo = (from r in ordered_list // where r.EmployeeID.ToString() == MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember).ToString() // select r).FirstOrDefault(); // if (currentEmployeeInfo != null) // { // ordered_list = (from m in ordered_list // where m.SequenceNo > currentEmployeeInfo.SequenceNo // select m).ToList(); // APMemberFeedbackEntity aPMemberFeedbackEntity = new APMemberFeedbackEntity(); // aPMemberFeedbackEntity.APApprovalProcessID = aPApprovalProcessEntity.APApprovalProcessID; // aPMemberFeedbackEntity.DepartmentID = aPPanelForwardMemberEntity.DepartmentID; // aPMemberFeedbackEntity.EmployeeID = aPPanelForwardMemberEntity.EmployeeID; // aPMemberFeedbackEntity.SequenceNo = currentEmployeeInfo.SequenceNo + 1; // aPMemberFeedbackEntity.APFeedbackID = MasterDataConstants.APFeedback.NOT_YET_REQUESTED; // aPMemberFeedbackEntity.FeedbackRequestDate = DateTime.Now; // aPMemberFeedbackEntity.FeedbackLastResponseDate = null; // aPMemberFeedbackEntity.FeedbackSubmitDate = null; // aPMemberFeedbackEntity.IsProxyEmployeeEnabled = false; // aPMemberFeedbackEntity.ProxyEmployeeID = null; // Int64 aPMemberFeedbackID = FCCAPMemberFeedback.GetFacadeCreate().Add(aPMemberFeedbackEntity, DatabaseOperationType.Add, TransactionRequired.No); // foreach (APMemberFeedbackEntity ent in ordered_list) // { // String fe = SqlExpressionBuilder.PrepareFilterExpression(APMemberFeedbackEntity.FLD_NAME_APMemberFeedbackID, ent.APMemberFeedbackID.ToString(), SQLMatchType.Equal); // ent.SequenceNo += 1; // FCCAPMemberFeedback.GetFacadeCreate().Update(ent, fe, DatabaseOperationType.Update, TransactionRequired.No); // } // APRobot.UpdateApprovalProcessFeedback(APMemberFeedbackID, MasterDataConstants.APFeedback.APPROVED, MasterDataConstants.APType.BILL, CMBillID); // String remarks = txtRemarks.Text.Trim(); // if (remarks.IsNullOrEmpty()) // { // remarks = "Approved"; // } // remarks = AddProxyMemberInfo(remarks); // APRobot.AddAPMemberFeedbackRemarks(APMemberFeedbackID, remarks); // EnableDisableApprovalButtons(); // MiscUtil.ShowMessage(lblMessage, "You have Approved Successfully", UIConstants.MessageType.GREEN); // PrepareInitialView(); // BindList(); // RedirectPageToPendingList(); // } //} ////Previous Code //else //{ if (ddlRejectTo.Items.Count > 0) { APRobot.UpdateMemberFeedbackFeedback(APMemberFeedbackID, MasterDataConstants.APFeedback.FORWARDED); APRobot.UpdateMemberFeedbackLastResponseDate(APMemberFeedbackID, DateTime.Now); String remarks = txtLoanRemarks.Text.Trim(); if (remarks.IsNullOrEmpty()) { remarks = "Forwarded"; } remarks = AddProxyMemberInfo(remarks); Int64 aPMemberFeedbackRemarksID = APRobot.AddAPMemberFeedbackRemarks(APMemberFeedbackID, remarks); Int64 aPPanelForwardMemberID = Int64.Parse(ddlForwardTo.SelectedValue); APPanelForwardMemberEntity aPPanelForwardMemberEntity = APRobot.GetAPPanelForwardMemberByID(aPPanelForwardMemberID); APForwardInfoEntity aPForwardInfoEntity = new APForwardInfoEntity(); aPForwardInfoEntity.APMemberFeedbackID = APMemberFeedbackID; aPForwardInfoEntity.APApprovalProcessID = APApprovalProcessID; aPForwardInfoEntity.APMemberFeedbackRemarksID = aPMemberFeedbackRemarksID; aPForwardInfoEntity.DepartmentID = aPPanelForwardMemberEntity.DepartmentID; aPForwardInfoEntity.EmployeeID = aPPanelForwardMemberEntity.EmployeeID; aPForwardInfoEntity.CommentRequestDate = DateTime.Now; aPForwardInfoEntity.CommentSubmitDate = null; aPForwardInfoEntity.APMemberComment = txtForwardRemarks.Text.Trim(); aPForwardInfoEntity.APForwardMemberComment = String.Empty; FCCAPForwardInfo.GetFacadeCreate().Add(aPForwardInfoEntity, DatabaseOperationType.Add, TransactionRequired.No); MiscUtil.ShowMessage(lblMessage, "You have forwarded the thread successfully", UIConstants.MessageType.GREEN); PrepareInitialView(); BindList(); #region Forwarded Mail String MailBody = String.Empty; String Subject = String.Empty; StringBuilder sb = new StringBuilder(); sb.Append("Dear Sir,"); sb.Append("<br/>"); sb.Append("This is a auto generated mail from the ERP."); sb.Append("<br/>"); sb.Append("A Loan Application Request is Forwarded Request is waiting for your approval"); sb.Append("<br/>"); sb.Append("<br/>"); sb.Append("-"); sb.Append("<br/>"); sb.Append("Thanks"); sb.Append("<br/>"); sb.Append("ERP System"); MailBody = sb.ToString(); Subject = "ERP, Loan Application, Forwarded"; MailBody = @"Please note that a Bill is Forwarded.-Thanks ERP System"; HREmployeeEntity _hREmployeeEntity = FCCHREmployee.GetFacadeCreate().GetByID(aPForwardInfoEntity.EmployeeID); if (_hREmployeeEntity != null) { String[] sendToMail = new String[] { _hREmployeeEntity.PrimaryEmail }; MiscUtil.SendMail(sendToMail, Subject, MailBody); } #endregion //RedirectPageToForwardList(); } else { MiscUtil.ShowMessage(lblMessage, "Failed to forward", UIConstants.MessageType.RED); } //} }
private void SaveMDItemEntity() { if (IsValid) { try { Boolean addInputValidation = true; MDItemEntity mDItemEntity = BuildMDItemEntity(); Int64 result = -1; if (mDItemEntity.IsNew) { if (ValidateInput()) { if (treeItem.SelectedNode != null) { mDItemEntity.ItemCategoryID = Int64.Parse(treeItem.SelectedValue); } result = FCCMDItem.GetFacadeCreate().Add(mDItemEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { addInputValidation = false; } } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDItemEntity.FLD_NAME_ItemID, mDItemEntity.ItemID.ToString(), SQLMatchType.Equal); result = FCCMDItem.GetFacadeCreate().Update(mDItemEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (addInputValidation == true) { if (result > 0) { #region Item Brand Map ViewState["LastUpdatedItemID"] = result; try { IList <PRMItemBrandMapEntity> newMappedItems = new List <PRMItemBrandMapEntity>(); foreach (ListItem chbxItem in chbxItemBrand.Items) { if (chbxItem.Selected) { PRMItemBrandMapEntity mDItemBrandMapEntity = new PRMItemBrandMapEntity(); mDItemBrandMapEntity.ItemID = result; mDItemBrandMapEntity.BrandID = Int64.Parse(chbxItem.Value.ToString()); newMappedItems.Add(mDItemBrandMapEntity); } } IList <PRMItemBrandMapEntity> deleteList = _CurrentItemBrandMapList.Except(newMappedItems, new CustomerComparer()).ToList(); IList <PRMItemBrandMapEntity> addNewList = newMappedItems.Except(_CurrentItemBrandMapList, new CustomerComparer()).ToList(); if (deleteList != null && deleteList.Count > 0) { foreach (PRMItemBrandMapEntity ent in deleteList) { String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMItemBrandMapEntity.FLD_NAME_ItemID, ent.ItemID.ToString(), SQLMatchType.Equal); String fe2 = SqlExpressionBuilder.PrepareFilterExpression(PRMItemBrandMapEntity.FLD_NAME_BrandID, ent.BrandID.ToString(), SQLMatchType.Equal); String fe = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2); FCCPRMItemBrandMap.GetFacadeCreate().Delete(ent, fe, DatabaseOperationType.Delete, TransactionRequired.No); } } if (addNewList != null && addNewList.Count > 0) { foreach (PRMItemBrandMapEntity ent in addNewList) { FCCPRMItemBrandMap.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No); } } String feCurrent = SqlExpressionBuilder.PrepareFilterExpression(PRMItemBrandMapEntity.FLD_NAME_ItemID, result.ToString(), SQLMatchType.Equal); IList <PRMItemBrandMapEntity> ItemBrandList = FCCPRMItemBrandMap.GetFacadeCreate().GetIL(null, null, String.Empty, feCurrent, DatabaseOperationType.LoadWithFilterExpression); _CurrentItemBrandMapList = ItemBrandList; if (ddlBrandID.Items.Count > 0 && ddlBrandID.SelectedValue != MasterDataConstants.ItemDefaults.DEFAULT_BRAD.ToString()) { Boolean isNeedToInsert = false; if (ItemBrandList != null && ItemBrandList.Count > 0) { PRMItemBrandMapEntity itemBrandInfo = (from s in ItemBrandList where s.BrandID.ToString() == ddlBrandID.SelectedValue select s).FirstOrDefault(); if (itemBrandInfo == null) { isNeedToInsert = true; } } else { isNeedToInsert = true; } if (isNeedToInsert) { PRMItemBrandMapEntity pRMItemBrandMapEntity = new PRMItemBrandMapEntity(); pRMItemBrandMapEntity.BrandID = Int64.Parse(ddlBrandID.SelectedValue); pRMItemBrandMapEntity.ItemID = result; FCCPRMItemBrandMap.GetFacadeCreate().Add(pRMItemBrandMapEntity, DatabaseOperationType.Add, TransactionRequired.No); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } #endregion #region Item Defaults MDItemDefaultEntity mDItemDefaultEntity = BuildMDItemDefaultEntity(); mDItemDefaultEntity.ItemID = result; if (mDItemDefaultEntity.IsNew) { FCCMDItemDefault.GetFacadeCreate().Add(mDItemDefaultEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDItemDefaultEntity.FLD_NAME_ItemDefaultID, mDItemDefaultEntity.ItemDefaultID.ToString(), SQLMatchType.Equal); FCCMDItemDefault.GetFacadeCreate().Update(mDItemDefaultEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } #endregion //#region Item Thumb Rule //MDItemThumbRuleEntity mDItemThumbRuleEntity = BuildMDItemThumbRuleEntity(); //mDItemThumbRuleEntity.ItemID = result; //if (mDItemThumbRuleEntity.IsNew) //{ // result = FCCMDItemThumbRule.GetFacadeCreate().Add(mDItemThumbRuleEntity, DatabaseOperationType.Add, TransactionRequired.No); //} //else //{ // String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDItemThumbRuleEntity.FLD_NAME_MDItemThumbRuleID, mDItemThumbRuleEntity.MDItemThumbRuleID.ToString(), SQLMatchType.Equal); // result = FCCMDItemThumbRule.GetFacadeCreate().Update(mDItemThumbRuleEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); //} //#endregion //if (mDItemEntity.IsNew) //{ // if (Roles.IsUserInRole(this.Page.User.Identity.Name, "Admin") == true || Roles.IsUserInRole(this.Page.User.Identity.Name, "Engineer") || Roles.IsUserInRole(this.Page.User.Identity.Name, "MIS") == true) // { // lblItemName.Text = mDItemEntity.ItemName.ToString(); // this.Panel2_ModalPopupExtender.Show(); // } //} _ItemID = 0; _MDItemEntity = new MDItemEntity(); // clearing cache FCCMDItem.GetFacadeCreate().RemoveCache(); PrepareInitialView(); LoadTreeView(); if (mDItemEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Item Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Item Information has been updated successfully.", false); } } else { if (mDItemEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Item Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Item Information.", false); } } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvOTIssue_Detailed_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 IssueID; Int64.TryParse(e.CommandArgument.ToString(), out IssueID); if (IssueID > 0) { if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, IssueID.ToString(), SQLMatchType.Equal); OTIssueEntity oTIssueEntity = new OTIssueEntity(); result = FCCOTIssue.GetFacadeCreate().Delete(oTIssueEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _IssueID = 0; _OTIssueEntity = new OTIssueEntity(); PrepareInitialView(); BindOTIssueList(); MiscUtil.ShowMessage(lblMessage, "Issue has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Issue.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } else if (string.Equals(e.CommandName, "UpdateItem")) { try { _IssueID = IssueID; OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; if (CurrentOTIssueEntity.IssueStatusID == MasterDataConstants.MDIssueStatus.COMPLETED) { MiscUtil.ShowMessage(lblMessage, "Issue Already Completed.", false); return; } Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, IssueID.ToString(), SQLMatchType.Equal); oTIssueEntity.IssueStatusID = MasterDataConstants.MDIssueStatus.COMPLETED; oTIssueEntity.CompletionPercentage = 100; result = FCCOTIssue.GetFacadeCreate().Update(oTIssueEntity, fe, DatabaseOperationType.Update, TransactionRequired.No); if (result > 0) { _IssueID = 0; _OTIssueEntity = new OTIssueEntity(); PrepareInitialView(); BindOTIssueList(); MiscUtil.ShowMessage(lblMessage, "Issue has been successfully Updated.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to Update Issue.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } else if (string.Equals(e.CommandName, "AddToSchedule")) { try { OTIssueEntity oTIssueEntity = FCCOTIssue.GetFacadeCreate().GetByID(IssueID); OTScheduleEntity oTScheduleEntity = new OTScheduleEntity(); } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private void DeleteItem() { Int64 ItemID; Int64.TryParse(treeItem.SelectedValue, out ItemID); if (ItemID > 0) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(MDItemEntity.FLD_NAME_ItemID, ItemID.ToString(), SQLMatchType.Equal); MDItemEntity mDItemEntity = new MDItemEntity(); #region Item Brand Map String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMItemBrandMapEntity.FLD_NAME_ItemID, ItemID.ToString(), SQLMatchType.Equal); PRMItemBrandMapEntity prmItemBrandMap = new PRMItemBrandMapEntity(); FCCPRMItemBrandMap.GetFacadeCreate().Delete(prmItemBrandMap, fe, DatabaseOperationType.Delete, TransactionRequired.No); #endregion #region Item Default String fe2 = SqlExpressionBuilder.PrepareFilterExpression(MDItemDefaultEntity.FLD_NAME_ItemID, ItemID.ToString(), SQLMatchType.Equal); MDItemDefaultEntity mDItemDefaultEntity = new MDItemDefaultEntity(); FCCMDItemDefault.GetFacadeCreate().Delete(mDItemDefaultEntity, fe2, DatabaseOperationType.Delete, TransactionRequired.No); #endregion #region Item Thumb Rule String fe3 = SqlExpressionBuilder.PrepareFilterExpression(MDItemThumbRuleEntity.FLD_NAME_ItemID, ItemID.ToString(), SQLMatchType.Equal); MDItemThumbRuleEntity mDItemThumbRuleEntity = new MDItemThumbRuleEntity(); result = FCCMDItemThumbRule.GetFacadeCreate().Delete(mDItemThumbRuleEntity, fe3, DatabaseOperationType.Delete, TransactionRequired.No); #endregion result = FCCMDItem.GetFacadeCreate().Delete(mDItemEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _ItemID = 0; _MDItemEntity = new MDItemEntity(); // clearing cache FCCMDItem.GetFacadeCreate().RemoveCache(); PrepareInitialView(); LoadTreeView(); MiscUtil.ShowMessage(lblMessage, "Item has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Item.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private CRMPaymentScheduleMapEntity BuildCRMPaymentScheduleMapEntity() { CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity = CurrentCRMPaymentScheduleMapEntity; if (ddlLinkPaymentScheduleMapID.Items.Count > 0) { if (ddlLinkPaymentScheduleMapID.SelectedValue == "0") { cRMPaymentScheduleMapEntity.LinkPaymentScheduleMapID = null; } else { cRMPaymentScheduleMapEntity.LinkPaymentScheduleMapID = Int64.Parse(ddlLinkPaymentScheduleMapID.SelectedValue); } } if (ddlPaymentScheduleID.Items.Count > 0) { if (ddlPaymentScheduleID.SelectedValue == "0") { } else { cRMPaymentScheduleMapEntity.PaymentScheduleID = Int64.Parse(ddlPaymentScheduleID.SelectedValue); } } cRMPaymentScheduleMapEntity.InstallmentName = txtInstallmentName.Text.Trim(); if (txtInstallmentDueDate.Text.Trim().IsNotNullOrEmpty()) { cRMPaymentScheduleMapEntity.InstallmentDueDate = MiscUtil.ParseToDateTime(txtInstallmentDueDate.Text); } if (txtInstallmentDueDateNew.Text.Trim().IsNotNullOrEmpty()) { cRMPaymentScheduleMapEntity.InstallmentDueDateNew = MiscUtil.ParseToDateTime(txtInstallmentDueDateNew.Text); } else { cRMPaymentScheduleMapEntity.InstallmentDueDateNew = null; } if (ddlAgreementID.Items.Count > 0) { if (ddlAgreementID.SelectedValue == "0") { } else { cRMPaymentScheduleMapEntity.AgreementID = Int64.Parse(ddlAgreementID.SelectedValue); } } if (!txtAgreementAAmount.Text.Trim().IsNullOrEmpty()) { cRMPaymentScheduleMapEntity.AgreementAAmount = Decimal.Parse(txtAgreementAAmount.Text.Trim()); } else { cRMPaymentScheduleMapEntity.AgreementAAmount = null; } if (!txtAgreementBAmount.Text.Trim().IsNullOrEmpty()) { cRMPaymentScheduleMapEntity.AgreementBAmount = Decimal.Parse(txtAgreementBAmount.Text.Trim()); } else { cRMPaymentScheduleMapEntity.AgreementBAmount = null; } if (!txtAgreementCAmount.Text.Trim().IsNullOrEmpty()) { cRMPaymentScheduleMapEntity.AgreementCAmount = Decimal.Parse(txtAgreementCAmount.Text.Trim()); } else { cRMPaymentScheduleMapEntity.AgreementCAmount = null; } if (!txtAgreementDAmount.Text.Trim().IsNullOrEmpty()) { cRMPaymentScheduleMapEntity.AgreementDAmount = Decimal.Parse(txtAgreementDAmount.Text.Trim()); } else { cRMPaymentScheduleMapEntity.AgreementDAmount = null; } if (!txtAgreementEAmount.Text.Trim().IsNullOrEmpty()) { cRMPaymentScheduleMapEntity.AgreementEAmount = Decimal.Parse(txtAgreementEAmount.Text.Trim()); } else { cRMPaymentScheduleMapEntity.AgreementEAmount = null; } if (txtPaymentDueDate.Text.Trim().IsNotNullOrEmpty()) { cRMPaymentScheduleMapEntity.PaymentDueDate = MiscUtil.ParseToDateTime(txtPaymentDueDate.Text); } else { cRMPaymentScheduleMapEntity.PaymentDueDate = null; } cRMPaymentScheduleMapEntity.FinalPayment = chkFinalPayment.Checked; cRMPaymentScheduleMapEntity.Revised = chkRevised.Checked; cRMPaymentScheduleMapEntity.RevisedIP = txtRevisedIP.Text.Trim(); if (ddlLastRevisedByEmployeeID.Items.Count > 0) { if (ddlLastRevisedByEmployeeID.SelectedValue == "0") { cRMPaymentScheduleMapEntity.LastRevisedByEmployeeID = null; } else { cRMPaymentScheduleMapEntity.LastRevisedByEmployeeID = Int64.Parse(ddlLastRevisedByEmployeeID.SelectedValue); } } if (txtLastRevisedDate.Text.Trim().IsNotNullOrEmpty()) { cRMPaymentScheduleMapEntity.LastRevisedDate = MiscUtil.ParseToDateTime(txtLastRevisedDate.Text); } cRMPaymentScheduleMapEntity.Remarks = txtRemarks.Text.Trim(); if (txtCreateDate.Text.Trim().IsNotNullOrEmpty()) { cRMPaymentScheduleMapEntity.CreateDate = MiscUtil.ParseToDateTime(txtCreateDate.Text); } if (ddlCreateByEmployeeID.Items.Count > 0) { if (ddlCreateByEmployeeID.SelectedValue == "0") { } else { cRMPaymentScheduleMapEntity.CreateByEmployeeID = Int64.Parse(ddlCreateByEmployeeID.SelectedValue); } } cRMPaymentScheduleMapEntity.IP = txtIP.Text.Trim(); return(cRMPaymentScheduleMapEntity); }
private void SavePRMBOQTemplateItemMapEntity() { try { foreach (TreeNode catNode in treeItem.Nodes) { PrepareCurrentlyPopulatedMappedItems(catNode); } foreach (TreeNode tn in treeItem.CheckedNodes) { PRMBOQTemplateItemMapEntity ent = new PRMBOQTemplateItemMapEntity(); ent.ItemID = Int64.Parse(tn.Value.ToString()); ent.BOQTemplateID = BOQTemplateID; newMappedItems.Add(ent); } if (currentMappedItems.Count <= 0) { IList <PRMBOQTemplateItemMapEntity> unCheckedList = currentlyPopulatedMappedItems.Except(newMappedItems, new CustomerComparer()).ToList(); IList <PRMBOQTemplateItemMapEntity> templateItemList = new List <PRMBOQTemplateItemMapEntity>(); foreach (var v in temporaryMappedItems) { PRMBOQTemplateItemMapEntity ent = new PRMBOQTemplateItemMapEntity(); ent.ItemID = v.ItemID; ent.BOQTemplateID = BOQTemplateID; templateItemList.Add(ent); } IList <PRMBOQTemplateItemMapEntity> addCheckedList = templateItemList.Except(unCheckedList, new CustomerComparerAnother()).ToList(); Int64 i = 0; StringBuilder xmlStr = new StringBuilder(); xmlStr.Append("<m>"); String subXmlStr = null; foreach (PRMBOQTemplateItemMapEntity ent in addCheckedList) { i++; subXmlStr = subXmlStr + "<i><a>" + ent.BOQTemplateID + "</a><b>" + ent.ItemID + "</b><c>" + i + "</c></i>"; } xmlStr.Append(subXmlStr.ToString()); xmlStr.Append("</m>"); FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.BOQItemMapTableInfo); } else if (currentMappedItems.Count > 0) { currentlyPopulatedMappedItems = currentlyPopulatedMappedItems.Intersect(currentMappedItems, new CustomerComparer()).ToList(); IList <PRMBOQTemplateItemMapEntity> deleteList = currentlyPopulatedMappedItems.Except(newMappedItems, new CustomerComparer()).ToList(); IList <PRMBOQTemplateItemMapEntity> addNewList = newMappedItems.Except(currentlyPopulatedMappedItems, new CustomerComparer()).ToList(); if (deleteList != null && deleteList.Count > 0) { foreach (PRMBOQTemplateItemMapEntity ent in deleteList) { String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQTemplateItemMapEntity.FLD_NAME_BOQTemplateID, ent.BOQTemplateID.ToString(), SQLMatchType.Equal); String fe2 = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQTemplateItemMapEntity.FLD_NAME_ItemID, ent.ItemID.ToString(), SQLMatchType.Equal); String fe = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2); FCCPRMBOQTemplateItemMap.GetFacadeCreate().Delete(ent, fe, DatabaseOperationType.Delete, TransactionRequired.No); } } if (addNewList != null && addNewList.Count > 0) { foreach (PRMBOQTemplateItemMapEntity ent in addNewList) { FCCPRMBOQTemplateItemMap.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No); } } } MiscUtil.ShowMessage(lblMessage, "Template Project Cost Item Map Updated Successfully.", false); } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true); } }