Beispiel #1
0
 private void LoadAllDocs(BackgroundWorker bw)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new System.Action <BackgroundWorker>(LoadAllDocs), bw);
     }
     else
     {
         List <DocObject> docs = null;
         if (allDocs)
         {
             docs = DocObjectLogic.GetInstance().GetAllDocObjects();
             bw.ReportProgress(50);
         }
         else
         {
             docs = new List <DocObject>();
             List <DocObject> doc = DocObjectLogic.GetInstance().GetDocObjectsByOwner(this.User);
             docs.AddRange(doc);
             bw.ReportProgress(30);
             List <int> tempIds = FlowTemplateLogic.GetInstance().GetTepmIdsByExecOrAppr(this.User.ID.ToString());
             bw.ReportProgress(50);
             List <DocObject> doc2 = DocObjectLogic.GetInstance().GetDocObjectsByTemplateId(tempIds);
             docs.AddRange(doc2);
             bw.ReportProgress(70);
         }
         LoadDocObjects(docs);
         if (owner != null)
         {
             owner.RefreshMsg("载入完毕");
         }
     }
 }
Beispiel #2
0
        public Flow GetFlow(int id)
        {
            string    sql = "select * from Flow where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                int              templateId  = Convert.ToInt32(dt.Rows[0]["TemplateID"]);
                FlowTemplate     template    = FlowTemplateLogic.GetInstance().GetFlowTemplate(templateId);
                List <TaskStage> stages      = new List <TaskStage>();
                string           stagesIds   = dt.Rows[0]["Stages"].ToString();
                string[]         stageIdList = stagesIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string stageId in stageIdList)
                {
                    TaskStage stage = TaskStageLogic.GetInstance().GetTaskStage(Convert.ToInt32(stageId));
                    if (stage != null)
                    {
                        stages.Add(stage);
                    }
                }
                Flow element = new Flow(Convert.ToInt32(dt.Rows[0]["ID"]), dt.Rows[0]["Name"].ToString(), template, Convert.ToInt32(dt.Rows[0]["CurrentIndex"]), dt.Rows[0]["Remark"].ToString(), stages);
                return(element);
            }
            return(null);
        }
Beispiel #3
0
        public int AddTaskInfo(TaskInfo element)
        {
            string sql = "insert into TaskInfo (EntityId, FlowID, Sponsor, Remark) values (" + element.EntityId + ", " + element.Flow.ID + ", '" + element.Sponsor + "', '" + element.Remark + "'); select SCOPE_IDENTITY()";
            object obj = sqlHelper.ExecuteSqlReturn(sql);
            int    R;

            if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R))
            {
                Flow flow = FlowLogic.GetInstance().GetFlow(element.Flow.ID);
                if (flow != null)
                {
                    FlowTemplate temp = FlowTemplateLogic.GetInstance().GetFlowTemplate(flow.Template.ID);
                    if (temp != null)
                    {
                        Alert alert = new Alert();
                        alert.提醒对象 = string.Join(",", temp.Stages[flow.CurrentIndex].Executors.ToArray());
                        alert.提醒方式 = 提醒方式.执行流程;
                        alert.提醒时间 = DateTime.Now;
                        alert.提醒项目 = flow.Name;
                        alert.备注   = flow.ID.ToString();
                        AlertLogic.GetInstance().AddAlert(alert);
                        Alert alert2 = new Alert();
                        alert2.提醒对象 = string.Join(",", temp.Stages[flow.CurrentIndex].Approvers.ToArray());
                        alert2.提醒方式 = 提醒方式.审批流程;
                        alert2.提醒时间 = DateTime.Now;
                        alert2.提醒项目 = flow.Name;
                        alert.备注    = flow.ID.ToString();
                        AlertLogic.GetInstance().AddAlert(alert2);
                        return(R);
                    }
                }
            }
            return(0);
        }
Beispiel #4
0
        public List <Flow> GetAllFlows()
        {
            List <Flow> elements = new List <Flow>();
            string      sql      = "select * from Flow order by ID desc";
            DataTable   dt       = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                TaskStageLogic tsl = TaskStageLogic.GetInstance();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    FlowTemplate     template    = FlowTemplateLogic.GetInstance().GetFlowTemplate(Convert.ToInt32(dt.Rows[i]["TemplateID"]));
                    List <TaskStage> stages      = new List <TaskStage>();
                    string           stagesIds   = dt.Rows[i]["Stages"].ToString();
                    string[]         stageIdList = stagesIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (string stageId in stageIdList)
                    {
                        TaskStage stage = TaskStageLogic.GetInstance().GetTaskStage(Convert.ToInt32(stageId));
                        if (stage != null)
                        {
                            stages.Add(stage);
                        }
                    }
                    Flow element = new Flow(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), template, Convert.ToInt32(dt.Rows[i]["CurrentIndex"]), dt.Rows[i]["Remark"].ToString(), stages);
                    elements.Add(element);
                }
            }
            return(elements);
        }
