예제 #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        this.txtMsg.Text = "开始压缩";
        string txtTitle        = this.txtTitle.Value.Trim();                                                                                       //标题
        string txtEmale        = this.txtEmale.Value.Trim();                                                                                       //邮件
        int    txtStartCount   = string.IsNullOrEmpty(this.txtStartCount.Value.Trim()) ? 0 : Convert.ToInt32(this.txtStartCount.Value.Trim());     //起始包
        int    txtPackageCount = string.IsNullOrEmpty(this.txtPackageCount.Value.Trim()) ? 0 : Convert.ToInt32(this.txtPackageCount.Value.Trim()); //包数量
        int    txtCount        = string.IsNullOrEmpty(this.txtCount.Value.Trim()) ? 0 : Convert.ToInt32(this.txtCount.Value.Trim());               //数量
        string txtCreateTime   = this.txtEffectiveDateBegin.Value;                                                                                 //压缩时间
        string txtEmaile       = this.txtEmale.Value.Trim();                                                                                       //邮件

        #region 查询串码数量是否足够
        if (cdal.GetRowCount(string.Format(" and ContentStatusId=2 ")) < txtCount * txtPackageCount)
        {
            this.txtMsg.Text = "库内数量不足";
            return;
        }
        #endregion

        #region 添加批次&&串码绑定批次
        ApployInfoModel amodel = new ApployInfoModel();
        amodel.ApployTime    = Convert.ToDateTime(txtCreateTime);
        amodel.CustomerEmail = txtEmaile;
        amodel.Type          = 0;
        amodel.Status        = 0;
        amodel.CreatedTime   = DateTime.Now;


        for (int i = 0; i < txtPackageCount; i++)
        {
            if (txtStartCount < 10)
            {
                amodel.Title = txtTitle + "0" + txtStartCount.ToString();   //标题
            }
            else
            {
                amodel.Title = txtTitle + txtStartCount.ToString();
            }
            amodel.FileName = amodel.Title + ".zip";    //文件名
            amodel.BathCode = amodel.Title;             //批次
            amodel.Secret   = GetCharAndNum(12);        //密码
            amodel.Url      = "/down/" + amodel.FileName;

            int ApployInfoId = adal.Add(amodel);

            if (ApployInfoId > 0)
            {
                cdal.SendPackage(txtCount, ApployInfoId);
            }

            txtStartCount++;
        }

        this.txtMsg.Text = "批量导包成功";
        #endregion
    }
예제 #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        this.txtMsg.Text = "开始压缩";
        string txtTitle      = this.txtTitle.Value.Trim();                                                                     //标题
        string txtFileName   = this.txtFileName.Value.Trim();                                                                  //压缩文件名称
        string txtBathCode   = this.txtBathCode.Value.Trim();                                                                  //批次
        string txtSecret     = this.txtSecret.Value.Trim();                                                                    //压缩密码
        int    txtCount      = string.IsNullOrEmpty(this.txtCount.Value.Trim())?0:Convert.ToInt32(this.txtCount.Value.Trim()); //数量
        string txtCreateTime = this.txtEffectiveDateBegin.Value;                                                               //压缩时间
        string txtEmaile     = this.txtEmale.Value.Trim();                                                                     //邮件

        #region 验证批次号唯一
        ApployInfoModel amodel = new ApployInfoModel();
        amodel = adal.GetModel(string.Format(" and FileName='{0}' ", txtFileName));
        if (amodel.ID > 0)
        {
            this.txtMsg.Text = "文件名不能重复";
            return;
        }
        #endregion

        #region 查询串码数量是否足够
        if (cdal.GetRowCount(string.Format(" and ContentStatusId=2 ")) < txtCount)
        {
            this.txtMsg.Text = "库内数量不足";
            return;
        }
        #endregion

        #region 添加批次&&串码绑定批次
        amodel.Title         = txtTitle;
        amodel.FileName      = txtFileName;
        amodel.ApployTime    = Convert.ToDateTime(txtCreateTime);
        amodel.BathCode      = txtBathCode;
        amodel.Secret        = txtSecret;
        amodel.CustomerEmail = txtEmaile;
        amodel.Type          = 0;
        amodel.Url           = "/down/" + amodel.FileName;
        amodel.Status        = 0;
        amodel.CreatedTime   = DateTime.Now;

        int ApployInfoId = adal.Add(amodel);

        if (ApployInfoId > 0)
        {
            int count = cdal.SendPackage(txtCount, ApployInfoId);
            if (count > 0)
            {
                ExportFileByZip(ApployInfoId);
            }
        }
        #endregion
    }