private void ProcessNormally(System.Data.SqlClient.SqlDataReader reader)
        {
            RuleSetDefinition dto;
            XmlDocument       document;

            using (reader)
            {
                while (reader.Read())
                {
                    dto      = new RuleSetDefinition();
                    document = new XmlDocument();

                    dto.OrganizationID =
                        _customDatabaseHelper.retrieveGuidFromDataReader(reader.GetOrdinal(DataAccessConstants.RuleTable.ORGANIZATION_ID_COLUMN), reader);
                    dto.RuleName =
                        _customDatabaseHelper.resolveNullString(reader.GetOrdinal(DataAccessConstants.RuleTable.RULE_NAME_COLUMN), reader);
                    dto.Definition =
                        _customDatabaseHelper.retrieveNullableTypeFromDataReader(reader.GetOrdinal(DataAccessConstants.RuleTable.DEFINITION_COLUMN), reader);
                    dto.Paused =
                        _customDatabaseHelper.resolveNullBoolean(reader.GetOrdinal(DataAccessConstants.RuleTable.PAUSED_COLUMN), reader);
                    dto.DateCreated =
                        _customDatabaseHelper.resolveNullDateTime(reader.GetOrdinal(DataAccessConstants.RuleTable.DATE_CREATED_COLUMN), reader);
                    dto.CreatedBy =
                        _customDatabaseHelper.retrieveGuidFromDataReader(reader.GetOrdinal(DataAccessConstants.RuleTable.CREATED_BY_COLUMN), reader);
                    dto.RuleID =
                        _customDatabaseHelper.retrieveGuidFromDataReader(reader.GetOrdinal(DataAccessConstants.RuleTable.RULE_ID_COLUMN), reader);

                    document.Load(reader.GetSqlXml(reader.GetOrdinal(DataAccessConstants.RuleTable.DEFINITION_COLUMN)).CreateReader());

                    dto.SourceXmlDocument = document;

                    this.Add(dto);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Возвращает настройки для импорта данных в приложение к плану
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <returns>список настроек</returns>
        public static CSettingForImportData GetSettingForImportDataInPlanByDepartCustomerSubtype(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL)
        {
            CSettingForImportData objRet = null;

            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        DevExpress.XtraEditors.XtraMessageBox.Show(
                            "Не удалось получить соединение с базой данных.", "Внимание",
                            System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        return(objRet);
                    }
                    cmd             = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection  = DBConnection;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                }
                else
                {
                    cmd = cmdSQL;
                    cmd.Parameters.Clear();
                }

                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetImportDataInPlanByDepartCustomerSubtypeSettings]", objProfile.GetOptionsDllDBName());
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_NUM", System.Data.SqlDbType.Int, 8, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_MES", System.Data.SqlDbType.NVarChar, 4000));
                cmd.Parameters["@ERROR_MES"].Direction = System.Data.ParameterDirection.Output;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    rs.Read();
                    {
                        objRet              = new CSettingForImportData();
                        objRet.ID           = (System.Guid)rs["Settings_Guid"];
                        objRet.Name         = System.Convert.ToString(rs["Settings_Name"]);
                        objRet.SettingsList = new List <CSettingItemForImportData>();

                        objRet.XMLSettings = new System.Xml.XmlDocument();
                        objRet.XMLSettings.LoadXml(rs.GetSqlXml(2).Value);

                        foreach (System.Xml.XmlNode objNode in objRet.XMLSettings.ChildNodes)
                        {
                            foreach (System.Xml.XmlNode objChildNode in objNode.ChildNodes)
                            {
                                objRet.SettingsList.Add(new CSettingItemForImportData()
                                {
                                    TOOLS_ID          = System.Convert.ToInt32(objChildNode.Attributes["TOOLS_ID"].Value),
                                    TOOLS_NAME        = System.Convert.ToString(objChildNode.Attributes["TOOLS_NAME"].Value),
                                    TOOLS_USERNAME    = System.Convert.ToString(objChildNode.Attributes["TOOLS_USERNAME"].Value),
                                    TOOLS_DESCRIPTION = System.Convert.ToString(objChildNode.Attributes["TOOLS_DESCRIPTION"].Value),
                                    TOOLS_VALUE       = System.Convert.ToInt32(objChildNode.Attributes["TOOLS_VALUE"].Value),
                                    TOOLSTYPE_ID      = System.Convert.ToInt32(objChildNode.Attributes["TOOLSTYPE_ID"].Value)
                                });
                            }
                        }
                    }
                }
                rs.Dispose();

                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(
                    "Не удалось получить список настроек.\n\nТекст ошибки: " + f.Message, "Внимание",
                    System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            return(objRet);
        }
