C# RAKAMI YAZIYA ÇEVİRME

Örnek 43221 = KIRK ÜÇ BİN ÜÇ YÜZ YİRMİ BİR

private static string ConvertNumberToTurkishText(double number)
{
    string[,] turkishNumberTexts = new string[3, 10]
    {
        {"", "BİR", "İKİ", "ÜÇ", "DÖRT", "BEŞ", "ALTI", "YEDİ", "SEKİZ", "DOKUZ"},
        {"", "ON", "YİRMİ", "OTUZ", "KIRK", "ELLİ", "ALTMIŞ", "YETMİŞ", "SEKSEN", "DOKSAN"},
        {"", "YÜZ", "İKİYÜZ", "ÜÇYÜZ", "DÖRTYÜZ", "BEŞYÜZ", "ALTIYÜZ", "YEDİYÜZ", "SEKİZYÜZ", "DOKUZYÜZ"}
    };

    string result = "";
    if (number == 0.0)
    {
        return "";
    }

    string numberText = number.ToString();
    int digitsCount = numberText.Length;

    if (digitsCount % 3 != 0)
    {
        int numberOfZeroesToAdd = 3 - (digitsCount % 3);
        numberText = new string('0', numberOfZeroesToAdd) + numberText;
        digitsCount += numberOfZeroesToAdd;
    }

    int blockCount = digitsCount / 3;
    int blockIndex = blockCount - 1;

    while (blockIndex >= 0)
    {
        string blockText = "";
        int digitIndex = (blockCount - blockIndex - 1) * 3;

        for (int i = 0; i < 3; i++)
        {
            int digit = int.Parse(numberText[digitIndex + i].ToString());
            if (digit == 0)
            {
                continue;
            }

            blockText += turkishNumberTexts[2, i == 0 ? digit : 0];
            blockText += (digit > 1 ? turkishNumberTexts[1, digit] : "");
            blockText += (i == 2 ? "" : " ");
        }

        if (!string.IsNullOrEmpty(blockText))
        {
            switch (blockIndex)
            {
                case 0:
                    result += blockText;
                    break;
                case 1:
                    result += (numberText.Substring(0, 3) == "001" ? "" : blockText + "BİN ");
                    break;
                default:
                    result += (blockText + (blockText.EndsWith("YÜZ") ? "" : " ") + GetMultiplierText(blockIndex) + " ");
                    break;
            }
        }

        blockIndex--;
    }

    return result.TrimEnd();
}

private static string GetMultiplierText(int multiplierIndex)
{
    string[] multipliers = { "MİLYON", "MİLYAR", "TRİLYON" };
    return multipliers[multiplierIndex - 2];
}

LOGO OBJECTS INVOICE ITEXT

Logo objectse invoice fatura atarken ITEXT her 255 karaktere ¦ konması gerekmektedir .

İlgili fonksiyon:

    public static string SplitString(string input)
        {
            int chunkSize = 255;
            List<string> chunks = new List<string>();
            for (int i = 0; i < input.Length; i += chunkSize)
            {
                int remaining = Math.Min(chunkSize, input.Length - i);
                chunks.Add(input.Substring(i, remaining));
            }
            return string.Join("¦", chunks);
        }
            F.DataFields.FieldByName("ITEXT").Value = SplitString(description);

C# TCMBDEN KURLARI GETİR(ESKİLER DAHİL)

