Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MapData       md      = new MapData(this.FK_MapData);
            FrmAttachment athDesc = new FrmAttachment();
            int           i       = athDesc.Retrieve(FrmAttachmentAttr.FK_MapData,
                                                     this.FK_MapData, FrmAttachmentAttr.NoOfObj, "DocMainAth");

            if (i == 0)
            {
                /*如果没有数据.*/
                /*如果没有查询到它,就有可能是公文多附件被删除了.*/
                athDesc.NoOfObj    = "DocMainAth";
                athDesc.Exts       = "doc,docx,xls,xlsx";
                athDesc.MyPK       = athDesc.FK_MapData + "_" + athDesc.NoOfObj;
                athDesc.FK_MapData = this.FK_MapData;


                //存储路径.
                string path = Server.MapPath("/DataUser/UploadFile/");
                path          += "\\F" + this.FK_Flow + "MainAth";
                athDesc.SaveTo = path;

                //位置.
                athDesc.X = (float)94.09;
                athDesc.Y = (float)140.18;
                athDesc.W = (float)626.36;
                athDesc.H = (float)150;

                //多附件.
                athDesc.UploadType = AttachmentUploadType.Single;
                athDesc.Name       = "公文正文(系统自动增加)";
                athDesc.SetValByKey("AtPara",
                                    "@IsWoEnablePageset=1@IsWoEnablePrint=1@IsWoEnableViewModel=1@IsWoEnableReadonly=0@IsWoEnableSave=1@IsWoEnableWF=1@IsWoEnableProperty=1@IsWoEnableRevise=1@IsWoEnableIntoKeepMarkModel=1@FastKeyIsEnable=0@IsWoEnableViewKeepMark=1@FastKeyGenerRole=@IsWoEnableTemplete=1");
                athDesc.Insert();

                //有可能在其其它的节点上没有这个附件,所以也要循环增加上它.
                BP.WF.Nodes nds = new Nodes(this.FK_Flow);
                foreach (Node nd in nds)
                {
                    athDesc.FK_MapData = "ND" + nd.NodeID;
                    athDesc.MyPK       = athDesc.FK_MapData + "_" + athDesc.NoOfObj;
                    if (athDesc.IsExits == true)
                    {
                        continue;
                    }
                    athDesc.Insert();
                }

                //重新查询一次,把默认值加上.
                athDesc.RetrieveFromDBSources();
            }

            FrmAttachmentDBs athDBs = null;

            athDBs = new FrmAttachmentDBs(this.FK_MapData, this.WorkID.ToString());

            FrmAttachmentDB athDB = null;

            if (athDBs.Count == 0 && this.IsCC == "1")
            {
                /*如果是抄送过来的, 有可能是抄送到的节点不是发送到的节点,导致附件数据没有copy。
                 * 也就是说,发给b节点,但是抄送到c节点上去了,导致c节点上的人看不到附件数据。*/

                CCList cc  = new CCList();
                int    nnn = cc.Retrieve(CCListAttr.FK_Node, this.FK_Node, CCListAttr.WorkID, this.WorkID, CCListAttr.CCTo, WebUser.No);
                this._fk_node = cc.NDFrom;
                if (cc.NDFrom != 0)
                {
                    athDBs.Retrieve(FrmAttachmentDBAttr.FK_MapData, "ND" + cc.NDFrom, FrmAttachmentDBAttr.RefPKVal, this.WorkID.ToString());

                    string ndFromMapdata = athDesc.MyPK.Replace(athDesc.FK_MapData, "ND" + cc.NDFrom);
                    athDB = athDBs.GetEntityByKey(FrmAttachmentDBAttr.FK_FrmAttachment, ndFromMapdata) as FrmAttachmentDB;
                    //重新设置文件描述。
                    athDesc.Retrieve(FrmAttachmentAttr.FK_MapData, this.FK_MapData, FrmAttachmentAttr.NoOfObj, "DocMainAth");
                }
            }
            else
            {
                /* 单个文件 */
                athDB = athDBs.GetEntityByKey(FrmAttachmentDBAttr.FK_FrmAttachment, athDesc.MyPK) as FrmAttachmentDB;
            }


            Label lab = new Label();

            lab.ID = "Lab" + athDesc.MyPK;
            this.Pub1.Add(lab);
            if (athDB != null)
            {
                if (athDB.FileExts == "ceb")
                {
                    athDB.FileExts = "pdf";
                }
                if (athDesc.IsWoEnableWF)
                {
                    lab.Text = "<a  href=\"javascript:OpenOfiice('" + athDB.FK_FrmAttachment + "','" + this.WorkID + "','" + athDB.MyPK + "','" + this.FK_MapData + "','" + athDesc.NoOfObj + "','" + this.FK_Node + "')\"><img src='" + BP.WF.Glo.CCFlowAppPath + "WF/Img/FileType/" + athDB.FileExts + ".gif' border=0/>" + athDB.FileName + "</a>";
                }
                else
                {
                    lab.Text = "<img src='" + BP.WF.Glo.CCFlowAppPath + "WF/Img/FileType/" + athDB.FileExts + ".gif' border=0/>" + athDB.FileName;
                }
            }

            #region 处理权限问题.
            // 处理权限问题, 有可能当前节点是可以上传或者删除,但是当前节点上不能让此人执行工作。
            bool isDel    = athDesc.IsDeleteInt == 0 ? false : true;
            bool isUpdate = athDesc.IsUpload;
            if (isDel == true || isUpdate == true)
            {
                if (this.WorkID != 0 &&
                    string.IsNullOrEmpty(this.FK_Flow) == false)
                {
                    isDel = BP.WF.Dev2Interface.Flow_IsCanDoCurrentWork(this.FK_Flow, this.FK_Node, this.WorkID, WebUser.No);
                    if (isDel == false)
                    {
                        isUpdate = false;
                    }
                }
            }
            #endregion 处理权限问题.

            Button mybtn = new Button();
            mybtn.CssClass = "Btn";

            if (athDesc.IsUpload && isUpdate == true)
            {
                FileUpload fu = new FileUpload();
                fu.ID                     = athDesc.MyPK;
                Btn_Upload.ID             = "Btn_Upload_" + athDesc.MyPK + "_" + this.WorkID;
                fu.Attributes["Width"]    = athDesc.W.ToString();
                fu.Attributes["onchange"] = "UploadChange('" + mybtn.ID + "');";
                this.Pub1.Add(fu);
            }

            if (athDesc.IsDownload)
            {
                mybtn          = new Button();
                mybtn.Text     = "下载";
                mybtn.CssClass = "Btn";

                mybtn.ID       = "Btn_Download_" + athDesc.MyPK + "_" + this.WorkID;
                mybtn.Click   += new EventHandler(btnUpload_Click);
                mybtn.CssClass = "bg";
                if (athDB == null)
                {
                    mybtn.Visible = false;
                }
                else
                {
                    mybtn.Visible = true;
                }
                this.Pub1.Add(mybtn);
            }

            if (this.IsReadonly == false)
            {
                if (athDesc.IsDeleteInt != 0 && isDel == true)
                {
                    bool isDeleteBtn = true;
                    if (athDesc.IsDeleteInt == 2)
                    {
                        if (!athDB.Rec.Equals(WebUser.No))
                        {
                            isDeleteBtn = false;
                        }
                    }
                    if (isDeleteBtn)
                    {
                        mybtn          = new Button();
                        mybtn.CssClass = "Btn";
                        mybtn.Text     = "删除";
                        mybtn.Attributes["onclick"] = " return confirm('您确定要执行删除吗?');";
                        mybtn.ID       = "Btn_Delete_" + athDesc.MyPK + "_" + this.WorkID;
                        mybtn.Click   += new EventHandler(btnUpload_Click);
                        mybtn.CssClass = "bg";
                        if (athDB == null)
                        {
                            mybtn.Visible = false;
                        }
                        else
                        {
                            mybtn.Visible = true;
                        }
                        this.Pub1.Add(mybtn);
                    }
                }

                if (athDesc.IsWoEnableWF)
                {
                    mybtn          = new Button();
                    mybtn.CssClass = "Btn";
                    mybtn.Text     = "打开";
                    mybtn.ID       = "Btn_Open_" + athDesc.MyPK + "_" + this.WorkID;
                    mybtn.Click   += new EventHandler(btnUpload_Click);
                    mybtn.CssClass = "bg";
                    if (athDB == null)
                    {
                        mybtn.Visible = false;
                    }
                    else
                    {
                        mybtn.Visible = true;
                    }
                    this.Pub1.Add(mybtn);
                }
            }
        }
