zoukankan      html  css  js  c++  java
  • Aras学习笔记 (14) DotNet操作Aras常用代码代码汇总(陆续更新中)

    1、连接Aras Innovator。

    HttpServerConnection conn = IomFactory.CreateHttpServerConnection("http://localhost/InnovatorServer/", "InnovatorSolutions", "admin", "innovator");
    Item login = conn.Login();
    Innovator inn = IomFactory.CreateInnovator(conn);
    if (inn != null)
    {
      
    }

    2、AML格式举例。

    string aml = "<AML><Item type='User' action='get'><id>3C70CC6FD09B480092E49C12D4845392</id></Item></AML>"; //单条数据
    //string aml = "<AML><Item type='User' action='get'></Item></AML>"; //多条数据

    3、获取Item实体类的泛型方法。

    /// <summary>
        /// 得到对象
        /// </summary>
        /// <param name="xml">传入值如user.node.InnerXml参数</param>
        /// <returns></returns>
        public T GetModelFromXml<T>(string xml)
        {
            T obj = default(T);
    
            try
            {
                //1、读取Xml
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xml);
                XmlNodeList nodeList = xmlDoc.GetElementsByTagName("Item");
    
                //2、取得对象属性列表
                PropertyInfo[] propertyList = typeof(T).GetProperties();
    
                //3、取得第一个节点
                XmlNode node = nodeList[0];
                obj = Activator.CreateInstance<T>();//创建指定类型实例
    
                foreach (PropertyInfo property in propertyList)
                {
                    for (int i = 0; i < node.ChildNodes.Count; i++)
                    {
                        if (node.ChildNodes[i].Name.ToLower() == property.Name.ToLower())
                        {
                            property.SetValue(obj, node.ChildNodes[i].InnerText, null);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
    
            }
            finally
            {
                
            }
    
            return obj;
        }

     4、记录windows事件日志。

    System.Diagnostics.EventLog MyEventLog = new System.Diagnostics.EventLog();
    MyEventLog.WriteEntry("Terminating - no jobs to process",EventLogEntryType.Error);

     5、循环Item列表:

    Item UserList = this.newItem("user", "get");
    UserList = UserList .apply();
    
    for(int i=0;i<UserList .getItemCount();i++)
    {
        string Id = UserList.getItemByIndex(i).getProperty("id","");
        string LoginName= UserList .getItemByIndex(i).getProperty("login_name","");
    }
    

    6、获取当前时间:

    string dt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
    

    7、

  • 相关阅读:
    利用virtual box安装ubuntu16.4,没有继续(下一步)的解决方案
    最好用的几个谷歌镜像(推荐理由:无广告)
    vs2017和vs2019专业版和企业版
    c# List根据某个属性进行分类,变成以属性名称作为分类的多个List
    vs2015安装编辑神器:resharper10.0
    c# 正则表达式替换字符串中常见的特殊字符
    IL中间语言指令大全
    c#进阶一:使用ILDASM来查看c#中间语言
    SQL server脚本语句积累
    SQLServer事务在C#当中的应用
  • 原文地址:https://www.cnblogs.com/61007257Steven/p/10007704.html
Copyright © 2011-2022 走看看