Exemplo n.º 1
0
        public void Inline_WithCommands()
        {
            QueryCommand cmd = new InlineQuery().GetCommand("SELECT productID from products WHERE productid=@productid", 1);

            Assert.IsTrue(cmd.Parameters[0].ParameterName == "@productid");
            Assert.IsTrue((int)cmd.Parameters[0].ParameterValue == 1);
        }
Exemplo n.º 2
0
        public void Inline_WithCommands()
        {
            QueryCommand cmd = new InlineQuery().GetCommand("SELECT productID from products WHERE productid=@productid", 1);

            Assert.IsTrue(cmd.Parameters[0].ParameterName == "@productid");
            Assert.IsTrue((int)cmd.Parameters[0].ParameterValue == 1);
        }
Exemplo n.º 3
0
        protected override async void OnInlineQuery(InlineQuery query)
        {
            var from = query.From;

            Logger.Info($"Received inline query from: {from.Id,-10} {from.FirstName}");

            if (!Data.Users.Contains(from))
            {
                Data.AddOrUpdate(from, UserRole.Guest);
            }

            var words = query.Query.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var inlineQueryResults = Ctb.Exchanges.Values
                                     .Select(x => x.ToInlineQueryResult(words))
                                     .ToList( );

            try
            {
                await Client
                .AnswerInlineQueryAsync(
                    query.Id,
                    inlineQueryResults,
                    0,
                    cancellationToken : CancellationToken
                    ).ConfigureAwait(false);
            }
            catch (Exception exception)
            {
                Logger.Error(exception);
            }
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        protected override async Task OnInlineQueryAsync(ITurnContext turnContext, InlineQuery inlineQuery,
                                                         CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrWhiteSpace(inlineQuery.Query))
            {
                return;
            }

            var statePropertyAccessor = _userState.CreateProperty <DuckUserState>(nameof(DuckUserState));
            var user = await statePropertyAccessor.GetAsync(turnContext, () => new DuckUserState(), cancellationToken);

            var duckResponse = await _imagesService.GetAsync(inlineQuery.Query, user, cancellationToken);

            var answer = CreateAnswerInlineQuery(inlineQuery, duckResponse);

            var reply = turnContext.CreateBotReply(answer);

            user.Vqd   = duckResponse.Vqd;
            user.Next  = duckResponse.Next;
            user.Query = inlineQuery.Query;

            await turnContext.SendActivityAsync(reply, cancellationToken);

            await _userState.SaveChangesAsync(turnContext, false, cancellationToken);
        }
Exemplo n.º 5
0
        public KilledByInlineCommand(InlineQuery q)
        {
            User u = q.From;

            Command = "killedby";
            try
            {
                using (var db = new WWContext())
                {
                    Content = "";
                    //find the player
                    Player p;
                    p = db.Players.FirstOrDefault(x => x.TelegramId == u.Id);
                    if (p == null)
                    {
                        //remove the command
                        Command = "";
                        return;
                    }
                    Description = $"Get the players who killed {p.Name} the most";

                    var killed = db.PlayerMostKilledBy(p.TelegramId).AsEnumerable().Take(5);
                    Content += $"\nPlayers who killed <a href='tg://user?id={p.TelegramId}'>{p.Name.FormatHTML()}</a> most:\n";
                    foreach (var a in killed)
                    {
                        Content += $"{a.times?.Pad()} {a.Name.ToBold()}\n";
                    }
                }
            }
            catch (Exception e)
            {
                Content = "Unable to load kills: " + e.Message;
            }
        }
        public async Task <bool?> Handle(InlineQuery data, object context = default, CancellationToken cancellationToken = default)
        {
            var queryParts = new StringSegment(data.Query).Split(new[] { ' ' }).FirstOrDefault().Split(new[] { ':' });

            if (!PollEx.TryGetPollId(queryParts.ElementAtOrDefault(1), out var pollId, out var format))
            {
                return(null);
            }

            var poll = (await myRaidService.GetOrCreatePollAndMessage(new PollMessage(data)
            {
                BotId = myBot.BotId, PollId = pollId
            }, myUrlHelper,
                                                                      format, cancellationToken))?.Poll;

            if (poll == null)
            {
                return(null);
            }

            var result = await GetResult(poll, cancellationToken);

            result ??= new InlineQueryResultArticle("NobodyToInvite", "Nobody to invite",
                                                    new TextBuilder().Sanitize($"Nobody to invite").ToTextMessageContent())
            {
                ThumbUrl = myUrlHelper.AssetsContent(@"static_assets/png/btn_close_normal.png").ToString()
            };

            await myBot.AnswerInlineQueryWithValidationAsync(data.Id, new[] { result }, cacheTime : 0, isPersonal : true, cancellationToken : cancellationToken);

            return(true);
        }
Exemplo n.º 7
0
        /// <inheritdoc />
        public override async Task HandleAsync(InlineQuery query)
        {
            _log.Information("Handling a new inline query: {query}", query.Query);

            if (string.IsNullOrWhiteSpace(query.Query))
            {
                return;
            }

            var me = await Bot.GetMeAsync();

            // log user query
            _storage.AddUserQuery(new UserQuery(query.From, query.Query));

            var filtered = _storage.Find(query.Query, null, 10)
                           .Where(p => p.RetailPrice > 0m)
                           .ToArray();

            if (filtered.Length == 0)
            {
                await Bot.AnswerInlineQueryAsync(query.Id, Enumerable.Empty <InlineQueryResultBase>());
            }
            else
            {
                var rate   = filtered.FirstOrDefault()?.CurrencyRate ?? 1.0m;
                var result = filtered
                             .Select((p, i) => p.ToInlineResult(i, query.Query, rate, me.Username));
                await Bot.AnswerInlineQueryAsync(query.Id, result);
            }
        }
Exemplo n.º 8
0
 private static void OnInlineQuery(InlineQuery inlinequery)
 {
     Bot.AnswerInlineQuery(new AnswerInlineQuery
     {
         InlineQueryId = inlinequery.Id,
         Results       = new List <InlineQueryResult>
         {
             new InlineQueryResultArticle
             {
                 Id                    = inlinequery.Query,
                 Title                 = DateTime.Now.ToLongDateString(),
                 MessageText           = Guid.NewGuid().ToString(),
                 ParseMode             = "",
                 Url                   = "",
                 DisableWebPagePreview = false,
                 Description           = "",
                 HideUrl               = false,
                 ThumbHeight           = 0,
                 ThumbWidth            = 0,
                 ThumbUrl              = ""
             }
         },
         IsPersonal = false,
         CacheTime  = 300,
         NextOffset = "0"
     });
 }
