Esempio n. 1
0
        protected void btnNext_Click(object sender, EventArgs e)
        {
            string commonExcelPath = ConfigurationManager.AppSettings["RootRadioSmartXLS"] + System.IO.Path.DirectorySeparatorChar;

            string[] strExcelPathArr = hfExcelPath.Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            string[] strExcelNameArr = txtUploadExcelFile.Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            string   strImagePath    = hfImagePath.Value.Trim('|');
            string   currentURL      = Request.Url.ToString();
            int      cusId           = Profile.CusId;
            string   cusName         = Profile.CusName;
            string   tids            = string.Empty;
            string   errorMessage    = string.Empty;

            if (!string.IsNullOrEmpty(txtCusName.Value.Trim()))
            {
                Customer customer = monitor.GetCustomerInfoByName(txtCusName.Value.Trim());
                if (customer != null)
                {
                    cusId   = customer.CusId;
                    cusName = customer.CusName;
                }
            }
            int sid = SId > 0 ? SId : monitor.AddSchedule(txtScheduleName.Value);

            for (int i = 0; i < strExcelPathArr.Length; i++)
            {
                int tid = monitor.AddTask(cusId, cusName, strExcelNameArr[i].Substring(0, strExcelNameArr[i].LastIndexOf('.')), sid, strExcelPathArr[i], strImagePath == "," ? "" : strImagePath);
                if (tid > 0)
                {
                    int result = Resolve(tid, commonExcelPath, strExcelPathArr[i]);
                    if (result == 0)
                    {
                        tids += tid + ",";
                        continue;
                    }
                    else if (result == -1)
                    {
                        errorMessage += (strExcelNameArr[i] + "排期格式错误,");
                        continue;
                    }
                    else
                    {
                        errorMessage += ("Excel" + strExcelNameArr[i] + "第" + result + "行解析出错,");
                        continue;
                    }
                }
                else
                {
                    ScriptHelper.ShowCustomScript(this, "effect.Dialog.alert_error('操作出错!',function(){window.history.go(-1)})");
                    return;
                }
            }
            if (Profile.CustomerType == 0)
            {
                //给客户发邮件
                string subject  = "友情提醒--户外监测上传Excel了";
                string mailInfo = "户外监测客户" + Profile.CusName + "刚刚上传Excel生成了任务,排期号:" + sid + ",任务号:" + tids.Trim(',');
                NotifyHelper.SendMailNotify(ConfigurationManager.AppSettings["SendEmailAddress"].ToString(), "", subject, mailInfo);
            }
            if (!string.IsNullOrEmpty(beginDate) && !string.IsNullOrEmpty(endDate))
            {
                monitor.UpdateScheduleDate(sid, ConvertHelper.GetDateTime(beginDate), ConvertHelper.GetDateTime(endDate));
            }
            if (!string.IsNullOrEmpty(errorMessage))
            {
                ScriptHelper.ShowCustomScript(this, "effect.Dialog.alert_error('" + errorMessage + "',function(){window.location.href='TaskList.aspx?sid=" + sid + "'})");
                if (monitor.GetTaskListCount(" SId=" + sid) == 0)
                {
                    monitor.DeleteSchedule(sid);
                }
                return;
            }
            Response.Redirect("TaskList.aspx?sid=" + sid);
        }