1

Konu: c# kodunu dönüştürme

c# bilen arkadaşlar aşağıdaki kodu foxpro ya çevirseniz

        SmsParams sms = SmsParams;
            const string apino = "5";
            string user = sms.Username;
            string pass = sms.Password;
            string baslik = sms.Originator;/
            const string islem = "kayit";
            string postNumaralar = "";
            foreach (var numara in sms.SmsContainerList)
            {
                postNumaralar += "numaralar[]=" + numara.TelNo + "&";
            }
            postNumaralar = postNumaralar.Remove(postNumaralar.Length-1);
            string postMesajlar = "";
            foreach (var mesajim in sms.SmsContainerList)
            {
                postMesajlar += "mesaj[]=" + mesajim.Mesaj + "&";
            }
            postMesajlar = postMesajlar.Remove(postMesajlar.Length-1);
            var req = (HttpWebRequest)WebRequest.Create("http://eracell.com.tr/eracellapiV2/test/yunus.php");//("http://eraecell.com.tr/kurecellapiV2/api-center/index.php");////
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            string strNewValue = req + "&apiNo=" + apino + "&user=" + user + "&pass=" + pass + "&"  + postNumaralar +
                                 "&" + postMesajlar + "&baslik=" + baslik + "&islem=" + islem;
            req.ContentLength = strNewValue.Length;
            var stOut = new StreamWriter(req.GetRequestStream(), Encoding.ASCII);
            stOut.Write(strNewValue);
            stOut.Close();
            var stIn = new StreamReader(req.GetResponse().GetResponseStream());
            string strResponse = stIn.ReadToEnd();
            stIn.Close();
            MessageBox.Show(strResponse);

2

Re: c# kodunu dönüştürme

Barı bunuda çevir kim çevirecekse.

private Element ReadMemberExpression(){var queue = new Queue<Element[]>();var newDepth = 0;var argsCount = 0;_scanner.CreateRestorePoint();while (true){_scanner.CreateRestorePoint();{
var a = ReadArguments();if (a != null){argsCount++;if (argsCount > newDepth){_scanner.Restore();break;
}queue.Enqueue(new[] { default(Element), default(Element), a });_scanner.DeleteRestorePoint();continue;}}_scanner.DeleteRestorePoint();
var pe = ReadPrimaryExpression();if (pe != null){queue.Enqueue(new[] { pe });continue;}var fe = ReadFunctionExpression();
if (fe != null){queue.Enqueue(new[] { fe });continue;}if (_scanner.MatchNext(Grammar.New)){
newDepth++;queue.Enqueue(new[] { Grammar.New });}else if (_scanner.Match(Grammar.LeftSquareBracket)){var e = ReadExpression();if (e == null){
throw new ParseException();}if (!_scanner.MatchNext(Grammar.RightSquareBracket)){throw new ParseException();}queue.Enqueue(new[]{default(Element), Grammar.LeftSquareBracket, e, Grammar.RightSquareBracket});}
else if (_scanner.Match(Grammar.FullStop)){if (!_scanner.MatchNext(ElementType.IdentifierName)){throw new ParseException();}queue.Enqueue(new[] { default(Element), Grammar.FullStop, _scanner.Current });}
else{_scanner.Unwind();break;}}if (queue.Count == 0){
_scanner.DeleteRestorePoint();return null;}else{var element = default(Element);var children = queue.Dequeue();while (children[0] == Grammar.New)
{children = queue.Dequeue();}element = new Element(ElementType.MemberExpression, children);while (queue.Count > 0){children = queue.Dequeue();if (children.Length == 3 && children[2].Type == ElementType.Arguments)
{newDepth--;children[0] = Grammar.New;children[1] = element;element = new Element(ElementType.MemberExpression, children);}else{
children[0] = element;element = new Element(ElementType.MemberExpression, children);}}if (newDepth > 0){_scanner.Restore();return null;
}_scanner.DeleteRestorePoint();return element;}}

Bir projenin bitmesi için 3 seçenek vardır: hızlı, ucuz, iyi. Bu seçeneklerden iki tanesini seçiniz.

3

Re: c# kodunu dönüştürme

Ben hayrına VB.NET' e çevirdim, daha doğrusu ben değil Instant VB adlı bir programla çevirdim. Buradan foxproya çevirmek daha mümkün ama FoxPro dan o Web servisine bir Webrequest nasıl gönderilir bilmiyorum.

C#
Dim sms As SmsParams = SmsParams

            Const apino As String = "5"
            Dim user As String = sms.Username
            Dim pass As String = sms.Password
            Dim baslik As String = sms.Originator
            / const String islem = "kayit"
            Dim postNumaralar As String = ""
            For Each numara İn sms.SmsContainerList
                postNumaralar &= "numaralar[]=" & numara.TelNo & "&"
            Next numara
            postNumaralar = postNumaralar.Remove(postNumaralar.Length-1)
            Dim postMesajlar As String = ""
            For Each mesajim İn sms.SmsContainerList
                postMesajlar &= "mesaj[]=" & mesajim.Mesaj & "&"
            Next mesajim
            postMesajlar = postMesajlar.Remove(postMesajlar.Length-1)
            Dim req = CType(WebRequest.Create("http://eracell.com.tr/eracellapiV2/test/yunus.php"), HttpWebRequest) '("http://eraecell.com.tr/kurecellapiV2/api-center/index.php");////
            req.Method = "POST"
            req.ContentType = "application/x-www-form-urlencoded"
            Dim strNewValue As String = req & "&apiNo=" & apino & "&user=" & user & "&pass=" & pass & "&" & postNumaralar & "&" & postMesajlar & "&baslik=" & baslik & "&islem=" & islem
            req.ContentLength = strNewValue.Length
            Dim stOut = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
            stOut.Write(strNewValue)
            stOut.Close()
            Dim stIn = New StreamReader(req.GetResponse().GetResponseStream())
            Dim strResponse As String = stIn.ReadToEnd()
            stIn.Close()
            MessageBox.Show(strResponse)

