コード例 #1
0
ファイル: HouseHelperFtx.cs プロジェクト: cfan1236/HouseTag
        /// <summary>
        /// 获取评论
        /// </summary>
        /// <param name="pUrl"></param>
        /// <param name="pId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="maxPageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        private static List <CommentInfo> GetComment(CommentParam param)
        {
            var cinfo = new List <CommentInfo>();
            var url   = $"{param.url}house/ajaxrequest/dianpingList_201501.php";

            if (!url.Contains("https:") && !url.Contains("http:"))
            {
                if (url.Contains("//"))
                {
                    url = "https:" + url;
                }
                else
                {
                    url = "https://" + url;
                }
            }
            int pageIndex = param.pageIndex;

            //循环获取评论
            while ((pageIndex <= param.maxPageIndex) || (param.maxPageIndex == 0))
            {
                //判断是否有某些线程已经跑到了数据的最后一页 避免不必要的请求
                if (endPageIndex != 0 && pageIndex > endPageIndex && param.maxPageIndex != 0)
                {
                    pageIndex++;
                    continue;
                }
                var postParam = $"page={pageIndex}&pagesize={param.pageSize}&dianpingNewcode={param.id}";
                int status    = 0;

                var html = NetHttpHelper.HttpPostRequest(url, postParam, out status);

                if (status == 200)
                {
                    var list = JsonConvert.DeserializeObject <model.CommentResultFtx>(html);
                    if (list != null && list.list.Count > 0)
                    {
                        foreach (var item in list.list)
                        {
                            cinfo.Add(new CommentInfo
                            {
                                author  = string.IsNullOrWhiteSpace(item.nickname) ? item.username : item.nickname,
                                content = item.content.Replace("&hellip;", "…").Replace("<br/>", " "), //替换部分html 关键字
                                date    = item.create_time
                            });
                        }
                    }
                    else
                    {
                        endPageIndex = pageIndex;
                        break;
                    }
                }
                pageIndex++;
                Thread.Sleep(10);
            }
            return(cinfo);
        }
コード例 #2
0
ファイル: HouseHelperFtx.cs プロジェクト: cfan1236/HouseTag
        /// <summary>
        /// 楼盘评论
        /// </summary>
        /// <param name="pUrl">楼盘url</param>
        /// <param name="pId">楼盘id</param>
        /// <param name="c_count">楼盘评论数</param>
        /// <returns></returns>
        public static List <CommentInfo> GetProjectCommenInfo(string pUrl, string pId, int c_count)
        {
            var cinfo = new List <CommentInfo>();

            if (c_count == 0)
            {
                var param = new CommentParam()
                {
                    id           = pId,
                    pageIndex    = 1,
                    url          = pUrl,
                    maxPageIndex = 0,
                    pageSize     = 80
                };
                cinfo = GetComment(param);
                return(cinfo);
            }
            else
            {
                //多线程分批获取评论
                int threadCount = c_count / 1000;
                if (c_count % 1000 > 0)
                {
                    threadCount++;
                }
                threadCount = threadCount > 6 ? 6 : threadCount;
                Task[] tk = new Task[threadCount];
                //线程获取评论的当前页索引
                int pageIndex    = 1;
                int maxPageIndex = 10;
                for (int i = 0; i < threadCount; i++)
                {
                    var param = new CommentParam()
                    {
                        id           = pId,
                        pageIndex    = pageIndex,
                        url          = pUrl,
                        maxPageIndex = maxPageIndex,
                        pageSize     = 80
                    };
                    //判断是否是最后一个线程
                    if (i == threadCount - 1)
                    {
                        //让最后一个线程获取后面所有评论 没有页面限制
                        param.maxPageIndex = 0;
                    }
                    tk[i] = Task.Factory.StartNew(() =>
                    {
                        cinfo.AddRange(GetComment(param));
                    });
                    pageIndex    += 10;
                    maxPageIndex += 10;
                }

                Task.WaitAll(tk);
            }
            return(cinfo);
        }
