Sunday, March 26, 2023

Important Quotes of good bye

Thank you for the work you have done for Viridor, your support has been invaluable. Wish you the very best in your future endeavors.

Monday, February 20, 2023

News Extrator

 using Newtonsoft.Json;

using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using System.Net;

using System.Text;

using System.Threading.Tasks;


namespace NewsExtractor

{

    class Program

    {

        static void Main(string[] args)

        {


            NewsEntities newsEntities = new NewsEntities();

            var list = newsEntities.NewsURLs;

            foreach (var url in list)

            {

                var data = GetURLData(url.URL.Replace("200", url.Count.ToString()));

                AddNews(data);      

            }

        }


        private static string GetURLData(string url)

        {

            Console.WriteLine(url);

            WebClient client = new WebClient();


            client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36)");


            Stream data = client.OpenRead(url);

            StreamReader reader = new StreamReader(data);

            var s = reader.ReadToEnd();

            data.Close();

            reader.Close();

            return s;

        }


        private static void AddNews(string fileData)

        {

            NewsEntities newsEntities = new NewsEntities();


            var weatherForecast = JsonConvert.DeserializeObject<RootNew>(fileData);

            foreach (var item in weatherForecast.data.items)

            {

                if (!newsEntities.News.Any(p => p.TickerTapeId == item._id))

                {

                    News n = new News();

                    n.Title = item.title;

                    n.TickerTapeId = item._id;

                    n.Description = item.description;

                    n.NewsDate2 = item.date;

                    n.NewsDate = item.date.ToString();

                    n.Image = item.image;

                    n.Stocks = string.Join(",", item.stocks.Select(p => p.sid));

                    n.link = item.link;

                    newsEntities.News.Add(n);

                    Console.WriteLine(item.title);


                }

            }

            newsEntities.SaveChanges();

        }

    }



}


Sunday, January 8, 2023

How to Remove Empty Folders Using Command Prompt

How to Remove Empty Folders Using Command Prompt


Managing your files and folders effectively is crucial for maintaining an organized and efficient system. Over time, your directories may accumulate empty folders that no longer serve a purpose. These empty folders can clutter your system and make it harder to find the files you need. Fortunately, there's a simple command you can use in the Command Prompt to remove all empty folders from a directory and its subdirectories.

In this blog post, we'll walk you through the command step-by-step and explain how it works.

Step-by-Step Guide

  1. Open Command Prompt:
    • Press Win + R to open the Run dialog.
    • Type cmd and press Enter to open the Command Prompt.
  2. Navigate to the Desired Directory:

    Use the cd command to navigate to the directory where you want to remove empty folders. For example:

    cd C:\path\to\your\directory
  3. Run the Command:

    Use the following command to remove empty folders:

    for /f "delims=" %d in ('dir /s /b /ad ^| sort /r') do rd "%d"

    If you are running this command in a batch file, remember to double the percentage signs (%):

    for /f "delims=" %%d in ('dir /s /b /ad ^| sort /r') do rd "%%d"

How the Command Works

Let's break down the command to understand how it works:

  • for /f "delims=" %d in ('dir /s /b /ad ^| sort /r') do rd "%d"
    • for /f "delims=" %d: This is a for loop that processes each line of output from the command inside the parentheses.
    • dir /s /b /ad: This part of the command lists all directories (/ad) in the current directory and all subdirectories (/s), displaying them in bare format (/b), which means no header information or summary.
    • ^| sort /r: The | symbol is used for piping the output of one command to another. The sort /r command sorts the directories in reverse order. Sorting in reverse is crucial because it ensures that subdirectories are processed before their parent directories, preventing errors when trying to delete a non-empty parent directory.
    • do rd "%d": The rd command is used to remove directories. %d represents each directory path processed by the for loop. If the directory is empty, it will be removed.

Additional Tips

Run as Administrator: Sometimes, you may need administrative privileges to delete certain folders. Right-click on Command Prompt and select "Run as administrator".

Test First: It's always a good idea to test the command in a directory with a few test folders to ensure it works as expected before running it on important directories.

Backup: Make sure you have backups of your important files and directories before running bulk delete operations to avoid accidental data loss.

Conclusion

Using the Command Prompt to remove empty folders is a powerful and efficient method to keep your file system clean and organized. By understanding and utilizing this command, you can save time and maintain a clutter-free environment on your computer.

Feel free to share this guide with others who might find it helpful, and happy organizing!

By following these steps, you can effectively manage and clean up empty folders in your directories. If you have any questions or run into any issues, leave a comment below, and we'll be happy to help!

Friday, March 25, 2022

Get Questions

     var x = document.getElementsByTagName("select");

    var txt = "";

    var i;

var j;