Exemplo n.º 9
0
        private void btnRestore_Click(object sender, EventArgs e)
        {
            string      queryString = "use [master]\r\n select * from sysprocesses where dbid=DB_ID('dd')\r\n ";
            InlineQuery query       = DB.Query();
            IDataReader SidList     = query.ExecuteReader(queryString);

            while (SidList.Read())
            {
                try
                {
                    queryString = "kill " + SidList["spid"].ToString();
                    query.Execute(queryString);
                }
                catch
                {
                }
            }

            try
            {
                queryString = "use [master]\r\n  RESTORE DATABASE DD FROM disk='" + this.tbxRestoreFile.Text + "'";
                query.Execute(queryString);
                MessageBox.Show("恢复成功", "提示信息");
            }
            catch
            {
                MessageBox.Show("恢复失败", "提示信息");
            }
        }
Exemplo n.º 10
0
 private void TryRaiseNewInlineQueryEvent(InlineQuery sender)
 {
     if (sender == null)
     {
         return;
     }
     TelegramInlineQueryEvent?.Invoke(sender);
 }
        public async Task SaveLogAsync(long botId, InlineQuery inlineQuery)
        {
            var tableName = "bot" + botId + "year" + DateTimeOffset.UtcNow.Year;
            var table     = await GetTable(tableName);

            var entity = ChatMessage.Create(inlineQuery);
            await table.ExecuteAsync(TableOperation.InsertOrReplace(entity));
        }
Exemplo n.º 12
0
        public void HandleInlineQuery(InlineQuery inlineQuery)
        {
            _userId = inlineQuery.From.Id;
            var list           = _checkListService.GetQueriedLists(_userId, inlineQuery.Query);
            var responseMarkup = BuildInlineQueryResponse(list);

            _bot.AnswerInlineQueryAsync(inlineQuery.Id, responseMarkup, switchPmText: "Create new checklist", switchPmParameter: "_", cacheTime: 0);
        }
        private async Task InnerHandler(InlineQuery query, CancellationToken ct)
        {
            var stickers = await mediator.Send(new FindMatchingStickersQuery(query.Query), ct);

            var results = stickers.Select((s, i) => new InlineQueryResultCachedSticker(i.ToString(), s.FileId));

            await botClient.AnswerInlineQueryAsync(query.Id, results, cancellationToken : ct);
        }