コード例 #3
0
ファイル: CommentBLL.cs プロジェクト: WorldExcSoft/Community
        public string GetCommentParam(CommentParam param)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("where 1=1 ");

            if (!string.IsNullOrEmpty(param.CommentContent))
            {
                sb.AppendFormat(" and CommentContent like '%{0}%' ", Utils.SqlSafe(param.CommentContent));
            }

            if (!DateTime.MinValue.Equals(param.CreateTime))  //0001/1/1 0:00:00
            {
                sb.AppendFormat(" and CreateTime >= '{0}' ", param.CreateTime);
            }

            return(sb.ToString());
        }
コード例 #4
0
        /// <summary>
        /// 保存表单数据
        /// </summary>
        /// <param name="workItem"></param>
        /// <param name="user"></param>
        /// <param name="boolMatchValue"></param>
        /// <param name="paramValues"></param>
        private void SaveBizObject(OThinker.H3.WorkItem.WorkItem workItem, OThinker.Organization.User user, OThinker.Data.BoolMatchValue boolMatchValue, List <DataItemParam> paramValues)
        {
            InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(workItem.InstanceId);
            string          bizObjectId     = InstanceContext == null ? string.Empty : InstanceContext.BizObjectId;

            OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(InstanceContext.BizObjectSchemaCode);
            OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(this.Engine, schema, workItem.Participant);
            bo.ObjectID = bizObjectId;
            bo.Load();

            // 设置数据项的值
            foreach (DataItemParam param in paramValues)
            {
                OThinker.H3.DataModel.PropertySchema property = schema.GetProperty(param.ItemName);
                if (property.LogicType == DataLogicType.Comment)
                {// 审核意见
                    CommentParam comment = JSSerializer.Deserialize <CommentParam>(param.ItemValue + string.Empty);
                    this.Engine.BizObjectManager.AddComment(new Comment()
                    {
                        BizObjectId         = bo.ObjectID,
                        BizObjectSchemaCode = schema.SchemaCode,
                        InstanceId          = workItem.InstanceId,
                        TokenId             = workItem.TokenId,
                        Approval            = boolMatchValue,
                        Activity            = workItem.ActivityCode,
                        DataField           = property.Name,
                        UserID      = user.ObjectID,
                        SignatureId = comment.SignatureId,
                        Text        = comment.Text
                    });
                }
                else
                {
                    new BPM().SetItemValue(bo, property, param.ItemValue);
                }
            }

            bo.Update();
        }