Exemplo n.º 2
0
        protected void Btn_Start_Click(object sender, EventArgs e)
        {
            People en = new People();

            en.No = this.TB_SFZ.Text;
            if (en.RetrieveFromDBSources() == 0)
            {
                this.Response.Write("证件号码错误.....");
                return;
            }

            //获得该节点需要的证照信息,并把证照写入到附件表里.
            Node nd = new Node(int.Parse(this.FK_Flow + "01"));
            Work wk = nd.HisWork;

            //获得附件描述.
            FrmAttachment ath = new FrmAttachment("ND" + nd.NodeID + "_AttachM1");

            string[] sort = ath.Sort.Split(','); //获得附件类型.
            if (sort.Length == 1)
            {
                throw new Exception("@该流程不需要上传证照信息.");
            }

            //删除原来的数据,如果有。
            FrmAttachmentDBs dbs = new FrmAttachmentDBs();

            dbs.Delete(FrmAttachmentDBAttr.RefPKVal, this.WorkID);

            //求出证件库下的证照集合.
            Licenses lis = new Licenses(this.SFZ);

            //开始象流程的开始节点写附件数据.
            foreach (string str in sort)
            {
                foreach (License li in lis)
                {
                    if (li.Name != str)
                    {
                        continue; //不是continue.
                    }
                    FrmAttachmentDB db = new FrmAttachmentDB();
                    db.MyPK       = BP.DA.DBAccess.GenerGUID();
                    db.UploadGUID = li.MyPK;
                    db.Rec        = BP.Web.WebUser.No;
                    db.RecName    = BP.Web.WebUser.Name;

                    db.RDT              = BP.DA.DataType.CurrentDataTime;
                    db.MyNote           = "从证照库导入";
                    db.FID              = 0;
                    db.RefPKVal         = this.WorkID.ToString();
                    db.FK_FrmAttachment = "ND" + nd.NodeID + "_AttachM1";
                    db.FK_MapData       = "ND" + nd.NodeID;
                    db.FileFullName     = li.FilePath;
                    db.FileName         = str;
                    db.FileExts         = li.Ext;
                    db.FileSize         = li.FileSize;
                    db.Sort             = str;
                    db.Insert();
                }
            }

            //生成Url把其他的参数带入里面去.
            string url = "/WF/MyFlow.aspx?FK_Flow=" + this.FK_Flow + "&IsCheckGuide=1&DiZhi=" + en.Addr + "&SFZH=" + en.No + "&DianHua=" + en.Tel + "&XingBie=" + en.XB + "&YouJian=" + en.Email + "&XingMing=" + en.Name;

            this.Response.Redirect(url, true);
        }