public static List <ShareDocVM> RetrieveAllSharedDocs(Controller ctrl) { var ret = new List <ShareDocVM>(); var sql = "select DOCPJK,DOCType,DOCKey,DOCTag,DOCCreator,DOCDate,DOCFavorTimes,APVal1,BackLink from ShareDoc order by DOCDate"; var dbret = DBUtility.ExeLocalSqlWithRes(sql, null); foreach (var line in dbret) { var tempvm = new ShareDocVM(); tempvm.DOCPJK = Convert.ToString(line[0]); tempvm.DOCType = Convert.ToString(line[1]); tempvm.DOCKey = Convert.ToString(line[2]); tempvm.DOCTag = Convert.ToString(line[3]); tempvm.DOCCreator = Convert.ToString(line[4]); tempvm.DOCDate = DateTime.Parse(Convert.ToString(line[5])); tempvm.DOCFavorTimes = Convert.ToInt32(line[6]); tempvm.DocID = Convert.ToString(line[7]); tempvm.BACKLink = Convert.ToString(line[8]); if (string.Compare(tempvm.DOCType, ShareDocType.ISSUE, true) == 0) { var issue = IssueViewModels.RetrieveIssueByIssueKey(tempvm.DOCKey, ctrl); if (issue == null) { continue; } tempvm.Summary = issue.Summary; tempvm.DocURL = "/Issue/UpdateIssue?issuekey=" + tempvm.DOCKey; } else if (string.Compare(tempvm.DOCType, ShareDocType.DEBUG, true) == 0) { var debugtree = ProjectErrorViewModels.RetrieveErrorByErrorKey(tempvm.DOCKey, ctrl); tempvm.Summary = debugtree[0].ProjectKey + "-" + debugtree[0].OrignalCode; tempvm.DocURL = "/Project/UpdateProjectError?ErrorKey=" + tempvm.DOCKey; } else if (string.Compare(tempvm.DOCType, ShareDocType.BLOG, true) == 0) { var blog = UserBlogVM.RetrieveBlogDoc(tempvm.DOCKey, ctrl); if (string.IsNullOrEmpty(blog.DocKey)) { continue; } tempvm.Summary = blog.Title; tempvm.DocURL = blog.DocURL; } else { tempvm.Summary = tempvm.DOCKey; //var tempstrs = tempvm.Summary.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries); //var datestr = tempstrs[tempstrs.Length - 1].Substring(0, 8); //tempvm.DocURL = "/userfiles/docs/" + datestr + "/" + tempvm.DOCKey; tempvm.DocURL = "/User/WebDoc?DocKey=" + tempvm.DOCKey + "&Creator=" + tempvm.DOCCreator; } ret.Add(tempvm); } return(ret); }
public static List <ShareDocVM> RetrieveYesterdayDocs(Controller ctrl) { var ret = new List <ShareDocVM>(); string tempdate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); var starttime = tempdate + " 00:00:01"; var endtime = tempdate + " 23:59:59"; var sql = "select DOCPJK,DOCType,DOCKey,DOCTag,DOCCreator,DOCDate,DOCFavorTimes,APVal1,BackLink from ShareDoc where DOCDate >= '<starttime>' and DOCDate <= '<endtime>'"; sql = sql.Replace("<starttime>", starttime).Replace("<endtime>", endtime); var dbret = DBUtility.ExeLocalSqlWithRes(sql, null); foreach (var line in dbret) { var tempvm = new ShareDocVM(); tempvm.DOCPJK = Convert.ToString(line[0]); tempvm.DOCType = Convert.ToString(line[1]); tempvm.DOCKey = Convert.ToString(line[2]); tempvm.DOCTag = Convert.ToString(line[3]); tempvm.DOCCreator = Convert.ToString(line[4]); tempvm.DOCDate = DateTime.Parse(Convert.ToString(line[5])); tempvm.DOCFavorTimes = Convert.ToInt32(line[6]); tempvm.DocID = Convert.ToString(line[7]); tempvm.BACKLink = Convert.ToString(line[8]); if (string.Compare(tempvm.DOCType, ShareDocType.ISSUE, true) == 0) { var issue = IssueViewModels.RetrieveIssueByIssueKey(tempvm.DOCKey, ctrl); if (issue == null) { continue; } tempvm.Summary = issue.Summary; tempvm.DocURL = "/Issue/UpdateIssue?issuekey=" + tempvm.DOCKey; } else if (string.Compare(tempvm.DOCType, ShareDocType.DEBUG, true) == 0) { var debugtree = ProjectErrorViewModels.RetrieveErrorByErrorKey(tempvm.DOCKey, ctrl); tempvm.Summary = debugtree[0].ProjectKey + "-" + debugtree[0].OrignalCode; tempvm.DocURL = "/Project/UpdateProjectError?ErrorKey=" + tempvm.DOCKey; } else { tempvm.Summary = tempvm.DOCKey; //var tempstrs = tempvm.Summary.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries); //var datestr = tempstrs[tempstrs.Length - 1].Substring(0, 8); //tempvm.DocURL = "/userfiles/docs/" + datestr + "/" + tempvm.DOCKey; tempvm.DocURL = "/User/WebDoc?DocKey=" + tempvm.DOCKey + "&Creator=" + tempvm.DOCCreator; } ret.Add(tempvm); } return(ret); }
private static List <ShareDocVM> RetrieveMyLearnBlog(string UserName, Controller ctrl) { var ret = new List <ShareDocVM>(); var sql = "select a.DOCPJK,a.DOCType,a.DOCKey,a.DOCTag,a.DOCCreator,a.DOCDate,a.DOCPusher,a.DOCFavor,a.APVal1,a.BackLink from UserLearn a where a.UserName= '******' and a.DOCType = '<DOCType>' order by a.DOCDate DESC"; sql = sql.Replace("<UserName>", UserName).Replace("<DOCType>", ShareDocType.BLOG); var dbret = DBUtility.ExeLocalSqlWithRes(sql, null); foreach (var line in dbret) { var tempvm = new ShareDocVM(); tempvm.BookerName = UserName; tempvm.DOCPJK = Convert.ToString(line[0]); tempvm.DOCType = Convert.ToString(line[1]); tempvm.DOCKey = Convert.ToString(line[2]); tempvm.DOCTag = Convert.ToString(line[3]); tempvm.DOCCreator = Convert.ToString(line[4]); tempvm.DOCDate = DateTime.Parse(Convert.ToString(line[5])); tempvm.DOCPusher = Convert.ToString(line[6]); tempvm.DOCFavor = Convert.ToString(line[7]); tempvm.DOCFavorTimes = RetrieveBlogFavorTimes(tempvm.DOCKey, tempvm.DOCCreator); tempvm.DocID = Convert.ToString(line[8]); tempvm.BACKLink = Convert.ToString(line[9]); var blog = UserBlogVM.RetrieveBlogDoc(tempvm.DOCKey, ctrl); if (string.IsNullOrEmpty(blog.DocKey)) { continue; } tempvm.Summary = blog.Title; tempvm.DocURL = blog.DocURL; ret.Add(tempvm); } foreach (var doc in ret) { if (string.IsNullOrEmpty(doc.DocID)) { doc.DocID = UpdateDocID(doc.DOCPJK, doc.DOCKey); } } return(ret); }
public static ShareDocVM RetrieveUserBookedTag(string UserName) { var ret = new ShareDocVM(); var sql = "select DocTag from UserTable where UserName = '******'"; sql = sql.Replace("<UserName>", UserName); var dbret = DBUtility.ExeLocalSqlWithRes(sql, null); if (dbret.Count > 0) { ret.BookerName = UserName; ret.DOCTag = Convert.ToString(dbret[0][0]); } return(ret); }
public static List <ShareDocVM> RetrieveAllUserBookedTag() { var ret = new List <ShareDocVM>(); var sql = "select UserName,DocTag from UserTable"; var dbret = DBUtility.ExeLocalSqlWithRes(sql, null); foreach (var line in dbret) { if (!string.IsNullOrEmpty(Convert.ToString(line[1]))) { var tempitem = new ShareDocVM(); tempitem.BookerName = Convert.ToString(line[0]); tempitem.DOCTag = Convert.ToString(line[1]); ret.Add(tempitem); } } return(ret); }
public static void LikeDoc(string DOCKey, string DOCCreator, string updater, Controller ctrl) { var sql = "select DOCFavor from UserLearn where DOCKey = N'<DOCKey>' and DOCCreator = '<DOCCreator>' and UserName = '******'"; sql = sql.Replace("<DOCKey>", DOCKey).Replace("<DOCCreator>", DOCCreator).Replace("<UserName>", updater); var dbret2 = DBUtility.ExeLocalSqlWithRes(sql, null); if (dbret2.Count == 0) { return; } if (!string.IsNullOrEmpty(Convert.ToString(dbret2[0][0]))) { return; } var ret = new List <ShareDocVM>(); sql = "select a.DOCPJK,a.DOCType,a.DOCKey,a.DOCTag,a.DOCCreator,a.DOCDate,b.DOCPusher,b.DOCFavor,a.DOCFavorTimes,a.APVal1,a.BackLink from ShareDoc a left join UserLearn b ON a.DOCKey = b.DOCKey " + " where a.DOCKey = N'<DOCKey>' and a.DOCCreator = '<DOCCreator>' and b.UserName='******'"; sql = sql.Replace("<DOCKey>", DOCKey).Replace("<DOCCreator>", DOCCreator).Replace("<UserName>", updater); var dbret = DBUtility.ExeLocalSqlWithRes(sql, null); foreach (var line in dbret) { var tempvm = new ShareDocVM(); tempvm.DOCPJK = Convert.ToString(line[0]); tempvm.DOCType = Convert.ToString(line[1]); tempvm.DOCKey = Convert.ToString(line[2]); tempvm.DOCTag = Convert.ToString(line[3]); tempvm.DOCCreator = Convert.ToString(line[4]); tempvm.DOCDate = DateTime.Parse(Convert.ToString(line[5])); tempvm.DOCPusher = Convert.ToString(line[6]); tempvm.DOCFavor = Convert.ToString(line[7]); tempvm.DOCFavorTimes = Convert.ToInt32(line[8]); tempvm.DocID = Convert.ToString(line[9]); tempvm.BACKLink = Convert.ToString(line[10]); ret.Add(tempvm); } if (ret.Count > 0) { var sql1 = "Update ShareDoc set DOCFavorTimes = <DOCFavorTimes> where DOCKey = N'<DOCKey>' and DOCCreator = '<DOCCreator>'"; sql1 = sql1.Replace("<DOCKey>", DOCKey).Replace("<DOCCreator>", DOCCreator).Replace("<DOCFavorTimes>", (ret[0].DOCFavorTimes + 1).ToString()); DBUtility.ExeLocalSqlNoRes(sql1); } var sql2 = "Update UserLearn set DOCFavor='LIKE' where DOCKey = N'<DOCKey>' and DOCCreator = '<DOCCreator>' and UserName='******'"; sql2 = sql2.Replace("<DOCKey>", DOCKey).Replace("<DOCCreator>", DOCCreator).Replace("<UserName>", updater); DBUtility.ExeLocalSqlNoRes(sql2); if (ret.Count > 0) { if (string.Compare(ret[0].DOCType, ShareDocType.ISSUE, true) == 0) { var issue = IssueViewModels.RetrieveIssueByIssueKey(ret[0].DOCKey, ctrl); if (issue != null) { var Summary = issue.Summary; var DocURL = "/Issue/UpdateIssue?issuekey=" + ret[0].DOCKey; UserKPIVM.AddUserDailyRank(ret[0].DOCKey, issue.Assignee, UserRankType.VOTE, "Like your task analyse: " + Summary, DocURL, 1); } } else if (string.Compare(ret[0].DOCType, ShareDocType.DEBUG, true) == 0) { var debugtree = ProjectErrorViewModels.RetrieveErrorByErrorKey(ret[0].DOCKey, ctrl); var Summary = debugtree[0].ProjectKey + "-" + debugtree[0].OrignalCode; var DocURL = "/Project/UpdateProjectError?ErrorKey=" + ret[0].DOCKey; UserKPIVM.AddUserDailyRank(ret[0].DOCKey, ret[0].DOCCreator, UserRankType.VOTE, "Like your Debug Tree analyse: " + Summary, DocURL, 1); } else if (string.Compare(ret[0].DOCType, ShareDocType.DOCUMENT, true) == 0) { var Summary = ret[0].DOCKey; var DocURL = "/User/WebDoc?DocKey=" + ret[0].DOCKey + "&Creator=" + ret[0].DOCCreator; if (!string.IsNullOrEmpty(ret[0].BACKLink)) { UserKPIVM.AddUserAttachDailyRank(ret[0].DocID, ret[0].DOCCreator, UserRankType.VOTE, "Like your technical document: " + Summary, ret[0].BACKLink, 1, ret[0].DOCKey, ctrl); } else { UserKPIVM.AddUserAttachDailyRank(ret[0].DocID, ret[0].DOCCreator, UserRankType.VOTE, "Like your technical document: " + Summary, DocURL, 1, ret[0].DOCKey, ctrl); } } else if (string.Compare(ret[0].DOCType, ShareDocType.BLOG, true) == 0) { var vm = UserBlogVM.RetrieveBlogDoc(ret[0].DOCKey, ctrl); var DocURL = "/User/WebDoc?DocKey=" + ret[0].DOCKey; UserKPIVM.AddUserDailyRank(ret[0].DOCKey, ret[0].DOCCreator, UserRankType.VOTE, "Like your blog: " + vm.Title, DocURL, 1); } } }
public static List <ShareDocVM> RetrieveMyLearn(string UserName, Controller ctrl) { var ret = new List <ShareDocVM>(); var sql = "select a.DOCPJK,a.DOCType,a.DOCKey,a.DOCTag,a.DOCCreator,a.DOCDate,a.DOCPusher,a.DOCFavor,b.DOCFavorTimes,b.APVal1,a.BackLink from UserLearn a left join ShareDoc b ON a.DOCKey = b.DOCKey where a.UserName= '******' and a.DOCType <> '<DOCType>' order by a.DOCDate DESC"; sql = sql.Replace("<UserName>", UserName).Replace("<DOCType>", ShareDocType.BLOG); var dbret = DBUtility.ExeLocalSqlWithRes(sql, null); foreach (var line in dbret) { var tempvm = new ShareDocVM(); tempvm.BookerName = UserName; tempvm.DOCPJK = Convert.ToString(line[0]); tempvm.DOCType = Convert.ToString(line[1]); tempvm.DOCKey = Convert.ToString(line[2]); tempvm.DOCTag = Convert.ToString(line[3]); tempvm.DOCCreator = Convert.ToString(line[4]); tempvm.DOCDate = DateTime.Parse(Convert.ToString(line[5])); tempvm.DOCPusher = Convert.ToString(line[6]); tempvm.DOCFavor = Convert.ToString(line[7]); tempvm.DOCFavorTimes = Convert.ToInt32(line[8]); tempvm.DocID = Convert.ToString(line[9]); tempvm.BACKLink = Convert.ToString(line[10]); if (string.Compare(tempvm.DOCType, ShareDocType.ISSUE, true) == 0) { var issue = IssueViewModels.RetrieveIssueByIssueKey(tempvm.DOCKey, ctrl); if (issue == null) { continue; } tempvm.Summary = issue.Summary; tempvm.DocURL = "/Issue/UpdateIssue?issuekey=" + tempvm.DOCKey; } else if (string.Compare(tempvm.DOCType, ShareDocType.DEBUG, true) == 0) { var debugtree = ProjectErrorViewModels.RetrieveErrorByErrorKey(tempvm.DOCKey, ctrl); tempvm.Summary = debugtree[0].ProjectKey + "-" + debugtree[0].OrignalCode; tempvm.DocURL = "/Project/UpdateProjectError?ErrorKey=" + tempvm.DOCKey; } else if (string.Compare(tempvm.DOCType, ShareDocType.DOCUMENT, true) == 0) { tempvm.Summary = tempvm.DOCKey; tempvm.DocURL = "/User/WebDoc?DocKey=" + tempvm.DOCKey + "&Creator=" + tempvm.DOCCreator; } ret.Add(tempvm); } foreach (var doc in ret) { if (string.IsNullOrEmpty(doc.DocID)) { doc.DocID = UpdateDocID(doc.DOCPJK, doc.DOCKey); } } var bloglist = RetrieveMyLearnBlog(UserName, ctrl); if (bloglist.Count > 0) { ret.AddRange(bloglist); } ret.Sort(delegate(ShareDocVM item1, ShareDocVM item2) { if (item1.DOCDate > item2.DOCDate) { return(-1); } else if (item1.DOCDate < item2.DOCDate) { return(1); } else { return(0); } }); return(ret); }
public static void IPushDoc(string DOCPJK, string DOCKey, string ToWho, string Pusher, Controller ctrl, string reason = "") { var sql = "select DOCPJK,DOCType,DOCKey,DOCTag,DOCCreator,DOCDate,DOCFavorTimes,APVal1,BackLink from ShareDoc where DOCPJK = '<DOCPJK>' and DOCKey = N'<DOCKey>'"; sql = sql.Replace("<DOCPJK>", DOCPJK).Replace("<DOCKey>", DOCKey); var dbret = DBUtility.ExeLocalSqlWithRes(sql, null); foreach (var line in dbret) { var tempvm = new ShareDocVM(); tempvm.DOCPJK = Convert.ToString(line[0]); tempvm.DOCType = Convert.ToString(line[1]); tempvm.DOCKey = Convert.ToString(line[2]); tempvm.DOCTag = Convert.ToString(line[3]); tempvm.DOCCreator = Convert.ToString(line[4]); tempvm.DOCDate = DateTime.Parse(Convert.ToString(line[5])); tempvm.DOCFavorTimes = Convert.ToInt32(line[6]); tempvm.DocID = Convert.ToString(line[7]); tempvm.BACKLink = Convert.ToString(line[8]); if (string.Compare(tempvm.DOCType, ShareDocType.ISSUE, true) == 0) { var issue = IssueViewModels.RetrieveIssueByIssueKey(tempvm.DOCKey, ctrl); if (issue == null) { continue; } tempvm.Summary = issue.Summary; tempvm.DocURL = "/Issue/UpdateIssue?issuekey=" + tempvm.DOCKey; } else if (string.Compare(tempvm.DOCType, ShareDocType.DEBUG, true) == 0) { var debugtree = ProjectErrorViewModels.RetrieveErrorByErrorKey(tempvm.DOCKey, ctrl); tempvm.Summary = debugtree[0].ProjectKey + "-" + debugtree[0].OrignalCode; tempvm.DocURL = "/Project/UpdateProjectError?ErrorKey=" + tempvm.DOCKey; } else { tempvm.Summary = tempvm.DOCKey; var tempstrs = tempvm.Summary.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries); var datestr = tempstrs[tempstrs.Length - 1].Substring(0, 8); tempvm.DocURL = "/userfiles/docs/" + datestr + "/" + tempvm.DOCKey; } PushDoc(ToWho, tempvm.DOCPJK, tempvm.DOCType, tempvm.DOCKey, tempvm.DOCTag, tempvm.DOCCreator, tempvm.DOCDate.ToString(), Pusher, tempvm.DocID, tempvm.BACKLink); if (string.Compare(tempvm.DOCType, ShareDocType.ISSUE, true) == 0) { SendPushDocEvent("a new Issue about " + tempvm.DOCTag, tempvm.DocURL, ToWho, Pusher, ctrl, reason); } else if (string.Compare(tempvm.DOCType, ShareDocType.DEBUG, true) == 0) { SendPushDocEvent("a debug about " + tempvm.DOCPJK + "-" + tempvm.Summary, tempvm.DocURL, ToWho, Pusher, ctrl, reason); } else { SendPushDocEvent("a new document about " + tempvm.DOCTag, "/User/WebDoc?DocKey=" + HttpUtility.UrlEncode(tempvm.DOCKey) + "&Creator=" + tempvm.DOCCreator, ToWho, Pusher, ctrl); } } }