/// <summary> /// Selects all demand quotes by wechat user id. /// </summary> /// <param name="conn"></param> /// <param name="demandId"></param> /// <returns></returns> public List<Demand> SelectRecievedQuotes(SqlConnection conn, int wechatUserId, int pageSize, int pageIndex, out int totalCount) { var quotes = new List<DemandQuote>(); var demands = new List<Demand>(); totalCount = 0; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter(Parameter_WeChatUserId, wechatUserId), new SqlParameter("@PageIndex", pageIndex), new SqlParameter("@PageSize", pageSize) }; var dts = DBHelper.GetMuiltiDataFromDB(conn, "sp_SelectRecievedQuotes", parameters); totalCount = Int32.Parse(dts["0"].Rows[0][0].ToString()); demands = DBHelper.DataTableToList<Demand>(dts["1"]); quotes = DBHelper.DataTableToList<DemandQuote>(dts["2"]); if (quotes.HasItem() && demands.HasItem()) { foreach (var quote in quotes) { var demand = demands.FirstOrDefault(x => x.Id == quote.DemandId); if (demand.IsNotNull()) { demand.QuoteEntities.Add(quote); } } } return demands; }
/// <summary> /// Creates the dynamic assembly. /// </summary> /// <param name="provider">The provider.</param> /// <param name="referencedAssemblies">The referenced assemblies.</param> /// <param name="namespace">The namespace.</param> /// <param name="usingNameSpaces">The using nameSpaces.</param> /// <param name="classCodesToCompile">The class codes to compile.</param> /// <returns>Assembly.</returns> /// <exception cref="OperationFailureException">CompileAssemblyFromSource;null</exception> public SandboxAssembly CreateDynamicAssembly(CodeDomProvider provider, List<string> referencedAssemblies, string @namespace, IEnumerable<string> usingNameSpaces, string classCodesToCompile) { try { provider.CheckNullObject("provider"); classCodesToCompile.CheckEmptyString("classCodesToCompile"); @namespace = @namespace.SafeToString("Beyova.DynamicCompile.Sandbox"); var objCompilerParameters = new CompilerParameters { GenerateExecutable = false, GenerateInMemory = true }; // Prepare references. var references = GetCommonAssemblyNameList(); if (referencedAssemblies.HasItem()) { references.AddRange(referencedAssemblies); } objCompilerParameters.ReferencedAssemblies.AddRange(references.ToArray()); // Prepare references done. // Prepare namespace var nameSpaces = GetCommonNamespaces(); if (usingNameSpaces.HasItem()) { nameSpaces.AddRange(usingNameSpaces); } // Prepare namespace done; StringBuilder builder = new StringBuilder(512); foreach (var one in nameSpaces) { builder.AppendLineWithFormat("using {0};", one); } builder.AppendLineWithFormat("namespace {0}", @namespace); //Namespace start builder.AppendLine("{"); builder.AppendLine(classCodesToCompile); //End of namespace builder.Append("}"); var compilerResult = provider.CompileAssemblyFromSource(objCompilerParameters, classCodesToCompile); if (compilerResult.Errors.HasErrors) { List<dynamic> errors = new List<dynamic>(); foreach (CompilerError one in compilerResult.Errors) { errors.Add(new { one.ErrorText, one.ErrorNumber, one.Line }); } throw new OperationFailureException("CompileAssemblyFromSource", null, errors); } return new SandboxAssembly(compilerResult.CompiledAssembly, @namespace); } catch (Exception ex) { throw ex.Handle("CreateDynamicAssembly"); } }
/// <summary> /// Selects quotes without histories for one specified demand. /// </summary> /// <param name="demandId"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <returns></returns> //public List<DemandQuote> GetAllDemandQuotesForOneDemand(int demandId, int pageSize, int pageIndex, out int totalCount) //{ // var quotes = new List<DemandQuote>(); // var conn = DBHelper.GetSqlConnection(); // totalCount = 0; // try // { // conn.Open(); // quotes = quoteDao.SelectDemandQuotesByDemandId(conn, demandId, pageSize, pageIndex, out totalCount); // if (quotes.HasItem()) // { // foreach (var quote in quotes) // { // var history = GetDemandQuote(quote.QuoteId, true); // } // } // } // catch (Exception ex) // { // LogService.Log("Failed to select quotes without histories for one demand.", ex.ToString()); // } // finally // { // conn.Close(); // } // return quotes; //} /// <summary> /// Selects quotes without histories for one specified demand. /// </summary> /// <param name="demandId"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <returns></returns> public List<DemandQuote> GetAllDemandQuotesForOneDemand(int demandId) { var quotes = new List<DemandQuote>(); var conn = DBHelper.GetSqlConnection(); try { conn.Open(); quotes = quoteDao.SelectDemandQuotesByDemandId(conn, demandId); if (quotes.HasItem()) { foreach (var quote in quotes) { var history = GetDemandQuote(quote.QuoteId, true); } } } catch (Exception ex) { LogService.Log("Failed to select quotes without histories for one demand.", ex.ToString()); } finally { conn.Close(); } return quotes; }