/// <summary> /// Converter from CompareKind to String /// </summary> /// <param name="connection">Connection</param> /// <param name="parameter">Parameter</param> /// <param name="CompareKind">Compare Type</param> /// <returns>CompareKind converted into string with format</returns> public static String SignWithFormat(DbConnection connection, RecordParameter parameter, CompareKind CompareKind) { //if (connection == null) // connection = Record.SharedProviderFactory.CreateConnection(); String pName = InternalConvert.ConvertQueryArgument(connection, parameter.ParameterName); switch (CompareKind) { case CompareKind.None: return(String.Format(" ([{0}] = {1}) ", parameter.ParameterField, pName)); case CompareKind.Equal: return(String.Format(" ([{0}] = {1}) ", parameter.ParameterField, pName)); case CompareKind.IsNULL: return(String.Format(" ([{0}] IS NULL) ", parameter.ParameterField)); case CompareKind.Major: return(String.Format(" ([{0}] > {1}) ", parameter.ParameterField, pName)); case CompareKind.Minor: return(String.Format(" ([{0}] < {1}) ", parameter.ParameterField, pName)); case CompareKind.IsNotNULL: return(String.Format(" ([{0}] IS NOT NULL) ", parameter.ParameterField)); case CompareKind.NotEqual: return(String.Format(" ([{0}] <> {1}) ", parameter.ParameterField, pName)); case CompareKind.Like: return(String.Format(" ([{0}] LIKE '%{1}%') ", parameter.ParameterField, parameter.Value)); case CompareKind.In: if (parameter.Value is IList) { String listFieldValue = ""; foreach (var item in (IList)parameter.Value) { listFieldValue += "," + item; } return(String.Format(" ([{0}] IN ({1})) ", parameter.ParameterField, listFieldValue.Substring(1))); } else { return(String.Format(" ([{0}] IN ({1})) ", parameter.ParameterField, parameter.Value)); } case CompareKind.MajorAndEqual: return(String.Format(" ([{0}] >= {1}) ", parameter.ParameterField, pName)); case CompareKind.MinorAndEqual: return(String.Format(" ([{0}] <= {1}) ", parameter.ParameterField, pName)); case CompareKind.IsNullOrEmpty: return(String.Format(" (([{0}] IS NULL) OR ([{0}] = '')) ", parameter.ParameterField)); default: return(String.Format(" ([{0}] = {1}) ", parameter.ParameterField, pName)); } }
/// <summary> /// Create a new parameter instance /// </summary> /// <param name="pParameterName">Parameter's name</param> /// <param name="pCompareKind">Compare operation</param> /// <param name="pValue">Parameter's value</param> /// <returns>Parameter</returns> protected RecordParameter CreateParameter(String pParameterName, CompareKind pCompareKind, object pValue) { if (ProviderFactory == null) { throw new RecordProviderFactoryNullException("Provider Factory is null"); } DbParameter parameter = (DbParameter)ProviderFactory.CreateParameter(); parameter.ParameterName = pParameterName; parameter.Value = pValue != null ? pValue : String.Empty; RecordParameter rparameter = new RecordParameter(parameter, pCompareKind); return(rparameter); }
/// <summary> /// Prints records that has specified values /// </summary> /// <param name="parameters">Key-value array with key for property and value for record value</param> public static void FindCommand(List <string> parameters) { parameters.RemoveAt(0); Dictionary <RecordParameter, object> searchParams = new Dictionary <RecordParameter, object>(); foreach (var parameter in parameters) { string parameterStr = parameter.Split(':')[0]; string valueStr = parameter.Split(':')[1]; RecordParameter enumParam = StrParamToEnum(parameterStr); object parsedValue = null; if (enumParam == RecordParameter.WrongParameter) { Console.WriteLine("Wrong parameter in find command"); return; } else if (enumParam == RecordParameter.DateOfBirth) { DateTime date; if (!DateTime.TryParse(valueStr, out date)) { Console.WriteLine("Wrong date of birth in find command"); return; } parsedValue = date; } else if (enumParam == RecordParameter.ID) { int idToFind = 0; if (!int.TryParse(valueStr, out idToFind)) { Console.WriteLine("Wrong id in find command"); return; } parsedValue = idToFind; return; } else { parsedValue = valueStr; } searchParams.Add(enumParam, parsedValue); } DatabaseCommands.FindRecords(searchParams); }
/// <summary> /// Create a new parameter instance /// </summary> /// <typeparam name="TRECORD">A generic Record type</typeparam> /// <param name="pParameterName">Parameter's name</param> /// <param name="pCompareKind">Compare operation</param> /// <param name="pValue">Parameter's value</param> /// <returns>Parameter</returns> public static RecordParameter CreateParameter <TRECORD>(String pParameterName, CompareKind pCompareKind, object pValue) where TRECORD : Record, new() { object[] customs = typeof(TRECORD).GetCustomAttributes(true); //foreach (object obj in customs) // if (obj is FieldProviderName) // SharedProviderFactory = CreateProviderFactoty((obj as FieldProviderName).ProviderSupport); //if (SharedProviderFactory == null) // throw new RecordProviderFactoryNullException("Provider Factory is null"); //DbParameter parameter = (DbParameter)SharedProviderFactory.CreateParameter(); DbParameter parameter = (DbParameter) new TRECORD().ProviderFactory.CreateParameter(); parameter.ParameterName = pParameterName; parameter.Value = pValue != null ? pValue : String.Empty; RecordParameter rparameter = new RecordParameter(parameter, pCompareKind); return(rparameter); }
public Task <ReturnMessage> SetRecordParameter(RecordParameter recordParameter) { Task <ReturnMessage> checkTask = _meetingManager.CheckMeetingServerStatus(); if (checkTask != null) { return(checkTask); } var tcs = new TaskCallback <ReturnMessage>("SetRecordParameter"); if (_meetingManager.TaskCallbacks.ContainsKey(tcs.Name)) { _meetingManager.TaskCallbacks.Remove(tcs.Name); } _meetingManager.TaskCallbacks.Add(tcs.Name, tcs); RecordParam recordParam = new RecordParam() { AudioBitrate = recordParameter.AudioBitrate, BitsPerSample = recordParameter.BitsPerSample, Channels = recordParameter.Channels, Height = recordParameter.Height, SampleRate = recordParameter.SampleRate, VideoBitrate = recordParameter.VideoBitrate, Width = recordParameter.Width }; var result = MeetingAgent.SetRecordParam(recordParam); if (result != 0) { return(Task.FromResult(MessageManager.FailedToSetRecordParameter)); } return(tcs.Task); }
public bool GetRecordParam() { if (!File.Exists(ConfigFile)) { return(false); } try { RecordParameter recordParam = new RecordParameter() { AudioBitrate = 64, BitsPerSample = 16, Channels = 1, SampleRate = 8000, VideoBitrate = int.Parse(GlobalData.Instance.AggregatedConfig.RecordConfig.CodeRate) }; string[] resolutionStrings = GlobalData.Instance.AggregatedConfig.RecordConfig.Resolution.Split(new[] { '*' }, StringSplitOptions.RemoveEmptyEntries); recordParam.Width = int.Parse(resolutionStrings[0]); recordParam.Height = int.Parse(resolutionStrings[1]); RecordParam = recordParam; RecordDirectory = GlobalData.Instance.AggregatedConfig.RecordConfig.RecordPath; return(true); } catch (Exception ex) { Log.Logger.Error($"【get record param exception】:{ex}"); return(false); } }
/// <summary> /// Converter from CompareKind to String /// </summary> /// <param name="parameter">Parameter</param> /// <param name="CompareKind">Compare Type</param> /// <returns>CompareKind converted into string with format</returns> public static String SignWithFormat(RecordParameter parameter, CompareKind CompareKind) { return(SignWithFormat(null, parameter, CompareKind)); }