for (j = 0; j < x.length; j++) {

var y = x[0];

txt ='';

    for (i = 1; i < y.length; i++) {

        txt = txt + "</br>" + y.options[i].text;

    }

console.log(txt);

var $temp = $("<div>");

$(y).append($temp);

$temp.html(txt).select();

}

Thursday, September 9, 2021

Dynamics 365 and AD groups

 Dynamics 365 has some security features which integrate Dynamics 365 with AD Groups. AD Groups can be used to grant and restrict access to a Dynamics 365 environment and with AAD security teams you can automatically add users to teams.

I hate doing manual tasks (Dynamics 365 — The cost of manual deployments activities) and if it can be automated it should, so AAD security teams offer a great way to automate adding users and giving them security roles.

This blog post will discuss both security groups and AAD security teams.

Microsoft Documentation — Control user access to environments: security groups and licenses

AD security group

The first AD security group I recommend to setup is a group which grants people access to an environment. Microsoft cover it here

You create an AD group and then you go to Power Platform Admin and navigate to environments where you will see all environments you have access to.

If you add AD group in the security group setting, this allows users to access or see the Dynamics 365 environment if they are added to that group. This is an easy way to control which users can access different environments.

It acts as a layer before security roles and stops accidently giving access to users. For projects its common for developers and consultants to have access to most of the Dynamics 365 environments accept Preproduction and Production.

Microsoft documentation — Control user access to environments: security groups and licenses

Group teams

Dynamics 365 lets you create a few different types of team

·         Owner teams

·         Access Teams

·         Group teams

Owner teams are the classic team in Dynamics and works like a user, they can own records and have security roles.

Access teams allow record access and give people access to a particular record, e.g. sales people working on an opportunity

Groups teams are different because they link an AD Group to a team in Dynamics 365 AAD team. AD groups can be of type office or security. The office AD group can be created with users with less privileges and as a way to create groups of users.

An AD security group will need an IT person to create them.

Both Azure AD groups will have an Azure AD Object Id for the group and we link that to a team in Dynamics by putting that guid in azureactivedirectoryobjectidazureactivedirectoryobjectid field

You can create these in Dynamics by creating a new team and selecting the AAD Security type or AAD Group type.

A few things to note

·         You have to put Azure AD object ID on creation of the team

·         It will validate the it’s a valid guid

·         You cannot change this guid after creation

This page describes how group teams and owner teams work in Dynamics

The picture below shows how AD Groups work

The security gives access to the environment

The team AD group automatically adds a user. In the example above, you add a user into the Sales Manager AD team and it will automatically add that user to the Sales Manager team in Dynamics (as long as you have created the team and put in the correct Azure AD Object ID)

If you assign the team a security role then you don’t have to do any manual setup of the users for security roles or field level security.

The diagram below show it without AD groups linked with teams.

Each AD group can only work with an Dynamics team in one Dynamics instance.

You can keep the guids the same but you need to change the AzureID field

Why aren’t people in the Dynamics groups?

I setup up my teams, put in the correct Azure AD Object Id for a group. The user was added to the correct group and then………nothing.

Where was the user? why wasn’t the user appearing in my team?

In the Microsoft documentation

The list of team members listed in each group team only displays the user members who have accessed the environment. This list doesn’t show all the group members of the Azure AD group. The team member’s privileges are derived dynamically at run-time when the team member accesses the application. The security role of the team is not assigned directly to the team member. Since team member’s privileges are derived dynamically at run-time, the team member’s Azure AD group memberships are cached upon the team member’s log-in. This means that any Azure AD group membership maintenance done on the team member in Azure AD will not be reflected until the next time the team member logs in or when the system refreshes the cache (after 8 hours of continuous log-in).

The members show in the team in Dynamics 365 only when users have accessed Dynamics 365 (logged in). If the user in the AD Group hasn’t logged in then they won’t show in the team members in Dynamics.

Other potential gotcha’s from Microsoft documentation

You can only create one group team for each Azure AD group per environment, and the Azure AD ObjectId of the group team cannot be edited once the group team is created.

Team members are maintained in each group team at run-time and the operation is done at the database level; therefore, the update to group team event is not available for plugin.

Data

If you have a release pipeline, you can keep the GUIDs of the AAD security group team the same but you have change the Azure AD Object ID to the AD group.

It’s worth doing because you will have the teams with the same guids in each environment.

Conclusion

AD groups can be an effective way to add security and simplify adding users to a Dynamics 365 environment.

I think all Dynamics 365 environment should have a security group, it stops accidently enabling users to environments.

AAD security groups are good if you have distinct security roles with no cross over. If you can do it, it will save time adding users and is worth looking into to.

picture from here

 

Monday, August 2, 2021

Essential Interview Questions for MSCRM Developers

