public static bool UpdateManagerSettings(Guid userId,Guid settingId,SettingParameterType type, Dictionary<string, object> fieldAndValues) { string settingDetails = SettingParameterHelper.GetSettingDetailsUpdateXml(settingId, type, fieldAndValues); using (SqlConnection sqlConnection = DataAccess.GetInstance().GetSqlConnection()) { SqlCommand sqlCommand = sqlConnection.CreateCommand(); sqlCommand.CommandText = "dbo.P_SettingsDetailParameter_Upd"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandTimeout = 60 * 30; SqlParameter parameter = new SqlParameter("@userId", SqlDbType.UniqueIdentifier); parameter.Value = userId; sqlCommand.Parameters.Add(parameter); parameter = new SqlParameter("@settingId", SqlDbType.UniqueIdentifier); parameter.Value = settingId; sqlCommand.Parameters.Add(parameter); parameter = new SqlParameter("@settingDetailsXml", SqlDbType.NText); parameter.Value = settingDetails; sqlCommand.Parameters.Add(parameter); SqlParameter resultParameter = new SqlParameter("@result", SqlDbType.Bit); resultParameter.Direction = ParameterDirection.Output; sqlCommand.Parameters.Add(resultParameter); sqlCommand.ExecuteNonQuery(); return (bool)sqlCommand.Parameters["@result"].Value; } }
public static string GetSettingDetailsUpdateXml(Guid settingId, SettingParameterType type, Dictionary<string, object> fieldAndValues) { XmlDocument doc = new XmlDocument(); XmlElement settingDetailRoot = doc.CreateElement("SettingDetails"); foreach (string parameterKey in fieldAndValues.Keys) { object parameterValue = fieldAndValues[parameterKey]; XmlElement settingElement = doc.CreateElement("SettingDetail"); settingElement.SetAttribute("SettingId", settingId.ToString()); settingElement.SetAttribute("ParameterKey", parameterKey); settingElement.SetAttribute("ParameterValue", parameterValue.ToString()); settingElement.SetAttribute("SettingParameterType", ((byte)type).ToString()); settingDetailRoot.AppendChild(settingElement); } doc.AppendChild(settingDetailRoot); return doc.OuterXml; }
public void UpdateManagerSettings(Guid settingId,SettingParameterType type,Dictionary<string, object> fieldAndValues, Action<bool> NotifyResult) { this._ServiceProxy.BeginUpdateManagerSettings(settingId,type, fieldAndValues, delegate(IAsyncResult ar) { bool result = this._ServiceProxy.EndUpdateManagerSettings(ar); App.MainFrameWindow.Dispatcher.BeginInvoke((Action<bool>)delegate(bool success) { NotifyResult(success); }, result); }, null); }