示例#3
0
        /// <summary>
        /// Возвращает список настроект
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="SettingNamesListForInitParams">список имён настроек, параметры которых необходимо проинициализировать</param>
        /// <param name="strErr">текст ошибки</param>
        /// <returns>список настроект</returns>
        public static List <CSettingForImportData> GetSettingslist(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL,
                                                                   List <System.String> SettingNamesListForInitParams, ref System.String strErr)
        {
            List <CSettingForImportData> objRet = new List <CSettingForImportData>();

            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr += ("\nНе удалось получить соединение с базой данных.");
                        return(objRet);
                    }
                    cmd             = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection  = DBConnection;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                }
                else
                {
                    cmd = cmdSQL;
                    cmd.Parameters.Clear();
                }

                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetSettings]", objProfile.GetOptionsDllDBName());
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_NUM", System.Data.SqlDbType.Int, 8, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_MES", System.Data.SqlDbType.NVarChar, 4000));
                cmd.Parameters["@ERROR_MES"].Direction = System.Data.ParameterDirection.Output;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    CSettingForImportData objItem = null;
                    while (rs.Read())
                    {
                        objItem              = new CSettingForImportData();
                        objItem.ID           = (System.Guid)rs["Settings_Guid"];
                        objItem.Name         = ((rs["Settings_Name"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["Settings_Name"]));
                        objItem.UserName     = ((rs["Settings_UserName"] == System.DBNull.Value) ? System.Convert.ToString(rs["Settings_Name"]) : System.Convert.ToString(rs["Settings_UserName"]));
                        objItem.SettingsList = new List <CSettingItemForImportData>();

                        objItem.XMLSettings = new System.Xml.XmlDocument();
                        objItem.XMLSettings.LoadXml(rs.GetSqlXml(2).Value);

                        if (SettingNamesListForInitParams.SingleOrDefault <String>(x => x == objItem.Name) != null)
                        {
                            foreach (System.Xml.XmlNode objNode in objItem.XMLSettings.ChildNodes)
                            {
                                foreach (System.Xml.XmlNode objChildNode in objNode.ChildNodes)
                                {
                                    objItem.SettingsList.Add(new CSettingItemForImportData()
                                    {
                                        TOOLS_ID          = System.Convert.ToInt32(objChildNode.Attributes["TOOLS_ID"].Value),
                                        TOOLS_NAME        = System.Convert.ToString(objChildNode.Attributes["TOOLS_NAME"].Value),
                                        TOOLS_USERNAME    = System.Convert.ToString(objChildNode.Attributes["TOOLS_USERNAME"].Value),
                                        TOOLS_DESCRIPTION = System.Convert.ToString(objChildNode.Attributes["TOOLS_DESCRIPTION"].Value),
                                        TOOLS_VALUE       = System.Convert.ToInt32(objChildNode.Attributes["TOOLS_VALUE"].Value),
                                        TOOLSTYPE_ID      = System.Convert.ToInt32(objChildNode.Attributes["TOOLSTYPE_ID"].Value)
                                    });
                                }
                            }
                        }

                        objRet.Add(objItem);
                    }
                }
                rs.Dispose();

                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                strErr += (String.Format("Не удалось получить список настроек.\n\nТекст ошибки: {0}", f.Message));
            }
            return(objRet);
        }