public class Currency
        {
            public string Tarih { get; set; }
            public string Kod { get; set; }
            public string CurrencyCode { get; set; }
            public string CrossOrder { get; set; }
            public string Unit { get; set; }
            public string Isim { get; set; }
            public string CurrencyName { get; set; }
            public double ForexBuying { get; set; }
            public double ForexSelling { get; set; }
            public double BanknoteBuying { get; set; }
            public double BanknoteSelling { get; set; }
            public double CrossRateUSD { get; set; }
            public double CrossRateOther { get; set; }
        }
        public static List<Currency> GetCurrencies(DateTime Tarih)
        {
            if (Tarih.DayOfWeek == DayOfWeek.Saturday || Tarih.DayOfWeek == DayOfWeek.Sunday)
                return null;
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            List<Currency> currenciesL = new List<Currency>();
            string yearmonth = Tarih.ToString("yyyyMM");
            string monthyear = Tarih.ToString("MMyyyy");
            string day = Tarih.ToString("dd");
            string url = "";
            if (Tarih == DateTime.Now.Date)
                url = "https://www.tcmb.gov.tr/kurlar/today.xml"; 
            else url = "https://www.tcmb.gov.tr/kurlar/" + yearmonth + "/" + day + monthyear + ".xml";
            System.Net.WebRequest request = System.Net.WebRequest.Create(url);
            System.Net.WebResponse response = request.GetResponse();
            System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());
            string xml = reader.ReadToEnd();
            reader.Close();
            response.Close();
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(xml);
            System.Xml.XmlNodeList nodes = doc.SelectNodes("Tarih_Date/Currency");
            foreach (System.Xml.XmlNode node in nodes)
            {
                Currency currency = new Currency();
                currency.Tarih = Tarih.ToString("dd.MM.yyyy");
                currency.Kod = node.Attributes["Kod"].Value;
                currency.CurrencyCode = node.Attributes["CurrencyCode"].Value;
                currency.CrossOrder = node.Attributes["CrossOrder"].Value;
                currency.Unit = node.SelectSingleNode("Unit").InnerText;
                currency.Isim = node.SelectSingleNode("Isim").InnerText;
                currency.CurrencyName = node.SelectSingleNode("CurrencyName").InnerText;
                try { currency.ForexBuying = Convert.ToDouble(node.SelectSingleNode("ForexBuying").InnerText); } catch { }
                try { currency.ForexSelling = Convert.ToDouble(node.SelectSingleNode("ForexSelling").InnerText); } catch { }
                try { currency.BanknoteBuying = Convert.ToDouble(node.SelectSingleNode("BanknoteBuying").InnerText); } catch { }
                try { currency.BanknoteSelling = Convert.ToDouble(node.SelectSingleNode("BanknoteSelling").InnerText); } catch { }
                try { currency.CrossRateUSD = Convert.ToDouble(node.SelectSingleNode("CrossRateUSD").InnerText); } catch { }
                try { currency.CrossRateOther = Convert.ToDouble(node.SelectSingleNode("CrossRateOther").InnerText); } catch { }
                currenciesL.Add(currency);
            }
            return currenciesL;
        }
