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); }
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 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); } } }