コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <param name="projectname"></param>
        /// <param name="workinglayer"></param>
        /// <param name="query_fullname"></param>
        /// <param name="startobject_fullname"></param>
        /// <returns></returns>
        public TResult <CQueryResult> ExecuteQuery(string user, string projectname, int workinglayer, string query_fullname, string startobject_fullname)
        {
            try
            {
                if (m_ComosSession == null)
                {
                    return(new TResult <CQueryResult>()
                    {
                        Status = false,
                        Message = "Session is NULL",
                    });
                }

                m_ComosSession.SetCurrentUser(user);
                m_ComosSession.SetCurrentProjectAndWorkingOverlay(projectname, workinglayer);
                var device = m_ComosSession.GetDeviceByFullName(query_fullname);
                Plt.IComosBaseObject startobject = null;
                if (!string.IsNullOrEmpty(startobject_fullname))
                {
                    startobject = m_ComosSession.GetDeviceByFullName(startobject_fullname);
                }
                var table = m_ComosSession.GetQueryData(device, startobject);

                return(new TResult <CQueryResult>()
                {
                    data = table,
                    Status = true,
                });
            }
            catch (Exception ex)
            {
                Log.WriteLog(ex.Message + ":ExecuteQuery", System.Diagnostics.EventLogEntryType.Warning);
                System.Diagnostics.Debug.Assert(false);
            }
            return(null);
        }