wcf项目中我的方法实现中的错误 [英] error in the implementation of my method in my wcf project

查看:119
本文介绍了wcf项目中我的方法实现中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


当我实现方法
MiseAjourEtatFactureWCF(ref string REF_COMPTE_FACTURATION, ref int STATUT)
在我的wcf项目中,出现以下错误:

错误:

无效的表达词"if"

代码:

Hi,
when i implement the method
MiseAjourEtatFactureWCF(ref string REF_COMPTE_FACTURATION, ref int STATUT)
in my wcf project this following error has appeared:

error:

Invalid expression term ''if''

code:

public retour MiseAjourEtatFactureWCF(ref string REF_COMPTE_FACTURATION, ref int STATUT)
{
  Service1 ser = new Service1();
  retour rt = new retour();
  ser.MiseAJourFacture( //removed this
  if (ser.MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT).Equals(-1))
  {
    try
    {
      rt.CodeRetour = -1;
      rt.msgRetour = "mise à jour etat facture échoué";
    }
    catch (Exception e)
    {
      CreateLog log = new CreateLog(e);

      log.ErrorLog(@"C:\Documents and Settings\Administrateur\Bureau\fichierLog.txt");
    }

    return rt;
  }
  else
  {
    rt.CodeRetour = 0;
    rt.msgRetour = "mise à jour etat facture réussit";
    return rt;
  }
}





知道此方法的目标是返回错误消息并在方法调用失败的情况下创建日志文件
MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT)以及成功调用此方法的情况下的成功消息.

[添加]
问题出在if循环中,因为当我运行我的项目时,它总是向我展示成功的案例
[/添加]

请帮助我,因为我是初学者. :((:((:((

[已修改:对于较大的代码块,pre标记要好得多.添加单行代码时,可以使用代码标签.另外,只需很少的时间来添加适当的间距就可以更轻松地获得答案.]





knowing that the goal of this method is to return error an message and to create log file in the case of failed call of the method
MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT) and the succes message in the case of succeeded call of this method.

[Added]
the problem is in if loop because when i run my project it show me always the case of success
[/Added]

Please help me because i''m a beginner. :(( :(( :((

[Modified: pre tags are much better for large blocks of code. code tags can be used when adding single lines of code. Also, just a small amount of time to add the proper spacing makes getting answers much easier.]

推荐答案

好,所以您的问题是它总是成功返回?对我来说,这听起来不像是个问题.

好吧,如果您永远都不会收到消息; 期待",这是一个问题,但是在不知道ser是什么或MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT)在不同情况下应该返回什么的情况下,我无法告诉您原因它不起作用.

我会说,尽管您永远都不会创建错误日志.因为,我假设
Ok, so your problem is that it always returns successfully? That doesn''t sound like a problem to me.

Well, if you''re never getting the message; "mise à jour etat facture échoué", and you''re expecting to, then that is a problem, but without knowing what ser is or what MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT) should return with different cases, I can''t tell you why it''s not working.

I will say that you should never get an error log created though. Because, I would assume that
rt.CodeRetour = -1;
rt.msgRetour = "mise à jour etat facture échoué";


永远不要抛出错误.

另外,我对您的CreateLog感到有些困惑.您创建一个新的日志,并将其传递给异常.然后,您向它传递一个文件位置.那是你自己写的课吗?因为如果是这样,您似乎会倒退.通常,您在磁盘上创建日志文件或在磁盘上打开日志文件,然后将信息传递给日志文件.



[您已经解决了]
您的问题似乎在这里:

ser.MiseAJourFacture(
如果(ser.MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT).Equals(-1))

您有一个不完整的声明.我不知道ser.MiseAJourFacture有什么用,但是它说那是一个关于if的无效表达式,因为您没有完成该语句.

如果它是一种对Ser起作用的方法调用,则它可以是独立的,但可能不需要存在.如果有,请尝试将其更改为:
ser.MiseAJourFacture( );
if(ser.MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT).Equals(-1))


should never throw an error.

Also, I''m a little confused with what your CreateLog is. You create a new log and pass it the exception. Then, you pass it a file location. Is that a class you wrote yourself? Because if so, you seem to do it backwards. Generally, you create a log file on disk or open a log file on disk, and then you pass it the information to put into the log.



[You''ve dealt with this]
It looks like your problem is here:

ser.MiseAJourFacture(
if (ser.MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT).Equals(-1))

You have an icomplete statement. I don''t know what the ser.MiseAJourFacture is there for, but it''s saying that the if is an invalid expression with regards to that because you didn''t finish that statement.

If it''s a method call that does some work to ser, then it could stand-alone, but it may not need to be there. if it does, try changing it to:
ser.MiseAJourFacture();
if (ser.MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT).Equals(-1))


这篇关于wcf项目中我的方法实现中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