public void SetPrintAttachExport(UC_Print ucPrint, EntityLetterSend cEntity)
 {
     switch (ucPrint.FileName)
     {
         case "函件发文表单":
             //ucPrint.WriteContent("拟稿/日期:", WriteMode.Up, 1);
             //ucPrint.WriteAttach();
             break;
     }
 }
        public void SetPrintBeginExport(UC_Print ucPrint, EntityLetterSend cEntity)
        {
            switch (ucPrint.FileName)
            {
                case "函件发文表单":

                    ucPrint.ExportData.Add(cEntity.company1);  //<col>主送单位:|right</col>
                    ucPrint.ExportData.Add(cEntity.ourRef);    //<col>我方发文号:|right</col>
                    ucPrint.ExportData.Add(cEntity.to);       //<col>主送人:|right</col>
                    ucPrint.ExportData.Add(cEntity.yourRef);   //<col>对方发文号:|right</col>

                    ucPrint.ExportData.Add(cEntity.ccCompany); //<col>抄送单位:|right</col>
                    ucPrint.ExportData.Add(cEntity.ccDept + "\r\n" + cEntity.ccLeader);   //<col>内部抄送:|right</col>
                    ucPrint.ExportData.Add(cEntity.pages);     //<col>页数:|right</col>

                    //string str = string.Empty;

                    //System.Drawing.Font font = new Font("Wingdings 2", 10);

                    //if (cEntity.jinJi)
                    //{
                    //    //str = "紧急";
                    //    //ucPrint.FontStyle.FontName = "Wingdings 2";
                    //    //str += (char)0x0052;
                    //    //ucPrint.FontStyle.FontName = "仿宋";
                    //}
                    //else
                    //{
                    //    str = "紧急□";
                    //}
                    //ucPrint.ExportData.Add(str);
                    //if (cEntity.huiZhi)
                    //{
                    //    //str = "回复";
                    //    //ucPrint.FontStyle.FontName = "Wingdings 2";
                    //    //str += (char)0x0052;
                    //    //ucPrint.FontStyle.FontName = "仿宋";
                    //}
                    //else
                    //{
                    //    str = "回复□";
                    //}
                    //ucPrint.ExportData.Add(str);
                    if (ucPrint.IsCN(cEntity.signDate) == true)
                        ucPrint.ExportData.Add(cEntity.signDate);           //<col>签发/日期:|right</col>
                    else
                        ucPrint.ExportData.Add(cEntity.qianFaRen+"\n"+ucPrint.CheckDateTime(cEntity.signDate));

                    ucPrint.ExportData.Add(cEntity.DocumentTitle);            ////<col>主题:|right</col>//.subject
                    //string tmp = cEntity.content.Replace("<br/>", "\r\n");  //<col>内容|shift</col>
                    //tmp = tmp.Replace("&nbsp", " ");
                    //tmp = tmp.Replace("&lt", "<");
                    //tmp = tmp.Replace("&gt", ">");
                    //tmp = tmp.Replace("&quot", "\"");
                    //string tmp = SysString.HtmlToTextCode(cEntity.content);
                    string tmp = cEntity.content;//renjinquan+
                    if (!string.IsNullOrEmpty(tmp))
                    {
                        ucPrint.ExportData.Add(tmp);
                    }
                    else
                    {
                        ucPrint.ExportData.Add("");
                    }
                    ucPrint.ExportData.Add(cEntity.Drafter + "\n" + ucPrint.CheckDateTime(cEntity.DraftDate.ToString()));       //<col>拟稿/日期:|right</col>

                    if (ucPrint.IsCN(cEntity.heGaoRenDate)==false)
                        ucPrint.ExportData.Add(cEntity.heGaoRen+"\n"+ ucPrint.CheckDateTime(cEntity.heGaoRenDate));       //<col>核稿/日期:|right</col>
                    else
                        ucPrint.ExportData.Add(ucPrint.CheckDateTime(cEntity.heGaoRenDate));
                    string result1 = FormatSplit(EntityToHuiQian(cEntity), new char[] { ';' });
                    result1 = FormatSplit(result1, new char[] { ' ' });
                    ucPrint.ExportData.Add(result1);                   //<col>会签/日期:|right</col>
                    //ucPrint.ExportData.Add(ucPrint.AttachFilesList(cEntity.FileList));                   //<col>附件:|down</col>

                    //ucPrint.AttachFileList = cEntity.FileList;
                    ucPrint.Position = "拟稿/日期:";
                    ucPrint.Mode = WriteMode.Up;
                    break;
            }
        }
 private string EntityToHuiQian(EntityLetterSend entity)
 {
     if (entity.huiQian.Count > 0)//新版从list里取
     {
         string shuiqian = "";
         if (entity.huiQian.Count > 0)
         {
             for (int i = 0; i < entity.huiQian.Count; i++)
             {
                 if (entity.huiQian[i].ICount == entity.iHuiQianCount)
                 {
                     shuiqian += ";" + entity.huiQian[i].UserName + " " + entity.huiQian[i].Date.ToString(DateFormat);
                 }
             }
             if (shuiqian.Length > 0)
             {
                 shuiqian = shuiqian.Substring(1);
             }
         }
         return shuiqian;
     }
     else
     {            //兼容旧版
         if (entity.huiqianDates != "")
         {
             return entity.huiqianDates;
         }
     }
     return "";
 }
        /// <summary>
        /// 复制函件发文
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="p_strStepName"></param>
        /// <param name="receiveUserID"></param>
        /// <param name="p_strProcessID"></param>
        /// <param name="p_strWorkItemID"></param>
        /// <returns></returns>
        private bool CopyLSInfo(String ID, String p_strStepName, String p_strUserID, String p_strProcessID, String p_strWorkItemID, String p_strPoolID)
        {
            try
            {
                EntityLetterSend selectEntity = new EntityLetterSend();
                selectEntity.ID = int.Parse(ID);

                EntityLetterSend newEntity = new EntityLetterSend();
                selectEntity.Clone(newEntity);

                newEntity.WorkItemID = p_strWorkItemID;
                newEntity.StepName = p_strStepName;
                newEntity.ReceiveUserID = p_strUserID;
                newEntity.D_StepStatus = String.IsNullOrEmpty(p_strPoolID) ? "Assign" : "New";//公办:New 其他:Assign
                return newEntity.Save();
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        private void Print_OnBeginExport(object sender, EventArgs e)
        {
            if (m_print == null || m_print.m_ls == null || m_print.m_ls.Count == 0) return;
            Print print = new Print();

            m_Entity = m_print.m_CurrEntity as EntityLetterSend;
            print.SetPrintBeginExport(m_print, m_Entity);
        }
        private void Print_OnExtraExport(object sender, EventArgs e)
        {
            if (m_print == null || m_Entity == null) return;
            Print print = new Print();
            switch (m_print.FileName)
            {
                case "函件发文表单":
                    m_print.BatchAddPicture("函件发文", "函件发文表单", m_Entity);
                    break;
            }

            if (this.IsPreview)
            {
                //m_Entity = ControlToEntity(false) as EntityLetterSend;
            }
            else
            {
                m_Entity = ControlToEntity(false) as EntityLetterSend;
            }

            if (m_Entity.jinJi)
            {
                m_print.WriteByFont(0x0052, 2, "Wingdings 2");
            }
            else
            {
                m_print.WriteByFont(0x00A3, 2, "Wingdings 2");
            }
            if (m_Entity.huiZhi)
            {
                m_print.WriteByFont(0x0052, 1, "Wingdings 2");
            }
            else
            {
                m_print.WriteByFont(0x00A3, 1, "Wingdings 2");
            }

            ArrayList al = new ArrayList();
            for (int i = 0; i < m_Entity.FileList.Count; i++)
            {
                ArrayList tmp = new ArrayList();
                tmp.Add((i + 1).ToString());
                tmp.Add(m_Entity.FileList[i].Alias + "." + m_Entity.FileList[i].Type);
                tmp.Add(m_Entity.FileList[i].Encode/* + "  " + m_Entity.FileList[i].Edition*/);
                tmp.Add(m_Entity.FileList[i].iPage);
                al.Add(tmp);
            }
            m_print.WriteTable(1, 1, al);
        }
        private bool CheckData(EntityLetterSend entity)
        {
            List<String> arrErr = new List<string>();

            if (entity.DocumentTitle == "")
            {
                arrErr.Add("标题不能为空!");
            }
            if (entity.DocumentTitle.Contains("#") || entity.DocumentTitle.Contains("'"))
            {
                arrErr.Add("含有特殊字符,请替换后再上传");
            }
            if (entity.company == "")
            {
                arrErr.Add("主送单位不能为空!");
            }
            if (entity.pages != "")
            {
                if (!Regex.IsMatch(entity.pages.Trim(), @"^[0-9]*[1-9][0-9]*$", RegexOptions.IgnoreCase))
                {
                    arrErr.Add("页数应为正整数!");
                }
            }

            if (entity.content == "")
            {
                arrErr.Add("正文不能为空!");
            }

            switch (base.StepName)
            {
                #region 发起函件
                case ProcessConstString.StepName.LetterSend.发起函件:
                    if (entity.sendDeptID1 == "")
                    {
                        arrErr.Add("发文部门不能为空!");
                    }

                    //根据提交动作做不同的判断
                    if (entity.SubmitAction == "提交核稿")
                    {
                        if (string.IsNullOrEmpty(entity.wfHeGaoRenID))
                        {
                            arrErr.Add("核稿人不能为空!");
                        }
                    }
                    if (entity.SubmitAction == "提交会签")
                    {
                        if (string.IsNullOrEmpty(wfHeGaoRenID.Text) == false)
                        {
                            arrErr.Add("请先清空核稿人后再提交会签!");
                        }
                        if (string.IsNullOrEmpty(entity.wfHuiQianRenIDs))
                        {
                            arrErr.Add("会签人不能为空!");
                        }
                    }
                    if (entity.SubmitAction == "提交签发")
                    {
                        if (string.IsNullOrEmpty(wfHeGaoRenID.Text) == false)
                        {
                            arrErr.Add("请先清空核稿人后再提交签发!");
                        }
                        if (string.IsNullOrEmpty(wfHuiQianRenIDs.Text) == false)
                        {
                            arrErr.Add("请先清空会签人后再提交签发!");
                        }
                        if (string.IsNullOrEmpty(entity.wfQianFaRenID))
                        {
                            arrErr.Add("签发人不能为空!");
                        }
                    }
                    if (string.IsNullOrEmpty(entity.wfFaQiRenID))
                    {
                        arrErr.Add("发起人不能为空!");
                    }
                    if (string.IsNullOrEmpty(entity.wfQianFaRenID))
                    {
                        arrErr.Add("签发人不能为空!");
                    }

                    break;
                #endregion

                #region 核稿
                case ProcessConstString.StepName.LetterSend.核稿:
                    if (entity.SubmitAction == "提交会签")
                    {
                        if (string.IsNullOrEmpty(entity.wfHuiQianRenIDs))
                        {
                            arrErr.Add("会签人不能为空!");
                        }
                        if (string.IsNullOrEmpty(entity.wfQianFaRenID))
                        {
                            arrErr.Add("签发人不能为空!");
                        }
                    }
                    if (entity.SubmitAction == "提交签发")
                    {
                        if (string.IsNullOrEmpty(entity.wfHuiQianRenIDs) == false)
                        {
                            arrErr.Add("请先清空会签人后再提交签发!");
                        }
                    }
                    break;
                #endregion

                #region 会签
                case ProcessConstString.StepName.LetterSend.会签:
                    if (entity.SubmitAction == "提交签发")
                    {
                        if (string.IsNullOrEmpty(entity.wfQianFaRenID))
                        {
                            arrErr.Add("签发人不能为空!");
                        }
                    }
                    break;
                #endregion

                #region 签发

                case ProcessConstString.StepName.LetterSend.签发:
                    if (entity.HanJianAdminID == "")
                    {
                        arrErr.Add("角色:函件管理员没有成员!");
                    }
                    break;
                #endregion

                #region 函件分发
                case ProcessConstString.StepName.LetterSend.函件分发:
                    if (entity.SubmitAction == "完成")
                    {
                        if (entity.pages == "")
                        {
                            arrErr.Add("页数不能为空!");
                        }
                        if (txtOurRef.Text.Trim() == "")
                        {
                            arrErr.Add("我方发文号不能为空!");
                        }
                        if (ucAttachment.UCDataList.Count == 0)
                        {
                            arrErr.Add("附件不能为空!");
                        }
                    }
                    if (entity.SubmitAction == "退回")
                    {

                    }
                    break;
                #endregion

                case ProcessConstString.StepName.LetterSend.二次分发:
                    entity.ourRef = txtOurRef.Text;
                    entity.DocumentNo = txtOurRef.Text;
                    break;
                default: break;
            }

            if (arrErr.Count > 0)
            {
                //JScript.ShowErrMsg(Page, arrErr);
                string strMessages = string.Empty;
                if (arrErr.Count > 0)
                {
                    for (int i = 0; i < arrErr.Count; i++)
                    {
                        if (i == 0)
                        {
                            strMessages = arrErr[i];
                        }
                        else
                        {
                            strMessages += "\\n" + arrErr[i];
                        }
                    }
                }
                JScript.Alert(strMessages, false);
                return false;
            }
            return true;
        }
        private string GetCYNames(EntityLetterSend entity)
        {
            string chuanYueIDs = "";
            if (entity.ccLeaderIDs != "")
            {
                chuanYueIDs += entity.ccLeaderIDs + ";";
            }
            if (entity.deptLeaderIDs != "") //旧版才有
            {
                chuanYueIDs += entity.deptLeaderIDs + ";";
            }
            if (entity.DrafterID != "") // 发起人
            {
                chuanYueIDs += entity.DrafterID + ";";
            }
            if (entity.wfHeGaoRenID != "") //核稿人
            {
                chuanYueIDs += entity.wfHeGaoRenID + ";";
            }
            if (entity.wfHuiQianRenIDs != "") //会签人
            {
                chuanYueIDs += entity.wfHuiQianRenIDs + ";";
            }
            if (entity.wfQianFaRenID != "") //签发人
            {
                chuanYueIDs += entity.wfQianFaRenID + ";";
            }

            return chuanYueIDs;
        }