Bahadır Bekeç

www.bahadirbekec.com

Register Javascrip Script

clock Mart 10, 2010 16:00 by author Bahadır Bekeç
  1: public class JavaScriptKodu
  2: {
  3:     private Page page;
  4: 
  5:     private string StartScript;
  6:     private string EndScript;
  7: 
  8:     public JavaScriptKodu(Page ThisPage)
  9:     {
 10:         page = ThisPage;
 11:         StartScript = "<script language='javascript' type='text/javascript'> \r\n";
 12:         EndScript =  "</Script>";
 13:     }
 14: 
 15:     private string ClearText(string myString)
 16:     {
 17:         myString = myString.Replace("\r\n", String.Empty);
 18:         myString = myString.Replace("\n", String.Empty);
 19:         myString = myString.Replace("\r", String.Empty);
 20:         myString = myString.Replace("\"", "\\\"");
 21:         myString = myString.Replace("\'", "\\\'");
 22:         return myString;
 23:     }
 24: 
 25:     public void ShowAlert(string mesaj)
 26:     {
 27:         string script = "     alert(\" " + ClearText(mesaj) + " \");";
 28:         page.ClientScript.RegisterStartupScript(typeof(string), "key", script);
 29:     }
 30: }
 31: 


Regular Expression Library

clock Mart 9, 2010 16:13 by author Bahadır Bekeç

 using System.Text.RegularExpressions;


        public bool IsEmailAdress(String emailAdress)
        {
            string MailAdressFormat = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
            Regex regEx = new Regex(MailAdressFormat);
            return regEx.IsMatch(emailAdress);
        }
        public bool IsDate(String strDate)
        {
            Regex objAlphaPattern = new Regex(@"(^|\s|\()((([1-9]){1}|([0][1-9]){1}|
([1][012]){1}){1}[\/-]((2[0-9]){1}|(3[01]){1}|([01][1-9]){1}|([1-9]){1}){1}[\/-](((19|20)(
[0-9][0-9]){1}|([0-9][0-9]){1})){1}(([\s|\)|:])|(^|\s|\()((([0-9]){1}|([0][1-9]){1}|([1][0
12]){1}){1}[\/-](([11-31]){1}|([01][1-9]){1}|([1-9]){1}){1}[\/-](((19|20)([0-9][0-9]){1}|(
[0-9][0-9]){1})){1}(([\s|\)|:|$|\&gt;])){1}){1}){1}){1}"
);
            return !objAlphaPattern.IsMatch(strDate);
        }

http://regexlib.com/DisplayPatterns.aspx adresinden yüzlece regex örnegi bulabilirsini. 



LINQ to SQL

clock Mart 7, 2010 16:52 by author Bahadır Bekeç

 

ScottGu



SQL Reportin Service

clock Mayıs 14, 2009 09:10 by author Bahadır Bekeç

Reporting servis ile oluşturulan raporu programatik olarak render etmek:
Parametreler:

  1. FileFormat: XML, NULL, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL, HTMLOWC
  2. reportPath: /MyReportPath/MyReport
  3. Parameters: Raporun aldığı parametreler.
  4. NewFilePathAndName: FileFormat ile belirttiğimiz tip ile render edilen raporu kaydetme konumu ve adı.

Imports Microsoft.VisualBasic
Imports System.Data
Imports System.IO
Imports reportingservice 'Reportin Service web referansi


Public Class ReportingServiceHelper

    
Public Shared Sub Render(ByVal FileFormat As String, _
                            
ByVal reportPath As String, _
                            
ByVal parameters() As ParameterValue, _
                            
ByVal NewFilePathAndName As String)

        
Dim rs As New reportingservice.ReportingService
        rs.Credentials 
System.Net.CredentialCache.DefaultCredentials
        rs.Credentials 
= New System.Net.NetworkCredential("UserName", _
                                                  
"Password""Domain")

        
' Render parametreleri
        
Dim result As Byte() Nothing
        
Dim historyID As String = Nothing
        
Dim devInfo As String = "<DeviceInfo><Encoding>ISO 8859-8" & _
                                "</Encoding></DeviceInfo>"
'Türkçe için
       

        
Dim credentials As DataSourceCredentials() Nothing
        
Dim showHideToggle As String = Nothing
        
Dim encoding As String = Nothing

        
Dim mimeType As String = Nothing
        
Dim warnings() As reportingservice.Warning Nothing
        
Dim reportHistoryParameters As ParameterValue() Nothing
        
Dim streamIDs As String() Nothing
        
Dim sh As New SessionHeader()
        rs.SessionHeaderValue 
sh

        rs.RequestEncoding 
System.Text.Encoding.UTF8'Türkçe için


        
result rs.Render(reportPath, FileFormat, historyID, devInfo, parameters, _
                          credentials, showHideToggle, encoding, mimeType, _
                   reportHistoryParameters, warnings, streamIDs)


        sh.SessionId 
rs.SessionHeaderValue.SessionId

        
Dim stream As FileStream File.Create(NewFilePathAndName, result.Length, _
                                               FileOptions.RandomAccess)
        stream.Write(result, 
0, result.Length)
        stream.Close()

    
End Sub
End Class

 



Global.asax Application_Error

clock Şubat 21, 2009 15:59 by author Bahadır Bekeç

    Global.asax

    void Application_Error(object sender, EventArgs e)
    {
          
//  Code that runs on application shutdown

        
Exception ex Server.GetLastError().GetBaseException();

         
// olusumum tarihini getir
        
string dateTime DateTime.Now.ToLongDateString() + ", at "
                            
+ DateTime.Now.ToShortTimeString();

        string 
errorMessage "Exception generated on " + dateTime;
        
// hatanin olustusgu url
        
System.Web.HttpContext context System.Web.HttpContext.Current;
        
errorMessage +"\n\n Page location: " + context.Request.RawUrl;      
        
errorMessage +"\n\n Message: " + ex.Message;
        
errorMessage +"\n\n Source: " + ex.Source;
        
errorMessage +"\n\n Method: " + ex.TargetSite;
        
errorMessage +"\n\n Stack Trace: \n\n" + ex.StackTrace;
        string 
from Configuration.AdminMail;
        string 
to Configuration.ErrorMailAddress;
        string 
subject " Error Report";
        string 
body errorMessage;
        
SendMail(from, to, subject, body);
            
        
Server.ClearError();
        
Response.Redirect("GenericErrorPage.aspx"true);
    
}


Bahadır Bekeç

    Bahadır Bekeç 1985, Kırıkkale doğumlu. 2006 yılına kadar hayatına Kırıkkale' de devam etti. İlk ve orta öğrenimini Kırıkkale Dede Korkut İlköğretim Okulu’ nda tamamladı.

Devamı

Son Yazılar

Sign in