Interviewing for a developer position can be challenging, but being prepared with the right questions can make all the difference. Here’s a comprehensive list of useful interview questions to help you prepare for your next technical interview.

Q1) Please introduce yourself. +
Answer: I am [Your Name], currently working as a [Your Current Position] with [Your Company/Organization]. I have [Number] years of experience in [Your Field], specializing in [Your Area of Expertise]. I completed my [Your Degree] in [Your Major] from [Your University/College].
Q2) What kind of security mechanism do you use for securing web APIs? +
Answer: I use various security mechanisms such as HTTPS/TLS for secure communication, OAuth 2.0 with JWT (JSON Web Tokens) for authentication and authorization, CORS policies to restrict cross-origin requests, and rate limiting to prevent abuse.
Q3) How does OAuth work? +
Answer: OAuth is an open-standard authorization protocol that allows applications to gain limited access to user accounts on an HTTP service. It works by enabling secure delegated access and authorization without exposing user credentials.
Q4) Is there any expiration mechanism for the token? +
Answer: Yes, tokens issued through OAuth typically have an expiration time (expires_in) after which they are no longer valid. This helps mitigate security risks associated with long-lived tokens.
Q5) Have you used the refresh token mechanism? +
Answer: Yes, refresh tokens are used in OAuth flows to obtain new access tokens without prompting the user to re-enter their credentials. They help maintain persistent authentication sessions.
Q6) What are different state management techniques in ASP .NET? +
Answer: ASP.NET offers various state management techniques including in-process (Session state, Application state), out-of-process (StateServer and SQLServer), and client-side (Cookies, Query strings, Hidden fields).
Q7) What is in-proc session management? +
Answer: In-process session management stores session data within the ASP.NET worker process memory. It's fast but can lead to scalability issues in web farms or during application restarts.
Q8) What are different options to store session data in ASP.NET? +
Answer: Session data in ASP.NET can be stored in-process (default), StateServer (out-of-process), SQLServer (out-of-process), or using custom session providers.
Q9) What are the steps to store session data in SQL Server? +
Answer: To store session data in SQL Server, configure the session state mode to SQLServer in web.config, provide a connection string to the SQL Server database, and ensure the session state database schema is installed using aspnet_regsql.exe.
Q10) Have you hosted applications in the cloud? +
Answer: Yes, I have experience deploying applications to cloud platforms like Microsoft Azure, AWS, and Google Cloud Platform. I utilize cloud services for scalability, reliability, and ease of maintenance.
Q11) What is an application pool? +
Answer: An application pool in IIS (Internet Information Services) is a set of one or more web applications that share a common configuration and worker process. It provides isolation, resource management, and improved application reliability.
Q12) What is an out of memory exception? How will you handle this? +
Answer: An out of memory exception occurs when an application attempts to allocate memory but fails due to insufficient available memory. Handling involves optimizing memory usage, identifying memory leaks, and implementing robust error handling and logging.
Q13) Sometimes there are cases where you need to store data such as reports in session. How will you clear data of one report in session if you move to another? +
Answer: To clear data of one report stored in session when navigating to another, I would explicitly remove or invalidate the session variables associated with the previous report. This ensures efficient memory usage and prevents data inconsistencies.
Q14) How do you store a data table in view state? What if the data table has millions of records? +
Answer: Storing a data table in view state involves serializing the data table object into a string and assigning it to the ViewState["key"]. For large data tables, it's recommended to consider alternative storage solutions such as caching or retrieving data on demand to avoid performance issues.
Q15) What are ref and out parameters? +
Answer: ref and out are keywords used in C# to pass arguments to methods by reference instead of by value. ref parameters must be initialized before they are passed to a method, whereas out parameters are typically used for returning values from methods.
Q16) What is the finally block? When will it execute? +
Answer: The finally block in C# is used in exception handling to specify code that should always execute, regardless of whether an exception occurs or not. It executes after try and catch blocks, or after the try block if no exceptions are thrown.
Q17) Can you explain access modifiers? +
Answer: Access modifiers (e.g., public, private, protected, internal, protected internal) control the visibility and accessibility of classes, methods, and properties in C#. They enforce encapsulation, data hiding, and code security within applications.
Q18) What is a design pattern? Have you used any in your application? +
Answer: Design patterns are reusable solutions to common software design problems. Examples include Singleton, Factory, and MVC (Model-View-Controller). I have implemented design patterns like Singleton for managing global resources and MVC for structuring web applications.
Q19) Can you describe the dependency injection pattern? +
Answer: Dependency Injection (DI) is a software design pattern used to implement Inversion of Control (IoC) by injecting dependencies into a class rather than the class creating them. It enhances modularity, testability, and maintainability of applications.
Q20) Which domain are you working in? +
Answer: I am currently working in [Your Domain/Industry], focusing on [Specific Projects or Technologies]. This includes [Brief Description of Your Responsibilities or Projects].
Q21) Do you have healthcare experience? +
Answer: Yes, I have experience working on healthcare-related projects, ensuring compliance with regulations such as HIPAA (Health Insurance Portability and Accountability Act). This involves handling sensitive patient data securely and implementing robust data protection measures.
Q22) Have you worked with LINQ? +
Answer: LINQ (Language-Integrated Query) is a powerful feature in C# used for querying and manipulating data. I have utilized LINQ to SQL for database queries and LINQ to Objects for in-memory data manipulation in various projects.
Q23) What is lazy loading in LINQ? +
Answer: Lazy loading in LINQ defers the loading of related objects or data until the point where they are actually needed. This optimization technique improves performance by loading data only when required, reducing unnecessary database queries.
Q24) You have used global and local temp variables. What is the difference? Which do you use when? +
Answer: Global variables are accessible throughout the entire program, whereas local variables are limited to the scope in which they are defined (like within a function or a block). When to use: Use global variables when you need data to be accessible across multiple functions or modules. Use local variables when you only need data within a specific function or block and want to avoid unintended side effects or variable name conflicts.
Q25) What are magic tables? +
Answer: Magic tables in SQL Server refer to two special virtual tables inserted and deleted that are used in triggers. Inserted contains copies of the affected rows during INSERT and UPDATE operations, and deleted contains copies of the affected rows during DELETE and UPDATE operations.
Q26) What is SQL Injection? +
Answer: SQL Injection is a technique where malicious SQL statements are inserted into an entry field for execution. This can allow attackers to gain unauthorized access to a database or manipulate its contents.
Q27) How can you prevent SQL Injection? +
Answer: To prevent SQL Injection, use parameterized queries or prepared statements with bound parameters. These methods separate SQL code from user input, preventing the interpreter from confusing them.
Q28) What is a filtered index? +
Answer: A filtered index is an index with a filter condition that allows it to include only a subset of rows in a table. It improves query performance and reduces index maintenance costs by excluding rows that are not needed by queries.
Q29) Clustered and Non-Clustered index. Which is used when? +
Answer: Clustered index: Physically orders the data rows in the table based on the indexed column(s). Typically used on columns that are frequently searched for ranges of data. Non-Clustered index: Creates a separate structure (like a binary tree) for the indexed columns that points back to the original table rows. Useful for columns frequently used in queries for lookups but not for sorting the physical order of the table.
Q30) What is the virtual keyword? +
Answer: In C#, the virtual keyword is used to modify a method, property, indexer, or event declaration and allow for it to be overridden in derived classes.
Q31) Have you worked on collections? What are the different collections available in C#? +
Answer: C# provides several built-in collection types such as List, Dictionary, HashSet, Queue, Stack, etc., each optimized for different kinds of operations.
Q32) What is the difference between hash table and dictionary? +
Answer: Both HashTable and Dictionary are key-value pair collections, but Dictionary is strongly typed and offers better performance than HashTable, which is weakly typed and considered obsolete in C#.
Q33) Which collection will give better performance - hash table or dictionary? +
Answer: Dictionary generally provides better performance because it is strongly typed and more efficient due to its hash-based implementation compared to HashTable.
Q34) Can you explain where you have used collection objects in your project? +
Describe where you have used collection objects (like lists, dictionaries) in your projects, emphasizing their role in managing and manipulating data efficiently.
Q35) What are the different components available in ADO.NET? +
ADO.NET includes components such as Connection, Command, DataReader, DataAdapter, and DataSet, which facilitate data access and manipulation in .NET applications.
Q36) What is a dataset? +
A DataSet is an in-memory cache of data retrieved from a data source, typically a database. It can hold multiple tables with relationships, constraints, and changes tracked in memory.
Q37) Can you talk about execute scalar and execute non-query commands? +
ExecuteScalar is used to retrieve a single value (like a count or aggregate result) from a database, while ExecuteNonQuery is used for executing commands that do not return any data, such as INSERT, UPDATE, DELETE queries.
Q38) Have you used encryption? What is that? +
Encryption is the process of transforming data into a secure form that can only be read or processed by those with the proper decryption key or algorithm.
Q39) What is the ideal timeout for a connection string? +
The ideal timeout for a connection string depends on the specific application's requirements and network conditions. A typical value ranges from 15 to 30 seconds but can be adjusted based on the complexity of queries and the reliability of the network.

Friday, July 9, 2021

When will you use workflow?

The answer would likely be: it depends on the characteristics of the task that is under consideration. And the same thing applies to plug-in.

Featured Post

Links

https://www.examtopics.com/discussions/microsoft/view/52755-exam-pl-600-topic-2-question-4-discussion/ https://www.examtopics.com/discussion...