protected string GetEditUrl(object container) { MetricTrac.Bll.MetricValue.Extend val = GetValue(container); int BackPageIndex = 4; switch (DataMode) { case Mode.Input: BackPageIndex = 3; break; case Mode.View: BackPageIndex = 4; break; case Mode.Approve: BackPageIndex = 5; break; default: BackPageIndex = 4; break; } return("MetricInputEdit.aspx?MetricID=" + val.MetricID + "&Date=" + val.Date.ToString("MM-dd-yyyy") + "&OrgLocationID=" + LastMetricMetricValue.OrgLocationID + "&Mode=" + DataMode.ToString() + "&BackPage=" + BackPageIndex.ToString()); }
protected string GetEditUrl(object container) { System.Web.UI.WebControls.RepeaterItem ri = container as System.Web.UI.WebControls.RepeaterItem; MetricTrac.Bll.MetricValue.Extend val = ri.DataItem as MetricTrac.Bll.MetricValue.Extend; int BackPageIndex = 1; switch (DataMode) { case Mode.Input: BackPageIndex = 1; break; case Mode.Approve: BackPageIndex = 2; break; default: BackPageIndex = 1; break; } return("MetricInputEdit.aspx?MetricID=" + val.MetricID + "&Date=" + val.Date.ToString("MM-dd-yyyy") + "&OrgLocationID=" + LastMetricMetricValue.OrgLocationID + "&Mode=" + DataMode.ToString() + "&BulkEdit=True" + "&BackPage=" + BackPageIndex.ToString()); }
private T getArray <T>() { if (DataMode != RhspDataMode.Array) { throw new RhspException( "Cannot get array data when mode is " + DataMode.ToString() + "."); } if (RawData != null) { return((T)(object)RawData.Cast(typeof(T).GetElementType())); //return (T)(object)createArray(typeof(T).GetElementType(), RawData); //List<T> list = new List<T>(); //foreach (object o in RawData) //{ // list.Add((T)o); //} //return list.ToArray(); } else { return((T)(object)(new T[0])); } }
private T getSingle <T>() { if (DataMode != RhspDataMode.Single) { throw new RhspException( "Cannot get single data when mode is " + DataMode.ToString() + "."); } if (RawData[0] != null) { // When not null, OK to cast. return((T)RawData[0]); } else { // Cannot cast null to T, so return default instead. return(default(T)); } }
/// <summary> /// 校验加密算法数据模式。 /// </summary> /// <param name="dataMode"></param> protected void ValidateDataMode(DataMode dataMode) { if (!AvailableDataModes.Contains(dataMode)) { throw new NotSupportedException(string.Format("DataMode {0} & CrytoAlgorithm {1} not support!", dataMode.ToString(), CryptoAlgorithm.ToString())); } }
public void UpdatePostsOfMode(DataMode mode, bool showProgress = false) { var url = ""; switch (mode) { case DataMode.Following: url = POSTS_OF_FOLLOWINGS_URL; break; case DataMode.Latest: url = POSTS_OF_LATEST_URL; break; case DataMode.Top: url = POSTS_OF_TOP_URL; break; } if (showProgress) { GlobalUtil.NativeUtil.ShowMessage("صبر کنید"); } Task.Run(async() => { var result = await Call(url, new NameValueCollection() { { "lastUpdateId", (Database.GetInstance().GetDbCon().Table <Post>().Any() ? Database.GetInstance().GetDbCon().Table <Post>().Max(q => q.Id) : -1).ToString() } }); //if an Error Accured if (result == "{}") { new MessageBusPayload(MessageBusPayload.BroadcastEnum.UpdatePostsMode, false) { Entity = mode } .Post(); } var array = AnalyzeArrayResult(result); bool hasNewPost = false; foreach (var item in array) { int id = item.Value <int>("id"); var postItem = Database.GetInstance().GetDbCon().Table <Post>().FirstOrDefault(q => q.Id == id); if (postItem == null) { hasNewPost = true; postItem = new Post() { Id = item.Value <int>("id"), PublishDate = item.Value <int>("publishDate"), Avatar = item.Value <string>("avatar"), BookCoverUrl = item.Value <string>("bookCoverUrl"), BookId = item.Value <int>("bookId"), BookTitle = item.Value <string>("bookTitle"), CommentsCount = item.Value <int>("commentsCount"), Description = item.Value <string>("description"), LikesCount = item.Value <int>("likesCount"), Nickname = item.Value <string>("nickname"), Score = item.Value <byte>("score"), Status = item.Value <int>("status"), UserId = item.Value <int>("userId"), Username = item.Value <string>("username"), }; Database.GetInstance().GetDbCon().Insert(postItem); } else { postItem.PublishDate = item.Value <int>("publishDate"); postItem.Avatar = item.Value <string>("avatar"); postItem.BookCoverUrl = item.Value <string>("bookCoverUrl"); postItem.BookId = item.Value <int>("BookId"); postItem.BookTitle = item.Value <string>("bookTitle"); postItem.CommentsCount = item.Value <int>("commentsCount"); postItem.Description = item.Value <string>("description"); postItem.LikesCount = item.Value <int>("likesCount"); postItem.Nickname = item.Value <string>("nickname"); postItem.Score = item.Value <byte>("score"); postItem.Status = item.Value <int>("status"); postItem.UserId = item.Value <int>("userId"); postItem.Username = item.Value <string>("username"); Database.GetInstance().GetDbCon().Update(postItem); } string strMode = mode.ToString().ToLower(); if (!Database.GetInstance().GetDbCon().Table <PostMode>() .Any(q => q.Mode == strMode && q.PostId == postItem.Id)) { Database.GetInstance().GetDbCon().Insert(new PostMode() { Mode = strMode, PostId = postItem.Id }); } } new MessageBusPayload(MessageBusPayload.BroadcastEnum.UpdatePostsMode, hasNewPost) { Entity = mode } .Post(); }); }
/// <summary> /// 校验加密算法数据模式。 /// </summary> /// <param name="dataMode"></param> protected void ValidateDataMode(DataMode dataMode) { if (!AvailableDataModes.Contains(dataMode)) { throw new NotSupportedException(string.Format("DataMode {0} & CrytoAlgorithm {1} not support!", dataMode.ToString(),CryptoAlgorithm.ToString())); } }