コード例 #5
0
        public RestfulResult StartWorkflow_Base(string USER_CODE, string WORKFLOW_CODE, bool FINISH_START, string INSTANCE_ID, string PARAM_VALUES)
        {
            Engine.LogWriter.Write("Restful 服务,方法:StartWorkflow,参数:USER_CODE-->" + USER_CODE + ",WORKFLOW_CODE-->" + WORKFLOW_CODE + ",FINISH_START-->" + FINISH_START + ",INSTANCE_ID-->" + INSTANCE_ID + ",PARAM_VALUES-->" + JsonConvert.SerializeObject(PARAM_VALUES));
            RestfulResult result = new RestfulResult();
            Dictionary <string, object> listParams = JsonConvert.DeserializeObject <Dictionary <string, object> >(PARAM_VALUES);
            string workItemID, keyItem, errorMessage;

            workItemID = keyItem = errorMessage = string.Empty;
            try
            {
                #region 参数校验
                OThinker.H3.WorkflowTemplate.PublishedWorkflowTemplate workflowTemplate = this.Engine.WorkflowManager.GetDefaultWorkflow(WORKFLOW_CODE);
                if (workflowTemplate == null)
                {
                    result.INSTANCE_ID   = "";
                    result.MESSAGE       = "流程模板不存在,模板编码:" + WORKFLOW_CODE + "。";
                    result.STATUS        = "0";
                    result.WORKFLOW_CODE = WORKFLOW_CODE;
                    result.USER_CODE     = USER_CODE;
                    return(result);
                }
                // 查找流程发起人
                OThinker.Organization.User user = this.Engine.Organization.GetUserByCode(USER_CODE);
                if (user == null)
                {
                    result.INSTANCE_ID   = "";
                    result.MESSAGE       = "用户{" + USER_CODE + "}不存在。";
                    result.STATUS        = "0";
                    result.WORKFLOW_CODE = WORKFLOW_CODE;
                    result.USER_CODE     = USER_CODE;
                    return(result);
                }
                #endregion

                #region 流程实例ID为空:发起新流程
                if (string.IsNullOrEmpty(INSTANCE_ID))
                {
                    OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(workflowTemplate.BizObjectSchemaCode);
                    OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(
                        this.Engine.Organization,
                        this.Engine.MetadataRepository,
                        this.Engine.BizObjectManager,
                        null,
                        schema,
                        user.ObjectID,
                        user.ParentID);

                    if (listParams != null)
                    {
                        // 这里可以在创建流程的时候赋值
                        foreach (KeyValuePair <string, object> param in listParams)
                        {
                            OThinker.H3.DataModel.PropertySchema property = schema.GetProperty(param.Key);
                            if (property == null)
                            {
                                continue;
                            }
                            SetItemValue(bo, property, param.Value);
                        }
                    }

                    bo.Create();

                    // 创建流程实例
                    string InstanceId = this.Engine.InstanceManager.CreateInstance(
                        bo.ObjectID,
                        workflowTemplate.WorkflowCode,
                        workflowTemplate.WorkflowVersion,
                        null,
                        null,
                        user.UnitID,
                        null,
                        false,
                        InstanceContext.UnspecifiedID,
                        null,
                        Token.UnspecifiedID);

                    if (listParams != null)
                    {
                        // 这里可以在创建流程的时候赋值
                        foreach (KeyValuePair <string, object> param in listParams)
                        {
                            OThinker.H3.DataModel.PropertySchema property = schema.GetProperty(param.Key);
                            if (property == null)
                            {
                                continue;
                            }
                            if (property.LogicType == DataLogicType.Comment)
                            {// 审核意见
                                CommentParam comment = JsonConvert.DeserializeObject <CommentParam>(JsonConvert.SerializeObject(param.Value));
                                this.Engine.BizObjectManager.AddComment(new Comment()
                                {
                                    BizObjectId         = bo.ObjectID,
                                    BizObjectSchemaCode = schema.SchemaCode,
                                    InstanceId          = InstanceId,
                                    Activity            = workflowTemplate.StartActivityCode,
                                    TokenId             = 1,
                                    Approval            = OThinker.Data.BoolMatchValue.True,
                                    DataField           = property.Name,
                                    UserID      = user.ObjectID,
                                    UserName    = user.Name,
                                    SignatureId = comment.SignatureId,
                                    Text        = comment.Text
                                });
                            }
                        }
                    }

                    // 启动流程的消息
                    OThinker.H3.Messages.StartInstanceMessage startInstanceMessage
                        = new OThinker.H3.Messages.StartInstanceMessage(
                              MessageEmergencyType.Normal,
                              InstanceId,
                              workItemID,
                              null,
                              PriorityType.Normal,
                              FINISH_START,
                              null,
                              false,
                              OThinker.H3.Instance.Token.UnspecifiedID,
                              null);
                    Engine.InstanceManager.SendMessage(startInstanceMessage);

                    result.INSTANCE_ID   = InstanceId;
                    result.MESSAGE       = "流程实例启动成功!";
                    result.BIZOBJECTID   = bo.ObjectID;
                    result.STATUS        = "2";
                    result.WORKFLOW_CODE = WORKFLOW_CODE;
                    result.USER_CODE     = USER_CODE;
                }
                #endregion

                #region 流程实例ID不为空:更新流程数据;
                else
                {
                    InstanceContext ic = this.Engine.InstanceManager.GetInstanceContext(INSTANCE_ID);
                    if (ic == null)
                    {
                        result.INSTANCE_ID   = INSTANCE_ID;
                        result.MESSAGE       = "InstanceID错误,此ID在H3系统中不存在,请检查";
                        result.STATUS        = "0";
                        result.WORKFLOW_CODE = WORKFLOW_CODE;
                        result.USER_CODE     = USER_CODE;
                        return(result);
                    }

                    OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(workflowTemplate.BizObjectSchemaCode);
                    OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(
                        this.Engine.Organization,
                        this.Engine.MetadataRepository,
                        this.Engine.BizObjectManager,
                        null,
                        schema,
                        user.ObjectID,
                        user.ParentID);

                    bo.ObjectID = ic.BizObjectId;
                    bo.Load();//装载流程数据;

                    if (listParams != null)
                    {
                        // 这里可以在创建流程的时候赋值
                        foreach (KeyValuePair <string, object> param in listParams)
                        {
                            OThinker.H3.DataModel.PropertySchema property = schema.GetProperty(param.Key);
                            if (property == null)
                            {
                                continue;
                            }
                            SetItemValue(bo, property, param.Value);
                        }
                    }

                    bo.Update();
                    #region 提交当前任务,往下流转
                    if (FINISH_START)
                    {
                        string sql = "SELECT ObjectID FROM OT_WorkItem WHERE InstanceId='{0}' ORDER BY TokenId desc";
                        sql = string.Format(sql, INSTANCE_ID);
                        string workItemId = this.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(sql) + string.Empty;
                        if (workItemId != "")
                        {
                            // 获取工作项
                            OThinker.H3.WorkItem.WorkItem item = this.Engine.WorkItemManager.GetWorkItem(workItemId);

                            // 结束工作项
                            this.Engine.WorkItemManager.FinishWorkItem(
                                item.ObjectID,
                                user.UnitID,
                                OThinker.H3.WorkItem.AccessPoint.ExternalSystem,
                                null,
                                OThinker.Data.BoolMatchValue.True,
                                string.Empty,
                                null,
                                OThinker.H3.WorkItem.ActionEventType.Forward,
                                11);

                            // 需要通知实例事件管理器结束事件
                            AsyncEndMessage endMessage = new OThinker.H3.Messages.AsyncEndMessage(
                                MessageEmergencyType.Normal,
                                item.InstanceId,
                                item.ActivityCode,
                                item.TokenId,
                                OThinker.Data.BoolMatchValue.True,
                                false,
                                OThinker.Data.BoolMatchValue.True,
                                true,
                                null);
                            this.Engine.InstanceManager.SendMessage(endMessage);
                        }
                    }
                    #endregion

                    result.INSTANCE_ID   = INSTANCE_ID;
                    result.MESSAGE       = "流程实例启动成功!(更新数据项的值)";
                    result.BIZOBJECTID   = ic.BizObjectId;
                    result.STATUS        = "2";
                    result.WORKFLOW_CODE = WORKFLOW_CODE;
                    result.USER_CODE     = USER_CODE;
                }
                #endregion
            }
            catch (Exception ex)
            {
                result               = new RestfulResult();
                result.INSTANCE_ID   = "";
                result.BIZOBJECTID   = "";
                result.MESSAGE       = "接口异常:" + ex.ToString();
                result.STATUS        = "0";
                result.WORKFLOW_CODE = WORKFLOW_CODE;
                result.USER_CODE     = USER_CODE;
            }
            return(result);
        }
