Wednesday, 5 February 2025

PDF installation Steps

 

 PDF installation Steps:

  1. Open Add Remove Programs
  2. Uninstall PDF if present
  3. Take a full backup of Registry
  4. Open Registry with Administrator permission
  5. Remove entry of WebSupergo from HKEY_LOCAL_MACHINE -> Software -> WebSupergoo
  6. Remove entry of WebSupergo from HKEY_LOCAL_MACHINE -> Software -> WOW6432Node -> WebSupergoo
  7. Stop and Start the IIS Application Pool
  8. Install PDF Setup available in exe file
  9. Stop and Start the IIS Application Pool

Wednesday, 26 June 2024

Find Table definition SQL

 SELECT

COLUMN_NAME, DATA_TYPE,character_maximum_length 

FROM INFORMATION_SCHEMA.COLUMNS 

WHERE 

TABLE_SCHEMA = 'dbo' AND  TABLE_NAME = 'Table name' 

-----------------------------------------------------

SELECT

    clmns.name +','

    FROM

    sys.tables AS tbl

    INNER JOIN sys.all_columns AS clmns ON clmns.object_id=tbl.object_id

    LEFT OUTER JOIN sys.indexes AS ik ON ik.object_id = clmns.object_id and 1=ik.is_primary_key

    LEFT OUTER JOIN sys.index_columns AS cik ON cik.index_id = ik.index_id and cik.column_id = clmns.column_id and cik.object_id = clmns.object_id and 0 = cik.is_included_column

    where tbl.name = N'Table' AND is_identity != 1

Thursday, 2 May 2024

Text, content, table name search in all store procedure and find out store procedure name

  SELECT DISTINCT

       o.name AS Object_Name,

       o.type_desc

  FROM sys.sql_modules m

       INNER JOIN

       sys.objects o

         ON m.object_id = o.object_id

 WHERE m.definition Like '%AddCookiesLead%';

Monday, 11 March 2024

Read Outlook mail c sharp .net C# Azure Active Directory

 using Microsoft.Exchange.WebServices.Data;

using MailKit;

using MailKit.Net.Imap;

using MailKit.Search;

using MailKit.Security;

using Microsoft.Identity.Client;

using Microsoft.Win32.SafeHandles;

using MimeKit;

using Newtonsoft.Json;

using Newtonsoft.Json.Linq;

using System;

using System.Collections.Generic;

using System.Configuration;

using System.Data;

using System.Data.SqlClient;

using System.IO;

using System.Linq;

using System.Net;

using System.Net.Http;

using System.Net.Http.Headers;

using System.Net.Mail;

using System.Runtime.InteropServices;

using System.Security.Authentication;

using System.Text;

using System.Text.RegularExpressions;

using System.Threading;

using System.Threading.Tasks;

using System.Windows.Forms;


namespace PopClient

{

    static class Program

    {

        #region SASMechanism Variables

        static readonly string tenant = "tenant";

        static readonly string smtp_server = "smtp.office365.com";

        static readonly string aad_app_id = "aad_app_id";

        static readonly string aad_app_secret = "aad_app_secret";

        static readonly string user = "user";

        static readonly string pass = "pass";

        static readonly string imap_server = "outlook.office365.com";

        #endregion

        const string ExchangeAccount = "pass";

        /// <summary>

        /// The main entry point for the application.

        /// </summary>

        static void Main()

        {

            #region SecurityProtocolType  Setting 

            try

            { //try TLS 1.3

                ServicePointManager.SecurityProtocol = (SecurityProtocolType)12288

                                                     | (SecurityProtocolType)3072

                                                     | (SecurityProtocolType)768

                                                     | SecurityProtocolType.Tls;

            }

            catch (NotSupportedException)

            {

                try

                { //try TLS 1.2

                    ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072

                                                         | (SecurityProtocolType)768

                                                         | SecurityProtocolType.Tls;

                }

                catch (NotSupportedException)

                {

                    try

                    { //try TLS 1.1

                        ServicePointManager.SecurityProtocol = (SecurityProtocolType)768

                                                             | SecurityProtocolType.Tls;

                    }

                    catch (NotSupportedException)

                    { //TLS 1.0

                        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

                    }

                }

            }

            #endregion        

            MainAsync().GetAwaiter().GetResult();

            Console.ReadLine();

        }

        static async System.Threading.Tasks.Task MainAsync()