Beispiel #5
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex > -1)
     {
         if (MessageBox.Show("确定要删除该流程模板么?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
         {
             FlowTemplate temp = (FlowTemplate)listBox1.SelectedItem;
             if (temp != null)
             {
                 if (FlowTemplateLogic.GetInstance().DeleteFlowTemplate(temp))
                 {
                     LoadAllTemps();
                     MessageBox.Show("删除成功!");
                 }
                 else
                 {
                     MessageBox.Show("删除失败!");
                 }
             }
         }
     }
     else
     {
         MessageBox.Show("请先选定要删除的流程模板!");
     }
 }
        public static FlowTemplateLogic GetInstance()
        {
            if (instance == null)
            {
                instance = new FlowTemplateLogic();
            }

            return(instance);
        }
Beispiel #7
0
        private void LoadFormObjects(int stageCount)
        {
            List <FlowTemplate> temps = FlowTemplateLogic.GetInstance().GetFlowTemplates(null, stageCount);

            listBox1.Items.Clear();
            foreach (FlowTemplate temp in temps)
            {
                listBox1.Items.Add(temp);
            }
        }
Beispiel #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            FlowTemplate template = new FlowTemplate(0, textBox1.Text.Trim(), flowTemplateControl1.Nodes);
            int          i        = FlowTemplateLogic.GetInstance().AddFlowTemplate(template);

            if (i > 0)
            {
                MessageBox.Show("添加流程模板成功!");
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
Beispiel #9
0
        /// <summary>
        /// 获取指定的流程
        /// </summary>
        /// <param name="name"></param>
        /// <param name="status">1为未完成,2为已完成,其他为所有</param>
        /// <returns></returns>
        public List <Flow> GetFlows(string name, int status)
        {
            List <Flow> elements = new List <Flow>();

            string where = "where (1=1)";
            if (!string.IsNullOrEmpty(name))
            {
                where += " and Name like '%" + name + "%'";
            }
            string    sql = "select * from Flow " + where + " order by ID desc";
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                TaskStageLogic tsl = TaskStageLogic.GetInstance();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    FlowTemplate     template    = FlowTemplateLogic.GetInstance().GetFlowTemplate(Convert.ToInt32(dt.Rows[i]["TemplateID"]));
                    List <TaskStage> stages      = new List <TaskStage>();
                    string           stagesIds   = dt.Rows[i]["Stages"].ToString();
                    string[]         stageIdList = stagesIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (string stageId in stageIdList)
                    {
                        TaskStage stage = TaskStageLogic.GetInstance().GetTaskStage(Convert.ToInt32(stageId));
                        if (stage != null)
                        {
                            stages.Add(stage);
                        }
                    }
                    int  currentIndex = Convert.ToInt32(dt.Rows[i]["CurrentIndex"]);
                    Flow element      = new Flow(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), template, currentIndex, dt.Rows[i]["Remark"].ToString(), stages);
                    if (status == 1)
                    {
                        if ((currentIndex < stages.Count - 1) || (currentIndex == stages.Count - 1 && stages[stages.Count - 1].Status != TaskStatus.Finished))
                        {
                            elements.Add(element);
                        }
                    }
                    else if (status == 2)
                    {
                        if (currentIndex == stages.Count - 1 && stages[stages.Count - 1].Status == TaskStatus.Finished)
                        {
                            elements.Add(element);
                        }
                    }
                    else
                    {
                        elements.Add(element);
                    }
                }
            }
            return(elements);
        }
Beispiel #10
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (templateId > 0)
     {
         FlowTemplate template = new FlowTemplate(templateId, textBox1.Text.Trim(), flowTemplateControl1.Nodes);
         if (FlowTemplateLogic.GetInstance().UpdateFlowTemplate(template))
         {
             MessageBox.Show("修改流程模板成功!");
             this.DialogResult = System.Windows.Forms.DialogResult.OK;
         }
     }
     else
     {
         MessageBox.Show("请先指定一个要修改的流程模板!或者当前是添加新的流程模板,请点击【添加】按钮。");
     }
 }
Beispiel #11
0
 private List <FlowTemplate> Search(string name, int stageCount)
 {
     return(FlowTemplateLogic.GetInstance().GetFlowTemplates(name, stageCount));
 }
Beispiel #12
0
        private void LoadAllTemps()
        {
            List <FlowTemplate> templates = FlowTemplateLogic.GetInstance().GetAllFlowTemplates();

            LoadFlowTemplates(templates);
        }