public async Task <ResponseModel <List <PageChannelListEntity> > > PageChannelList() { var account = base.GetAccount(); if (null == account) { return(new ResponseModel <List <PageChannelListEntity> >(Enum.ResponseCode.NonLogin, "未登录或者登录超时", null)); } List <PageChannelListEntity> list = new List <PageChannelListEntity>(); string sql = @$ "select d.id, d.ParentId,d.ChannelName,d.IconName,d.ChannelLink,d.EventName from HJSF_SysUser a left join HJSF_SysUserRoleMapping b on a.Id=b.UserId left join HJSF_SysRoleChannelMapping c on b.RoleId=c.RoleId left join HJSF_SysChannel d on c.ChannelId=d.id where a.Id={account.UserId} and ChannelType=0"; string msg = ""; List <HjsfSysChannel> query = await _defaultService.QuerySqlAsync <HjsfSysChannel>(sql); try { var lists = GetPageChannelListLoop(query, 0); list.AddRange(lists); list = list.Where((x, i) => list.FindIndex(z => z.Title == x.Title) == i).ToList(); } catch (Exception ex) { return(new ResponseModel <List <PageChannelListEntity> >(Enum.ResponseCode.Error, ex.Message, null)); } return(new ResponseModel <List <PageChannelListEntity> >(Enum.ResponseCode.Success, "Success", list)); }
public async Task <IEnumerable <EventoDto> > ObterPorDreUeTurmaMes(string dre_id, string ue_id, string turma_id, int modalidadeCalendario, DateTime mesAno) { var dataInicio = new DateTime(mesAno.Year, mesAno.Month, 1); var dataFim = dataInicio.AddMonths(1).AddMilliseconds(-1); var queryDre = string.IsNullOrWhiteSpace(dre_id) ? "" : "and (dre_id isnull or dre_id = @dre_id)"; var queryUe = string.IsNullOrWhiteSpace(ue_id) ? "" : "and (ue_id isnull or ue_id = @ue_id)"; var queryTurmna = string.IsNullOrWhiteSpace(turma_id) ? "" : "and (turma_id isnull or turma_id = @turma_id)"; var sql = @$ " Select distinct evento_id, nome, descricao, data_inicio, data_fim, dre_id, ue_id, tipo_evento, turma_id, ano_letivo, modalidade, ultima_alteracao_sgp, componente_curricular, tipo_calendario_id from evento where (data_inicio between @dataInicio and @dataFim or data_fim between @dataInicio and @dataFim) and modalidade = @modalidadeCalendario {queryDre} {queryUe} {queryTurmna} "; using var conn = CriaConexao(); await conn.OpenAsync(); var eventos = await conn.QueryAsync <EventoDto>(sql, new { dataInicio, dataFim, dre_id, ue_id, turma_id, modalidadeCalendario }); await conn.CloseAsync(); return(eventos); }
private static void WorkerProcess(object state) { while (true) { Job job = GetAvailableJob( IsProcessing = false and IsOver = flase); if (job == null) { arWait.WaitOne(10 * 1000); // wait ten seconds. // to increase performance // increase wait time continue; } try{ // //depending upon job type do something... } catch (Exception ex) { job.LastError = ex.ToString(); // important step // this will update your error in JobTable // for later investigation job.UpdateDB(); } } }
public async Task <int> SetAsPayed(string order_no, string transaction_id, PayMethodEnum method) { var pay_time = DateTime.UtcNow; var sql = @$ " update {table} set Status=@payed_status, PayTime=@pay_time, ExternalPaymentNo=@transaction_id, PayMethod=@pay_method where OrderNo=@order_no and Status=@where_status "; var p = new { payed_status = (int)OrderStatusEnum.待设计, where_status = (int)OrderStatusEnum.待付款, pay_method = (int)method, order_no = order_no, pay_time = pay_time, transaction_id = transaction_id, }; using (var con = this._dbFactory.GetMetroAdDatabase()) { var count = await con.ExecuteAsync(sql, p); return(count); } }
public async Task <TradingEngineSnapshot> Get(string correlationId) { var sql = @$ "select top(1) TradingDay, CorrelationId, Orders as OrdersJson, Positions as PositionsJson, AccountStats as AccountsJson, BestFxPrices as BestFxPricesJson, BestPrices as BestTradingPricesJson, Timestamp from {TableName} where correlationId = @id and status = '{nameof(SnapshotStatus.Final)}'
public static string FrequenciaPorAlunoTurmaBimestre(int?bimestre) { var query = @$ "select {CamposFrequencia} from frequencia_aluno fa where fa.codigo_aluno = @codigoAluno and fa.turma_id = @codigoTurma and fa.tipo = 1"; if (bimestre.HasValue) { query += " and fa.bimestre = @bimestre"; } return(query); }
public LineItem GetLineItemById(int purchaseOrderId, int id) { using var db = new SqlConnection(_connectionString); var query = @$ "select * from LineItem where LineItemId = @Id and PurchaseOrderId = @PurchaseOrderId"; var parameters = new { Id = id, PurchaseOrderId = purchaseOrderId }; var item = db.QueryFirstOrDefault <LineItem>(query, parameters); return(item); }
public async Task <List <SnacksDTO> > GetSnacks() { var listSnacks = new List <SnacksDTO>(); listSnacks.Add(new SnacksDTO { id_snacks = 1, name = "1", description = "01" }); listSnacks.Add(new SnacksDTO { id_snacks = 2, name = "2", description = "02" }); listSnacks.Add(new SnacksDTO { id_snacks = 3, name = "3", description = "03" }); listSnacks.Add(new SnacksDTO { id_snacks = 4, name = "4", description = "04" }); listSnacks.Add(new SnacksDTO { id_snacks = 5, name = "5", description = "05" }); //_settings.ConnectionString var ConnectionString = ""; using (var connection = new SqlConnection(ConnectionString)) { await connection.OpenAsync(); var selectSql = @$ " select cdt_id_create_account as " "idAccount" ", bank_account_digit as " "bankAccountDigit" ", bank_branch_digit as " "bankBranchDigit" ", bank_number as " "bankNumber" ", bank_account_number as " "bankAccountNumber" ", bank_branch_number as " "bankBranchNumber" ", is_alias_bank_accounts as " "IsAliasBankAccounts" " from account WHERE is_alias_bank_accounts = 1 and cdt_id_create_account = @cdt_id_create_account "; var ret = await connection.QueryAsync <SnacksDTO>(selectSql); // return ret; } return(listSnacks); }
public Task <GameKey> GetGameKey(int userId, int gameId) { return(gamestakDb.Use(async conn => { var Query = @$ " SELECT * FROM {DbTables.GameKeys} WHERE GameID = @GameId and UserID = @UserId "; var gameKey = (await conn.QueryAsync <GameKey>(Query, new { GameId = gameId, UserId = userId, })).FirstOrDefault(); return gameKey; })); }
public Task <User> Login(User user) { return(gamestakDb.Use(async conn => { var query = @$ " select * from {DbTables.Users} where Username = @User and Password = @Pass "; var response = await conn.QueryAsync <User>(query, new { User = user.Username, Pass = user.Password, }); return await PopulateUserFields(response.FirstOrDefault()); })); }
public async Task <List <PostagesTimeLine> > GetTimeLine(int userIdLogado) { using (var con = new SqlConnection(_configuration["ConnectionString"])) { var sqlCmd = @$ "select u0.nome, u0.foto as Perfil, p.Id, p.Texto, p.Foto, p.Criacao as dataPost from Convite co inner join Usuario u0 on (co.UsuarioIdRecebeu = u0.Id and AceitouConvite = 1) or (co.UsuarioIdConvidou = u0.Id and AceitouConvite = 1) inner join Usuario u1 on (co.UsuarioIdConvidou = u1.Id and AceitouConvite = 1) or (co.UsuarioIdRecebeu = u1.Id and AceitouConvite = 1) inner join Postagem p on p.UsuarioId = u0.Id where u1.Id = {userIdLogado} order by p.Criacao desc"; using (var cmd = new SqlCommand(sqlCmd, con)) { cmd.CommandType = CommandType.Text; con.Open(); var reader = await cmd .ExecuteReaderAsync() .ConfigureAwait(false); var postageTimeLine = new List <PostagesTimeLine>(); while (reader.Read()) { var postage = new PostagesTimeLine(reader["Nome"].ToString(), reader["Perfil"].ToString(), reader["Texto"].ToString(), reader["Foto"].ToString(), DateTime.Parse(reader["dataPost"].ToString()), int.Parse(reader["Id"].ToString())); postageTimeLine.Add(postage); } return(postageTimeLine); } } }
public void TestMethod15() { // testing and RegisterFile <Vector4> vRF = new RegisterFile <Vector4>(32); RegisterFile <Scalar> sRF = new RegisterFile <Scalar>(32); Memory m = new Memory(5000); Memory m_ic = new Memory(5000); IntersectionCore ic = new IntersectionCore(m_ic); sRF[1] = 10; sRF[2] = 9; and a = new and(0, 1, 2); a.Process(vRF, sRF, m, ic); Assert.AreEqual <int>(8, sRF[0].i); }
given name will exist (and can be retrieved) prior to the operation
internal AIMLTagHandler GetTagHandlerU(User user, SubQuery query, Request request, Result result, XmlNode node, bool liText) { AIMLTagHandler tagHandlerU = getBespokeTags(user, query, request, result, node); string nodeNameLower = StaticAIMLUtils.ToLower(node.LocalName); AltBot targetBot = query.TargetBot; if (Equals(null, tagHandlerU)) { switch (nodeNameLower) { case "template": case "answer": //CML tagHandlerU = new template(targetBot, user, query, request, result, node); break; case "aiml": case "cml": //CML tagHandlerU = new aiml(targetBot, user, query, request, result, node); break; case "aimlexec": case "eval": tagHandlerU = new aimlexec(targetBot, user, query, request, result, node); break; case "vars": case "root": case "predicates": //CML tagHandlerU = new root(targetBot, user, query, request, result, node, (() => query.TargetSettings)); break; case "properties": case "bots": tagHandlerU = new root(targetBot, user, query, request, result, node, (() => request.TargetBot.GlobalSettings)); break; case "substitutions": tagHandlerU = new root(targetBot, user, query, request, result, node, (() => request.TargetBot.InputSubstitutions)); break; case "topic": case "conversation": //CML tagHandlerU = new topic(targetBot, user, query, request, result, node); break; case "category": case "conv": //CML tagHandlerU = new category(targetBot, user, query, request, result, node); break; case "and": tagHandlerU = new and(targetBot, user, query, request, result, node); break; case "or": tagHandlerU = new or(targetBot, user, query, request, result, node); break; case "optional": tagHandlerU = new optional(targetBot, user, query, request, result, node); break; case "isa": tagHandlerU = new isa(targetBot, user, query, request, result, node); break; case "bot": tagHandlerU = new bot(targetBot, user, query, request, result, node); break; case "condition": case "options": //cml tagHandlerU = new condition_aima(targetBot, user, query, request, result, node); break; case "li": if (liText) { tagHandlerU = new liif(targetBot, user, query, request, result, node); } break; case "if": tagHandlerU = new liif(targetBot, user, query, request, result, node); break; case "personf": tagHandlerU = new format(targetBot, user, query, request, result, node, new Func <string, string>(HttpUtility.UrlEncode), null); break; case "date": tagHandlerU = new date(targetBot, user, query, request, result, node); break; case "formal": tagHandlerU = new formal(targetBot, user, query, request, result, node); break; case "gender": tagHandlerU = new gender(targetBot, user, query, request, result, node); break; case "get": tagHandlerU = new get(targetBot, user, query, request, result, node); break; case "gossip": tagHandlerU = new gossip(targetBot, user, query, request, result, node); break; case "get_ip": case "id": tagHandlerU = new id(targetBot, user, query, request, result, node); break; case "inputreq": tagHandlerU = new inputreq(targetBot, user, query, request, result, node); break; case "request": tagHandlerU = new input(targetBot, user, query, request, result, node, 1); break; case "input": tagHandlerU = new input(targetBot, user, query, request, result, node, 1); break; case "justthat": // <input index="2"/> tagHandlerU = new input(targetBot, user, query, request, result, node, 2); break; case "beforethat": // <input index="3"/> tagHandlerU = new input(targetBot, user, query, request, result, node, 3); break; #if !(__MonoCS__) case "javascript": tagHandlerU = new javascript(targetBot, user, query, request, result, node); break; #endif case "learn": case "load": case "noload": // the commented version of <load> tagHandlerU = new learn(targetBot, user, query, request, result, node); break; case "lowercase": tagHandlerU = new lowercase(targetBot, user, query, request, result, node); break; case "person": tagHandlerU = new substitute(targetBot, user, query, request, result, node); break; case "person2": tagHandlerU = new substitute(targetBot, user, query, request, result, node); break; case "random": tagHandlerU = new random(targetBot, user, query, request, result, node); break; case "sentence": tagHandlerU = new sentence(targetBot, user, query, request, result, node); break; case "set": tagHandlerU = new set(targetBot, user, query, request, result, node); break; case "size": case "getsize": tagHandlerU = new size(targetBot, user, query, request, result, node); break; case "sr": tagHandlerU = new sr(targetBot, user, query, request, result, node); break; case "srai_odd": tagHandlerU = new srai_odd(targetBot, user, query, request, result, node); break; case "star": tagHandlerU = new star(targetBot, user, query, request, result, node); break; case "system": tagHandlerU = new system(targetBot, user, query, request, result, node); break; case "that": //default <that index="1,1"/> tagHandlerU = new that(targetBot, user, query, request, result, node, 1); break; case "justbeforethat": //treated as <that index="2,1"/> tagHandlerU = new that(targetBot, user, query, request, result, node, 2); break; case "response": //treated as <that index="1,1"/> tagHandlerU = new that(targetBot, user, query, request, result, node, 2); break; case "thatstar": tagHandlerU = new thatstar(targetBot, user, query, request, result, node); break; case "think": tagHandlerU = new think(targetBot, user, query, request, result, node); break; case "topicstar": tagHandlerU = new topicstar(targetBot, user, query, request, result, node); break; case "uppercase": tagHandlerU = new uppercase(targetBot, user, query, request, result, node); break; case "version": case "getversion": tagHandlerU = new version(targetBot, user, query, request, result, node); break; case "cycsystem": tagHandlerU = new cycsystem(targetBot, user, query, request, result, node); break; case "cycretract": tagHandlerU = new cycretract(targetBot, user, query, request, result, node); break; case "cycassert": tagHandlerU = new cycassert(targetBot, user, query, request, result, node); break; case "cycterm": tagHandlerU = new cycterm(targetBot, user, query, request, result, node); break; case "cycquery": tagHandlerU = new cycquery(targetBot, user, query, request, result, node); break; case "cyccondition": tagHandlerU = new cyccondition(targetBot, user, query, request, result, node); break; case "cycphrase": tagHandlerU = new cycphrase(targetBot, user, query, request, result, node); break; case "cycparaphrase": tagHandlerU = new cycphrase(targetBot, user, query, request, result, node); break; case "guard": tagHandlerU = new guard(targetBot, user, query, request, result, node); break; case "guardstar": tagHandlerU = new guardstar(targetBot, user, query, request, result, node); break; case "cycrandom": tagHandlerU = new cycrandom(targetBot, user, query, request, result, node); break; case "tscore": tagHandlerU = new tscore(targetBot, user, query, request, result, node); break; case "space": tagHandlerU = new space(targetBot, user, query, request, result, node); break; case "markov": tagHandlerU = new markov(targetBot, user, query, request, result, node); break; case "soundcode": tagHandlerU = new soundcode(targetBot, user, query, request, result, node); break; // MSM case "msm": tagHandlerU = new msm(targetBot, user, query, request, result, node); break; case "processmsm": tagHandlerU = new process_msm(targetBot, user, query, request, result, node); break; case "setstate": tagHandlerU = new setstate(targetBot, user, query, request, result, node); break; case "state": tagHandlerU = new state(targetBot, user, query, request, result, node); break; case "transition": tagHandlerU = new transition(targetBot, user, query, request, result, node); break; case "setevidence": tagHandlerU = new setevidence(targetBot, user, query, request, result, node); break; case "evidenceassoc": tagHandlerU = new evidence_assoc(targetBot, user, query, request, result, node); break; case "evidencepattern": tagHandlerU = new evidence_pattern(targetBot, user, query, request, result, node); break; case "evidencestate": tagHandlerU = new evidencestate(targetBot, user, query, request, result, node); break; case "dependentmachine": tagHandlerU = new dependentmachine(targetBot, user, query, request, result, node); break; case "responsetopic": tagHandlerU = new response_topic(targetBot, user, query, request, result, node); break; case "push": tagHandlerU = new push(targetBot, user, query, request, result, node); break; case "pop": tagHandlerU = new pop(targetBot, user, query, request, result, node); break; case "peekstack": tagHandlerU = new peekstack(targetBot, user, query, request, result, node); break; case "lex": tagHandlerU = new lex(targetBot, user, query, request, result, node); break; case "lexset": tagHandlerU = new lexset(targetBot, user, query, request, result, node); break; case "lexis": tagHandlerU = new lexis(targetBot, user, query, request, result, node); break; case "dbpush": tagHandlerU = new dbpush(targetBot, user, query, request, result, node); break; case "dbquery": tagHandlerU = new dbquery(targetBot, user, query, request, result, node); break; case "dbupdate": tagHandlerU = new dbupdate(targetBot, user, query, request, result, node); break; case "dbdelete": tagHandlerU = new dbdelete(targetBot, user, query, request, result, node); break; case "dbload": tagHandlerU = new dbload(targetBot, user, query, request, result, node); break; case "regex": tagHandlerU = new regex(targetBot, user, query, request, result, node); break; case "bind": // <bind>#$isa</bind> tagHandlerU = new bind(targetBot, user, query, request, result, node); break; case "#text": if (!liText) { return(null); } return(new verbatum(node.Value, targetBot, user, query, request, result, node)); case "#comment": return(new verbatum(node.OuterXml, targetBot, user, query, request, result, node)); case "br": return(new verbatum("\n", targetBot, user, query, request, result, node)); case "pre": return(new verbatum(StaticXMLUtils.InnerXmlText(node), targetBot, user, query, request, result, node)); case "p": return(new verbatum("\n\n", targetBot, user, query, request, result, node)); case "meta": return(new verbatum(node.OuterXml, targetBot, user, query, request, result, node)); default: break; } } if (tagHandlerU != null) { return(tagHandlerU); } if (StaticAIMLUtils.IsHtmlTag(node.Name)) { return(new recursiveVerbatum(node, targetBot, user, query, request, result, node, true)); } if (tagHandlerU == null) { // "bot", "favorite", "fav" foreach (KeyValuePair <string, string> prefix in new[] { new KeyValuePair <string, string>("get_", "get"), new KeyValuePair <string, string>("set_", "set"), new KeyValuePair <string, string>("bot_", "bot"), new KeyValuePair <string, string>("favorite_", "bot"), new KeyValuePair <string, string>("favorite", "bot"), new KeyValuePair <string, string>("fav_", "bot"), new KeyValuePair <string, string>("fav", "bot"), new KeyValuePair <string, string>("get", "get"), new KeyValuePair <string, string>("set", "set"), new KeyValuePair <string, string>("bot", "bot"), }) { if (nodeNameLower.StartsWith(prefix.Key) && node.Name.Length > prefix.Key.Length) { string name = node.Name.Substring(prefix.Key.Length); XmlNode pn = node.ParentNode; LineInfoElementImpl newnode = StaticXMLUtils.CopyNode(prefix.Value, node, false); XmlAttributeLineInfo atr = (XmlAttributeLineInfo)newnode.OwnerDocument.CreateAttribute("name"); atr.ReadOnly = false; atr.Value = name; newnode.Attributes.Append(atr); if (node.Name.ToLower() != newnode.Name.ToLower()) { writeToLog("AIMLLOADER: converted " + node.OuterXml + " -> " + newnode.OuterXml); return(targetBot.GetTagHandler(newnode, query, request, result, user, liText)); } writeToLog("AIMLLOADER: ! convert " + node.OuterXml + " -> " + newnode.OuterXml); } } } if (tagHandlerU != null) { return(tagHandlerU); } if (nodeNameLower == "name") { return(new bot(targetBot, user, query, request, result, node)); } tagHandlerU = new lazyClosure(targetBot, user, query, request, result, node); writeToLog("AIMLLOADER: lazyClosure: " + node.OuterXml); return(tagHandlerU); }
public void TestMethod33() { // ToString test and and = new and(1, 2, 3); Assert.AreEqual("and r1 r2 r3", and.ToString()); bne bne = new bne(1); Assert.AreEqual("bne 1", bne.ToString()); bg bg = new bg(1); Assert.AreEqual("bg 1", bg.ToString()); bl bl = new bl(1); Assert.AreEqual("bl 1", bl.ToString()); bge_rt bge_rt = new bge_rt(1); Assert.AreEqual("bge_rt 1", bge_rt.ToString()); ble_rt ble_rt = new ble_rt(1); Assert.AreEqual("ble_rt 1", ble_rt.ToString()); cmp_i cmpi = new cmp_i(1, 2); Assert.AreEqual("cmp_i r1 r2", cmpi.ToString()); cmp_f cmpf = new cmp_f(1, 2); Assert.AreEqual("cmp_f r1 r2", cmpf.ToString()); cmp_v cmpv = new cmp_v(1, 2); Assert.AreEqual("cmp_v r1 r2", cmpv.ToString()); ff_add ff_add = new ff_add(1, 2, 3); Assert.AreEqual("ff_add r1 r2 r3", ff_add.ToString()); ff_sub ff_sub = new ff_sub(1, 2, 3); Assert.AreEqual("ff_sub r1 r2 r3", ff_sub.ToString()); ff_mul ff_mul = new ff_mul(1, 2, 3); Assert.AreEqual("ff_mul r1 r2 r3", ff_mul.ToString()); ff_div ff_div = new ff_div(1, 2, 3); Assert.AreEqual("ff_div r1 r2 r3", ff_div.ToString()); fin fin = new fin(); Assert.AreEqual("fin", fin.ToString()); ftoi ftoi = new ftoi(1, 2); Assert.AreEqual("ftoi r1 r2", ftoi.ToString()); ii_add ii_add = new ii_add(1, 2, 3); Assert.AreEqual("ii_add r1 r2 r3", ii_add.ToString()); ii_addi ii_addi = new ii_addi(1, 2, 3); Assert.AreEqual("ii_addi r1 r2 3", ii_addi.ToString()); ii_sub ii_sub = new ii_sub(1, 2, 3); Assert.AreEqual("ii_sub r1 r2 r3", ii_sub.ToString()); ii_subi ii_subi = new ii_subi(1, 2, 3); Assert.AreEqual("ii_subi r1 r2 3", ii_subi.ToString()); ii_mul ii_mul = new ii_mul(1, 2, 3); Assert.AreEqual("ii_mul r1 r2 r3", ii_mul.ToString()); ii_muli ii_muli = new ii_muli(1, 2, 3); Assert.AreEqual("ii_muli r1 r2 3", ii_muli.ToString()); ii_div ii_div = new ii_div(1, 2, 3); Assert.AreEqual("ii_div r1 r2 r3", ii_div.ToString()); ii_divi ii_divi = new ii_divi(1, 2, 3); Assert.AreEqual("ii_divi r1 r2 3", ii_divi.ToString()); itof itof = new itof(1, 2); Assert.AreEqual("itof r1 r2", itof.ToString()); real_jmp real_jmp = new real_jmp(1); Assert.AreEqual("real_jmp 1", real_jmp.ToString()); jmp_link jmp_link = new jmp_link(1); Assert.AreEqual("jmp_link 1", jmp_link.ToString()); not not = new not(1, 2); Assert.AreEqual("not r1 r2", not.ToString()); or or = new or(1, 2, 3); Assert.AreEqual("or r1 r2 r3", or.ToString()); ret ret = new ret(); Assert.AreEqual("ret", ret.ToString()); s_get_from_v sgfv = new s_get_from_v(1, 2, 3); Assert.AreEqual("s_get_from_v r1 r2 3", sgfv.ToString()); s_load_4byte sl4b = new s_load_4byte(1, 2, 3); Assert.AreEqual("s_load_4byte r1 r2 3", sl4b.ToString()); s_store_4byte ss4b = new s_store_4byte(1, 2, 3); Assert.AreEqual("s_store_4byte r1 r2 3", ss4b.ToString()); s_write_high swh = new s_write_high(1, 5); Assert.AreEqual("s_write_high r1 5", swh.ToString()); s_write_low swl = new s_write_low(1, 5); Assert.AreEqual("s_write_low r1 5", swl.ToString()); s_push s_push = new s_push(1); Assert.AreEqual("s_push r1", s_push.ToString()); s_pop s_pop = new s_pop(1); Assert.AreEqual("s_pop r1", s_pop.ToString()); v_push v_push = new v_push(1); Assert.AreEqual("v_push r1", v_push.ToString()); v_pop v_pop = new v_pop(1); Assert.AreEqual("v_pop r1", v_pop.ToString()); v_get_from_s vgfs = new v_get_from_s(1, 2, 3); Assert.AreEqual("v_get_from_s r1 r2 3", vgfs.ToString()); v_load_16byte vl16 = new v_load_16byte(1, 2, 3); Assert.AreEqual("v_load_16byte r1 r2 3", vl16.ToString()); v_magn v_magn = new v_magn(1, 2); Assert.AreEqual("v_magn r1 r2", v_magn.ToString()); v_store_16byte vs16 = new v_store_16byte(1, 2, 3); Assert.AreEqual("v_store_16byte r1 r2 3", vs16.ToString()); vf_add vf_add = new vf_add(1, 2, 3); Assert.AreEqual("vf_add r1 r2 r3", vf_add.ToString()); vf_sub vf_sub = new vf_sub(1, 2, 3); Assert.AreEqual("vf_sub r1 r2 r3", vf_sub.ToString()); vf_mul vf_mul = new vf_mul(1, 2, 3); Assert.AreEqual("vf_mul r1 r2 r3", vf_mul.ToString()); vf_div vf_div = new vf_div(1, 2, 3); Assert.AreEqual("vf_div r1 r2 r3", vf_div.ToString()); vi_add vi_add = new vi_add(1, 2, 3); Assert.AreEqual("vi_add r1 r2 r3", vi_add.ToString()); vi_sub vi_sub = new vi_sub(1, 2, 3); Assert.AreEqual("vi_sub r1 r2 r3", vi_sub.ToString()); vi_mul vi_mul = new vi_mul(1, 2, 3); Assert.AreEqual("vi_mul r1 r2 r3", vi_mul.ToString()); vi_div vi_div = new vi_div(1, 2, 3); Assert.AreEqual("vi_div r1 r2 r3", vi_div.ToString()); vv_add vv_add = new vv_add(1, 2, 3); Assert.AreEqual("vv_add r1 r2 r3", vv_add.ToString()); vv_sub vv_sub = new vv_sub(1, 2, 3); Assert.AreEqual("vv_sub r1 r2 r3", vv_sub.ToString()); vv_mul_ele vv_mul_ele = new vv_mul_ele(1, 2, 3); Assert.AreEqual("vv_mul_ele r1 r2 r3", vv_mul_ele.ToString()); vv_mul_dot vv_mul_dot = new vv_mul_dot(1, 2, 3); Assert.AreEqual("vv_mul_dot r1 r2 r3", vv_mul_dot.ToString()); vv_div vv_div = new vv_div(1, 2, 3); Assert.AreEqual("vv_div r1 r2 r3", vv_div.ToString()); xor xor = new xor(1, 2, 3); Assert.AreEqual("xor r1 r2 r3", xor.ToString()); }
private async Task <Stream> GetNaturalGasBillsInternalAsync(SqlParams @params) { var bills = await _dbConnection.QueryAsync <Bill>(@$ "select company.name as CompanyFullName, company.short_name as CompanyShortName, company.www as CompanySite, company.email as CompanyEmail, company.taxpayer_phone as CompanyPhone, company.state_registry_code as CompanyStateRegistryCode, company.address as CompanyAddress, branch_offices.iban as BranchOfficeIban, branch_offices.bank_full_name as BranchOfficeBankFullName, ap.name as AccountingPointName, concat(address.cityName, ' ', address.streetName, ' ', address.building, ' ', address.apt) as AccountingPointAddress, concat(people.last_name, ' ', people.first_name, ' ', people.patronymic) as OwnerFullName, periods.name as PeriodShortDate, apdh.debt_value::decimal as AccountingPointDebtHistory, payments.sumAmount::decimal as PaymentSumByPeriod, inv.total_units::decimal as InvoiceTotalUnits, inv.total_amount_due::decimal as InvoiceTotalAmountDue, (jsonb_array_elements(inv.usage_t1 -> 'Calculations') -> 'PriceValue')::decimal as TariffRate, ap.debt::decimal as AccountingPointDebt from invoices inv join accounting_points ap on ap.id = inv.accounting_point_id join branch_offices on ap.branch_office_id = branch_offices.id join company on branch_offices.company_id = company.id join periods on branch_offices.current_period_id = periods.id join ( select addresses.id, cities.name as cityName, streets.name as streetName, building, apt from addresses join streets on addresses.street_id = streets.id join cities on streets.city_id = cities.id ) as address on ap.address_id = address.id join people on ap.owner_id = people.id left join accounting_point_debt_history as apdh on ap.id = apdh.accounting_point_id and apdh.period_id=inv.period_id left join LATERAL ( select p.accounting_point_id, sum(p.amount) as sumAmount from payments as p where period_id = inv.period_id and status = 1 and p.accounting_point_id=inv.accounting_point_id group by p.accounting_point_id ) payments on true where ap.branch_office_id = 101 and inv.period_id = case when @periodId is null then inv.period_id else @periodId end and inv.id = case when @id is null then inv.id else @id end", @params); var dict = new Dictionary <string, IList> { { "bill_gas", bills.ToList() } }; var ms = ReportBuilderXLS.GenerateReport(dict, "Templates/bill_gas.xlsx"); //if (@params.PeriodId.HasValue) //{ var counter = 1; using var naturalGasBills = new XLWorkbook(ms); // using var mergedBills = new XLWorkbook(); // mergedBills.AddWorksheet(); // var electricitySpace = 01; foreach (var bill in bills) { //var naturalGasBill = naturalGasBills.Worksheet(1).Range((counter - 1) * 17 + 1, 1, counter * 17, 15); //mergedBills.Worksheet(1).Cell((counter - 1) * 17 + 1, 1).Value = naturalGasBill; //mergedBills.Worksheet(1).LastRowUsed().InsertRowsBelow(1); //var baseUri = _recsBillLocations.Single(l => l.Prefix == bill.AccountingPointName.Substring(0, 2)).BaseUri; //var response = await _httpClient.GetAsync($"{baseUri}rp.name='{HttpUtility.UrlEncode(bill.AccountingPointName)}'?lastOnly=False"); //using var electricityBill = new XLWorkbook(await response.Content.ReadAsStreamAsync()); //var electricity = electricityBill.Range("Bill"); //var spaceIncriment = 24; //if (electricity.LastRow().RowNumber() < 2) //{ // electricity = electricityBill.Range("Billzone"); // spaceIncriment = 31; //} //if (electricity.LastRow().RowNumber() > 10) // naturalGasBills.Worksheet(1).Cell((counter * 19) + electricitySpace, 1).Value = electricity; //else // spaceIncriment = 0; //electricitySpace += spaceIncriment; //naturalGasBills.Worksheet(1).PageSetup.AddHorizontalPageBreak(naturalGasBills.Worksheet(1).LastRowUsed().RowNumber()); var ws = naturalGasBills.Worksheet(1); ws.AddPicture(@"Templates/n_gas.png") .MoveTo(ws.Cell($"A{(counter - 1) * 19 + 7}")) .Scale(0.66); // optional: resize picture if (counter != 0 && counter % 4 == 0) { ws.PageSetup.AddHorizontalPageBreak(counter * 19); } counter++; } // var s = new MemoryStream(); // mergedBills.SaveAs(s); // s.Position = 0; // return s; //} naturalGasBills.SaveAs(ms); ms.Position = 0; return(ms); }
public Task <int> SaveGameKeys(int userId, List <int> gameIds) { return(gamestakDb.Use(async conn => { var query = @$ " IF NOT EXISTS (SELECT GameID FROM {DbTables.GameKeys} WHERE UserID = @UserId and GameID = @GameId) BEGIN INSERT INTO {DbTables.GameKeys} (GameID, UserID) VALUES (@GameId, @UserId) END "; var parameters = gameIds.Select(gameId => new { GameId = gameId, UserId = userId, }).ToArray(); var rowsAffected = await conn.ExecuteAsync(query, parameters); if (rowsAffected < 0) { throw new ArgumentException("GameKey already exists or ids are invalid"); } return rowsAffected; })); }
/// <summary> /// 获取当前 正在排队的 队列数据集合 /// </summary> /// <param name="aId"></param> /// <param name="storeId"></param> /// <returns></returns> public List <SortQueue> GetListByQueueing(int aId, int storeId = 0) { string model_key = string.Format(Redis_SortQueues_queueing, aId, storeId); string version_key = string.Format(Redis_SortQueues_version, aId, storeId); RedisModel <SortQueue> redisModel_SortQueues = RedisUtil.Get <RedisModel <SortQueue> >(model_key); int version = RedisUtil.GetVersion(version_key); if (redisModel_SortQueues == null || redisModel_SortQueues.DataList == null || redisModel_SortQueues.DataList.Count > 0 || redisModel_SortQueues.DataVersion != version) { redisModel_SortQueues = new RedisModel <SortQueue>(); List <SortQueue> sortQueues = base.GetList($" aId={aId} {(storeId <= 0 ? "" : $" and storeId = {storeId} ")} and State = 0 "); string userIds = string.Join(",", sortQueues?.Select(s => s.userId).Distinct()); List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds); sortQueues?.ForEach(s => { s.nickName = userInfoList?.FirstOrDefault(f => f.Id == s.userId)?.NickName; }); redisModel_SortQueues.DataList = sortQueues; redisModel_SortQueues.DataVersion = version; redisModel_SortQueues.Count = sortQueues.Count; RedisUtil.Set <RedisModel <SortQueue> >(model_key, redisModel_SortQueues, TimeSpan.FromHours(12)); }
public void Load() { var select = "Select * from BolsaFamilia.Dados;"; using (var connection = new SqlConnection(ConnectionString)) { var command = new SqlCommand(select, connection); connection.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var data = Convert.ToDateTime(reader["DATA_REFERENCIA"]); var insert = @$ " DECLARE @ID_CIDADE INT, @ID_TEMPO INT; Select @ID_CIDADE = ID_CIDADE from BolsaFamiliaDW.DM_Cidade where NOM_CIDADE = '{reader[" NOME_IBGE "]}'; Select @ID_TEMPO = ID_TEMPO from BolsaFamiliaDW.DM_Tempo where NUM_MES = {data.Month} and NUM_ANO = {data.Year}; Insert into BolsaFamiliaDW.FT_Registros (ID_CIDADE, ID_TEMPO, VLR_GASTO, QTD_BENEFICIADOS) VALUES(@ID_CIDADE, @ID_TEMPO, {reader[" VALOR "]}, {reader[" QTD_BENEFICIADOS "]});
public DbCommand GetSaveScopeInfoCommand(bool exist, DbConnection connection, DbTransaction transaction) { var stmtText = new StringBuilder(); stmtText.AppendLine(exist ? $"Update {ScopeInfoTableName.Unquoted().ToString()} set sync_scope_schema=@sync_scope_schema, sync_scope_setup=@sync_scope_setup, sync_scope_version=@sync_scope_version, scope_last_sync=@scope_last_sync, scope_last_server_sync_timestamp=@scope_last_server_sync_timestamp, scope_last_sync_timestamp=@scope_last_sync_timestamp, scope_last_sync_duration=@scope_last_sync_duration where sync_scope_id=@sync_scope_id and sync_scope_name=@sync_scope_name;" : $"Insert into {ScopeInfoTableName.Unquoted().ToString()} (sync_scope_name, sync_scope_schema, sync_scope_setup, sync_scope_version, scope_last_sync, scope_last_sync_duration, scope_last_server_sync_timestamp, scope_last_sync_timestamp, sync_scope_id) values (@sync_scope_name, @sync_scope_schema, @sync_scope_setup, @sync_scope_version, @scope_last_sync, @scope_last_sync_duration, @scope_last_server_sync_timestamp, @scope_last_sync_timestamp, @sync_scope_id);"); stmtText.AppendLine(@$ "SELECT sync_scope_id , sync_scope_name , sync_scope_schema , sync_scope_setup , sync_scope_version , scope_last_sync , scope_last_server_sync_timestamp , scope_last_sync_timestamp , scope_last_sync_duration FROM {ScopeInfoTableName.Unquoted().ToString()} WHERE sync_scope_name=@sync_scope_name and sync_scope_id=@sync_scope_id"); var command = new SqliteCommand(stmtText.ToString(), (SqliteConnection)connection, (SqliteTransaction)transaction); var p = command.CreateParameter(); p.ParameterName = "@sync_scope_name"; p.DbType = DbType.String; p.Size = 100; command.Parameters.Add(p); p = command.CreateParameter(); p.ParameterName = "@sync_scope_schema"; p.DbType = DbType.String; p.Size = -1; command.Parameters.Add(p); p = command.CreateParameter(); p.ParameterName = "@sync_scope_setup"; p.DbType = DbType.String; p.Size = -1; command.Parameters.Add(p); p = command.CreateParameter(); p.ParameterName = "@sync_scope_version"; p.DbType = DbType.String; p.Size = 10; command.Parameters.Add(p); p = command.CreateParameter(); p.ParameterName = "@scope_last_sync"; p.DbType = DbType.DateTime; command.Parameters.Add(p); p = command.CreateParameter(); p.ParameterName = "@scope_last_server_sync_timestamp"; p.DbType = DbType.Int64; command.Parameters.Add(p); p = command.CreateParameter(); p.ParameterName = "@scope_last_sync_timestamp"; p.DbType = DbType.Int64; command.Parameters.Add(p); p = command.CreateParameter(); p.ParameterName = "@scope_last_sync_duration"; p.DbType = DbType.Int64; command.Parameters.Add(p); p = command.CreateParameter(); p.ParameterName = "@sync_scope_id"; p.DbType = DbType.String; p.Size = -1; command.Parameters.Add(p); return(command); }