Exemplo n.º 14
0
        public static void reflectInlineCommands(InlineQuery inlineQuery)
        {
            Type[] typelist = Assembly.GetExecutingAssembly().GetTypes();
            foreach (Type type in typelist)
            {
                if (type.GetCustomAttribute(typeof(ControllerAttribute)) != null)
                {
                    MethodInfo[] attrs = type.GetMethods();

                    foreach (MethodInfo m in attrs)
                    {
                        InlineCommandAttribute tx = (InlineCommandAttribute)Attribute.GetCustomAttribute(m, typeof(InlineCommandAttribute));
                        MatchCollection        mc = null;

                        if (tx != null)
                        {
                            Regex reg = new Regex(tx.path);
                            mc = reg.Matches(inlineQuery.Query.Trim().ToLower());
                            Console.WriteLine("{0} {1}", tx.path, inlineQuery.Query.Trim().ToLower());
                        }

                        foreach (CustomAttributeData cd in m.CustomAttributes)
                        {
                            if (cd.AttributeType == typeof(InlineCommandAttribute) &&
                                mc != null)
                            {
                                if (mc.Count == 0)
                                {
                                    continue;
                                }

                                try
                                {
                                    Console.WriteLine("TEST");
                                    List <object> obj = new List <object>();
                                    obj.Add(getBotInstance());
                                    obj.Add(inlineQuery);
                                    foreach (Match item in mc)
                                    {
                                        for (int i = 1; i < item.Groups.Count; i++)
                                        {
                                            obj.Add(item.Groups[i].Value);
                                        }
                                    }

                                    m.Invoke(Activator.CreateInstance(type), obj.ToArray());
                                }
                                catch (TargetInvocationException e)
                                {
                                    Console.WriteLine(((CommandException)e.InnerException).code);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 15
0
 private static object GetInlineQueryTransformation(InlineQuery inlineQuery)
 {
     return(new
     {
         inlineQuery.Id,
         inlineQuery.From,
         inlineQuery.Query
     });
 }
Exemplo n.º 16
0
        private void BotClient_OnInlineQuery(object sender, InlineQueryEventArgs e)
        {
            InlineQuery inlineQuery = e ? .InlineQuery;

            if (!(inlineQuery is null))
            {
                string req = inlineQuery.Query;
            }
        }
Exemplo n.º 17
0
        public void InlineMenu(InlineQuery query, IBot Parent)
        {
            if (Parent.Modules.Exists(fn => fn.Name == "_2chModule") && query.Query.Contains("2ch"))
            {
                Webm webm = Parent.GetModule <_2chModule>().WebmsSent.Find(fn => fn.Path == query.Query);
                if (webm != null)
                {
                    var msg = new Telegram.Bot.Types.InlineQueryResults.InputTextMessageContent($"<a href=\"{ webm.Thumbnail }\">&#8204;</a>{webm.Path}")
                    {
                        ParseMode = Telegram.Bot.Types.Enums.ParseMode.Html
                    };

                    Telegram.Bot.Types.InlineQueryResults.InlineQueryResultArticle[] results =
                    {
                        new Telegram.Bot.Types.InlineQueryResults.InlineQueryResultArticle("0", "WEBM", msg)
                        {
                            ReplyMarkup = LikeDislikeModule.getKeyBoard(),
                            Description = "POST"
                        }
                    };
                    Parent.Client.AnswerInlineQueryAsync(query.Id, results);
                }
            }
            else if (query.Query.Contains("opros"))
            {
                string id = query.Query.Split('-').Last();
                try
                {
                    var Oprs = Parent.GetModule <VoteModule>().Opros.Find(fn => fn.Id == int.Parse(id));
                    if (Oprs != null)
                    {
                        var msg = new Telegram.Bot.Types.InlineQueryResults.InputTextMessageContent($"{Oprs.About}")
                        {
                            ParseMode = Telegram.Bot.Types.Enums.ParseMode.Html
                        };

                        Pes7BotCrator.Modules.Types.VoteModule.Likes ll = null;
                        try
                        {
                            ll = Parent.GetModule <VoteModule>().LLikes.Find(fn => fn.ParentO.Id == int.Parse(id));
                        }
                        catch { }
                        Telegram.Bot.Types.InlineQueryResults.InlineQueryResultArticle[] results =
                        {
                            new Telegram.Bot.Types.InlineQueryResults.InlineQueryResultArticle("0", "Opros",            msg)
                            {
                                ReplyMarkup = VoteModule.getKeyBoard(ll.LikeId.Count,               ll.DisLikeId.Count, Oprs,Oprs.Query),
                                Description = "POST"
                            }
                        };
                        Parent.Client.AnswerInlineQueryAsync(query.Id, results);
                    }
                }
                catch {}
            }
        }
Exemplo n.º 18
0
        public TypesOfDeathInlineCommand(InlineQuery q)
        {
            User u = q.From;

            Command = "deaths";
            try
            {
                using (var db = new WWContext())
                {
                    Content = "";
                    //find the player
                    Player p;
                    if (String.IsNullOrWhiteSpace(q.Query))
                    {
                        p = db.Players.FirstOrDefault(x => x.TelegramId == u.Id);
                        if (p == null)
                        {
                            //remove the command
                            Command = "";
                            return;
                        }
                    }
                    else
                    {
                        p = db.Players.FirstOrDefault(x => x.UserName.Equals(q.Query.Substring(1).Trim(), StringComparison.CurrentCultureIgnoreCase));
                        if (p == null)
                        {
                            Description = $"Erro encontrando jogador com username {q.Query} para mostrar seus {Command}";
                            Content     = $"Erro encontrando jogador com username {q.Query} para mostrar seus {Command}";
                            return;
                        }
                        Command += $" ({p.Name})";
                    }
                    Description = $"Obtem os tipos de morte que {p.Name} mais teve";

                    var deaths = (from gk in db.GameKills
                                  join pla in db.Players on gk.VictimId equals pla.Id
                                  where pla.TelegramId == p.TelegramId
                                  where gk.KillMethodId != 0
                                  group gk by gk.KillMethodId);
                    var totalDeaths = deaths.Sum(x => x.Count());
                    var deathInfo   = deaths.OrderByDescending(x => x.Count()).Take(5);

                    Content += $"\nTipos de mortes que <a href=\"https://telegram.me/{p.UserName}\">{p.Name.FormatHTML()}</a> mais teve:\n";
                    foreach (var a in deathInfo)
                    {
                        var killMethod = Enum.GetName(typeof(KillMthd), a.Key);
                        Content += $"<code>{a.Count().ToString().PadLeft(4)} ({((double)(a.Count()/(double)totalDeaths)*100.0).ToString("#0.0").PadLeft(4)}%)</code> {killMethod.ToBold()}\n";
                    }
                }
            }
            catch (Exception e)
            {
                Content = "Unable to load kill methods: " + e.Message;
            }
        }
Exemplo n.º 19
0
        public TypesOfDeathInlineCommand(InlineQuery q)
        {
            User u = q.From;

            Command = "deaths";
            try
            {
                using (var db = new WWContext())
                {
                    Content = "";
                    //find the player
                    Player p;

                    p = db.Players.FirstOrDefault(x => x.TelegramId == u.Id);
                    if (p == null)
                    {
                        //remove the command
                        Command = "";
                        return;
                    }

                    Description = $"Get the types of death that {p.Name} most had";

                    var deaths = (from gk in db.GameKills
                                  join pla in db.Players on gk.VictimId equals pla.Id
                                  where pla.TelegramId == p.TelegramId
                                  where gk.KillMethodId != 0
                                  group gk by new { kid = gk.KillMethodId, gid = gk.GameId, day = gk.Day });
                    var temp = (from i in deaths
                                group i by i.Key.kid);
                    var totalDeaths = temp.Sum(x => x.Count());
                    // var totalDeaths = deaths.Sum(x => x.Count());
                    // var deathInfo = deaths.OrderByDescending(x => x.Count()).Take(5);
                    var deathInfo = temp.OrderByDescending(x => x.Count()).Take(5);

                    if (p.UserName != null)
                    {
                        Content += $"\nTypes of deaths that <a href=\"https://telegram.me/{p.UserName}\">{p.Name.FormatHTML()}</a> most had:\n";
                    }
                    else
                    {
                        Content += $"\nTypes of deaths that {p.Name.FormatHTML()} most had:\n";
                    }
                    foreach (var a in deathInfo)
                    {
                        var killMethod = Enum.GetName(typeof(KillMthd), a.Key);
                        Content += $"<code>{a.Count().ToString().PadLeft(4)} ({((double)(a.Count() / (double)totalDeaths) * 100.0).ToString("#0.0").PadLeft(4)}%)</code> {killMethod.ToBold()}\n";
                    }
                }
            }
            catch (Exception e)
            {
                Content = "Unable to load kill methods: " + e.Message;
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Get's a list of all contraints in the database that are not primary key contraints
        /// </summary>
        /// <param name="Provider"></param>
        /// <returns></returns>
        public override IEnumerable<IConstraint> GetConstraintsFromDB(IDataProvider Provider)
        {
            var Inline = new InlineQuery(Provider, GET_DB_CONSTRAINTS);

            constraints = Inline.ExecuteTypedList<DatabaseContraint>()
                .Select((X) =>
                    (IConstraint)X)
                .ToList();

            return constraints;
        }
Exemplo n.º 21
0
        public override IEnumerable<IColumnDefinition> GetColumnDefinitionsFromDB(IDataProvider Provider)
        {
            var Inline = new InlineQuery(Provider, GET_DB_COLUMN_DEFINITIONS);

            columnDefinitions = Inline.ExecuteTypedList<DBColumnDefinition>()
                .Select((X) =>
                    (IColumnDefinition)X)
                .ToList();

            return columnDefinitions;
        }
Exemplo n.º 22
0
        public DateTime GetSysDateTime()
        {
            var dataTable = new DataTable();
            var dt        = new DateTime();

            dt = DateTime.Now;
            //dataTable = SPs.GetSYSDateTime().GetDataSet().Tables[0];
            var dateTime = new InlineQuery().ExecuteScalar <DateTime>("select getdate()");

            return(dateTime);
        }
Exemplo n.º 23
0
        internal async void ShowHelp(Result result)
        {
            InlineQuery   message = result.data as InlineQuery;
            StringBuilder usage   = new StringBuilder("인라인 명령어 사용법은 다음과 같습니다.\n");

            foreach (var command in Commands)
            {
                usage.AppendLine(string.Format("{0} - ({1})\n", command.Value.Name.ToString(), command.Value.Description));
            }
            await Bot.SendTextMessageAsync(message.Id, usage.ToString(),
                                           replyMarkup : new ReplyKeyboardHide());
        }
Exemplo n.º 24
0
        public List <InlineQueryResultArticle> GetCards(InlineQuery query)
        {
            bool ruLang = false;

            List <InlineQueryResultArticle> results = new List <InlineQueryResultArticle>();
            var k = 0;

            foreach (var set in CardData.Instance.Sets)
            {
                List <Card> cards = new List <Card>();
                if (Regex.IsMatch(query.Query, @"\p{IsCyrillic}"))
                {
                    ruLang = true;
                    cards  = set.cards.Where(c => c.ruName.ToLower().Contains(query.Query.ToLower())).ToList();
                }
                else
                {
                    ruLang = false;
                    cards  = set.cards.Where(c => c.name.ToLower().Contains(query.Query.ToLower())).ToList();
                }

                if (cards.Count > 0)
                {
                    foreach (var card in cards)
                    {
                        var muId     = ruLang ? card.ruMultiverseId : card.multiverseId;
                        var cardName = ruLang ? card.ruName : card.name;

                        results.Add(new InlineQueryResultArticle((++k).ToString(), card.name, new InputTextMessageContent("/c " + card.name + "(" + set.code + ")"))
                        {
                            HideUrl     = true,
                            ThumbWidth  = 99,
                            ThumbHeight = 138,
                            ThumbUrl    = "https://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=" + muId + "&type=card",
                            Title       = cardName + " (" + set.name + ")",
                            Description = card.type + " \r\n" + card.manaCost
                        });

                        if (results.Count > 49)
                        {
                            break;
                        }
                    }
                }
                if (results.Count > 49)
                {
                    break;
                }
            }

            return(results);
        }
Exemplo n.º 25
0
        private static async Task OnInlineQuery(InlineQuery query)
        {
            var game = GetGame(query.From);

            if (game == null)
            {
                await Telegram.AnswerInline(query);
            }
            else
            {
                await game.OnInline(query);
            }
        }
Exemplo n.º 26
0
        private async Task ProcessInline(InlineQuery query)
        {
            Console.WriteLine($"Got query: {query.Query}");
            List <InlineQueryResultArticle> returnResults = new List <InlineQueryResultArticle>();

            try
            {
                var MediaApiQuery = await MediaWikiApi.GetStringAsync(string.Format(queryFormat, query.Query));

                var result = JsonConvert.DeserializeObject <JsonResultFormat.Root>(MediaApiQuery);

                if (result.Query?.Search?.Any() == true)

                {
                    Dictionary <string, JsonResultFormat.Page> URLresult = null;

                    try
                    {
                        var MediaApiQueryUrls = await MediaWikiApi.GetStringAsync(string.Format(urlsQueryFormat, string.Join('|', result.Query.Search.Select(c => c.Pageid).ToArray())));

                        URLresult = JsonConvert.DeserializeObject <JsonResultFormat.UrlRoot>(MediaApiQueryUrls).Query.Pages;
                    }
                    catch (Exception) // Fallback to titles
                    {
                        var MediaApiQueryUrls = await MediaWikiApi.GetStringAsync(string.Format(urlsQueryFormatFallbackTitle, string.Join('|', result.Query.Search.Select(c => c.Title).ToArray())));

                        URLresult = JsonConvert.DeserializeObject <JsonResultFormat.UrlRoot>(MediaApiQueryUrls).Query.Pages;

                        foreach (var item in result.Query.Search)
                        {
                            item.Pageid = URLresult.FirstOrDefault(c => c.Value.Title == item.Title).Value.Pageid;
                        }
                    }
                    returnResults = result
                                    .Query
                                    .Search
                                    .Join(URLresult, c => c.Pageid, c => c.Value.Pageid, (c, d) => new { c, d })
                                    .Take(10) // limit
                                    .Select(c =>
                                            new InlineQueryResultArticle(c.c.Pageid.ToString(), c.c.Title, new InputTextMessageContent(c.d.Value.Canonicalurl.ToString()))
                    {
                        Description = StripHTML(System.Net.WebUtility.HtmlDecode(c.c.Snippet))
                    }).ToList();
                }
                await client.AnswerInlineQueryAsync(query.Id, returnResults);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 27
0
 private void btnBackup_Click(object sender, EventArgs e)
 {
     try
     {
         string      queryString = "Backup database DD to disk='" + this.tbxBackupFile.Text + "'";
         InlineQuery query       = DB.Query();
         query.Execute(queryString);
         MessageBox.Show("备份成功", "提示信息");
     }
     catch
     {
         MessageBox.Show("备份失败", "提示信息");
     }
 }
Exemplo n.º 28
0
        /// <inheritdoc />
        public override async Task HandleAsync(InlineQuery query)
        {
            _log.Information("Handling a new inline query: {query}", query.Query);

            if (string.IsNullOrWhiteSpace(query.Query))
            {
                return;
            }

            var me = await Bot.GetMeAsync();


            await Bot.AnswerInlineQueryAsync(query.Id, Enumerable.Empty <InlineQueryResultBase>());
        }
        public static ChatMessage Create(InlineQuery inlineQuery)
        {
            var key = GetKey(0, DateTimeOffset.Now);

            return(new ChatMessage()
            {
                PartitionKey = key.PartitionKey,
                RowKey = key.RowKey,

                InlineQuery = inlineQuery,
                ChatId = 0,
                FromId = inlineQuery.From.Id,
            });
        }
Exemplo n.º 30
0
        public RolesInlineCommand(InlineQuery q)
        {
            User u = q.From;

            Command = "roles";
            try
            {
                using (var db = new WWContext())
                {
                    Content = "";
                    //find the player
                    Player p;
                    if (String.IsNullOrWhiteSpace(q.Query))
                    {
                        p = db.Players.FirstOrDefault(x => x.TelegramId == u.Id);
                        if (p == null)
                        {
                            //remove the command
                            Command = "";
                            return;
                        }
                    }
                    else
                    {
                        p = db.Players.FirstOrDefault(x => x.UserName.Equals(q.Query.Substring(1).Trim(), StringComparison.CurrentCultureIgnoreCase));
                        if (p == null)
                        {
                            Description = $"Erro encontrando jogador com username {q.Query} para mostrar seus {Command}";
                            Content     = $"Erro encontrando jogador com username {q.Query} para mostrar seus {Command}";
                            return;
                        }
                        Command += $" ({p.Name})";
                    }
                    Description = $"Obtem os papéis que {p.Name} mais jogou";

                    var totalRoles = db.PlayerRoles(p.TelegramId).Sum(x => x.times);
                    var roleInfo   = db.PlayerRoles(p.TelegramId).ToList().OrderByDescending(x => x.times).Take(5);
                    Content += $"\nPapéis que <a href=\"https://telegram.me/{p.UserName}\">{p.Name.FormatHTML()}</a> mais jogou:\n";
                    foreach (var a in roleInfo)
                    {
                        var role = Commands.GetLocaleString(a.role, p.Language);
                        Content += $"<code>{a.times.ToString().PadLeft(3)} ({(((double)a.times/(double)totalRoles)*100.0).ToString("#0.0").PadLeft(4)}%)</code> {role.ToBold()}\n";
                    }
                }
            }
            catch (Exception e)
            {
                Content = "Unable to load roles: " + e.Message;
            }
        }
        async Task <bool?> IHandler <InlineQuery, object, bool?> .Handle(InlineQuery data, object context, CancellationToken cancellationToken)
        {
            var queryParts = new StringSegment(data.Query).Split(new[] { ':' });

            if (queryParts.First() != ID)
            {
                return(null);
            }

            var inlineQueryResults = Enumerable.Empty <InlineQueryResult>();

            if (!PollEx.TryGetPollId(queryParts.ElementAtOrDefault(1), out var pollId, out var format))
            {
                inlineQueryResults = await GetActivePolls(data.From, cancellationToken);
            }
Exemplo n.º 32
0
        public KilledByInlineCommand(InlineQuery q)
        {
            User u = q.From;

            Command = "killedby";
            try
            {
                using (var db = new WWContext())
                {
                    Content = "";
                    //find the player
                    Player p;
                    if (String.IsNullOrWhiteSpace(q.Query))
                    {
                        p = db.Players.FirstOrDefault(x => x.TelegramId == u.Id);
                        if (p == null)
                        {
                            //remove the command
                            Command = "";
                            return;
                        }
                    }
                    else
                    {
                        p = db.Players.FirstOrDefault(x => x.UserName.Equals(q.Query.Substring(1).Trim(), StringComparison.CurrentCultureIgnoreCase));
                        if (p == null)
                        {
                            Description = $"Erro encontrando jogador com username {q.Query} para mostrar seus {Command}";
                            Content     = $"Erro encontrando jogador com username {q.Query} para mostrar seus {Command}";
                            return;
                        }
                        Command += $" ({p.Name})";
                    }
                    Description = $"Obtem os jogadores que mais mataram {p.Name}";

                    var killed = db.PlayerMostKilledBy(p.TelegramId).AsEnumerable();
                    Content += $"\nJogadores que mais mataram <a href=\"https://telegram.me/{p.UserName}\">{p.Name.FormatHTML()}</a>:\n";
                    foreach (var a in killed)
                    {
                        Content += $"{a.times?.Pad()} {a.Name.ToBold()}\n";
                    }
                }
            }
            catch (Exception e)
            {
                Content = "Unable to load kills: " + e.Message;
            }
        }
Exemplo n.º 33
0
        //label should be "SEND" to get user's contacts
        public async Task HandleShowContactsInlineQueryCommand(InlineQuery query, string labelId = null, string userContact = null)
        {
            var nmModel = await _dbWorker.FindNmStoreAsync(query.From);

            if (nmModel == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(userContact))
            {
                var userInfo = new UserInfo {
                    Email = userContact
                };
                await _botActions.ShowContactsAnswerInlineQuery(query.Id, new List <UserInfo> {
                    userInfo
                });

                return;
            }
            int offset;

            Int32.TryParse(query.Offset, out offset);
            if (offset == -1)
            {
                return;
            }
            var messagesInOneResponse = 10;
            var resultsPerPage        = offset + messagesInOneResponse;

            if (resultsPerPage > 500)
            {
                resultsPerPage = 500;
            }

            var formatedMessages = await GetMessages(query, offset, labelId, null, resultsPerPage, messagesInOneResponse);

            var uniqueContacts = Methods.GetUniqueContactsFromMessageList(formatedMessages);

            if (uniqueContacts.Count == messagesInOneResponse)
            {
                await _botActions.ShowContactsAnswerInlineQuery(query.Id, uniqueContacts, offset + messagesInOneResponse);
            }
            else
            {
                await _botActions.ShowContactsAnswerInlineQuery(query.Id, uniqueContacts); //last response
            }
        }
Exemplo n.º 34
0
        public CrptBusinessPrint()
        {
            ReportParameterTable.Columns.Add(colType, typeof (string));
            ReportParameterTable.Columns.Add(colName, typeof (string));
            ReportParameterTable.Columns.Add(colValue, typeof (object));
            ReportParameterTable.Rows.Add(vParameterType, "ShowSubReport", 0);
            ReportParameterTable.Rows.Add(vParameterType, "ShowMainReport", 1);
            ReportParameterTable.Rows.Add(vParameterType, "ParentBranchName", globalVariables.ParentBranch_Name);
            ReportParameterTable.Rows.Add(vParameterType, "Address", globalVariables.Branch_Email);
            ReportParameterTable.Rows.Add(vParameterType, "BranchName", globalVariables.Branch_Name);
            ReportParameterTable.Rows.Add(vParameterType, "sPhone", globalVariables.Branch_Phone);
            ReportParameterTable.Rows.Add(vParameterType, "sHotPhone", globalVariables.Branch_Phone);
            ReportParameterTable.Rows.Add(vParameterType, "sCurrentDate", DateTime.Now.ToString("dd/MM/yyyy"));
            ReportParameterTable.Rows.Add(vParameterType, "PrintDate", printDateTime);
            ReportParameterTable.Rows.Add(vParameterType, "sTenBacSyChiDinh","");
            ReportParameterTable.Rows.Add(vParameterType, "sBacSyChiDinh", "");
            ReportParameterTable.Rows.Add(vParameterType, "sTenUser", "");
            //SqlQuery query = new Select(TblUser.Columns.SFullName).From(TblUser.Schema.Name + " WITH (NOLOCK) ").Where(TblUser.Columns.PkSuid).
            //    IsEqualTo(globalVariables.UserName);
            //SqlQuery query = new Select(TblUser.Columns.SFullName).From(TblUser.Schema.Name).Where(TblUser.Columns.PkSuid).
            //    IsEqualTo(globalVariables.UserName);
            //object userName = query.ExecuteScalar();

            string sql = string.Format("SELECT Sys_Users.sFullName \n"
               + "FROM   Sys_Users  WITH (NOLOCK)  \n"
               + "WHERE  Sys_Users.PK_sUID = '{0}'", globalVariables.UserName);

               var userName = new InlineQuery().ExecuteScalar<string>(sql);

            ReportParameterTable.Rows.Add(vParameterType, "Nguoidung", userName == null ? "" : userName.ToString());
            ReportParameterTable.Rows.Add(vParameterType, "DMY",
                                          string.Format("Ngày {0} tháng {1} năm {2}", DateTime.Now.Day,
                                                        DateTime.Now.Month, DateTime.Now.Year));
            ReportParameterTable.Rows.Add(vFormulaFieldsType, "Formula_1", Strings.Chr(34) +
                                                                           "        NGƯỜI LẬP BÁO CÁO                                                           NGƯỜI XÁC NHẬN                "
                                                                               .Replace("#$X$#",
                                                                                        Strings.Chr(34) + "&Chr(13)&" +
                                                                                        Strings.Chr(34)) +
                                                                           Strings.Chr(34));
            FormPreviewTitle = "VietBaIT JSC.,";
            StrCode = "";
        }
Exemplo n.º 35
0
        /// <summary>
        /// hàm thực hiện việc xử lý thông tin in phiếu
        /// </summary>
        /// <param name="DT"></param>
        private void ProcessData(ref DataTable DT)
        {
            try
            {
                foreach (DataRow drv in DT.Rows)
                {
                    if (Utility.sDbnull(drv["PID"], "-1") == "-1") drv["PID"] = Utility.sDbnull(drv["Barcode"], "");
                }
                DT.AcceptChanges();

                Utility.AddColumToDataTable(ref DT, "BarcodeImg", typeof (byte[]));
                Utility.AddColumToDataTable(ref DT, "sTitleReport", typeof (string));
                Utility.AddColumToDataTable(ref DT, "sSex", typeof (string));
                Utility.AddColumToDataTable(ref DT, "Nguoidung", typeof (string));
                Utility.AddColumToDataTable(ref DT, "logo", typeof (byte[]));
                string path = "";
                if (System.IO.File.Exists(@"logo\logo.bmp")) path = @"logo\logo.bmp";
                if (System.IO.File.Exists(@"logo\logo.jpg")) path = @"logo\logo.jpg";
                if (System.IO.File.Exists(@"logo\logo.png")) path = @"logo\logo.png";
                byte[] logoBytes = new byte[] {};
                if (path != "") logoBytes = Utility.bytGetImage(path);
                var arrayList = new ArrayList();
                string sTitleReport = "";
                foreach (DataRow dr in DT.Rows)
                {
                    dr["BarcodeImg"] =
                        Utility.GenerateBarCode(
                            BarcodeInfo.CreateNewBarcode(Utility.sDbnull(dr["Barcode"], "0000000000")));
                    dr["logo"] = logoBytes;
                    dr["TESTTYPE_NAME"] = Utility.sDbnull(dr["TESTTYPE_NAME"], "").ToUpper();

                    if (dr["Sex"] == DBNull.Value)
                    {
                        dr["sSex"] = ""; 
                    }
                    else if (Utility.Int32Dbnull(dr["Sex"]) == 1)
                    {
                        //  dr["Normal_Level"] = dr["Normal_Level"];
                        dr["sSex"] = "Nam";
                    }
                    else
                    {
                        //dr["Normal_Level"] = dr["Normal_LevelW"];
                        dr["sSex"] = "Nữ";
                    }

                    arrayList.Add(dr[TResultDetail.Columns.TestDetailId].ToString());
                    string sql = string.Format("SELECT Sys_Users.sFullName \n"
        + "FROM   Sys_Users  WITH (NOLOCK)  \n"
        + "WHERE  Sys_Users.PK_sUID = '{0}'", globalVariables.UserName);

                    var userName = new InlineQuery().ExecuteScalar<string>(sql);

                    if (radGopChung.Checked)
                    {
                        //if (Utility.sDbnull(drv["PID"], "-1") == "-1") drv["PID"] = Utility.sDbnull(drv["Barcode"], "");
                        if (grdTestType.GetCheckedRows().Length == 1)
                        {
                            GridEXRow[] gridExRows = grdTestType.GetCheckedRows();
                            sTitleReport =
                                gridExRows[0].Cells[TTestTypeList.Columns.TestTypeName].Value.ToString().ToUpper();
                            sTitleReport = sTitleReport.Replace("XÉT NGHIỆM", "");
                            dr["sTitleReport"] = sTitleReport;
                            dr["Nguoidung"] = userName;
                        }
                    }
                    else
                    {
                        dr["PID"] = Utility.sDbnull(dr["PID"]) + Utility.sDbnull(dr[TTestInfo.Columns.TestTypeId], "-1");
                        sTitleReport = dr[TTestTypeList.Columns.TestTypeName].ToString().ToUpper();
                        sTitleReport = sTitleReport.Replace("XÉT NGHIỆM", "");
                        dr["sTitleReport"] = sTitleReport;
                        dr["Nguoidung"] = userName;
                    }
                }
                DT.AcceptChanges();

                new Update(TResultDetail.Schema)
                    .Set(TResultDetail.Columns.ParaStatus).EqualTo(1)
                    .Where(TResultDetail.Columns.TestDetailId).In(arrayList).Execute();
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Exemplo n.º 36
0
        public void Print(bool Quick,string printerName)
        {
            string path = "";// =SystemReports.GetPathReport(StrCode);
            try
            {
                if (Crpt == null && !string.IsNullOrEmpty(StrCode))
                {

                    ReportDocument crptDocument=new ReportDocument();
                    crptDocument.Load(path);
                    Crpt = crptDocument; //GetCrptFromAssembly(StrCode);
                   // Crpt = GetCrptFromAssembly(StrCode);
                }

                if (ValidData())
                {
                    bool hasSubReport = CheckHasSubReport(Crpt);
                    var oForm = new frmPrintPreview("Phiếu KQ Xét nghiệm", Crpt, true, ReportSourceTable.Rows.Count <= 0 ? false : true);
                    oForm.crptTrinhKyName = Path.GetFileName(path);
                    if (!hasSubReport)
                    {
                        Crpt.SetDataSource(ReportSourceTable);
                        SetReportParameter(Crpt);
                       // var oForm = new frmPrintPreview(FormPreviewTitle, Crpt, true, true);

                    if (SysPara.ParamaterReport != null)
                        {
                            if (SysPara.ParamaterReport == "THANHNHAN")
                            {
                                var patientId = Utility.Int32Dbnull(ReportSourceTable.Rows[0]["Patient_ID"]);
                                var dtAssignDoctor =
                                    new Select(TTestInfo.Columns.AssignId, LUser.Columns.UserName).From(TTestInfo.Schema.Name).InnerJoin
                                        (LUser.UserIdColumn, TTestInfo.AssignIdColumn).Where(TTestInfo.Columns.PatientId).IsEqualTo(patientId).And(TTestInfo.Columns.TestTypeId).In(testTypeList).ExecuteDataSet().Tables[0];

                                if (dtAssignDoctor.Rows.Count > 0)
                                {

                                    Crpt.SetParameterValue("sBacSyChiDinh", "BÁC SỸ CHỈ ĐỊNH");
                                    Crpt.SetParameterValue("sTenBacSyChiDinh", Utility.sDbnull(dtAssignDoctor.Rows[0]["User_Name"]));
                                }
                                //else
                                //{
                                //    Crpt.SetParameterValue("sBacSyChiDinh", "");
                                //    Crpt.SetParameterValue("sTenBacSyChiDinh", "");
                                //}

                                var sFullName =
                                    new Select(SysUser.Columns.SFullName).From(SysUser.Schema.Name).Where(SysUser.Columns.PkSuid)
                                        .IsEqualTo(globalVariables.UserName).ExecuteScalar();
                                if (!string.IsNullOrEmpty(Utility.sDbnull(sFullName)))
                                {
                                    Crpt.SetParameterValue("sTenUser", sFullName);
                                }
                                //else
                                //{
                                //    Crpt.SetParameterValue("sTenUser","");
                                //}
                            }
                        }

                        oForm.crptViewer.ReportSource = Crpt;
                        // FieldObject mv_oRptFieldObj = Crpt.ReportDefinition.ReportObjects["Field150181"] as FieldObject;
                        // Crpt.PrintToPrinter();
                        if (Quick)
                        {
                            //    mv_oNguoiKy = new VietBaIT.LABLink.Reports.Class.cls_SignInfor(mv_oRptFieldObj, "", Crpt.ToString(), Crpt.DataDefinition.FormulaFields["Formula_1"].Text);
                            //  mv_oNguoiKy = new cls_SignInfor(Crpt.ToString(), "", ReportSourceTable);
                            //  mv_oNguoiKy = newcls_SignInfor(string.IsNullOrEmpty(oForm.crptTrinhKyName) , Crpt.ToString(),oForm.crptTrinhKyName, "", "");
                            mv_oNguoiKy = new cls_SignInfor_new(string.IsNullOrEmpty(oForm.crptTrinhKyName) ? oForm.crptTrinhKyName : oForm.crptTrinhKyName, "");
                            //      mv_oNguoiKy = newcls_SignInfor(" ", "", Crpt, ReportSourceTable);
                            //chkPrint_CheckedChanged(chkPrint, New System.EventArgs)
                            if (mv_oNguoiKy._TonTai)
                            {
                                Crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) +
                                                                                      mv_oNguoiKy.mv_NOI_DUNG.Replace(
                                                                                          "&NHANVIEN",
                                                                                          globalVariables.UserName)
                                                                                          .Replace("\t",
                                                                                              Strings.Chr(34) +
                                                                                              "&Chr(13)&" +
                                                                                              Strings.Chr(34)) +
                                                                                      Strings.Chr(34);
                            }
                            else
                            {
                                Crpt.DataDefinition.FormulaFields["Formula_1"].Text = "";
                            }
                            Crpt.PrintOptions.PrinterName = printerName;
                            Crpt.PrintToPrinter(0, true, 0, 0);
                            Crpt.Dispose();
                            CleanTemporaryFolders();
                        }
                        else
                        {
                            oForm.ShowDialog();
                            oForm.Dispose();
                        }
                    }
                    else
                    {
                        //DataTable dt = new Select().From(TblTrinhky.Schema.Name).Where(TblTrinhky.Columns.ReportName).
                        //                            IsEqualTo(Crpt.GetClassName()).ExecuteDataSet().Tables[0];

                        string sql = string.Format("SELECT * \n"
                                                   + "FROM   Sys_Trinhky With (NOLOCK) \n"
                                                   + "WHERE  ReportName = N'{0}'", oForm.crptTrinhKyName);

                        var x = new InlineQuery().ExecuteAsCollection<SysTrinhkyCollection>(sql);

                        if (x.Count > 0)
                            Utility.GetDataRow(ReportParameterTable, colName, "Formula_1")[colValue] = Strings.Chr(34) +
                                                                                                       Utility.sDbnull(
                                                                                                           x[0]
                                                                                                               .ObjectContent) +
                                                                                                       Strings.Chr(34);

                        Crpt.SetDataSource(ReportSourceTable);
                        SetReportParameter(Crpt);
                        if (!ReportSourceTable.Columns.Contains("ParentBranchName"))
                            ReportSourceTable.Columns.Add("ParentBranchName");
                        if (!ReportSourceTable.Columns.Contains("BranchName"))
                            ReportSourceTable.Columns.Add("BranchName");

                        DataTable dtHematology = ReportSourceTable.Clone();
                        DataTable dtOther = ReportSourceTable.Clone();
                        DataTable dtImages = ReportSourceTable.Clone();
                           string sql2 = string.Format("SELECT Sys_Users.sFullName \n"
                                                    + "FROM   Sys_Users  WITH (NOLOCK)  \n"
                                                    + "WHERE  Sys_Users.PK_sUID = '{0}'", globalVariables.UserName);

                        var objuserName = new InlineQuery().ExecuteScalar<string>(sql2);

                        string sNguoiDung = objuserName == null ? "" : objuserName;
                        foreach (DataRow row in ReportSourceTable.Rows)
                        {
                            row["ParentBranchName"] = globalVariables.ParentBranch_Name;
                            row["BranchName"] = globalVariables.Branch_Name;
                            row["Nguoidung"] = sNguoiDung;

                            if (row["isHematology"].ToString() == "1")
                            {
                                if (row["Data_Sequence"].ToString().Contains("-"))
                                {
                                    string pvSImgPath = row["Test_Result"].ToString();
                                    if (File.Exists(pvSImgPath))
                                    {
                                        //row["BarcodeImg"] = Utility.bytGetImage(pvSImgPath);
                                        var bitmap = new Bitmap(pvSImgPath);
                                        Invert(ref bitmap);
                                        row["BarcodeImg"] = Utility.ConvertImageToByteArray(bitmap, ImageFormat.Tiff);
                                        dtImages.ImportRow(row);
                                    }
                                }
                                else dtHematology.ImportRow(row);
                            }
                            else dtOther.ImportRow(row);
                        }

                        // đẹt me lam rieng cho noi tiet to su bo no(.)

                        // cho cai kho A5
                        if (StrCode == "A5")
                        {

                            Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Hematology_Images.rpt"
                                ].SetDataSource(dtImages);
                            Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]
                                .SetDataSource(dtHematology);
                            Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]
                                .SetDataSource(dtOther);
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]);
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]);
                            //Crpt.SetParameterValue("PrintDate", printDateTime, Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"].Name);
                            //Crpt.SetParameterValue("PrintDate", printDateTime, Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"].Name);

                            SetReportParameter(Crpt);
                        }
                            // cho cai kho A4
                        else if (StrCode == "A4")
                        {
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]);
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]);

                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology_Images.rpt"
                                ].SetDataSource(dtImages);
                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]
                                .SetDataSource(dtHematology);
                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]
                                .SetDataSource(dtOther);
                            SetReportParameter(Crpt);
                            //  Crpt.SetParameterValue("Nguoidung", sNguoiDung);
                        }
                            //neu deo khai bao A4 hay A5 thi mac dinh lay cai nay nhung pai dung cai bao cao ko an cut no chay dc.
                        else if (StrCode == "LABREPORT")
                        {
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]);
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]);
                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology_Images.rpt"
                                ].SetDataSource(dtImages);
                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]
                                .SetDataSource(dtHematology);
                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]
                                .SetDataSource(dtOther);
                            SetReportParameter(Crpt);
                        }
                      //  if (Quick) Crpt.PrintToPrinter(0, false, 0, 0);
                        if (Quick)
                        {
                            //    mv_oNguoiKy = new VietBaIT.LABLink.Reports.Class.cls_SignInfor(mv_oRptFieldObj, "", Crpt.ToString(), Crpt.DataDefinition.FormulaFields["Formula_1"].Text);
                            //  mv_oNguoiKy = new cls_SignInfor(Crpt.ToString(), "", ReportSourceTable);
                            //  mv_oNguoiKy = newcls_SignInfor(string.IsNullOrEmpty(oForm.crptTrinhKyName) , Crpt.ToString(),oForm.crptTrinhKyName, "", "");
                            mv_oNguoiKy =
                                new cls_SignInfor_new(
                                    string.IsNullOrEmpty(oForm.crptTrinhKyName)
                                        ? oForm.crptTrinhKyName
                                        : oForm.crptTrinhKyName, "");
                            //      mv_oNguoiKy = newcls_SignInfor(" ", "", Crpt, ReportSourceTable);
                            //chkPrint_CheckedChanged(chkPrint, New System.EventArgs)
                            if (mv_oNguoiKy._TonTai)
                            {
                                Crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) +
                                                                                      mv_oNguoiKy.mv_NOI_DUNG.Replace(
                                                                                          "&NHANVIEN",
                                                                                          globalVariables.UserName)
                                                                                          .Replace("\t",
                                                                                              Strings.Chr(34) +
                                                                                              "&Chr(13)&" +
                                                                                              Strings.Chr(34)) +
                                                                                      Strings.Chr(34);
                            }
                            else
                            {
                                Crpt.DataDefinition.FormulaFields["Formula_1"].Text = "";
                            }

                            Crpt.PrintOptions.PrinterName = printerName;
                            Crpt.PrintToPrinter(0, true, 0, 0);
                            Crpt.Dispose();
                            CleanTemporaryFolders();
                        }
                        else
                        {
                          //  var oForm = newfrmPrintPreview("Phiếu KQ Xét nghiệm", Crpt, true, ReportSourceTable.Rows.Count <= 0 ? false : true);
                         //   oForm.crptTrinhKyName = Path.GetFileName(path);

                            oForm.ShowDialog();
                            oForm.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Exemplo n.º 37
0
 public void Inline_AsCollection()
 {
     ProductCollection products =
         new InlineQuery()
             .ExecuteAsCollection<ProductCollection>("SELECT productID from products WHERE productid=@productid", 1);
 }
Exemplo n.º 38
0
 public void Acc_Inline_AsCollection()
 {
     ProductCollection products =
         new InlineQuery("NorthwindAccess")
             .ExecuteAsCollection<ProductCollection>("SELECT productID from products WHERE categoryid=[PARM__madeupname]", 7);
 }
Exemplo n.º 39
0
 public void Acc_Inline_Simple()
 {
     QueryCommand cmd = new InlineQuery("NorthwindAccess").GetCommand("SELECT productID from products");
     Assert.IsTrue(cmd.CommandSql == "SELECT productID from products");
 }
Exemplo n.º 40
0
        public void Acc_Inline_WithCommands()
        {
            QueryCommand cmd = new InlineQuery("NorthwindAccess").GetCommand("SELECT productID from products WHERE productid=[PARM__productid]", 1);

            Assert.IsTrue(cmd.Parameters[0].ParameterName == "[PARM__productid]");
        }