饮酒买醉

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  9 随笔 :: 15 文章 :: 9 评论 :: 1 Trackbacks

2006年1月6日 #

将数据库从Win平台下的Oracle转到unix下后,突然某张表的查询操作报错。“cannot select a record  The SQL database has issued an error”。编译该表,对应的Form和Class都不起作用。最后终于在微软AX网站上找到了原因:

“Axapta normaly not synchronize the AOD to the Database directly, Axapta uses the Table 'SQLDictionary' to recognize
differences between AOD and Database. Only the "check/synchronize" prozedure from Admin menu does check the real
SQL Dictionary in the database.”

posted @ 2008-07-19 11:52 饮酒买醉 阅读(6) | 评论 (0)编辑

server static void Job1(Args _args)
{
      CLRObject rdm;
      CLRObject num;
      int value;
      rdm = new CLRObject(\'System.Random\');
      num = rdm.Next();
        value = CLRInterop::getAnyTypeForObject(num);
      box::info(int2str(value));

static void Job1(Args _args)
{
    DLL dll ;
    DLLFunction interFaceLibrary;
    ;

    dll = new DLL(\'Net_DLL_Ax.dll\');
    interFaceLibrary  = new DLLFunction(dll,\'FirstClass.GetInformation\');

    interFaceLibrary.returns(ExtTypes::String);
   info(interFaceLibrary.call());

}

DLL文件C#代码:

using System;

namespace Net_DLL_Ax
{
    public class FirstClass
    {
        public FirstClass()
        {
        }

        public static string GetInformation()
        {
            return "HelloWorld";
        }
    }
}

 

 

总结了一下AX中调用NET中的DLL时要注意的一些方面(服务器端的部署):

1.在服务器上注册DLL程序集文件到GAC(全局程序集缓存)中,可以使用.Net的工具gacutil -i assemblyname.dll。

2.在ax中添加对NET的DLL文件的引用。

3.在代码中调用DLL之前要开启权限:

    Set                                     _assertSet;
    InteropPermission                       _ipCLR;    ;

    _assertSet = new Set(Types::Class);
    _ipCLR = new InteropPermission(InteropKind::ClrInterop);

    _assertSet.add(_ipCLR);

    CodeAccessPermission::assertMultiple(_assertSet);

部署好了以后就可以直接在客户端直接运行服务器端调用NET中DLL的项目了。

最郁闷的是按照步骤也不成功:( ,经验告诉我们“重启AX”!!!

posted @ 2008-07-02 09:03 饮酒买醉 阅读(60) | 评论 (2)编辑

备忘:Excel导出大数据量时使用了会报此错误。

调查原因:

progress.setText(strfmt("Exporting Records %1", i));

progress.incCount(1);

最简单的解决方法:注释掉此句。时间紧,暂时不调查更明确的原因。

posted @ 2008-06-18 10:06 饮酒买醉 阅读(12) | 评论 (0)编辑

 

1:直接调用函数

       str 24 ComName;

       ;

       ComName=appl.company().ext();//当前公司ID

       curUserid();//当前用户iD

       systemDateget();//当前时间

       Time2Str(timenow(),1,2);//时间转换函数

       curuserid()//当前用户

 

2,使用Session对象

       session xSession;

       ;

       xSession=new session();

       print xsession.userId();pause;

       print xsession.interfaceLanguage();pause;

 

3,使用XInfo对象

static void currentConfiguartion(Args _args)

{

       AOSSessionInfo info = new AOSSessionInfo();

       SqlSystem SqlSystem = new SqlSystem();

       ;

       print xinfo::componentName();

       print xinfo::configuration();

       print xinfo::dbName();

       print xinfo::licenseName();

       print xinfo::releaseVersion();

       print info.clientMode();

       print SqlSystem.loginConnectString();

       print xinfo::directory(directorytype::Appl);

       print xinfo::directory(directorytype::DB);//....

 

       pause;

 

}

4,得到数据库信息: 我们可以使用类SqlSystem得到数据库的信息,

static void Job52(Args _args)

{

    sqlsystem sql;

    ;

    sql=new sqlsystem();

    print sql.databaseName();

    print sql.databaseId();

    print sql.loginServer();

    print sql.loginDatabase();

    print sql.loginName();

    pause;

}

 

5,取余,取整,取小数

static void job1 (Args   args)
{

real i,j;

  ;

  i=10;

  j=3;

  print trunc(i/j);              //取整

  print frac(i/j);                //小数

  print i-j*trunc(i/j);        //取余

  pause;

}

 

6, 判断文件访问权限

 

private void checkFileAccess(Filename _filename)

{

    #WinAPI

 

    FilePath            filePath = conpeek(fileNameSplit(_filename), 1);

    Filename            filename = 'AxaptaTestFile';

    str                 fileExt  = '.Axapta';

 

    Filename            testFilename;

    int                 handle;

 

    Counter             counter;

 

    Filename getFileName()

    {

        ;

        counter ++;

        return filePath + filename + strRFix(int2str(counter), 3, '0') + fileExt;

    }

 

    do

    {

        testFilename = getFileName();

    }

    while (WinAPI::fileExists(testFilename));

 

    handle = WinAPI::createFile(testFilename, #CREATE_NEW, #CREATE_ALWAYS);

 

    if (handle == -1)

    {

        throw error("@SYS97423");

    }

 

    WinAPI::closeHandle(handle);

    WinAPI::deleteFile(testFilename);

}

posted @ 2008-06-02 17:09 饮酒买醉 阅读(9) | 评论 (0)编辑

学会至少半打编程语言。包括一门支持类抽象(class abstraction)的语言(如Java或C++),一门支持函数抽象(functional abstraction)的语言(如Lisp或ML),一门支持句法抽象(syntactic abstraction)的语言(如Lisp),一门支持说明性规约(declarative specification)的语言(如Prolog或C++模版),一门支持协程(coroutine)的语言(如Icon或Scheme),以及一门支持并行处理(parallelism)的语言(如Sisal)。
好多听都没听过……,程序员的路越走越没有尽头。
posted @ 2006-02-03 23:07 饮酒买醉 阅读(97) | 评论 (0)编辑

以前收藏了徐虎专栏里的一篇AD操作的类,后来的AD操作省了不少的时间。但今天发现类中的一个小错误。就是新建用户后,启用帐户时代码不正确。
原代码:
  /// 
  /// 启用指定 的用户
  /// 
  /// 
  public static void EnableUser(DirectoryEntry de)
  {
   impersonate.BeginImpersonate();
   de.Properties["userAccountControl"][0] =  ADClass.ADS_USER_FLAG_ENUM.ADS_UF_NORMAL_ACCOUNT | ADClass.ADS_USER_FLAG_ENUM.ADS_UF_DONT_EXPIRE_PASSWD;
   de.CommitChanges();
   impersonate.StopImpersonate();
   de.Close();
  }
上面的ADClass.ADS_USER_FLAG_ENUM.ADS_UF_NORMAL_ACCOUNT = 0X0200;    //普通用户的默认帐号类型
            ADClass.ADS_USER_FLAG_ENUM.ADS_UF_DONT_EXPIRE_PASSWD = 0X10000;   //密码永不过期标志

上述代码运行时竟让报“该服务器不愿意处理该请求”?狂晕!!!第一次遇见这种异常消息!!

后来在微软网站找到了原因所在:Enabling and Disabling the User Account 
启用帐号:

DirectoryEntry usr = 
    new DirectoryEntry("LDAP://CN=New User,CN=users,DC=fabrikam,DC=com");
int val = (int) usr.Properties["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val & ~ADS_UF_ACCOUNTDISABLE;
usr.CommitChanges();


上班时间就不多废话了,userAccountControl的其他属性操作请查阅ADS_USER_FLAG_ENUM




posted @ 2006-01-16 15:52 饮酒买醉 阅读(393) | 评论 (4)编辑

using System.DirectoryServices;

try
            
{

                
string sAMAccountName = "xingtingting";
                
string newPassword = "12345678";
                
//iw.local/OU=HXZ,
                DirectoryEntry de = new DirectoryEntry("LDAP://iw.local/OU=HXZ,DC=iw,DC=local","iw\\spsadmin","iswind",AuthenticationTypes.Sealing );
                DirectorySearcher deSearch 
= new DirectorySearcher(de);
                deSearch.Filter    
= "(&(&(objectCategory=person)(objectClass=user))(sAMAccountName=" + sAMAccountName    + "))";
                deSearch.SearchScope 
= SearchScope.Subtree;
                SearchResult result    
= deSearch.FindOne();
                de 
= new DirectoryEntry(result.Path);
                de.Invoke(
"SetPassword"new object[]{newPassword});
                de.CommitChanges();
                de.Close();

                System.Windows.Forms.MessageBox.Show(
"修改成功!");

            }

            
catch (Exception ex)
            
{
                
throw ex;
            }
执行至:de.Invoke("SetPassword",new object []{newPassword});抛异常。
在AD服务器上运行正常,但在加入域的服务器运行就出错。可以断定应该不是程序的问题,但找了很久也没找到解决办法。后来在http://www.highdots.com/forums/asp-net-security/change-password-active-directory-webapplication-700434.html看到一段话:
You may need to experiment with different variations on the dcDNS variable
and you may need to remove the ServerBind flag if you are using a NETBIOS
name. Also, you may need to remove the Sealing flag as well, but be warned
that in order to set or change passwords, some sort of encrypted channel
(SSL or Kerberos) must be available.
突然想到犯了一个低级错误!没有把DNS设置正确!!因为测试AD服务器也是DNS服务器,所以需要把AD服务器的地址配到本机的DNS中。配置后运行成功!
posted @ 2006-01-07 12:08 饮酒买醉 阅读(1331) | 评论 (2)编辑

一个困扰很久的问题!!!
需求:将AD用户密码和SSO中的帐户密码进行同步,因为AD中是取不出密码的,所以在用户修改AD密码的同时修改对应SSO的密码。
遇到的问题:
   WindowsImpersonationContext wic = null;
   try
   {
    wic = CreateIdentity("administrator", "iswind", "iswind").Impersonate(); //提升权限
    string [] args = new string[2];
    //userName
    args[0] = "username";
    //pwd
    args[1] = "12345678";
    //应用名
    string AppName = "SSOApp";

    string domainAndName = "iswind\\username"; 
    Credentials.SetUserCredentials(AppName,domainAndName,args);
   }
   catch (SingleSignonException ex)
   {
    throw ex;
   }
   finally
   {
    wic.Undo();
   } 
此段代码运行在web应用程序里报错:到Credentials.SetUserCredentials(AppName,domainAndName,args);
报错:服务器应用程序不可用
但是如果把此代码编译成Win程序就可以正常执行,而且在portal里手工更改用户密码也是正常的。现在可能的原因就是SPS配置问题了,但是具体哪个地方的问题我还是搞不清楚,希望高手能帮帮我!感激不尽。

posted @ 2006-01-06 14:12 饮酒买醉 阅读(425) | 评论 (0)编辑