/// <summary>
        /// 下载文件
        /// </summary>
        public bool DownLoadFile(string fileLocalPath, int index)
        {
            string functionName = "DownLoadFile";

            try
            {
                AMS.ServiceProxy.FileOperate fileDownLoad = new ServiceProxy.FileOperate();
                fileDownLoad.HandleProgress += new ServiceProxy.EventHandleFileTransport(fileDownLoad_HandleProgress);
                Vm_ProgressBar.ProgressType  = "文件下载进度";
                Vm_ProgressBar.ProgressName  = "正在下载\"" + _FileSharingList[index].FileModel.Name + "\"……";
                string result = fileDownLoad.FileDownLoad(fileLocalPath + "\\" + _FileSharingList[index].FileModel.Name, _FileSharingList[index].FileModel.FilePath, SeatManage.EnumType.SeatManageSubsystem.SharingFile);
                if (!string.IsNullOrEmpty(result))
                {
                    ErrorMessage = string.Format("下载失败!{0}", result);
                    return(false);
                }
                return(true);
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
Esempio n. 2
0
        public bool FileDownLoad(string filedownloadpath)
        {
            string functionName = "FileDownLoad";

            try
            {
                AMS.ServiceProxy.FileOperate filedownload = new ServiceProxy.FileOperate();
                string result = filedownload.FileDownLoad(filedownloadpath + "\\" + _FileModel.Name, _FileModel.FilePath, SeatManage.EnumType.SeatManageSubsystem.SharingFile);
                if (!string.IsNullOrEmpty(result))
                {
                    ErrorMessage = string.Format("下载文件失败!{0}", result);
                    return(false);
                }
                return(true);
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
Esempio n. 3
0
        public static bool Upload()
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                AMS.ServiceProxy.FileOperate fileOperate = new ServiceProxy.FileOperate();
                SeatManage.DAL.T_SM_Reader   t_sm_Reader = new SeatManage.DAL.T_SM_Reader();
                DataSet ds = t_sm_Reader.GetList(null, null);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    sb.Append(ds.Tables[0].Rows[i]["cardId"].ToString());
                    sb.Append(ds.Tables[0].Rows[i]["cardNo"].ToString());
                    sb.Append(ds.Tables[0].Rows[i]["ReaderName"].ToString());
                    sb.Append(ds.Tables[0].Rows[i]["ReaderTypeName"].ToString());
                    sb.Append(ds.Tables[0].Rows[i]["Sex"].ToString());
                    sb.Append(ds.Tables[0].Rows[i]["ReaderDeptName"].ToString());
                    sb.Append(ds.Tables[0].Rows[i]["Flag"].ToString());
                    sb.AppendLine("");
                }
                SaveLog("RI", sb.ToString());
                string fileDircetoryPath = AppDomain.CurrentDomain.BaseDirectory + "RITmp\\";
                SeatManage.SeatManageComm.ZipUtil.ZipFile(fileDircetoryPath + "RI", fileDircetoryPath + "ZRI");
                //上传文件
                fileOperate.UpdateFile(fileDircetoryPath + "ZRI", ServiceSet.SchoolNums + "_ZRI", SeatManageSubsystem.ReaderInfo);
                //删除缓存文件
                Directory.Delete(fileDircetoryPath, true);

                return(true);
            }
            catch (Exception ex)
            {
                SeatManage.SeatManageComm.WriteLog.Write(string.Format("获取信息失败:{0}", ex.Message));
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <returns></returns>
        public bool DownLoadFile()
        {
            string functionName = "DownLoadFile";

            try
            {
                string resultstr = "";
                AMS.ServiceProxy.FileOperate download = new ServiceProxy.FileOperate();
                download.HandleProgress    += new ServiceProxy.EventHandleFileTransport(download_HandleProgress);
                Vm_Progressbar.ProgressType = "媒体文件下载";
                Vm_Progressbar.FullProgress = _PlayModel.MediaFiles.Count;
                foreach (AMS.Model.AMS_VideoItem item in _PlayModel.MediaFiles)
                {
                    Vm_Progressbar.ProgressName = "正在下载\"" + item.Name + "\"……";
                    resultstr = download.FileDownLoad(loaclPath + item.Name, item.ReRelativeUrl, SeatManage.EnumType.SeatManageSubsystem.MediaFiles);
                    if (!string.IsNullOrEmpty(resultstr))
                    {
                        ErrorMessage = resultstr;
                        return(false);
                    }
                }
                return(true);
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
Esempio n. 5
0
        public bool FileUpLoad()
        {
            string functionName = "FileUpLoad";

            try
            {
                if (FileType == (int)Model.Enum.FileSharingType.None)
                {
                    ErrorMessage = "请选择文件类型!";
                    return(false);
                }
                if (string.IsNullOrEmpty(Name))
                {
                    ErrorMessage = "文件名不能为空!";
                    return(false);
                }
                Vm_ProgressBar.ProgressType = "文件上传进度";
                Vm_ProgressBar.FullProgress = 1;
                Vm_ProgressBar.ProgressName = "正在上传\"" + _FileModel.Name + "\"……";
                AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                fileUpload.HandleProgress += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                string result = fileUpload.UpdateFile(_FileModel.FilePath, ((AMS.Model.Enum.FileSharingType)_FileModel.FileType).ToString() + "\\" + _FileModel.Name, SeatManage.EnumType.SeatManageSubsystem.SharingFile);
                if (!string.IsNullOrEmpty(result))
                {
                    ErrorMessage = string.Format("上传文件失败!{0}", result);
                    Vm_ProgressBar.IsFinish();
                    return(false);
                }
                //Vm_ProgressBar.IsFinish();
                _FileModel.FilePath = ((AMS.Model.Enum.FileSharingType)_FileModel.FileType).ToString() + "\\" + _FileModel.Name;
                _FileModel.UpManID  = User.ID;
                result = AMS.ServiceProxy.FileSharingWindow.AddNewFile(_FileModel);
                if (!string.IsNullOrEmpty(result))
                {
                    ErrorMessage = string.Format("保存失败!{0}", result);
                    return(false);
                }
                return(true);
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
 public bool FileUpload()
 {
     AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
     //string result = fileUpload.UpdateFile(FilePath, Name, ProjectType);
     //if (!string.IsNullOrEmpty(result))
     //{
     //    ErrorMessage = string.Format("上传文件失败!{0}", result);
     //    return false;
     //}
     //AMS.Model.FileSharingInfo model = new Model.FileSharingInfo();
     //result = AMS.ServiceProxy.FileSharingWindow.AddNewFile(_FileModel);
     //if (!string.IsNullOrEmpty(result))
     //{
     //    ErrorMessage = string.Format("保存失败!{0}", result);
     //    return false;
     //}
     return(true);
 }
Esempio n. 7
0
        /// <summary>
        /// 开始计算
        /// </summary>
        public static bool Upload()
        {
            try
            {
                DateTime sdt;
                string   lastdate = GetLastDate();
                if (!string.IsNullOrEmpty(lastdate))
                {
                    sdt = DateTime.Parse(lastdate);
                }
                else
                {
                    sdt = SeatManage.Bll.T_SM_EnterOutLog_bak.GetFristLogDate();
                }
                if (sdt <= DateTime.Parse("2000-1-1"))
                {
                    return(true);
                }
                AMS.ServiceProxy.FileOperate fileOperate = new ServiceProxy.FileOperate();
                sdt = sdt.AddDays(1);
                while (true)
                {
                    //获取进出记录
                    List <EnterOutLogInfo>         enterOutLogList  = T_SM_EnterOutLog_bak.GetStatisticsLogsByDate(sdt);
                    List <BespeakLogInfo>          bespeakLogList   = T_SM_SeatBespeak.GetBespeakList(null, null, sdt, 0, null);
                    List <ViolationRecordsLogInfo> violationLogList = T_SM_ViolateDiscipline.GetViolationRecords(null, null, sdt.ToShortDateString(), sdt.Date.AddDays(1).AddSeconds(-1).ToString(), LogStatus.None, LogStatus.None);
                    List <BlackListInfo>           blacklistList    = T_SM_Blacklist.GetAllBlackListInfo(null, LogStatus.None, sdt.ToShortDateString(), sdt.Date.AddDays(1).AddSeconds(-1).ToString());
                    if (enterOutLogList.Count <= 0 && bespeakLogList.Count <= 0 && violationLogList.Count <= 0 && sdt >= ServiceDateTime.Now.Date.AddDays(-1))
                    {
                        break;
                    }
                    StringBuilder eolsb = new StringBuilder();
                    StringBuilder blisb = new StringBuilder();
                    StringBuilder vrisb = new StringBuilder();
                    StringBuilder bllsb = new StringBuilder();
                    foreach (EnterOutLogInfo eol in enterOutLogList)
                    {
                        //记录内容
                        eolsb.Append(eol.EnterOutLogID + ",");
                        eolsb.Append(eol.EnterOutLogNo + ",");
                        eolsb.Append(eol.EnterOutState + ",");
                        eolsb.Append(eol.EnterOutTime + ",");
                        //座位信息
                        eolsb.Append(eol.TerminalNum + ",");
                        eolsb.Append(eol.SeatNo + ",");
                        eolsb.Append(eol.ReadingRoomNo + ",");
                        eolsb.Append(eol.ReadingRoomName + ",");
                        //备注
                        eolsb.Append(eol.Flag + ",");
                        eolsb.Append(eol.Remark + ",");
                        //读者信息
                        eolsb.Append(eol.CardNo + ",");
                        eolsb.Append(eol.ReaderName + ",");
                        eolsb.Append(eol.Sex + ",");
                        vrisb.Append(eol.DeptName + ",");
                        vrisb.Append(eol.TypeName + ";");
                        eolsb.AppendLine();
                    }
                    foreach (BespeakLogInfo bli in bespeakLogList)
                    {
                        blisb.Append(bli.BsepeaklogID + ",");
                        blisb.Append(bli.BsepeakTime + ",");
                        blisb.Append(bli.BsepeakState + ",");
                        blisb.Append(bli.SubmitTime + ",");
                        blisb.Append(bli.CancelPerson + ",");
                        blisb.Append(bli.CancelTime + ",");

                        blisb.Append(bli.SeatNo + ",");
                        blisb.Append(bli.ReadingRoomNo + ",");
                        blisb.Append(bli.ReadingRoomName + ",");

                        blisb.Append(bli.Remark + ",");

                        blisb.Append(bli.CardNo + ",");
                        blisb.Append(bli.ReaderName + ",");
                        blisb.Append(bli.Sex + ",");
                        vrisb.Append(bli.DeptName + ",");
                        vrisb.Append(bli.TypeName + ";");
                        blisb.AppendLine();
                    }
                    foreach (ViolationRecordsLogInfo vri in violationLogList)
                    {
                        vrisb.Append(vri.ID + ",");
                        vrisb.Append(vri.BlacklistID + ",");
                        vrisb.Append(vri.WarningState + ",");
                        vrisb.Append(vri.EnterFlag + ",");
                        vrisb.Append(vri.EnterOutTime + ",");
                        vrisb.Append(vri.Flag + ",");

                        vrisb.Append(vri.SeatID + ",");
                        vrisb.Append(vri.ReadingRoomID + ",");
                        vrisb.Append(vri.ReadingRoomName + ",");

                        vrisb.Append(vri.Remark + ",");

                        vrisb.Append(vri.CardNo + ",");
                        vrisb.Append(vri.ReaderName + ",");
                        vrisb.Append(vri.Sex + ",");
                        vrisb.Append(vri.DeptName + ",");
                        vrisb.Append(vri.TypeName + ";");
                        vrisb.AppendLine();
                    }
                    foreach (BlackListInfo bli in blacklistList)
                    {
                        bllsb.Append(bli.ID + ",");
                        bllsb.Append(bli.AddTime + ",");
                        bllsb.Append(bli.BlacklistState + ",");
                        bllsb.Append(bli.OutBlacklistMode + ",");
                        bllsb.Append(bli.OutTime + ",");

                        bllsb.Append(bli.ReadingRoomID + ",");
                        bllsb.Append(bli.ReadingRoomName + ",");

                        bllsb.Append(bli.ReMark + ",");

                        bllsb.Append(bli.CardNo + ",");
                        bllsb.Append(bli.ReaderName + ",");
                        bllsb.Append(bli.Sex + ",");
                        bllsb.Append(bli.DeptName + ",");
                        bllsb.Append(bli.TypeName + ";");
                        bllsb.AppendLine();
                    }
                    try
                    {
                        string filedateName = sdt.Year + "-" + sdt.Month + "-" + sdt.Day;
                        SaveLog("EOL_" + filedateName, eolsb.ToString());
                        SaveLog("BSL_" + filedateName, blisb.ToString());
                        SaveLog("VRL_" + filedateName, vrisb.ToString());
                        SaveLog("BLL_" + filedateName, bllsb.ToString());
                        //压缩文件
                        string fileDircetoryPath = AppDomain.CurrentDomain.BaseDirectory + "StatisticsTmp\\";
                        SeatManage.SeatManageComm.ZipUtil.ZipFile(fileDircetoryPath + "EOL_" + filedateName, fileDircetoryPath + "ZEOL_" + filedateName);
                        SeatManage.SeatManageComm.ZipUtil.ZipFile(fileDircetoryPath + "BSL_" + filedateName, fileDircetoryPath + "ZBSL_" + filedateName);
                        SeatManage.SeatManageComm.ZipUtil.ZipFile(fileDircetoryPath + "VRL_" + filedateName, fileDircetoryPath + "ZVRL_" + filedateName);
                        SeatManage.SeatManageComm.ZipUtil.ZipFile(fileDircetoryPath + "BLL_" + filedateName, fileDircetoryPath + "ZBLL_" + filedateName);
                        //上传文件
                        fileOperate.UpdateFile(fileDircetoryPath + "ZEOL_" + filedateName, ServiceSet.SchoolNums + "_ZEOL_" + filedateName, SeatManageSubsystem.EnterOutLog);
                        fileOperate.UpdateFile(fileDircetoryPath + "ZBSL_" + filedateName, ServiceSet.SchoolNums + "_ZBSL_" + filedateName, SeatManageSubsystem.BespeakLog);
                        fileOperate.UpdateFile(fileDircetoryPath + "ZVRL_" + filedateName, ServiceSet.SchoolNums + "_ZVRL_" + filedateName, SeatManageSubsystem.ViolateDiscipline);
                        fileOperate.UpdateFile(fileDircetoryPath + "ZBLL_" + filedateName, ServiceSet.SchoolNums + "_ZBLL_" + filedateName, SeatManageSubsystem.Blistlist);
                        //删除缓存文件
                        Directory.Delete(fileDircetoryPath, true);
                        SetLastDate(sdt.ToShortDateString());
                        sdt = sdt.AddDays(1);
                        if (sdt >= ServiceDateTime.Now.Date)
                        {
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        SeatManage.SeatManageComm.WriteLog.Write(string.Format("统计{0}记录失败:{1}", sdt.ToShortDateString(), ex.Message));
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                SeatManage.SeatManageComm.WriteLog.Write(string.Format("统计记录失败:{0}", ex.Message));
                return(false);
            }
        }
Esempio n. 8
0
        public bool Save()
        {
            string functionName = "Save";

            try
            {
                if (_IsEdit)
                {
                    if (string.IsNullOrEmpty(_PrintModel.Number))
                    {
                        ErrorMessage = "凭条编号不能为空!";
                        return(false);
                    }
                    if (string.IsNullOrEmpty(_PrintModel.Name))
                    {
                        ErrorMessage = "打印凭条名称不能为空!";
                        return(false);
                    }
                    if (_PrintModel.EffectDate == null)
                    {
                        ErrorMessage = "请选择开始日期!";
                        return(false);
                    }
                    if (_PrintModel.EndDate == null)
                    {
                        ErrorMessage = "请选择结束日期!";
                        return(false);
                    }
                    if (_PrintModel.EndDate < _PrintModel.EffectDate)
                    {
                        ErrorMessage = "结束日期不能小于开始日期!";
                        return(false);
                    }
                    if (_VM_Template.PrintIiemList.Count == 0)
                    {
                        ErrorMessage = "请添加打印项目!";
                        return(false);
                    }
                    if (_PrintModel.CustomerId < 0)
                    {
                        ErrorMessage = "请选择凭条客户!";
                        return(false);
                    }
                    _PrintModel.Operator = User.ID;
                    if (_IsOldType)
                    {
                        _PrintModel.Template = GetOldTypeTemp(VM_Template.XmlTxt);
                    }
                    else
                    {
                        _PrintModel.Template = VM_Template.XmlTxt;
                    }
                    //TODO:图片上传
                    string resultstr = "";
                    AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                    fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                    Vm_ProgressBar.ProgressType = "上传优惠券图片";
                    Vm_ProgressBar.FullProgress = 0;
                    foreach (AMS.ViewModel.ViewModelPrintItem item in _VM_Template.PrintIiemList)
                    {
                        if (item.IsImage)
                        {
                            Vm_ProgressBar.FullProgress++;
                        }
                    }
                    if (_VM_Template.PrintIiemList != null)
                    {
                        foreach (AMS.ViewModel.ViewModelPrintItem item in _VM_Template.PrintIiemList)
                        {
                            if (item.IsImage)
                            {
                                Vm_ProgressBar.ProgressName = "正在上传\"" + item.ImageName + "\"……";
                                resultstr = fileUpload.UpdateFile(item.ImagePath, item.ImageName, SeatManage.EnumType.SeatManageSubsystem.SeatSlip);
                                if (!string.IsNullOrEmpty(resultstr))
                                {
                                    ErrorMessage = string.Format("图片{0}上传失败!{1}", item.ImageName, resultstr);
                                    return(false);
                                }
                            }
                        }
                    }
                    resultstr = AMS.ServiceProxy.IPrintTemplateService.UpdatePrintTemplate(_PrintModel);
                    if (!string.IsNullOrEmpty(resultstr))
                    {
                        ErrorMessage = string.Format("保存失败!{0}", resultstr);
                        return(false);
                    }
                    return(true);
                }
                else
                {
                    #region 添加
                    if (string.IsNullOrEmpty(_PrintModel.Number))
                    {
                        ErrorMessage = "凭条编号不能为空!";
                        return(false);
                    }
                    if (string.IsNullOrEmpty(_PrintModel.Name))
                    {
                        ErrorMessage = "打印凭条名称不能为空!";
                        return(false);
                    }
                    if (_PrintModel.EffectDate == null)
                    {
                        ErrorMessage = "请选择开始日期!";
                        return(false);
                    }
                    if (_PrintModel.EndDate == null)
                    {
                        ErrorMessage = "请选择结束日期!";
                        return(false);
                    }
                    if (_PrintModel.EndDate < _PrintModel.EffectDate)
                    {
                        ErrorMessage = "结束日期不能小于开始日期!";
                        return(false);
                    }
                    if (_VM_Template.PrintIiemList.Count == 0)
                    {
                        ErrorMessage = "请添加打印项目!";
                        return(false);
                    }
                    if (_PrintModel.CustomerId < 0)
                    {
                        ErrorMessage = "请选择凭条客户!";
                        return(false);
                    }
                    _PrintModel.Operator = User.ID;
                    if (_IsOldType)
                    {
                        _PrintModel.Template = GetOldTypeTemp(VM_Template.XmlTxt);
                    }
                    else
                    {
                        _PrintModel.Template = VM_Template.XmlTxt;
                    }
                    //TODO:图片上传
                    string resultstr = "";
                    AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                    fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                    Vm_ProgressBar.ProgressType = "上传优惠券图片";
                    Vm_ProgressBar.FullProgress = 0;
                    foreach (AMS.ViewModel.ViewModelPrintItem item in _VM_Template.PrintIiemList)
                    {
                        if (item.IsImage)
                        {
                            Vm_ProgressBar.FullProgress++;
                        }
                    }
                    foreach (AMS.ViewModel.ViewModelPrintItem item in _VM_Template.PrintIiemList)
                    {
                        if (item.IsImage)
                        {
                            Vm_ProgressBar.ProgressName = "正在上传\"" + item.ImageName + "\"……";
                            resultstr = fileUpload.UpdateFile(item.ImagePath, item.ImageName, SeatManage.EnumType.SeatManageSubsystem.SeatSlip);
                            if (!string.IsNullOrEmpty(resultstr))
                            {
                                ErrorMessage = string.Format("图片{0}上传失败!{1}", item.ImageName, resultstr);
                                return(false);
                            }
                        }
                    }
                    resultstr = AMS.ServiceProxy.IPrintTemplateService.AddNewPrintTemplate(_PrintModel);
                    if (!string.IsNullOrEmpty(resultstr))
                    {
                        ErrorMessage = string.Format("保存失败!{0}", resultstr);
                        return(false);
                    }
                    return(true);

                    #endregion
                }
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
Esempio n. 9
0
        public bool Save()
        {
            string functionName = "save";

            try
            {
                if (string.IsNullOrEmpty(PopAdvertModel.Num))
                {
                    ErrorMessage = "弹窗广告的编号不能为空!";
                    return(false);
                }
                if (string.IsNullOrEmpty(PopAdvertModel.Name))
                {
                    ErrorMessage = "弹窗广告的名称不能为空!";
                    return(false);
                }
                if (_PopImageInfo == null)
                {
                    ErrorMessage = "弹窗图片不能为空!";
                    return(false);
                }
                if (PopAdvertModel.EffectDate == null)
                {
                    ErrorMessage = "弹窗广告的开始时间不能为空!";
                    return(false);
                }
                if (PopAdvertModel.EndDate == null)
                {
                    ErrorMessage = "弹窗广告的结束时间不能为空!";
                    return(false);
                }
                if (PopAdvertModel.EndDate < PopAdvertModel.EffectDate)
                {
                    ErrorMessage = "弹窗广告的结束时间要大于开始时间!";
                    return(false);
                }
                if (PopAdvertModel.CustomerID < 0)
                {
                    ErrorMessage = "请选择优惠券客户!";
                    return(false);
                }
                if (!IsEdit && AMS.ServiceProxy.AdvertisementOperationService.ExistSameAdvert(PopAdvertModel.Num, PopAdvertModel.Name, Model.Enum.AdType.PopAd))
                {
                    ErrorMessage = "已存在存在相同名称或编号的弹窗广告!";
                    return(false);
                }
                PopAdvertModel.OperatorID = User.ID;
                PopAdvertModel.ImageFilePath.Clear();
                PopAdvertModel.ImageFilePath.Add(PopAdvertModel.PopImagePath);

                string resultstr = "";
                //TODO:保存&文件上传
                AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                Vm_ProgressBar.ProgressType = "上传媒体文件";
                Vm_ProgressBar.FullProgress = PopAdvertModel.ImageFilePath.Count;
                foreach (string upFileItem in PopAdvertModel.ImageFilePath)
                {
                    Vm_ProgressBar.ProgressName = "正在上传\"" + upFileItem + "\"……";
                    resultstr = fileUpload.UpdateFile(upFileItem, PopAdvertModel.Num + "_" + upFileItem.Substring(upFileItem.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.PopAd);
                    if (!string.IsNullOrEmpty(resultstr))
                    {
                        ErrorMessage = string.Format("文件{0}上传失败!{1}", upFileItem, resultstr);
                        Vm_ProgressBar.IsFinish();
                        return(false);
                    }
                }
                //更换文件名
                PopAdvertModel.PopImagePath = PopAdvertModel.Num + "_" + PopAdvertModel.PopImagePath.Substring(PopAdvertModel.PopImagePath.LastIndexOf("\\") + 1);
                for (int i = 0; i < PopAdvertModel.ImageFilePath.Count; i++)
                {
                    PopAdvertModel.ImageFilePath[i] = PopAdvertModel.Num + "_" + PopAdvertModel.ImageFilePath[i].Substring(PopAdvertModel.ImageFilePath[i].LastIndexOf("\\") + 1);
                }
                PopAdvertModel.Type = Model.Enum.AdType.PopAd;
                AMS.Model.AMS_Advertisement model = new Model.AMS_Advertisement();
                model.Type       = Model.Enum.AdType.PopAd;
                model.ID         = PopAdvertModel.ID;
                model.Name       = PopAdvertModel.Name;
                model.Num        = PopAdvertModel.Num;
                model.OperatorID = PopAdvertModel.OperatorID;
                model.CustomerID = PopAdvertModel.CustomerID;
                model.AdContent  = PopAdvertModel.ToXml();
                model.EffectDate = PopAdvertModel.EffectDate;
                model.EndDate    = PopAdvertModel.EndDate;
                if (IsEdit)
                {
                    //TODO:更新
                    return(AMS.ServiceProxy.AdvertisementOperationService.UpdateAdvertisement(model));
                }
                else
                {
                    //DOTO:添加
                    return(AMS.ServiceProxy.AdvertisementOperationService.AddAdvertisement(model));
                }
                if (!string.IsNullOrEmpty(resultstr))
                {
                    ErrorMessage = string.Format("保存播放列表失败!{0}", resultstr);
                    return(false);
                }
                return(true);
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>
        public bool Save()
        {
            string functionName = "RefreshPlayList";

            try
            {
                if (string.IsNullOrEmpty(_PlayListModel.Number))
                {
                    ErrorMessage = "播放列表的编号不能为空!";
                    return(false);
                }
                if (string.IsNullOrEmpty(_PlayListModel.PlayListName))
                {
                    ErrorMessage = "播放列表的名称不能为空!";
                    return(false);
                }
                if (_PlayListModel.EffectDate == null)
                {
                    ErrorMessage = "播放列表的开始时间不能为空!";
                    return(false);
                }
                if (_PlayListModel.EndDate == null)
                {
                    ErrorMessage = "播放列表的结束时间不能为空!";
                    return(false);
                }
                if (_PlayListModel.EndDate < _PlayListModel.EffectDate)
                {
                    ErrorMessage = "播放列表的结束时间要大于开始时间!";
                    return(false);
                }
                if (PlayFileList.Count == 0)
                {
                    ErrorMessage = "当前没有需要播放的文件!";
                    return(false);
                }
                _PlayListModel.Operator = User.ID;
                ClearFileList();
                _PlayListModel.PlayFileList.Clear();
                _PlayListModel.MediaFiles.Clear();
                foreach (ViewModelVideoItem item in PlayFileList)
                {
                    AMS.Model.AMS_VideoItem newItem = new Model.AMS_VideoItem();
                    newItem.Name          = _PlayListModel.Number + "_" + item.Name;
                    newItem.PlayTime      = item.PlayTime;
                    newItem.ReRelativeUrl = _PlayListModel.Number + "_" + item.ReRelativeUrl;
                    newItem.SunTime       = item.SunTime;
                    newItem.MD5Value      = item.MD5Value;
                    _PlayListModel.PlayFileList.Add(newItem);
                }
                foreach (ViewModelVideoItem item in MediaFileList)
                {
                    AMS.Model.AMS_VideoItem newItem = new Model.AMS_VideoItem();
                    if (!IsEdit)
                    {
                        newItem.Name = _PlayListModel.Number + "_" + item.Name;
                    }
                    else
                    {
                        string name = item.Name.Substring(0, _PlayListModel.Number.Length);
                        if (_PlayListModel.Number == name)
                        {
                            newItem.Name = item.Name;
                        }
                        else
                        {
                            newItem.Name = _PlayListModel.Number + "_" + item.Name;
                        }
                    }
                    newItem.PlayTime      = item.PlayTime;
                    newItem.ReRelativeUrl = item.ReRelativeUrl;
                    newItem.SunTime       = item.SunTime;
                    newItem.MD5Value      = item.MD5Value;
                    _PlayListModel.MediaFiles.Add(newItem);
                }
                string resultstr = "";
                //TODO:保存&文件上传
                AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                Vm_ProgressBar.ProgressType = "上传媒体文件";
                Vm_ProgressBar.FullProgress = _PlayListModel.MediaFiles.Count;
                foreach (AMS.Model.AMS_VideoItem upFileItem in _PlayListModel.MediaFiles)
                {
                    Vm_ProgressBar.ProgressName = "正在上传\"" + upFileItem.Name + "\"……";
                    if (upFileItem.Name != upFileItem.ReRelativeUrl)
                    {
                        resultstr = fileUpload.UpdateFile(upFileItem.ReRelativeUrl, upFileItem.Name, SeatManage.EnumType.SeatManageSubsystem.MediaFiles);
                        if (!string.IsNullOrEmpty(resultstr))
                        {
                            ErrorMessage = string.Format("文件{0}上传失败!{1}", upFileItem.Name, resultstr);
                            Vm_ProgressBar.IsFinish();
                            return(false);
                        }
                    }
                }
                if (IsEdit)
                {
                    //TODO:更新
                    resultstr = AMS.ServiceProxy.IPlayListService.UpdatePlaylist(_PlayListModel);
                }
                else
                {
                    //DOTO:添加
                    resultstr = AMS.ServiceProxy.IPlayListService.AddNewPlaylist(_PlayListModel);
                }
                if (!string.IsNullOrEmpty(resultstr))
                {
                    ErrorMessage = string.Format("保存播放列表失败!{0}", resultstr);
                    return(false);
                }
                return(true);
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
        public bool Save()
        {
            string functionName = "Save";

            try
            {
                if (IsEdit)
                {
                    if (string.IsNullOrEmpty(_SlipModel.Number))
                    {
                        ErrorMessage = "优惠券编号不能为空!";
                        return(false);
                    }
                    if (string.IsNullOrEmpty(_SlipModel.SlipName))
                    {
                        ErrorMessage = "优惠券名称不能为空!";
                        return(false);
                    }
                    if (LogoImageInfo == null)
                    {
                        ErrorMessage = "滚动LOGO图片不能为空!";
                        return(false);
                    }
                    if (PrintWindowImageInfo == null)
                    {
                        ErrorMessage = "打印弹窗图片不能为空!";
                        return(false);
                    }
                    if (_SlipModel.EffectDate == null)
                    {
                        ErrorMessage = "请选择开始日期!";
                        return(false);
                    }
                    if (_SlipModel.EndDate == null)
                    {
                        ErrorMessage = "请选择结束日期!";
                        return(false);
                    }
                    if (_SlipModel.EndDate < _SlipModel.EffectDate)
                    {
                        ErrorMessage = "结束日期不能小于开始日期!";
                        return(false);
                    }
                    if (_VM_Template.PrintIiemList.Count == 0)
                    {
                        ErrorMessage = "请添加打印项目!";
                        return(false);
                    }
                    if (_SlipModel.CustomerId < 0)
                    {
                        ErrorMessage = "请选择优惠券客户!";
                        return(false);
                    }
                    _SlipModel.Operator     = User.ID;
                    _SlipModel.SlipTemplate = VM_Template.XmlTxt;
                    //TODO:图片上传,优惠券保存
                    string result = "";
                    AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                    fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                    Vm_ProgressBar.ProgressType = "上传优惠券图片";
                    Vm_ProgressBar.FullProgress = 2;
                    foreach (AMS.ViewModel.ViewModelPrintItem item in _VM_Template.PrintIiemList)
                    {
                        if (item.IsImage)
                        {
                            Vm_ProgressBar.FullProgress++;
                        }
                    }
                    Vm_ProgressBar.ProgressName = "正在上传\"" + _SlipModel.Number + "_" + _SlipModel.CustomerImage.Substring(_SlipModel.CustomerImage.LastIndexOf("\\") + 1) + "\"……";
                    result = fileUpload.UpdateFile(_SlipModel.CustomerImage, _SlipModel.Number + "_" + _SlipModel.CustomerImage.Substring(_SlipModel.CustomerImage.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ErrorMessage = string.Format("上传滚动Logo图片失败!{0}", result);
                        return(false);
                    }
                    _SlipModel.CustomerImage    = _SlipModel.Number + "_" + _SlipModel.CustomerImage.Substring(_SlipModel.CustomerImage.LastIndexOf("\\") + 1);
                    Vm_ProgressBar.ProgressName = "正在上传\"" + _SlipModel.ImageUrl + "\"……";
                    result = fileUpload.UpdateFile(_SlipModel.ImageUrl, _SlipModel.Number + "_" + _SlipModel.ImageUrl.Substring(_SlipModel.ImageUrl.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ErrorMessage = string.Format("上传打印界面图片失败!{0}", result);
                        return(false);
                    }
                    _SlipModel.ImageUrl = _SlipModel.Number + "_" + _SlipModel.ImageUrl.Substring(_SlipModel.ImageUrl.LastIndexOf("\\") + 1);
                    foreach (AMS.ViewModel.ViewModelPrintItem item in _VM_Template.PrintIiemList)
                    {
                        if (item.IsImage)
                        {
                            Vm_ProgressBar.ProgressName = "正在上传\"" + item.ImageName + "\"……";
                            result = fileUpload.UpdateFile(item.ImagePath, item.ImageName, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
                            if (!string.IsNullOrEmpty(result))
                            {
                                ErrorMessage = string.Format("图片{0}上传失败!{1}", item.ImageName, result);
                                return(false);
                            }
                        }
                    }
                    result = AMS.ServiceProxy.ISlipCustomerService.UpdateSlipCustomer(_SlipModel);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ErrorMessage = string.Format("保存优惠券失败!{0}", result);
                        return(false);
                    }
                    return(true);
                }
                else
                {
                    #region 添加
                    if (string.IsNullOrEmpty(_SlipModel.Number))
                    {
                        ErrorMessage = "优惠券编号不能为空!";
                        return(false);
                    }
                    if (string.IsNullOrEmpty(_SlipModel.SlipName))
                    {
                        ErrorMessage = "优惠券名称不能为空!";
                        return(false);
                    }
                    if (LogoImageInfo == null)
                    {
                        ErrorMessage = "滚动LOGO图片不能为空!";
                        return(false);
                    }
                    if (PrintWindowImageInfo == null)
                    {
                        ErrorMessage = "打印弹窗图片不能为空!";
                        return(false);
                    }
                    if (_SlipModel.EffectDate == null)
                    {
                        ErrorMessage = "请选择开始日期!";
                        return(false);
                    }
                    if (_SlipModel.EndDate == null)
                    {
                        ErrorMessage = "请选择结束日期!";
                        return(false);
                    }
                    if (_SlipModel.EndDate < _SlipModel.EffectDate)
                    {
                        ErrorMessage = "结束日期不能小于开始日期!";
                        return(false);
                    }
                    if (_VM_Template.PrintIiemList.Count == 0)
                    {
                        ErrorMessage = "请添加打印项目!";
                        return(false);
                    }
                    if (_SlipModel.CustomerId < 0)
                    {
                        ErrorMessage = "请选择优惠券客户!";
                        return(false);
                    }
                    _SlipModel.Operator     = User.ID;
                    _SlipModel.SlipTemplate = VM_Template.XmlTxt;
                    //TODO:图片上传,优惠券保存
                    string result = "";
                    AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                    fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                    Vm_ProgressBar.ProgressType = "上传优惠券图片";
                    Vm_ProgressBar.FullProgress = 2;
                    foreach (AMS.ViewModel.ViewModelPrintItem item in _VM_Template.PrintIiemList)
                    {
                        if (item.IsImage)
                        {
                            Vm_ProgressBar.FullProgress++;
                        }
                    }
                    Vm_ProgressBar.ProgressName = "正在上传\"" + _SlipModel.Number + "_" + _SlipModel.CustomerImage.Substring(_SlipModel.CustomerImage.LastIndexOf("\\") + 1) + "\"……";
                    result = fileUpload.UpdateFile(_SlipModel.CustomerImage, _SlipModel.Number + "_" + _SlipModel.CustomerImage.Substring(_SlipModel.CustomerImage.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ErrorMessage = string.Format("上传滚动Logo图片失败!{0}", result);
                        return(false);
                    }
                    _SlipModel.CustomerImage    = _SlipModel.Number + "_" + _SlipModel.CustomerImage.Substring(_SlipModel.CustomerImage.LastIndexOf("\\") + 1);
                    Vm_ProgressBar.ProgressName = "正在上传\"" + _SlipModel.ImageUrl + "\"……";
                    result = fileUpload.UpdateFile(_SlipModel.ImageUrl, _SlipModel.Number + "_" + _SlipModel.ImageUrl.Substring(_SlipModel.ImageUrl.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ErrorMessage = string.Format("上传打印界面图片失败!{0}", result);
                        return(false);
                    }
                    _SlipModel.ImageUrl = _SlipModel.Number + "_" + _SlipModel.ImageUrl.Substring(_SlipModel.ImageUrl.LastIndexOf("\\") + 1);
                    foreach (AMS.ViewModel.ViewModelPrintItem item in _VM_Template.PrintIiemList)
                    {
                        if (item.IsImage)
                        {
                            Vm_ProgressBar.ProgressName = "正在上传\"" + item.ImageName + "\"……";
                            result = fileUpload.UpdateFile(item.ImagePath, item.ImageName, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
                            if (!string.IsNullOrEmpty(result))
                            {
                                ErrorMessage = string.Format("图片{0}上传失败!{1}", item.ImageName, result);
                                return(false);
                            }
                        }
                    }
                    result = AMS.ServiceProxy.ISlipCustomerService.AddNewSlipCustomer(_SlipModel);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ErrorMessage = string.Format("保存优惠券失败!{0}", result);
                        return(false);
                    }
                    return(true);

                    #endregion
                }
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 保存
        /// </summary>
        public bool Save()
        {
            string functionName = "Save";

            try
            {
                if (string.IsNullOrEmpty(PrintReceiptModel.Num))
                {
                    ErrorMessage = "优惠券编号不能为空!";
                    return(false);
                }
                if (string.IsNullOrEmpty(PrintReceiptModel.Name))
                {
                    ErrorMessage = "优惠券名称不能为空!";
                    return(false);
                }

                if (TemplateItem.PrintIiemList.Count < 1)
                {
                    ErrorMessage = "打印项目不能为空!";
                    return(false);
                }

                if (PrintReceiptModel.EffectDate == null)
                {
                    ErrorMessage = "请选择开始日期!";
                    return(false);
                }
                if (PrintReceiptModel.EndDate == null)
                {
                    ErrorMessage = "请选择结束日期!";
                    return(false);
                }
                if (PrintReceiptModel.EndDate < PrintReceiptModel.EffectDate)
                {
                    ErrorMessage = "结束日期不能小于开始日期!";
                    return(false);
                }

                if (PrintReceiptModel.CustomerID < 0)
                {
                    ErrorMessage = "请选择优惠券客户!";
                    return(false);
                }

                if (!IsEdit && AMS.ServiceProxy.AdvertisementOperationService.ExistSameAdvert(PrintReceiptModel.Num, PrintReceiptModel.Name, Model.Enum.AdType.PrintReceiptAd))
                {
                    ErrorMessage = "存在相同的编号或名称!";
                    return(false);
                }
                PrintReceiptModel.OperatorID = User.ID;
                //添加上传图片
                PrintReceiptModel.ImageFilePath.Clear();

                foreach (AMS.ViewModel.ViewModelPrintItem pitem in TemplateItem.PrintIiemList)
                {
                    if (pitem.IsImage)
                    {
                        bool isnew = true;
                        foreach (string samefile in PrintReceiptModel.ImageFilePath)
                        {
                            if (samefile == pitem.ImagePath)
                            {
                                isnew = false;
                                break;
                            }
                        }
                        if (isnew)
                        {
                            PrintReceiptModel.ImageFilePath.Add(pitem.ImagePath);
                        }
                    }
                }

                //TODO:图片上传,优惠券保存
                string result = "";
                AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                Vm_ProgressBar.ProgressType = "上传打印图片";
                Vm_ProgressBar.FullProgress = PrintReceiptModel.ImageFilePath.Count;
                for (int i = 0; i < PrintReceiptModel.ImageFilePath.Count; i++)
                {
                    Vm_ProgressBar.ProgressName = "正在上传\"" + PrintReceiptModel.ImageFilePath[i].Substring(PrintReceiptModel.ImageFilePath[i].LastIndexOf("\\") + 1) + "\"……";
                    result = fileUpload.UpdateFile(PrintReceiptModel.ImageFilePath[i], PrintReceiptModel.Num + "_" + PrintReceiptModel.ImageFilePath[i].Substring(PrintReceiptModel.ImageFilePath[i].LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.PrintReceiptAd);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ErrorMessage = string.Format("上传图片失败!{0}", result);
                        return(false);
                    }
                    PrintReceiptModel.ImageFilePath[i] = PrintReceiptModel.Num + "_" + PrintReceiptModel.ImageFilePath[i].Substring(PrintReceiptModel.ImageFilePath[i].LastIndexOf("\\") + 1);
                }
                Getmodel();
                PrintReceiptModel.Type      = Model.Enum.AdType.PrintReceiptAd;
                PrintReceiptModel.AdContent = AMS.Model.PrintReceiptInfo.ToXml(PrintReceiptModel);
                Model.AMS_Advertisement model = new Model.AMS_Advertisement();
                model.AdContent     = PrintReceiptModel.AdContent;
                model.CustomerID    = PrintReceiptModel.CustomerID;
                model.EffectDate    = PrintReceiptModel.EffectDate;
                model.EndDate       = PrintReceiptModel.EndDate;
                model.ID            = PrintReceiptModel.ID;
                model.ImageFilePath = PrintReceiptModel.ImageFilePath;
                model.Name          = PrintReceiptModel.Name;
                model.Num           = PrintReceiptModel.Num;
                model.OperatorID    = PrintReceiptModel.OperatorID;
                model.Type          = Model.Enum.AdType.PrintReceiptAd;

                if (IsEdit)
                {
                    return(AMS.ServiceProxy.AdvertisementOperationService.UpdateAdvertisement(model));
                }
                else
                {
                    return(AMS.ServiceProxy.AdvertisementOperationService.AddAdvertisement(model));
                }
                return(true);
            }

            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
Esempio n. 13
0
        //int i = 0;//记录打印行数
        void pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            try
            {
                float       yPosition  = 0;//字符串纵向位置
                float       leftMargin = e.MarginBounds.Left;
                float       topMargin  = e.MarginBounds.Top;
                string      line       = "";
                Font        font;                                                  //字体
                string      strFont;                                               //字体名
                string      strSize;                                               //字体大小
                XmlNodeList nodes = newDoc.SelectSingleNode("//Print").ChildNodes; //获取文字内容

                for (int i = 0; i < nodes.Count; i++)
                {
                    switch (nodes[i].LocalName)
                    {
                    case "Content":
                        strFont = nodes[i].Attributes["font"].Value;
                        strSize = nodes[i].Attributes["size"].Value;
                        if (nodes[i].Attributes["italic"] != null && nodes[i].Attributes["bold"] != null && nodes[i].Attributes["bold"].Value == "Y" && nodes[i].Attributes["italic"].Value == "Y")
                        {
                            font = new Font(strFont, float.Parse(strSize), FontStyle.Bold | FontStyle.Italic);
                        }
                        else if (nodes[i].Attributes["bold"] != null && nodes[i].Attributes["bold"].Value == "Y")
                        {
                            font = new Font(strFont, float.Parse(strSize), FontStyle.Bold);
                        }
                        else if (nodes[i].Attributes["italic"] != null && nodes[i].Attributes["italic"].Value == "Y")
                        {
                            font = new Font(strFont, float.Parse(strSize), FontStyle.Italic);
                        }
                        else
                        {
                            font = new Font(strFont, float.Parse(strSize));
                        }

                        //替换打印内容中的标签
                        line = nodes[i].InnerText;
                        e.Graphics.DrawString(line, font, Brushes.Black, 0, yPosition);
                        yPosition = yPosition + font.GetHeight();      //判断上一行的高度

                        break;

                    case "Pic":
                        string imgUrl = AppDomain.CurrentDomain.BaseDirectory + "\\TestTemp\\" + type.ToString() + "\\" + nodes[i].InnerText;
                        AMS.ServiceProxy.FileOperate download = new ServiceProxy.FileOperate();
                        download.FileDownLoad(imgUrl, nodes[i].InnerText, type);
                        Image img    = imageLocation(imgUrl);
                        int   width  = Convert.ToInt32(nodes[i].Attributes["width"].Value.ToString().Split('.')[0]);
                        int   height = Convert.ToInt32(nodes[i].Attributes["height"].Value.ToString().Split('.')[0]);
                        e.Graphics.DrawImage(img, new Rectangle(0, (int)yPosition, width, height), 0, 0, img.Width, img.Height, System.Drawing.GraphicsUnit.Pixel);
                        img.Dispose();
                        yPosition = yPosition + height;      //判断上一行的高度
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                SeatManage.SeatManageComm.WriteLog.Write(ex.Message);
            }
        }
        /// <summary>
        /// 保存
        /// </summary>
        public bool Save()
        {
            string functionName = "Save";

            try
            {
                if (string.IsNullOrEmpty(CouponsModel.Num))
                {
                    ErrorMessage = "优惠券编号不能为空!";
                    return(false);
                }
                if (string.IsNullOrEmpty(CouponsModel.Name))
                {
                    ErrorMessage = "优惠券名称不能为空!";
                    return(false);
                }
                if (LogoImageInfo == null)
                {
                    ErrorMessage = "滚动LOGO图片不能为空!";
                    return(false);
                }
                if (CouponsItemList.Count < 1 && Station != 8)
                {
                    ErrorMessage = "弹窗图片不能为空!";
                    return(false);
                }
                foreach (ViewModelCouponsItem item in CouponsItemList)
                {
                    if (item.EffectDate == null)
                    {
                        ErrorMessage = "请选择开始日期!";
                        return(false);
                    }
                    if (item.EndDate == null)
                    {
                        ErrorMessage = "请选择结束日期!";
                        return(false);
                    }
                    if (item.EndDate < item.EffectDate)
                    {
                        ErrorMessage = "结束日期不能小于开始日期!";
                        return(false);
                    }
                }
                if (CouponsModel.CustomerID < 0)
                {
                    ErrorMessage = "请选择优惠券客户!";
                    return(false);
                }
                if (CouponsModel.Station < 1)
                {
                    ErrorMessage = "请选择优惠券位置!";
                    return(false);
                }
                if (!IsEdit && AMS.ServiceProxy.AdvertisementOperationService.ExistSameAdvert(CouponsModel.Num, CouponsModel.Name, Model.Enum.AdType.SlipCustomerAd))
                {
                    ErrorMessage = "存在相同的编号或名称!";
                    return(false);
                }
                CouponsModel.OperatorID = User.ID;
                //添加上传图片
                CouponsModel.ImageFilePath.Clear();
                CouponsModel.ImageFilePath.Add(_CouponsModel.LogoImage);
                foreach (ViewModelCouponsItem item in CouponsItemList)
                {
                    if (item.PopImageInfo != null)
                    {
                        bool isnew = true;
                        foreach (string samefile in CouponsModel.ImageFilePath)
                        {
                            if (samefile == item.PopImagePath)
                            {
                                isnew = false;
                                break;
                            }
                        }
                        if (isnew)
                        {
                            CouponsModel.ImageFilePath.Add(item.PopImagePath);
                        }
                    }
                    else
                    {
                        ErrorMessage = "优惠信息图片不能为空!";
                        return(false);
                    }
                    foreach (AMS.ViewModel.ViewModelPrintItem pitem in item.TemplateItem.PrintIiemList)
                    {
                        if (pitem.IsImage)
                        {
                            bool isnew = true;
                            foreach (string samefile in CouponsModel.ImageFilePath)
                            {
                                if (samefile == pitem.ImagePath)
                                {
                                    isnew = false;
                                    break;
                                }
                            }
                            if (isnew)
                            {
                                CouponsModel.ImageFilePath.Add(pitem.ImagePath);
                            }
                        }
                    }
                }
                //TODO:图片上传,优惠券保存
                string result = "";
                AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                Vm_ProgressBar.ProgressType = "上传优惠券图片";
                Vm_ProgressBar.FullProgress = CouponsModel.ImageFilePath.Count;
                for (int i = 0; i < CouponsModel.ImageFilePath.Count; i++)
                {
                    Vm_ProgressBar.ProgressName = "正在上传\"" + CouponsModel.ImageFilePath[i].Substring(CouponsModel.ImageFilePath[i].LastIndexOf("\\") + 1) + "\"……";
                    result = fileUpload.UpdateFile(CouponsModel.ImageFilePath[i], CouponsModel.Num + "_" + CouponsModel.ImageFilePath[i].Substring(CouponsModel.ImageFilePath[i].LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.SlipCustomerAd);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ErrorMessage = string.Format("上传图片失败!{0}", result);
                        return(false);
                    }
                    CouponsModel.ImageFilePath[i] = CouponsModel.Num + "_" + CouponsModel.ImageFilePath[i].Substring(CouponsModel.ImageFilePath[i].LastIndexOf("\\") + 1);
                }
                //修改文件名
                CouponsModel.LogoImage = CouponsModel.Num + "_" + CouponsModel.LogoImage.Substring(CouponsModel.LogoImage.LastIndexOf("\\") + 1);
                foreach (ViewModelCouponsItem item in CouponsItemList)
                {
                    if (item.PopImageInfo != null)
                    {
                        item.PopImagePath = CouponsModel.Num + "_" + item.PopImagePath.Substring(item.PopImagePath.LastIndexOf("\\") + 1);
                        item.Getmodel();
                        if (item.CouponsItem.ID == "")
                        {
                            item.CouponsItem.ID = Guid.NewGuid().ToString() + item.CouponsItem.PpoImagePath;
                        }
                        if (CouponsModel.EffectDate < DateTime.Parse("2000-1-1") || CouponsModel.EffectDate > item.EffectDate)
                        {
                            CouponsModel.EffectDate = item.EffectDate;
                        }
                        if (CouponsModel.EndDate < DateTime.Parse("2000-1-1") || CouponsModel.EndDate < item.EndDate)
                        {
                            CouponsModel.EndDate = item.EndDate;
                        }
                        CouponsModel.PopItemList.Add(item.CouponsItem);
                    }
                }
                CouponsModel.Type      = Model.Enum.AdType.SlipCustomerAd;
                CouponsModel.AdContent = AMS.Model.CouponsInfo.ToXml(CouponsModel);
                Model.AMS_Advertisement model = new Model.AMS_Advertisement();
                model.AdContent     = CouponsModel.AdContent;
                model.CustomerID    = CouponsModel.CustomerID;
                model.EffectDate    = CouponsModel.EffectDate;
                model.EndDate       = CouponsModel.EndDate;
                model.ID            = CouponsModel.ID;
                model.ImageFilePath = CouponsModel.ImageFilePath;
                model.Name          = CouponsModel.Name;
                model.Num           = CouponsModel.Num;
                model.OperatorID    = CouponsModel.OperatorID;
                model.Type          = Model.Enum.AdType.SlipCustomerAd;

                if (IsEdit)
                {
                    return(AMS.ServiceProxy.AdvertisementOperationService.UpdateAdvertisement(model));
                }
                else
                {
                    return(AMS.ServiceProxy.AdvertisementOperationService.AddAdvertisement(model));
                }
                return(true);
            }

            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
Esempio n. 15
0
        public bool Save()
        {
            string functionName = "save";

            try
            {
                if (string.IsNullOrEmpty(PlaylistModel.Num))
                {
                    ErrorMessage = "播放列表的编号不能为空!";
                    return(false);
                }
                if (string.IsNullOrEmpty(PlaylistModel.Name))
                {
                    ErrorMessage = "播放列表的名称不能为空!";
                    return(false);
                }
                if (PlaylistModel.EffectDate == null)
                {
                    ErrorMessage = "播放列表的开始时间不能为空!";
                    return(false);
                }
                if (PlaylistModel.EndDate == null)
                {
                    ErrorMessage = "播放列表的结束时间不能为空!";
                    return(false);
                }
                if (PlaylistModel.EndDate < PlaylistModel.EffectDate)
                {
                    ErrorMessage = "播放列表的结束时间要大于开始时间!";
                    return(false);
                }
                if (VideoItems.Count == 0)
                {
                    ErrorMessage = "当前没有需要播放的文件!";
                    return(false);
                }
                if (!IsEdit && AMS.ServiceProxy.AdvertisementOperationService.ExistSameAdvert(PlaylistModel.Num, PlaylistModel.Name, Model.Enum.AdType.PlaylistAd))
                {
                    ErrorMessage = "已存在存在相同名称或编号的播放列表!";
                    return(false);
                }
                PlaylistModel.OperatorID = User.ID;
                PlaylistModel.ImageFilePath.Clear();
                PlaylistModel.MediaPlayList.Clear();
                foreach (ViewModel_VideoItem item in VideoItems)
                {
                    AMS.Model.PlaylistItemInfo newItem = new Model.PlaylistItemInfo();
                    newItem = item.VideoItemModel;
                    newItem.MediaFileName = PlaylistModel.Num + "_" + newItem.MediaFileName.Substring(newItem.MediaFileName.LastIndexOf("\\") + 1);
                    PlaylistModel.MediaPlayList.Add(newItem);
                    bool isnew = true;
                    foreach (string samefile in PlaylistModel.ImageFilePath)
                    {
                        if (samefile == item.VideoFliePath)
                        {
                            isnew = false;
                            break;
                        }
                    }
                    if (isnew)
                    {
                        PlaylistModel.ImageFilePath.Add(item.VideoFliePath);
                    }
                }
                string resultstr = "";
                //TODO:保存&文件上传
                AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                Vm_ProgressBar.ProgressType = "上传媒体文件";
                Vm_ProgressBar.FullProgress = PlaylistModel.ImageFilePath.Count;
                foreach (string upFileItem in PlaylistModel.ImageFilePath)
                {
                    Vm_ProgressBar.ProgressName = "正在上传\"" + upFileItem + "\"……";
                    resultstr = fileUpload.UpdateFile(upFileItem, PlaylistModel.Num + "_" + upFileItem.Substring(upFileItem.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.PlaylistAd);
                    if (!string.IsNullOrEmpty(resultstr))
                    {
                        ErrorMessage = string.Format("文件{0}上传失败!{1}", upFileItem, resultstr);
                        Vm_ProgressBar.IsFinish();
                        return(false);
                    }
                }
                //更换文件名
                for (int i = 0; i < PlaylistModel.ImageFilePath.Count; i++)
                {
                    PlaylistModel.ImageFilePath[i] = PlaylistModel.Num + "_" + PlaylistModel.ImageFilePath[i].Substring(PlaylistModel.ImageFilePath[i].LastIndexOf("\\") + 1);
                }
                PlaylistModel.Type = Model.Enum.AdType.PlaylistAd;
                AMS.Model.AMS_Advertisement model = new Model.AMS_Advertisement();
                model.Type       = Model.Enum.AdType.PlaylistAd;
                model.ID         = PlaylistModel.ID;
                model.Name       = PlaylistModel.Name;
                model.Num        = PlaylistModel.Num;
                model.OperatorID = PlaylistModel.OperatorID;
                model.AdContent  = PlaylistModel.ToXml();
                model.EffectDate = PlaylistModel.EffectDate;
                model.EndDate    = PlaylistModel.EndDate;
                if (IsEdit)
                {
                    //TODO:更新
                    return(AMS.ServiceProxy.AdvertisementOperationService.UpdateAdvertisement(model));
                }
                else
                {
                    //DOTO:添加
                    return(AMS.ServiceProxy.AdvertisementOperationService.AddAdvertisement(model));
                }
                if (!string.IsNullOrEmpty(resultstr))
                {
                    ErrorMessage = string.Format("保存播放列表失败!{0}", resultstr);
                    return(false);
                }
                return(true);
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }