namespace CounsellorBL.PRD { using CounsellorBL.BLStructure; using CounsellorBL.Helper; using CounsellorBL.PRD.ConstDefinition; using MonumentDefine; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OT.COM.ArsenalDB; using OT.COM.ArsenalDB.SQL; using OT.COM.SignalerMessage; using Util = OT.COM.LogisticsUtil.Util; using SoldierData.EnterprizeV4; using System; using System.Collections.Generic; using System.Linq; class ProductManageService : SingleDataTableTemplate { public ProductManageService() { dgReadCommandPostDataHandler = readCommandPostDataHandler; } public CResponseMessage ProductByArticle(CRequestMessage i_crmInput) { string sMsg = null; Command cRes = null; Dictionary dicWhereData = GetQueryMasterFirstWhereData(i_crmInput); if (dicWhereData != null && dicWhereData.ContainsKey(tb_prd_article2product.CN_ARTICLE_UID)) { string sArticlueUid = dicWhereData[tb_prd_article2product.CN_ARTICLE_UID].ToString(); PrdSQLLib psl = new PrdSQLLib(new MSSQLDirectSQLHelper()); sMsg = psl.GetArticleProduct(sArticlueUid, out cRes); } else { sMsg = MessageWording.PARAM_NOT_EXPECTED; } return simpleRead(i_crmInput, sMsg, cRes); } protected string readCommandPostDataHandler(CRequestMessage i_crmInput, ArsenalInterface i_aiArsenal, Command i_cCmd, JArray i_jaData, tb_sys_session i_sSessionUser, out object o_c, [System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0, [System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "", [System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "") { if (i_sSourcePath is null) { throw new ArgumentNullException(nameof(i_sSourcePath)); } string sMsg; Command cRes = null; object oResultData = null; try { do { sMsg = ScheduleRange.ParseLogStartEnd(tb_prd_product.CN_CREATE_DATE, i_jaData, out ScheduleRange sr); if (sMsg != null) { break; } Dictionary dicCondition = GetQueryMasterFirstQJEDicwherecols(i_crmInput); var lsBranch = ProjectHelper.GetUserGroup(i_crmInput); QueryJsonElementCollection lBlocks = new QueryJsonElementCollection(); QueryJsonElement qjeA = lBlocks.GetInst(); qjeA.displaycols = new List() { tb_prd_product.CN_UID, tb_prd_product.CN_NAME, tb_prd_product.CN_MEMO, tb_prd_product.CN_STATUS_FLAG, tb_prd_product.CN_WHOLESALE_PRICE, tb_prd_product.CN_PRICE, tb_prd_product.CN_SERIAL_NUMBER, tb_prd_product.CN_GROUP_ID }; qjeA.ordercols = new List>() { new Tuple(qjeA, tb_prd_product.CN_CREATE_DATE, BLWording.ORDER_DESC) }; List lwnMainInfo = new List(); if (dicCondition.ContainsKey(tb_prd_product.CN_NAME)) { lwnMainInfo.Add(new WhereNode(tb_prd_product.CN_NAME, WhereNode.EColumnOperation.EOT_LIKE, typeof(tb_ord_message_log), dicCondition[tb_prd_product.CN_NAME])); } if (dicCondition.ContainsKey(tb_prd_product.CN_STATUS_FLAG)) { lwnMainInfo.Add(new WhereNode(tb_prd_product.CN_STATUS_FLAG, WhereNode.EColumnOperation.EOT_EQ, typeof(tb_ord_message_log), dicCondition[tb_prd_product.CN_STATUS_FLAG])); } lwnMainInfo.Add(new WhereNode(tb_prd_product.CN_GROUP_ID, WhereNode.EColumnOperation.EOT_IN, typeof(tb_prd_product), lsBranch.ToArray())); qjeA.wherecols = lwnMainInfo.Count == 1 ? lwnMainInfo.Single() : new WhereNode(WhereNode.ENodeOperation.ENO_AND, lwnMainInfo.ToArray()); lBlocks.Add(qjeA); QueryJsonElement qjeB = lBlocks.GetInst(); qjeB.aliascols = new Dictionary>() { { tb_grp_group.CN_NAME, new List(){ "group_name" } } }; qjeB.jointype = QueryJsonElement.JOIN; qjeB.jointable = qjeA; qjeB.joincols = new Dictionary() { {tb_grp_group.CN_UID, tb_prd_product.CN_GROUP_ID } }; lBlocks.Add(qjeB); sMsg = MakeSelectJoinByBlocks(lBlocks, out cRes); ArsenalInterface ai = ArsenalDBMgr.GetInst(cRes); QueryDataSet qds = ai.RunQueryDataSet(cRes); oResultData = new QueryResponse(qds); } while (false); } catch (Exception ex) { LogHelper.DBLog(Util.GetLastExceptionMsg(ex), i_nCodeLine, i_sMemberName, i_sSourcePath); sMsg = $"{nameof(readCommandPostDataHandler)} unknwon exception. i_crmInput={JsonConvert.SerializeObject(i_crmInput)}. Call from {i_sMemberName} {i_sSourcePath}({i_nCodeLine})."; #if DEBUG System.Diagnostics.Debug.WriteLine(sMsg); #endif } o_c = oResultData; return sMsg; } } }