コード例 #6
0
        public System.Web.Mvc.ActionResult StartWorkflow(string appId, string pwd, string userCode, string workflowCode,
            bool finishStart, string paramValues)
        {
            BPMServiceResult result = new BPMServiceResult();

            List<DataItemParam> listParams = JSSerializer.Deserialize<List<DataItemParam>>(paramValues);
            string workItemID, keyItem, errorMessage;
            workItemID = keyItem = errorMessage = string.Empty;

            try
            {
                OThinker.H3.WorkflowTemplate.PublishedWorkflowTemplate workflowTemplate = this.Engine.WorkflowManager.GetDefaultWorkflow(workflowCode);
                if (workflowTemplate == null)
                {
                    result = new BPMServiceResult(false, "流程模板不存在,模板编码:" + workflowCode + "。");
                    return Json(result);
                }
                // 查找流程发起人
                OThinker.Organization.User user = this.Engine.Organization.GetUserByCode(userCode) as OThinker.Organization.User;
                if (user == null)
                {
                    result = new BPMServiceResult(false, "用户{" + userCode + "}不存在。");
                    return Json(result);
                }

                OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(workflowTemplate.BizObjectSchemaCode);
                OThinker.H3.DataModel.BizObject bo = new OThinker.H3.DataModel.BizObject(
                    this.Engine.Organization,
                    this.Engine.MetadataRepository,
                    this.Engine.BizObjectManager,
                    null,
                    schema,
                    user.ObjectID,
                    user.ParentID);

                if (listParams != null)
                {
                    // 这里可以在创建流程的时候赋值
                    foreach (DataItemParam param in listParams)
                    {
                        OThinker.H3.DataModel.PropertySchema property = schema.GetProperty(param.ItemName);
                        if (property == null) continue;
                        SetItemValue(bo, property, param.ItemValue);
                    }
                }


                bo.Create();

                // 创建流程实例
                string InstanceId = this.Engine.InstanceManager.CreateInstance(
                     bo.ObjectID,
                     workflowTemplate.WorkflowCode,
                     workflowTemplate.WorkflowVersion,
                     null,
                     null,
                     user.UnitID,
                     null,
                     false,
                     InstanceContext.UnspecifiedID,
                     null,
                     Token.UnspecifiedID);

                if (listParams != null)
                {
                    // 这里可以在创建流程的时候赋值
                    foreach (DataItemParam param in listParams)
                    {
                        OThinker.H3.DataModel.PropertySchema property = schema.GetProperty(param.ItemName);
                        if (property == null) continue;
                        if (property.LogicType == DataLogicType.Comment)
                        {// 审核意见
                            CommentParam comment = JSSerializer.Deserialize<CommentParam>(param.ItemValue + string.Empty);
                            this.Engine.BizObjectManager.AddComment(new Comment()
                            {
                                BizObjectId = bo.ObjectID,
                                BizObjectSchemaCode = schema.SchemaCode,
                                InstanceId = InstanceId,
                                Activity = workflowTemplate.StartActivityCode,
                                TokenId = 1,
                                Approval = OThinker.Data.BoolMatchValue.True,
                                DataField = property.Name,
                                UserID = user.ObjectID,
                                SignatureId = comment.SignatureId,
                                Text = comment.Text
                            });
                        }
                    }
                }

                // 启动流程的消息
                OThinker.H3.Messages.StartInstanceMessage startInstanceMessage
                    = new OThinker.H3.Messages.StartInstanceMessage(
                        MessageEmergencyType.Normal,
                        InstanceId,
                        workItemID,
                        null,
                        PriorityType.Normal,
                        true,
                        null,
                        false,
                        OThinker.H3.Instance.Token.UnspecifiedID,
                        null);
                Engine.InstanceManager.SendMessage(startInstanceMessage);
                result = new BPMServiceResult(true, InstanceId, workItemID, "流程实例启动成功!", string.Empty);
            }
            catch (Exception ex)
            {
                result = new BPMServiceResult(false, ex.ToString());
            }
            return Json(result, JsonRequestBehavior.AllowGet);
        }
コード例 #7
0
 public Page <Comments> findComments(CommentParam commentParam)
 {
     return(null);
 }
コード例 #8
0
 public ApiResponse <List <Comments> > CommentList(CommentParam commentParam)
 {
     return(ApiResponse <List <Comments> > .Ok(new List <Comments>()));
 }