//Form içinde örnek kullanım:
        private void sb_Currencies_Click(object sender, EventArgs e)
        {
            //if datetime is saturday or sunday 
            if (de_CurrencyDate.DateTime.DayOfWeek == DayOfWeek.Saturday || de_CurrencyDate.DateTime.DayOfWeek == DayOfWeek.Sunday)
            {
                MessageBox.Show("Hafta Sonu Para Birimleri Alınamaz", "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            List<Methods.Currency> CURRENCIES = Methods.GetCurrencies(de_CurrencyDate.DateTime);
            te_Usd.Text = CURRENCIES.Where(x => x.CurrencyCode == "USD").FirstOrDefault().ForexSelling.ToString();
            te_Eur.Text = CURRENCIES.Where(x => x.CurrencyCode == "EUR").FirstOrDefault().ForexSelling.ToString();
            te_Gbp.Text = CURRENCIES.Where(x => x.CurrencyCode == "GBP").FirstOrDefault().ForexSelling.ToString();
            te_EurUsdParite.Text = CURRENCIES.Where(x => x.CurrencyCode == "EUR").FirstOrDefault().CrossRateOther.ToString();
        }

LOGO SAYISAL ZAMAN İŞLEMLERİ

C# Fonksiyonu

        private string LogoTimetoSystemTime(double GELENDEGER)
        {
            string RESULT = "";
            int HOUR = 0;
            if (GELENDEGER > 0)
            {
                HOUR = Convert.ToInt32(Math.Round(GELENDEGER / 16777216, 2));
            }
            int MINUTE = 0;
            if (GELENDEGER > 0)
            {
                MINUTE = Convert.ToInt32(Math.Round((GELENDEGER - HOUR * 16777216) / 65536, 2));
            }
            int SECOND = 0;
            if (GELENDEGER > 0)
            {
                SECOND = Convert.ToInt32(Math.Round((GELENDEGER - HOUR * 16777216 - MINUTE * 65536) / 256, 2));
            }
            RESULT = HOUR.ToString() + ":" + (MINUTE.ToString().Length == 0 ? 0 + MINUTE.ToString() : MINUTE.ToString()) + ":" + (SECOND.ToString().Length == 0 ? 0 + SECOND.ToString() : SECOND.ToString());
            return RESULT; 
        }

Sql Fonksiyonu

create FUNCTION [dbo].[fn_LogoTimetoSystemTime] (@GELENDEGER INT)
RETURNS VARCHAR(8)
AS
BEGIN
DECLARE @SAAT VARCHAR(2), @DAKIKA VARCHAR(2), @SANIYE VARCHAR(2), @SONUC VARCHAR(8)

SELECT
@SAAT=RTRIM(CONVERT(char(20), ROUND(@GELENDEGER / 16777216, 2))),
@DAKIKA=RTRIM(CONVERT(char(20), ROUND((@GELENDEGER - ROUND(@GELENDEGER / 16777216, 2) * 16777216)/ 65536, 2))),
@SANIYE=RTRIM(CONVERT(char(20), ROUND((@GELENDEGER - ROUND(@GELENDEGER / 16777216, 2) * 16777216 - ROUND((@GELENDEGER - ROUND(@GELENDEGER / 16777216, 2) * 16777216) / 65536, 2) * 65536) / 256, 2)))

SET @SAAT=CASE WHEN LEN(@SAAT)=1 THEN '0'+@SAAT ELSE @SAAT END 
SET @DAKIKA=CASE WHEN LEN(@DAKIKA)=1 THEN '0'+@DAKIKA ELSE @DAKIKA END 
SET @SANIYE=CASE WHEN LEN(@SANIYE)=1 THEN '0'+@SANIYE ELSE @SANIYE END


SET @SONUC= @SAAT + ':' +@DAKIKA + ':' + @SANIYE

RETURN @SONUC
END 
CREATE FUNCTION [dbo].[LG_TIMETOINT](@HH INT,@MM INT,@SS INT)
RETURNS INT
AS
BEGIN
DECLARE @TIME    INT
SELECT @TIME   = (@HH*65536*256+@MM*65536+@SS*256)
RETURN(@TIME)
END
GO

CREATE FUNCTION [dbo].[LG_INTTOTIME](@TIME INT)
RETURNS VARCHAR(8)
AS
BEGIN
DECLARE @HH INT
DECLARE @MM INT
DECLARE @SS INT
SELECT @HH = @TIME/65536/256
SELECT @MM = (@TIME/65536) - (@HH*256)
SELECT @SS = (@TIME/256) - (@HH*65536) - (@MM*256)
RETURN (RIGHT('0'+CAST(@HH AS VARCHAR(2)),2)+':'+RIGHT('0'+CAST(@MM AS VARCHAR(2)),2)+':'+RIGHT('0'+CAST(@SS AS VARCHAR(2)),2))
END
GO

CREATE FUNCTION [dbo].[LG_ADDTIME](@TIME INT,@ADD INT)
RETURNS INT
AS
BEGIN
DECLARE @HH INT
DECLARE @MM INT
DECLARE @SS INT
SELECT @HH = @TIME/65536/256
SELECT @MM = (@TIME/65536) - (@HH*256)
SELECT @SS = (@TIME/256) - (@HH*65536) - (@MM*256)
SELECT @SS = @SS + @ADD
IF @SS > 59
BEGIN
SELECT @MM = @MM + 1
SELECT @SS = @SS - 60
END
IF @MM > 59
BEGIN
SELECT @HH = @HH + 1
SELECT @MM = @MM - 60
END
RETURN (@HH*65536*256+@MM*65536+@SS*256)
END
GO
CREATE FUNCTION [dbo].[fn_LogoDatetoSystemDate] (@DEGER INT) 
RETURNS datetime
AS
BEGIN

DECLARE @GUN VARCHAR(2), @AY VARCHAR(2), @YIL VARCHAR(4)
DECLARE @SONUC datetime


SELECT
	@GUN=CAST((CONVERT(INT,CONVERT(BINARY,@DEGER,2),0)-(CONVERT(INT,CONVERT(BINARY,@DEGER,2),0)/256*256)) AS VARCHAR(3))
SELECT
	@AY=CAST(((CONVERT(INT,CONVERT(BINARY,@DEGER,2),0)-(65536*(CONVERT(INT,CONVERT(BINARY,@DEGER,2),0)/65536)))-(CONVERT(INT,CONVERT(BINARY,@DEGER,2),0)-(CONVERT(INT,CONVERT(BINARY,@DEGER,2),0)/256*256)))/256 AS VARCHAR(3))
SELECT
	@YIL=CAST((CONVERT(INT,CONVERT(BINARY,@DEGER,2),0)/65536) AS VARCHAR(6))

	SET @GUN=CASE WHEN LEN(@GUN)<2 THEN '0'+@GUN ELSE @GUN END
	SET @AY=CASE WHEN LEN(@AY)<2 THEN '0'+@AY ELSE @AY END


SONUC:
	IF @DEGER<>0
	BEGIN
		SET @SONUC=CONVERT(DATETIME, @YIL + '-' + @AY + '-' +  @GUN + ' 00:00:00', 102)
	END
	IF @DEGER=0
		SET @SONUC= NULL


RETURN @SONUC
END
GO
CREATE FUNCTION [dbo].[fn_SystemDateToLogoDate] (@date DATETIME) 
RETURNS INT
AS
BEGIN

DECLARE @GUN INT, @AY INT, @YIL INT
DECLARE @SONUC INT

SET @YIL = YEAR(@date)
SET @AY = MONTH(@date)
SET @GUN = DAY(@date)

SET @SONUC = (@YIL * 65536) + (@AY * 256) + @GUN

IF @SONUC = 0
    SET @SONUC = NULL

RETURN @SONUC
END
GO

C# DEVEXPRESS XTRAGRID KOLON SABITLE MENUSU

   private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
        {
                if (e.MenuType == GridMenuType.Column)
                {
                    GridViewColumnMenu menu = e.Menu as GridViewColumnMenu;
                    if (menu.Column != null)
                    {
                        var myMenu = new DXMenuCheckItem("Sola - Kolon Sabitle/Geri Al", menu.Column.Fixed == FixedStyle.Left, default, new EventHandler(FreezeUnfreezeColumnLeft_Click));
                        myMenu.Image = global::MYAPP.Properties.Resources.Left;        //LEFT ARROW ICON FOR myMenu.Image = Left.png

                        myMenu.BeginGroup = true;
                        myMenu.Enabled = true;
                        myMenu.Tag = menu.Column;
                        e.Menu.Items.Add(myMenu);

                        var myMenu2 = new DXMenuCheckItem("Sağa - Kolon Sabitle/Geri Al", menu.Column.Fixed == FixedStyle.Right, default, new EventHandler(FreezeUnfreezeColumnRight_Click));
                        myMenu2.Image = global::MYAPP.Properties.Resources.Right; //RIGHT ARROW ICON FOR myMenu2.Image = Right.png
                        myMenu2.BeginGroup = false;
                        myMenu2.Enabled = true;
                        myMenu2.Tag = menu.Column;
                        e.Menu.Items.Add(myMenu2);
                    }
                }
	}

        private void FreezeUnfreezeColumnLeft_Click(object sender, EventArgs e)
        {
            DXMenuCheckItem item = sender as DXMenuCheckItem;
            GridColumn info = (GridColumn)item.Tag;
            if (info is null)
                return;
            if (info.Fixed == FixedStyle.Left)
            {
                info.Fixed = FixedStyle.None;
            }
            else
            {
                info.Fixed = FixedStyle.Left;
            }

        }

    private void FreezeUnfreezeColumnRight_Click(object sender, EventArgs e)
        {
            DXMenuCheckItem item = sender as DXMenuCheckItem;
            GridColumn info = (GridColumn)item.Tag;
            if (info is null)
                return;
            if (info.Fixed == FixedStyle.Right)
            {
                info.Fixed = FixedStyle.None;
            }
            else
            {
                info.Fixed = FixedStyle.Right;
            }
        }

C# DEVEXPRESS PIVOTGRIDCONTROL

   pivotGridControl1.DataSource = DLL.SQL.SELECT(string.Format("SELECT * FROM MIZANMALZEME WHERE (Cast(Tarih as smalldatetime) between '" + TE_bASLANGICTARIHI.DateTime.ToString("yyyy-MM-dd") + "' and '" + TE_BITISTARIHI.DateTime.ToString("yyyy-MM-dd") + "')   AND  Isyeri_No IN (" + ISYERI_NRLERI + ")"));
            pivotGridControl1.RetrieveFields();
            pivotGridControl1.RestoreLayoutFromRegistry(@"Software\RAPOR\FRM_FINANSAL_RAPOR_212+" + pivotGridControl1.Name);

            PIVOTBESTFIT();

      private void PIVOTBESTFIT()
        {
            try
            {
                pivotGridControl1.BestFit();
                int i = 0;
                foreach (PivotGridField item in pivotGridControl1.Fields)
                {
                    item.BestFit();
                }
            }
            catch { }
        }

C# Devexpress xaf snippets

propxaf.snippet:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>propxaf</Title>
      <Shortcut>propxaf</Shortcut>
      <Description>Insert a property in XPO</Description>
      <Author>Llamachant Technology Ltd.</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>type</ID>
          <ToolTip>Property type</ToolTip>
          <Default>string</Default>
        </Literal>
        <Literal>
          <ID>property</ID>
          <ToolTip>Property name</ToolTip>
          <Default>Name</Default>
        </Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[
		private $type$ _$property$;
        public $type$ $property$ 
        { 
          get { return _$property$;} 
          set { SetPropertyValue<$type$>(nameof($property$), ref _$property$, value); } 
        }

			$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

propxafCollection.snippet:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>propxafCollection</Title>
      <Shortcut>propxafCollection</Shortcut>
      <Description>Insert a collection in XPO</Description>
      <Author>Llamachant Technology Ltd.</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>type</ID>
          <ToolTip>Remote Property type</ToolTip>
          <Default>DomainObject</Default>
        </Literal>
        <Literal>
          <ID>property</ID>
          <ToolTip>Collection Property name</ToolTip>
          <Default>MyProperty</Default>
        </Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[
        [Association]
        public XPCollection<$type$> $property$ {
          get { return GetCollection<$type$>(nameof($property$)); }
        }
			$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

propxafCollectionAggregated.snippet

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>propxafCollectionAggregated</Title>
      <Shortcut>propxafCollectionAggregated</Shortcut>
      <Description>Insert an aggregated collection (No link/unlink) in XPO</Description>
      <Author>Llamachant Technology Ltd.</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>type</ID>
          <ToolTip>Remote Property Type</ToolTip>
          <Default>DomainObject</Default>
        </Literal>
        <Literal>
          <ID>property</ID>
          <ToolTip>Collection Property Name</ToolTip>
          <Default>CollectionName</Default>
        </Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[
        [DevExpress.Xpo.Aggregated, Association]
        public XPCollection<$type$> $property$ {
          get { return GetCollection<$type$>(nameof($property$)); }
        }
			$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

propxafCust.snippet

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>propxafCust</Title>
      <Shortcut>propxafCust</Shortcut>
      <Description>Insert a custom object with default Name property</Description>
      <Author>Llamachant Technology Ltd.</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>class</ID>
          <ToolTip>Class Name</ToolTip>
          <Default>CustomObject</Default>
        </Literal>
		<Literal>
		  <ID>classtype</ID>
		  <ToolTip>XPO Base Object Type (BaseObject, XPCustomObject, XPLiteObject, etc.)</ToolTip>
		  <Default>BaseObject</Default>
		</Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[
		[DefaultProperty("Name")]
		public class $class$ : $classtype$
		{
			public $class$(Session session) : base(session) { }
			private string _Name;
			public string Name
			{
				get { return _Name; }
				set { SetPropertyValue<string>("Name", ref _Name, value); }
			}
		}

			$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

propxafOne.snippet

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>propxafOne</Title>
      <Shortcut>propxafOne</Shortcut>
      <Description>Insert a property with a One to Many relationship in XPO</Description>
      <Author>Llamachant Technology Ltd.</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>type</ID>
          <ToolTip>Property Type</ToolTip>
          <Default>DomainObject</Default>
        </Literal>
        <Literal>
          <ID>property</ID>
          <ToolTip>Property Name</ToolTip>
          <Default>MyProperty</Default>
        </Literal>
      </Declarations>
      <Code Language="csharp">
	   <![CDATA[
		private $type$ _$property$;
		[Association]
        public $type$ $property$ 
        { 
          get { return _$property$;} 
          set { SetPropertyValue<$type$>(nameof($property$), ref _$property$, value); } 
        }

			$end$]]>       
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

propxafPersistentAlias.snippet

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>propxafPersistentAlias</Title>
      <Shortcut>propxafPersistentAlias</Shortcut>
      <Description>Insert a persistent alias property in XPO</Description>
      <Author>Llamachant Technology Ltd.</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
	<Literal>
          <ID>expression</ID>
          <ToolTip>Alias Expression</ToolTip>
          <Default></Default>
        </Literal>
        <Literal>
          <ID>type</ID>
          <ToolTip>Property Type</ToolTip>
          <Default>string</Default>
        </Literal>
        <Literal>
          <ID>property</ID>
          <ToolTip>Property Name</ToolTip>
          <Default>Name</Default>
        </Literal>
		<Literal>
          <ID>converttype</ID>
          <ToolTip>Convert to Type</ToolTip>
          <Default>Int32</Default>
        </Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[
	[PersistentAlias("$expression$")]
        public $type$ $property$ 
        { 
          get { return Convert.To$converttype$(EvaluateAlias(nameof($property$))); } 
        }
			$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

https://www.llamachant.com/single-documents/code-snippets/

C# Open Excel File

        public static object OpenFile(string fileName)
        {
            if (!File.Exists(fileName))
            {
                MessageBox.Show("File not found");
                return null;
            }
            string connectionString = string.Empty;
            const string Excel03ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'";
            const string Excel07ConString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'";
            switch (Path.GetExtension(fileName))
            {
                case ".xls": //Excel 97-03
                    connectionString = string.Format(Excel03ConString, fileName);
                    break;
                case ".xlsx": //Excel 07
                    connectionString = string.Format(Excel07ConString, fileName);
                    break;
            }

            OleDbConnection con = new OleDbConnection(connectionString);
            con.Open();
            DataTable dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
            var adapter = new OleDbDataAdapter(string.Format("select * from [{0}]", dt.Rows[0]["TABLE_NAME"].ToString()), connectionString);
            var ds = new DataSet();
            const string tableName = "excelData";
            adapter.Fill(ds, tableName);
            DataTable data = ds.Tables[tableName];
            return data;
        }
    }

C# Windows Get Assembly Path

Wİndows service ‘de exenin bulundugu yere bazen ulaşmada sıkıntı olabiliyor. (windows klasorunu görüyor servisler bazen) . Örnek exe klasorunde dosyaya erişimde yaşanan sıkıntı ….

string pathofService = System.IO.Path.GetDirectoryName(new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath)+@"\";
/*or*/
string pathofService = AppDomain.CurrentDomain.BaseDirectory ++@"\";