Exemple #1
0
        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);
        }
Exemple #2
0
        public static UserBlogVM RetrieveBlogDoc(string dockey, Controller ctrl)
        {
            var ret = new UserBlogVM();

            ret.CommentList = ProjectErrorViewModels.RetrieveErrorComments(dockey, ctrl);

            var sql = "select UserName,APVal1,APVal2,APVal3,APVal4,APVal5,APVal9 from UserBlog where APVal2='<APVal2>'";

            sql = sql.Replace("<APVal2>", dockey);
            var dbret = DBUtility.ExeLocalSqlWithRes(sql, null);

            foreach (var line in dbret)
            {
                ret.UserName    = Convert.ToString(line[0]);
                ret.ContentType = Convert.ToString(line[1]);
                ret.DocKey      = Convert.ToString(line[2]);
                ret.dbTitle     = Convert.ToString(line[3]);
                ret.dbContent   = Convert.ToString(line[4]);
                ret.Tag         = Convert.ToString(line[5]);
                ret.CreateDate  = DateTime.Parse(Convert.ToString(line[6]));

                //if (string.Compare(ret.ContentType, UserBlogContentType.COMMENT) == 0)
                //{
                ret.DocURL = "/User/WebDoc?DocKey=" + ret.DocKey;
                //}

                //if (string.Compare(ret.ContentType, UserBlogContentType.ATTACH) == 0)
                //{
                //ret.DocURL = "/User/WebDoc?DocKey=" + ret.DocKey;
                //}
            }

            return(ret);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        public static List <UserBlogVM> RetrieveAllBlogDoc(string username)
        {
            var ret = new List <UserBlogVM>();
            var sql = "select UserName,APVal1,APVal2,APVal3,APVal4,APVal5,APVal9 from UserBlog where UserName='******' and (APVal1 = '<TYPE1>' or APVal1 = '<TYPE2>') order by APVal9 DESC";

            sql = sql.Replace("<UserName>", username).Replace("<TYPE1>", UserBlogContentType.ATTACH).Replace("<TYPE2>", UserBlogContentType.COMMENT);
            var dbret = DBUtility.ExeLocalSqlWithRes(sql, null);

            foreach (var line in dbret)
            {
                var tempinfo = new UserBlogVM();
                tempinfo.UserName    = Convert.ToString(line[0]);
                tempinfo.ContentType = Convert.ToString(line[1]);
                tempinfo.DocKey      = Convert.ToString(line[2]);
                tempinfo.dbTitle     = Convert.ToString(line[3]);
                tempinfo.dbContent   = Convert.ToString(line[4]);
                tempinfo.Tag         = Convert.ToString(line[5]);
                tempinfo.CreateDate  = DateTime.Parse(Convert.ToString(line[6]));

                //if (string.Compare(tempinfo.ContentType, UserBlogContentType.COMMENT) == 0)
                //{
                tempinfo.DocURL = "/User/WebDoc?DocKey=" + tempinfo.DocKey;
                //}

                //if (string.Compare(tempinfo.ContentType, UserBlogContentType.ATTACH) == 0)
                //{
                //    var tempstrs = tempinfo.Title.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
                //    var datestr = tempstrs[tempstrs.Length - 1].Substring(0, 8);
                //    tempinfo.DocURL = "/userfiles/docs/" + datestr + "/" + tempinfo.Title;
                //}

                ret.Add(tempinfo);
            }

            return(ret);
        }
Exemple #5
0
        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);
                }
            }
        }