Create a virtual printer that displays on screen in c#
last document that was sent to this printer. I ve been trying to find an SDK or even an application that already does that. O don't wish to have the file saved to pdf first and then read and display that file as it is super slow, looking for new files on a specific folder and then read it. Any idea/help will be greatly appreciated.
See also questions close to this topic
-
How to use Microsoft.AspNetCore.OData ApplyTo method to materialize a query on a service layer?
How to use OData with Microsoft.AspNetCore.OData nuget package passing ODataQueryOptions and process the query on a service layer rather in the controller. The idea is to use it to process a query using the extension method ApplyTo but instead of implementing that logic on the controller to query the data on a service class? The problem I when you pass a Dto with the ODataOptions and map it to an entity for example on the service layer and use the ApplyTo to materialize the query? A good example would be passing a PersonDto with FullName and the Entity Person has inside Name,LastName. Using Automapper you can do that map easily but when Odata is in between converting an ODataOption to ODataOption needs to keep the expression tree intact for using ApplyTo with IQueryable correctly and that is where I need help, to have an elegant way to create the mapper and materialize the query on a service layer.
-
Programmatically edit live excel document c#
Is there a way to edit live view excel documents with c#?
We have an excel document that has jobs being added to it from several different computers, via a c# program, but it is also being viewed through microsoft teams. As far as I can work out, the document needs to be closed in teamviewer on all computers to be able to be edited.
Is this correct? Or is there a workaround?
-
How to extract a specific database column from the query result
I have this sql query that successfully returns the desired result :
Basically for the given NameId there are multiple unique PlaceId.
` -----------------------SQL QUERY---------------------------------
Select NameId, PlaceId from db_schemaA_tableA a left join db_schemaB_tableB b on a.Id = b.NameId left join db_schemaC_tableC c on a.ItemId = c.ItemId where a.Id='C330ads' NOTE : NameId and PlaceId are type GUID ------------------------SQL RESULT -------------------- NameId | PlaceId -------------------- C330ads | 705ddf ----------------- C330ads | 618rre
`
In C# this is what I have
-------- Entity Class -------- public class Name { public Guid NameId {get; set:} public Guid PlaceId {get; set;} } ------------------ Class with DB Connection method -------------------- '\n' public List<Name> GetNames(Guid someId) { SqlConnection connection = new SqlConnection(); var result = new List<Name>(); string query = @"Select NameId, PlaceId from db_schemaA_tableA a left join db_schemaB_tableB b on a.Id = b.NameId left join db_schemaC_tableC c on a.ItemId = c.ItemId where a.Id= @NameId"; //HOW CAN I GET ALL PlaceIds ? using(connection) { result = connection.Query<Name>(query, new {NameId = someId}); } return result; }
How can I get all the corresponding PlaceId for the given NameId in c#?
Thank you
-
when trying to print a dictionary I get TypeError: list indices must be integers or slices, not str
I have the simple dictionary with multiple entries, and I'm trying to print specific fields from inside it:
trace = {} trace = {'request': {'trace': {'eth': {'dl_type': 2048, 'dl_vlan': 30, 'dl_vlan_pcp': 4}, 'ip': {'nw_dst': '0.0.0.2', 'nw_proto': 3, 'nw_src': '0.0.0.1', 'nw_tos': 5}, 'switch': {'dpid': '00:00:00:00:00:00:00:01', 'in_port': 16}, 'tp': {'tp_dst': 1, 'tp_src': 1} } }, 'request_id': 30005, 'result':[ { 'dpid': '00:00:00:00:00:00:00:01', 'port': 16, 'time': '2021-02-08 18:15:52.566319', 'type': 'starting' }, { 'dpid': '00:00:00:00:00:00:00:05', 'port': 1, 'time': '0:00:00.528112', 'type': 'trace' }, { 'dpid': '00:00:00:00:00:00:00:06', 'port': 8, 'time': '0:00:01.075010', 'type': 'trace' }, { 'msg': 'none', 'reason': 'done', 'time': '0:00:02.679952', 'type': 'last' } ], 'start_time': '2021-02-08 18:15:52.566319', 'total_time': '0:00:02.681042' } if trace["result"]["type"] == "last" and trace["result"]["reason"] != "done": print("Reason entry in last trace IS NOT done") print(trace["result"][-1]["type"]) print(trace["result"]["reason"])
But I get a Type Error. Can someone tell me what is wrong with my statements, and why I'm getting that type error if I declared the dictionary?
-
Input type = "text" name did not shown in print preview
I have seem the similar question, why
input-type="text"
name did not working in print preview. SO, I try to print this project, but input-type="text" won't work. Anyone know how to solve this? I have see many solutions and won't work and I try in other browsers and won't work too.This is the out put after I print preview. print preview which data is input-type="text"
This is the code
<input type="hidden" name="id[]" value="<?php echo $row->id ?>"> <input type="hidden" name="student_session_id[]" value="<?php echo $row->student_session_id ?>"> <input type="hidden" name="semester[]" value="1"> <input type="hidden" name="evaluation_period[]" value="1"> <input type="text" name="surah[]" value="<?php echo $row->surah ?>" class="form-control" required> <input type="text" name="score[]" value="<?php echo $row->score ?>" class="form-control" required> <input type="text" disabled value="<?php echo $row->predicate ?>">
This is the data data which I want to print preview
Anyone how to solve so the data from
input type="text"
is shown on print preview? -
How do I print information from a text file using if statements in python?
I am new to coding and I am using Python. This is everything I need to do: Instructions
I am struggling to figure out part 2a, my professor said to use if and else statements. This is what I have so far and all of this my professor said is correct:
def part1(): createfile=open("Assignment4.txt", "a+") createfile.write(f"Player Name MinsPlayed Goals Assists YellowCard\n") createfile.write(f"Lionel Messi 1943 19 4 4\n") createfile.write(f"Robert Lewandowski 1864 28 6 2\n") createfile.write(f"Harry Kane 2017 14 11 1\n") createfile.write(f"Jack Grealish 1977 6 10 6\n") createfile.write(f"Cristiano Ronaldo 1722 19 3 1\n") createfile.write(f"Zlatan Ibrahimovic 1102 14 1 2\n") createfile.write(f"Gerard Moreno 1735 14 2 3\n") createfile.write(f"Romelu Lukaku 1774 18 6 4\n") createfile.write(f"Kylian Mbappe 1706 18 6 3\n") createfile.write(f"Erlin Haaland 1542 17 4 2") createfile.close() part1() def part2(): filetoopen=open("Assignment4.txt", "r") for line in filetoopen.readlines(): linetosplit=line.split(' ') filetoopen.close()
-
Terraform - Enable virtual nodes in Azure AKS using system assigned Identity
I am trying to provision a kubernetes cluster service in Azure Cloud using Terraform. Based on the provided requirements I need to enable virtual nodes and work under the system assigned managed identity. The main steps I followed are to create a dedicated virtual network and assigned 2 subnets on it. Then, I added them to my cluster and I enabled the aci-connector-linux block.Finally, I joined both the subnets with the created cluster. Overall, I am able to provision the services, but, the aci-connector-linux node it stays always in a waiting state and with a warning flag. It seems to me that I miss some pieces of authentication. Also, I am able to do it with service principal , but this is out of scope.
Here is my code.
resource "azurerm_virtual_network" "usernatwork" { name = "virtual-network-${var.resource_group_prefix}" location = var.location resource_group_name = var.resource_group_name address_space = ["10.0.0.0/8"] } # Create AKS subnet to be used by nodes and pods resource "azurerm_subnet" "aks" { name = "${var.resource_group_prefix}-aks-subnet" resource_group_name = var.resource_group_name virtual_network_name = azurerm_virtual_network.usernatwork.name address_prefixes = ["10.240.0.0/16"]# } resource "azurerm_subnet" "aci" { name = "${var.resource_group_prefix}-aci-subnet" resource_group_name = var.resource_group_name virtual_network_name = azurerm_virtual_network.usernatwork.name address_prefixes = ["10.241.0.0/16"] # Designate subnet to be used by ACI delegation { name = "aci-delegation" service_delegation { name = "Microsoft.ContainerInstance/containerGroups" actions = ["Microsoft.Network/virtualNetworks/subnets/action"] } } } resource "azurerm_kubernetes_cluster" "usercluster" { name = "aks-v4-${var.resource_group_prefix}" location = var.location resource_group_name = var.resource_group_name dns_prefix = "${var.resource_group_name}-aks-dns" kubernetes_version = data.azurerm_kubernetes_service_versions.useraksversion.latest_version node_resource_group = "${var.resource_group_name}-nrg" default_node_pool { name = "agentpool" max_count = 3 min_count = 1 vm_size = var.aks_node_id os_disk_size_gb = 128 os_disk_type = "Managed" vnet_subnet_id = azurerm_subnet.aks.id max_pods = 110 type = "VirtualMachineScaleSets" availability_zones = [1, 2, 3] orchestrator_version = data.azurerm_kubernetes_service_versions.useraksversion.latest_version enable_auto_scaling = true node_labels = { "nodepool-type" = "system" "environment" = "dev" "nodepoolos" = "linux" "app" = "system-apps" } tags = { "nodepool-type" = "system" "environment" = var.environment "nodepools" = "linux" "app" = "system-apps" } } identity { type = "SystemAssigned" } addon_profile { azure_policy {enabled = true} oms_agent { enabled = true log_analytics_workspace_id = azurerm_log_analytics_workspace.insights.id } aci_connector_linux { enabled = true subnet_name = azurerm_subnet.aci.name } http_application_routing { enabled = false } } windows_profile { admin_username = var.windows_admin_username admin_password = var.windows_admin_password } network_profile { network_plugin = "azure" load_balancer_sku = "Standard" network_policy = "azure" } tags = { "environment" = var.environment } } ##join AKS and ACI subnet resource "azurerm_role_assignment" "aks_subnet" { scope = azurerm_subnet.aks.id role_definition_name = "Network Contributor" principal_id = azurerm_kubernetes_cluster.usercluster.identity.0.principal_id } resource "azurerm_role_assignment" "aci_subnet" { scope = azurerm_subnet.aci.id role_definition_name = "Network Contributor" principal_id = azurerm_kubernetes_cluster.usercluster.identity.0.principal_id }
Here is my error screenshot
-
How to initialize derived class member in case of multiple inheritance
I have the below program. When I try to execute it, I found that
Allrounder
didn't get the valid name. Any idea how can I solve it?#include <iostream> #include <string> using namespace std; class Player { std::string playerName; public: Player(std::string &playerName) :playerName(playerName) { cout << "Player Constructed\n"; } void printPlayerName() const { std::cout<<playerName<<endl; } Player() = default; virtual ~Player() { cout << "Player Destructed\n"; } }; class Batsman : virtual public Player { public: Batsman(std::string playerName) : Player(playerName) { cout << "Batsman info added\n"; } ~Batsman() { cout << "Batsman Destructed\n"; } }; class Bowler : virtual public Player { public: Bowler(std::string playerName) : Player(playerName) { cout << "Bowler info added\n"; } ~Bowler() { cout << "Bowler Destructed\n"; } }; class Allrounder : public Batsman, public Bowler { public: Allrounder(std::string playerName) :Batsman(playerName), Bowler(playerName) { cout << "Allrounder info added"; } ~Allrounder() { cout << "Allrounder Destructed\n"; } }; int main() { Player *ptr = new Batsman("Sachin Tendulkar"); ptr->printPlayerName(); delete ptr; cout << endl; Player *ptr1 = new Bowler("Anil Kumble"); ptr1->printPlayerName(); delete ptr1; cout << endl; Player * ptr2 = new Allrounder("Ravindra Jadeja"); ptr2->printPlayerName(); delete ptr2; cout << endl; }
I ensured calling super class constructor, but in case of multiple inheritance, somehow this doesn't seem to work.
Currently
ptr2->printPlayerName()
failed to print the name of theAllrounder
. -
How to calculate virtual pages, size of each page, and number of physical frames
Assume that a computer has a virtual address space of 2^48 bytes and physical memory of 2^34 bytes. Also, assume that the left 20 bits are used for the Virtual Page Number and the right 28 bits are used for the OFFSET.
How many virtual pages can a virtual address space for this system have?
What is the size of each page?
How many physical frames does this computer have in physical memory?
I know that the answers are 2^20 virtual pages, each virtual page is 16 KB, and there are 2^20 physical frames in physical memory but I do not know why.