        {

                       var cca = ConfidentialClientApplicationBuilder

                .Create(aad_app_id)

                .WithClientSecret(aad_app_secret)

                .WithTenantId(tenant)

                .Build();


            var ewsScopes = new string[] { "https://outlook.office365.com/.default" };

            try

            {

                var authResult = await cca.AcquireTokenForClient(ewsScopes)

                    .ExecuteAsync();


                // Configure the ExchangeService with the access token

                var ewsClient = new ExchangeService();

                ewsClient.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");

                ewsClient.Credentials = new OAuthCredentials(authResult.AccessToken);

                ewsClient.ImpersonatedUserId =

                    new ImpersonatedUserId(ConnectingIdType.SmtpAddress, user);


                //Include x-anchormailbox header

                ewsClient.HttpHeaders.Add("X-AnchorMailbox", user);


                // Make an EWS call

                // Read 100 mails

                foreach (EmailMessage email in ewsClient.FindItems(WellKnownFolderName.Inbox, new ItemView(10)))

                {

                    string strFrom = "", ToRecipients = "", BccRecipients = "", CcRecipients = "", Subject = "", Body = "", TextBody = "", Attachments = "";

                    //email.Load(new PropertySet(EmailMessageSchema.ConversationTopic, ItemSchema.Attachments,

                    // ItemSchema.TextBody));

                    PropertySet plainTextPropertySet = new PropertySet(BasePropertySet.FirstClassProperties)

                    { RequestedBodyType = BodyType.Text, };

                    EmailMessage emailMessage = EmailMessage.Bind(ewsClient, email.Id, plainTextPropertySet);

                    string body = emailMessage.Body.Text;

                    email.IsRead = true;

                    email.Update(ConflictResolutionMode.AutoResolve);


                    strFrom = email.From.Address;

                    Console.WriteLine(email.ConversationTopic);

                    Console.WriteLine("From : " + strFrom);

                    Console.WriteLine("To : " + email.ToRecipients.ToString());

                    Console.WriteLine("BCC : " + email.BccRecipients);

                    Console.WriteLine("CC : " + email.CcRecipients);


                    Console.WriteLine("Subject : " + email.Subject);

                    EmailMessage message = EmailMessage.Bind(ewsClient, new ItemId(email.Id.ToString()));

                    if (message.HasAttachments && message.Attachments[0] is FileAttachment)

                    {

                        FileAttachment fileAttachment = message.Attachments[0] as FileAttachment;

                        fileAttachment.Load(@"C:\PRAMOD\PROJECT\ReadMailOutlook\PopClient\PopClient\\Attachments\\" + fileAttachment.Name);

                       // lblAttach.Text = "Attachment Downloaded : " + fileAttachment.Name;

                    }

                     }

 }

            catch (MsalException ex)

            {

                Console.WriteLine($"Error acquiring access token: {ex}");

            }

            catch (Exception ex)

            {

                Console.WriteLine($"Error: {ex}");

            }


            if (System.Diagnostics.Debugger.IsAttached)

            {

                Console.WriteLine("Hit any key to exit...");

                Console.ReadLine();

            }

        }


    public class MailMessages

    {

        public MimeMessage mMessage { get; set; }

        public IMailFolder imFolder { get; set; }

        public UniqueId uid { get; set; }

    }

}


Thursday, 8 February 2024

SecurityProtocolType TLS use in code without error for - Tls11, Tls12, and Tls13

 try { //try TLS 1.3

    ServicePointManager.SecurityProtocol = (SecurityProtocolType)12288

                                         | (SecurityProtocolType)3072

                                         | (SecurityProtocolType)768

                                         | SecurityProtocolType.Tls;

} catch (NotSupportedException) {

    try { //try TLS 1.2

        ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072

                                             | (SecurityProtocolType)768

                                             | SecurityProtocolType.Tls;

    } catch (NotSupportedException) {

        try { //try TLS 1.1

            ServicePointManager.SecurityProtocol = (SecurityProtocolType)768

                                                 | SecurityProtocolType.Tls;

        } catch (NotSupportedException) { //TLS 1.0

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

        }

    }

}


Thursday, 10 November 2022

get Tiny URL

 public static string getTinyURL(string url_)

    {

        string retVal = "";

        try

        {


            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://tinyurl.com/api-create.php?url=" + url_);

            if (HttpContext.Current.Request.Url.Authority.Trim().ToLower().Contains("".Trim().ToLower()) || HttpContext.Current.Request.Url.Authority.Trim().ToLower().Contains("localhost".Trim().ToLower()))

            { }

            else

            {

                WebProxy myproxy = new WebProxy("", 8080);

                myproxy.BypassProxyOnLocal = false;

                request.Proxy = myproxy;

            }

            request.Method = "GET";

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            StreamReader srd = new StreamReader(response.GetResponseStream());

            retVal = srd.ReadToEnd();

        }

        catch (Exception ex)

        {

            

        }


        return retVal;

    } 


Get Convert DateTime

 public DateTime GetConvertDateTime(string Date)

    {

        DateTime date = new DateTime();

        string CurrentPattern = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern;

        string[] Split = new string[] { "-", "/", @"\", "." };

        string[] Patternvalue = CurrentPattern.Split(Split, StringSplitOptions.None);

        string[] DateSplit = Date.Split(Split, StringSplitOptions.None);

        string NewDate = "";

        try

        {

            NewDate = DateSplit[0] + "/" + DateSplit[1] + "/" + DateSplit[2];


            date = DateTime.Parse(NewDate, Thread.CurrentThread.CurrentCulture);


        }

        catch (Exception ex)

        {

            NewDate = DateSplit[1] + "/" + DateSplit[0] + "/" + DateSplit[2];


            date = DateTime.Parse(NewDate, Thread.CurrentThread.CurrentCulture);

        }

        finally

        {


        }


        return date;


    }