private void CheckIn() { using (var trans = DBFactory.GetDatabase().StartTransaction()) using (var conn = trans.Connection) { try { if (!GetCheckData()) { return; } Waiting(); int rows = 0; rows += DBFactory.GetDatabase().UpdateValue(DevicesCols.TableName, DevicesCols.CheckedOut, 0, DevicesCols.DeviceGuid, currentTrackingDevice.Guid, trans); ParamCollection checkParams = new ParamCollection(); checkParams.Add(TrackablesCols.CheckType, CheckType.Checkin); checkParams.Add(TrackablesCols.CheckoutTime, checkData.CheckoutTime); checkParams.Add(TrackablesCols.DueBackDate, checkData.DueBackTime); checkParams.Add(TrackablesCols.CheckinTime, checkData.CheckinTime); checkParams.Add(TrackablesCols.CheckoutUser, checkData.CheckoutUser); checkParams.Add(TrackablesCols.CheckinUser, checkData.CheckinUser); checkParams.Add(TrackablesCols.UseLocation, checkData.UseLocation); checkParams.Add(TrackablesCols.Notes, checkData.CheckinNotes); checkParams.Add(TrackablesCols.DeviceGuid, checkData.Guid); rows += DBFactory.GetDatabase().InsertFromParameters(TrackablesCols.TableName, checkParams.Parameters, trans); if (rows == 2) { trans.Commit(); OtherFunctions.Message("Device Checked In!", MessageBoxButtons.OK, MessageBoxIcon.Information, "Success", this); } else { trans.Rollback(); OtherFunctions.Message("Unsuccessful! The number of affected rows was not what was expected.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "Unexpected Result", this); } ParentForm.RefreshData(); } catch (Exception ex) { trans.Rollback(); ErrorHandling.ErrHandle(ex, System.Reflection.MethodBase.GetCurrentMethod()); } finally { this.Dispose(); } } }
public bool TryMatch(string path, out ParamCollection @params) { @params = new ParamCollection(); var breaked = path.Split('/').Where(n => !string.IsNullOrWhiteSpace(n)); int i = 0; if (breaked.Count() != template_breaked.Count) { @params = null; return(false); } foreach (var b in breaked) { TemplateNode template = template_breaked[i]; if (template.IsTemplate) { string key = template.Key; string value = b; @params.Add(key, b); } else { if (template.Key != b) { @params = null; return(false); } } i++; } return(true); }
public override UpdateAction Where(TableFilter filter) { if (this.UpdateColumns.Count == 0) { throw new Exception("no update columns"); } #region update columns string columnStr = string.Empty; foreach (var col in this.UpdateColumns) { var p = new DBParam(col.Key, col.Value); ParamCollection.Add(p); columnStr += string.Format(" {0} ={1},", col.Key, p.ParamName); } columnStr = columnStr.TrimEnd(','); #endregion #region where string filterCondition = string.Empty, where = string.Empty; if (filter != null) { filterCondition = filter.Build(base.ParamCollection); if (!string.IsNullOrWhiteSpace(filterCondition)) { where = string.Format(" where {0} ", filterCondition); } } #endregion base.MainSql = string.Format("update {0} set {1} {2}", base.TableCode, columnStr, where); return(this); }
/// <summary> /// 小于条件解析 /// </summary> /// <param name="condition">需要解析的条件对象</param> /// <returns>返回解析后的条件字符串</returns> protected override string LessThanParse(LessThanCondition condition) { StringBuilder conditionStr = new StringBuilder(" "); string queryColName = condition.SearchColumn.CurrentSearcher.TableName + "." + condition.SearchColumn.ColumnName; if (string.IsNullOrEmpty(condition.SearchColumn.ConditionString)) { conditionStr.Append(queryColName); } else { conditionStr.Append(condition.SearchColumn.ConditionString.Replace(SQLPlaceholder.ColName, queryColName)); } conditionStr.Append(" < "); if (condition.ParamValue is SearchColumn) { SearchColumn tmpColumn = (SearchColumn)condition.ParamValue; string valueColName = tmpColumn.CurrentSearcher.TableName + "." + tmpColumn.ColumnName; conditionStr.Append(valueColName); } else { string paramName = "P" + Guid.NewGuid().ToString().ToLower().Replace("-", ""); conditionStr.Append("@" + paramName); ParamCollection.Add(new DBParam(paramName, condition.ParamValue)); } conditionStr.Append(" "); return(conditionStr.ToString()); }
private ParamCollection Parse(ref string s, string pattern, bool remove, string tag, RegexOptions options) { ParamCollection cmd = new ParamCollection(Name); Regex rex = new Regex(pattern, options); Match m1 = rex.Match(s); while (m1.Success) { string param = m1.Groups[PARAM].Value; string arg = m1.Groups[ARGS].Value; if (param != null) { param = param.TrimEnd(' '); ArgCollection prm = cmd.Add(param, new ArgCollection(param, tag)); if (arg != null) { arg = arg.TrimEnd(' '); if (!string.IsNullOrEmpty(arg)) { prm.Add(arg); } } } if (remove) { s = s.Remove(m1.Index, m1.Length).Trim(); m1 = rex.Match(s); } else { m1 = rex.Match(s, m1.Index + m1.Length); } } return cmd; }
/// <summary> /// Combines the OAuth basic parameters and additional parameters. /// </summary> /// <returns></returns> private IEnumerable <ParamPair> CollectAllParams() { var parameters = new ParamCollection(); OAuthAccessToken accessToken = this.accessToken ?? Environment.AccessToken; parameters.Add(Constants.OAuthToken, accessToken.Token); if (null != Params) { foreach (var item in Params) { parameters.Add(item.Name, item.Value); } } return(parameters); }
public static void AddNewEmp(MunisEmployee empInfo) { try { if (!IsEmployeeInDB(empInfo.Number)) { string newGuid = Guid.NewGuid().ToString(); ParamCollection insertParams = new ParamCollection(); insertParams.Add(EmployeesCols.Name, empInfo.Name); insertParams.Add(EmployeesCols.Number, empInfo.Number); insertParams.Add(EmployeesCols.Guid, newGuid); DBFactory.GetDatabase().InsertFromParameters(EmployeesCols.TableName, insertParams.Parameters); } } catch (Exception ex) { ErrorHandling.ErrHandle(ex, System.Reflection.MethodBase.GetCurrentMethod()); } }
/// <summary> /// NOT IN条件解析 /// </summary> /// <param name="condition">需要解析的条件对象</param> /// <returns>返回解析后的条件字符串</returns> protected override string NotInParse(NotInCondition condition) { StringBuilder conditionStr = new StringBuilder(" "); string queryColName = condition.SearchColumn.CurrentSearcher.TableName + "." + condition.SearchColumn.ColumnName; if (string.IsNullOrEmpty(condition.SearchColumn.ConditionString)) { conditionStr.Append(queryColName); } else { conditionStr.Append(condition.SearchColumn.ConditionString.Replace(SQLPlaceholder.ColName, queryColName)); } conditionStr.Append(" NOT IN ( "); string paramName = string.Empty; int i = 0; foreach (object pvalue in condition.ParamValueList) { if (i != 0) { conditionStr.Append(","); } if (pvalue is SearchColumn) { SearchColumn tmpColumn = (SearchColumn)pvalue; string valueColName = tmpColumn.CurrentSearcher.TableName + "." + tmpColumn.ColumnName; conditionStr.Append(valueColName); } else { if (!string.IsNullOrEmpty(pvalue.ToString())) { paramName = "P" + Guid.NewGuid().ToString().ToLower().Replace("-", ""); conditionStr.Append("@" + paramName); ParamCollection.Add(new DBParam(paramName, pvalue)); } else { conditionStr.Append("''"); } } i++; } conditionStr.Append(") "); return(conditionStr.ToString()); }
/// <summary> /// /// </summary> /// <param name="i_sIpAddr"></param> /// <param name="i_sSessionId"></param> /// <param name="i_sThreadId"></param> /// <param name="i_sVmcId"></param> /// <param name="i_sComponentName"></param> /// <param name="i_sPath"></param> /// <returns></returns> public bool Init(string i_sIpAddr, string i_sSessionId, string i_sThreadId, string i_sVmcId, string i_sComponentName, string i_sPath) { bool bRet = true; ParamCollection aInitParams = null; try { aInitParams = new ParamCollection(); aInitParams.Add(new Param(eRequiredParams.IpAddress.ToString(), i_sIpAddr)); aInitParams.Add(new Param(eRequiredParams.SessionId.ToString(), i_sSessionId)); aInitParams.Add(new Param(eRequiredParams.ThreadId.ToString(), i_sThreadId)); aInitParams.Add(new Param(eRequiredParams.VmcId.ToString(), i_sVmcId)); aInitParams.Add(new Param(eRequiredParams.ComponentName.ToString(), i_sComponentName)); aInitParams.Add(new Param(TsvAndStdoutLogger.eMoreParams.Path.ToString(), i_sPath)); if (m_Logger == null) { m_Logger = new TsvAndStdoutLogger(); } bRet = m_Logger.Init(ref aInitParams); } catch (Exception exc) { bRet = false; Console.Error.WriteLine(DateTime.Now.ToString() + " " + "Caught exception in LegacyLogger.Init: " + exc.ToString()); } return(bRet); } // Init
/// <summary> /// 取得查询实体 /// </summary> /// <returns></returns> IShowCategoryProvider GetProvider() { ParamCollection col = new ParamCollection(); col.Add(new Param("dataSourceName", DataSourceName)); col.Add(new Param("ChannelName", ChannelName)); col.Add(new Param("ChannelID", ChannelID)); col.Add(new Param("FullUrl", FullUrl)); col.Add(new Param("TitleImage", TitleImage)); col.Add(new Param("ParentID", ParentID)); col.Add(new Param("ParentIDName", ParentIDName)); col.Add(new Param("LevelOneMax", LevelOneMax.ToString())); col.Add(new Param("ParentID", LevelTwoMax.ToString())); col.Add(new Param("ParentID", LevelThreeMax.ToString())); if (!String.IsNullOrEmpty(DataSourceType) && DataSourceType == "xml") { return(new XmlShowCategoryProvider(col)); } else { return(new DbShowCategoryProvider(col)); } }
/// <summary> /// Combines the OAuth basic parameters and additional parameters. /// </summary> /// <returns></returns> private IEnumerable<ParamPair> CollectAllParams() { var parameters = new ParamCollection(); parameters.Add(SinaConstants.OAuthToken,Token); if (null != Params) { foreach (var item in Params) { parameters.Add(item.Name, item.Value); } } return parameters; }
/// <summary>Получить коллекцию выходных параметров команды</summary> /// <param name="paramCollection">Коллекция параметров команды</param> /// <returns></returns> public static ParamCollection GetOutputParams(ParamCollection paramCollection) { if (paramCollection == null) { throw new ArgumentNullException("paramCollection"); } ParamCollection retVal = new ParamCollection(); for (int i = 0; i < paramCollection.Count; i++) { if (paramCollection[i].Direction == ParameterDirection.Input) { continue; } retVal.Add(paramCollection[i]); } return(retVal); }
/// <summary> /// 等于条件解析;如果条件值为NULL或空字符串时则判断字段的空字符串或NULL值 /// </summary> /// <param name="condition">需要解析的条件对象</param> /// <returns>返回解析后的条件字符串</returns> protected override string EqualParse(EqualCondition condition) { StringBuilder conditionStr = new StringBuilder(" "); string queryColName = condition.SearchColumn.CurrentSearcher.TableName + "." + condition.SearchColumn.ColumnName; if (string.IsNullOrEmpty(condition.SearchColumn.ConditionString)) { conditionStr.Append(queryColName); } else { conditionStr.Append(condition.SearchColumn.ConditionString.Replace(SQLPlaceholder.ColName, queryColName)); } conditionStr.Append(" = "); if (condition.ParamValue is SearchColumn) { SearchColumn tmpColumn = (SearchColumn)condition.ParamValue; string valueColName = tmpColumn.CurrentSearcher.TableName + "." + tmpColumn.ColumnName; conditionStr.Append(valueColName); } else { if (condition.ParamValue != null && !condition.ParamValue.ToString().Equals(string.Empty)) { string paramName = "P" + Guid.NewGuid().ToString().ToLower().Replace("-", ""); conditionStr.Append("@" + paramName); ParamCollection.Add(new DBParam(paramName, condition.ParamValue)); } else { conditionStr.Insert(0, " ("); conditionStr.Append("'' "); conditionStr.Append(" OR "); conditionStr.Append(queryColName); conditionStr.Append(" IS NULL) "); } } conditionStr.Append(" "); return(conditionStr.ToString()); }
/// <summary> /// Prepares a post body string for an access-token-required request. /// </summary> /// <param name="uri"> The uri to identify the resource. </param> /// <param name="customPostParams"> Additional parameters (in addition to the OAuth parameters) to be included in the post body. </param> /// <returns> The url-encoded post body string. </returns> public static string PreparePostBody(IEnumerable<ParamPair> customPostParams) { var parameters = new ParamCollection(); //OAuthAccessToken accessToken = Environment.AccessToken; //parameters.Add(Constants.OAuthToken, accessToken.Token); if (null != customPostParams) { foreach (ParamPair item in customPostParams) { parameters.Add(item.Name, item.Value); } } string postBody = ConstructPostBody(parameters); return postBody; }
/// <summary> /// Gets a collection of OAuth basic parameters(key/value pair). /// <remarks>Not include 'oauth_token' and'oauth_verifier' parameters.</remarks> /// </summary> /// <returns>The collection contains OAuth basic parameters.</returns> public static ParamCollection GetOAuthBasicParams() { var parameters = new ParamCollection(); parameters.Add(Constants.OAuthConsumerKey, Environment.AppKey); parameters.Add(Constants.OAuthSignatureMethod, Environment.OAuthSignatureMethod); var timestamp = RFC3986Encoder.ToUnixTime(DateTime.Now); parameters.Add(Constants.OAuthTimestamp, timestamp.ToString(CultureInfo.InvariantCulture)); var nonce = GenerateNonce(); parameters.Add(Constants.OAuthNonce, nonce); parameters.Add(Constants.OAuthVersion, Environment.OAuthVersion); return parameters; }
protected string Match(ref Regex rex, ref ParamCollection result, ref Match m, string s, string group, string tag) { string file_name = m.Groups[group].Value.Trim(); result.Add(file_name, new ArgCollection(file_name, tag)); s = s.Remove(m.Index, m.Length).Trim(); m = rex.Match(s); return s; }
private string PreparePostBody(IEnumerable<ParamPair> customPostParams) { var parameters = new ParamCollection(); if (null != customPostParams) { foreach (ParamPair item in customPostParams) { parameters.Add(item.Name, item.Value); } } string postBody = ConstructPostBody(parameters); return postBody; }