4

Re: c# kodunu dönüştürme

Mehmet buda sana,

C#
Private Function ReadMemberExpression() As Element

    Dim queue = New Queue(Of Element())()
    Dim newDepth = 0
    Dim argsCount = 0
    _scanner.CreateRestorePoint()
    Do
        _scanner.CreateRestorePoint()
Dim a = ReadArguments()
İf a IsNot Nothing Then
    argsCount += 1
    İf argsCount > newDepth Then
        _scanner.Restore()
        Exit Do
    End If
queue.Enqueue( { Nothing, Nothing, a })
_scanner.DeleteRestorePoint()
Continue Do
End If
        _scanner.DeleteRestorePoint()
Dim pe = ReadPrimaryExpression()
İf pe IsNot Nothing Then
    queue.Enqueue( { pe })
    Continue Do
End If
Dim fe = ReadFunctionExpression()
İf fe IsNot Nothing Then
    queue.Enqueue( { fe })
    Continue Do
End If
İf _scanner.MatchNext(Grammar.New) Then
newDepth += 1
queue.Enqueue( { Grammar.New })
ElseIf _scanner.Match(Grammar.LeftSquareBracket) Then
    Dim e = ReadExpression()
    İf e İs Nothing Then
Throw New ParseException()
    End If
    İf (Not _scanner.MatchNext(Grammar.RightSquareBracket)) Then
        Throw New ParseException()
    End If
    queue.Enqueue({Nothing, Grammar.LeftSquareBracket, e, Grammar.RightSquareBracket})
ElseIf _scanner.Match(Grammar.FullStop) Then
    İf (Not _scanner.MatchNext(ElementType.IdentifierName)) Then
        Throw New ParseException()
    End If
    queue.Enqueue( { Nothing, Grammar.FullStop, _scanner.Current })
Else
    _scanner.Unwind()
    Exit Do
End If
    Loop
    İf queue.Count = 0 Then
_scanner.DeleteRestorePoint()
Return Nothing
    Else
        Dim element = Nothing
        Dim children = queue.Dequeue()
        Do While children(0) = Grammar.New
    children = queue.Dequeue()
        Loop
element = New Element(ElementType.MemberExpression, children)
Do While queue.Count > 0
    children = queue.Dequeue()
    İf children.Length = 3 AndAlso children(2).Type = ElementType.Arguments Then
    newDepth -= 1
    children(0) = Grammar.New
    children(1) = element
    element = New Element(ElementType.MemberExpression, children)
Else
children(0) = element
element = New Element(ElementType.MemberExpression, children)
End If
Loop
İf newDepth > 0 Then
    _scanner.Restore()
    Return Nothing
End If
_scanner.DeleteRestorePoint()
Return element
    End If
End Function

5 Son düzenleyen, cetinbasoz (22.05.2014 18:33:58)

Re: c# kodunu dönüştürme

Motomot olmayan cevirisi (motomot degil cunku o kod kotu yazilmis):

Visual Fox Pro
apino = "5"

User = "smsUsername"
Pass = "smsPassword"
baslik = "smsOriginator"
islem = "kayit"
 
Create Cursor SmsContainerList (telno c(10), mesaj c(50))
Insert Into SmsContainerList (telno, mesaj) Values ("1234567890", "Mesaj123")
Insert Into SmsContainerList (telno, mesaj) Values ("2344567890", "Mesaj234")
Insert Into SmsContainerList (telno, mesaj) Values ("4564567890", "Mesaj456")
 
PostMessages(m.apino, m.user, m.pass, m.baslik, m.islem, 'SmsContainerList')
 
Procedure PostMessages( apino, User, Pass, baslik, islem, cursorName )
    Local lcUrl
    lcUrl = CreateUrl(m.apino, m.user, m.pass, m.baslik, m.islem, m.cursorname)
 
    Local loXmlHttp As "Microsoft.XMLHTTP"
    loXmlHttp = Newobject( "Microsoft.XMLHTTP" )
    loXmlHttp.Open( "POST" , m.lcUrl, .F. )
    loXmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
    loXmlHttp.Send( )
 
    Messagebox( loXmlHttp.responsetext )
Endproc
 
Procedure CreateUrl(apino, User, Pass, baslik, islem, cursorName)
    Local lcUrl, lnSelect
    lnSelect = Select()
 
    Set Textmerge To Memvar m.lcUrl On Noshow
\\http://eracell.com.tr/eracellapiV2/test/yunus.php
\\|apiNo=<< m.apiNo >>
\\|user=<< m.user >>
\\|pass=<< m.pass >>
 
    Select (m.cursorName)
    Scan
\\|numaralar[]=<< Trim(TelNo) >>
    Endscan
    Scan
\\|mesaj[]=<< Trim(Mesaj) >>
    Endscan
\\|baslik=<< m.baslik >>
\\|islem=<< m.islem >>
    Set Textmerge To
    Set Textmerge Off
 
    lcUrl = Chrtran(m.lcUrl, '|', Chr(38))
    Select (m.lnSelect)
    Return m.lcUrl
Endproc

Ben original C# kodunun calistigini zannetmiyorum, bu da calismayacaktir ama boyle.

6

Re: c# kodunu dönüştürme

bu kodla bende ugrastim ama sakat bir SMS gonderim mantigi var (:
tum firmalar xml paket alip gonderirken bu firma illa string alma konusunda israrli sebeb : server kaynaklari kasmasin imis

http://www.soykansoft.com/images/twitter.jpghttp://www.soykansoft.com/images/wp.jpg