public void FileDelete(DataReport.geReportKbn rptKbn, string pgId, string _deleteFileName, string _deleteFilePath)
        {
            try
            {
                string deleteFileName = "";
                string deleteFilePath = "";

                deleteFileName = System.Windows.Browser.HttpUtility.UrlEncode(_deleteFileName);
                deleteFilePath = _deleteFilePath.Replace(_deleteFileName, System.Windows.Browser.HttpUtility.UrlEncode(_deleteFileName)).Replace(@"\", "@AAB@").Replace("/", "@AAD@");;

                var requestUri = string.Format("{0}?rptKbn={1}&pgId={2}&random={3}&deleteFileName={4}&deleteFilePath={5}",
                                               Common.gstrReportDeleteUrl,
                                               ((int)rptKbn).ToString(), pgId,
                                               Common.gstrSessionString,
                                               deleteFileName,
                                               deleteFilePath);
                var client = new WebClient();
                client.UploadStringCompleted += OnFileDeleteCompleted;
                client.UploadStringAsync(new Uri(requestUri), "delete");
            }
            catch (Exception ex)
            {
                //ExMessageBox.Show("ファイルダウンロード処理で予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                return;
            }
        }
Beispiel #2
0
        // F2ボタン(ダウンロード) クリック
        public override void btnF2_Click(object sender, RoutedEventArgs e)
        {
            this.utlParentFKey.IsEnabled = false;

            // ボタン押下時非同期入力チェックON
            Common.gblnBtnDesynchronizeLock = true;

            this.rptKbn = DataReport.geReportKbn.Download;

            // 入力確定の為、BackgroundWorker経由で入力チェックを呼出
            ExBackgroundInputCheckWk bk = new ExBackgroundInputCheckWk();

            bk.utl = this;
            this.txtDummy.IsTabStop = true;
            bk.focusCtl             = this.txtDummy;
            bk.bw.RunWorkerAsync();
        }
        public void FileDownLoad(DataReport.geReportKbn rptKbn, string pgId, string[] prm)
        {
            try
            {
                this.saveDialog = new SaveFileDialog();
                switch (rptKbn)
                {
                case DataReport.geReportKbn.Download:
                    this.saveDialog.DefaultExt = ".pdf";
                    this.saveDialog.Filter     = "All Files|*.*|Pdf Files|*.pdf";
                    break;

                case DataReport.geReportKbn.Csv:
                    this.saveDialog.DefaultExt = ".csv";
                    this.saveDialog.Filter     = "All Files|*.*|Csv Files|*.csv";
                    break;

                case DataReport.geReportKbn.None:
                    this.saveDialog.Filter = "All Files|*.*";
                    break;

                default:
                    break;
                }
                this.saveDialog.FilterIndex = 2;
            }
            catch (Exception ex)
            {
                ExMessageBox.Show("ファイル保存処理(ダイアログ表示)で予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                if (this.utlParentFKey != null)
                {
                    this.utlParentFKey.IsEnabled = true;
                }
                return;
            }

            bool?dialogResult = this.saveDialog.ShowDialog();

            if (dialogResult == true)
            {
                try
                {
                    string downLoadFileName = "";
                    string downLoadFilePath = "";

                    downLoadFileName = System.Windows.Browser.HttpUtility.UrlEncode(prm[0]);
                    downLoadFilePath = prm[1].Replace(prm[0], System.Windows.Browser.HttpUtility.UrlEncode(prm[0])).Replace(@"\", "@AAB@").Replace("/", "@AAD@");;
                    var requestUri = string.Format("{0}?rptKbn={1}&pgId={2}&random={3}&downLoadFileName={4}&downLoadFilePath={5}", Common.gstrReportDownloadUrl, ((int)rptKbn).ToString(), pgId, Common.gstrSessionString, downLoadFileName, downLoadFilePath);
                    var client     = new WebClient();
                    client.OpenReadCompleted += OnFileDownloadCompleted;
                    client.OpenReadAsync(new Uri(requestUri), null);

                    switch (rptKbn)
                    {
                    case DataReport.geReportKbn.OutPut:
                    case DataReport.geReportKbn.Download:
                        Common.gstrProgressDialogTitle = "PDFファイルダウンロード中";
                        break;

                    case DataReport.geReportKbn.Csv:
                        Common.gstrProgressDialogTitle = "CSVファイルダウンロード中";
                        break;
                    }
                    if (dlgWin == null)
                    {
                        dlgWin = new Dlg_Progress();
                    }
                    dlgWin.Show();
                }
                catch (Exception ex)
                {
                    ExMessageBox.Show("ファイルダウンロード処理で予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                    if (this.utlParentFKey != null)
                    {
                        this.utlParentFKey.IsEnabled = true;
                    }
                    return;
                }
            }
            else
            {
                this.saveDialog = null;
                if (this.utlParentFKey != null)
                {
                    this.utlParentFKey.IsEnabled = true;
                }
                GC.Collect();
            }
        }
        // F3ボタン(CSV) クリック
        public override void btnF3_Click(object sender, RoutedEventArgs e)
        {
            this.utlParentFKey.IsEnabled = false;

            // ボタン押下時非同期入力チェックON
            Common.gblnBtnDesynchronizeLock = true;

            this.rptKbn = DataReport.geReportKbn.Csv;

            // 入力確定の為、BackgroundWorker経由で入力チェックを呼出
            ExBackgroundInputCheckWk bk = new ExBackgroundInputCheckWk();
            bk.utl = this;
            bk.waitTime = 500;
            this.txtDummy.IsTabStop = true;
            bk.focusCtl = this.txtDummy;
            bk.bw.RunWorkerAsync();
        }
        public EntityReport ReportOut(string random, string rptKbn, string pgId, string parameters)
        {
            EntityReport        entity;
            EntityReportSetting entitySetting;

            #region 認証処理

            string companyId           = "";
            string groupId             = "";
            string userId              = "";
            string ipAdress            = "";
            string sessionString       = "";
            int    reportSizeUser      = 0;
            int    idFigureCommodity   = 0;
            int    idFigureCustomer    = 0;
            int    idFigurePurchase    = 0;
            int    idFigureSlipNo      = 0;
            int    rpTotalAuthorityKbn = 0;

            try
            {
                companyId           = ExCast.zCStr(HttpContext.Current.Session[ExSession.COMPANY_ID]);
                groupId             = ExCast.zCStr(HttpContext.Current.Session[ExSession.GROUP_ID]);
                userId              = ExCast.zCStr(HttpContext.Current.Session[ExSession.USER_ID]);
                ipAdress            = ExCast.zCStr(HttpContext.Current.Session[ExSession.IP_ADRESS]);
                sessionString       = ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]);
                reportSizeUser      = ExCast.zCInt(HttpContext.Current.Session[ExSession.REPORT_SAVE_SIZE_USER]);
                idFigureCommodity   = ExCast.zCInt(HttpContext.Current.Session[ExSession.ID_FIGURE_GOODS]);
                idFigureCustomer    = ExCast.zCInt(HttpContext.Current.Session[ExSession.ID_FIGURE_CUSTOMER]);
                idFigurePurchase    = ExCast.zCInt(HttpContext.Current.Session[ExSession.ID_FIGURE_PURCHASE]);
                idFigureSlipNo      = ExCast.zCInt(HttpContext.Current.Session[ExSession.ID_FIGURE_SLIP_NO]);
                rpTotalAuthorityKbn = ExCast.zCInt(HttpContext.Current.Session[ExSession.REPORT_TOTAL_AUTHORITY_KBN]);

                string _message = ExSession.SessionUserUniqueCheck(random, ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]), ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID]));
                if (_message != "")
                {
                    entity         = new EntityReport();
                    entity.MESSAGE = _message;
                    return(entity);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".ReportOut(認証処理)", ex);
                entity         = new EntityReport();
                entity.MESSAGE = CLASS_NM + ".ReportOut : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString();
                return(entity);
            }

            #endregion

            ExMySQLData db = ExSession.GetSessionDb(ExCast.zCInt(userId), sessionString);

            try
            {
                #region Get Report Setting

                entitySetting = GetReportSetting(random, pgId);

                if (entitySetting == null)
                {
                    entitySetting               = new EntityReportSetting();
                    entitySetting.user_id       = ExCast.zCInt(userId);
                    entitySetting.pg_id         = pgId;
                    entitySetting.group_id_from = ExCast.zCInt(groupId).ToString();
                    entitySetting.group_id_to   = ExCast.zCInt(groupId).ToString();
                }
                else if (entitySetting != null)
                {
                    if (!string.IsNullOrEmpty(entitySetting.MESSAGE))
                    {
                        entitySetting               = new EntityReportSetting();
                        entitySetting.user_id       = ExCast.zCInt(userId);
                        entitySetting.pg_id         = pgId;
                        entitySetting.group_id_from = ExCast.zCInt(groupId).ToString();
                        entitySetting.group_id_to   = ExCast.zCInt(groupId).ToString();
                    }
                    else
                    {
                        if (ExCast.zCInt(entitySetting.group_id_from) == 0 && ExCast.zCInt(entitySetting.group_id_to) == 0)
                        {
                            entitySetting.group_id_from = ExCast.zCInt(groupId).ToString();
                            entitySetting.group_id_to   = ExCast.zCInt(groupId).ToString();
                        }
                    }
                }

                if (rpTotalAuthorityKbn < 2)
                {
                    entitySetting.group_id_from = ExCast.zCInt(groupId).ToString();
                    entitySetting.group_id_to   = ExCast.zCInt(groupId).ToString();
                }

                #endregion

                entity = new EntityReport();

                DataReport.geReportKbn kbn    = (DataReport.geReportKbn)ExCast.zCInt(rptKbn);
                ExReportManeger        rptMgr = new ExReportManeger();
                rptMgr.idFigureCommodity = idFigureCommodity;
                rptMgr.idFigureCustomer  = idFigureCustomer;
                rptMgr.idFigurePurchase  = idFigurePurchase;
                rptMgr.idFigureSlipNo    = idFigureSlipNo;
                rptMgr.entitySetting     = entitySetting;
                rptMgr.rptKbn            = kbn;

                #region Report FilePath Setting

                bool _ret = rptMgr.GetReportFilePath(pgId, companyId, userId);
                if (_ret == false)
                {
                    entity.MESSAGE = CommonUtl.gstrErrMsg;
                    return(entity);
                }
                entity.downLoadFilePath = rptMgr.reportFilePath;
                entity.downLoadFileName = rptMgr.reportFileName;
                entity.downLoadFileSize = rptMgr.reportFileSize.ToString();
                entity.downLoadUrl      = CommonUtl.gstrMainUrl + rptMgr.reportDir;

                #endregion

                DataSet ds = db.GetDataSet(rptMgr.ReportSQL(pgId, companyId, groupId, parameters), rptMgr.GetPGIDXsd(pgId));

                #region Export xsd

                System.IO.StreamWriter xmlSW = null;
                try
                {
                    xmlSW = new System.IO.StreamWriter(CommonUtl.gstrReportTemp + rptMgr.GetPGIDXsd(pgId) + ".xsd");
                    ds.WriteXmlSchema(xmlSW);
                    xmlSW.Close();
                }
                catch (Exception ex)
                {
                    CommonUtl.ExLogger.Error(CLASS_NM + ".WriteXmlSchema", ex);
                }
                finally
                {
                    if (xmlSW != null)
                    {
                        xmlSW.Dispose();
                        xmlSW = null;
                    }
                }

                #endregion

                if (ds.Tables[0].Rows.Count == 0)
                {
                    entity.MESSAGE = "データが存在しません。";
                    entity.ret     = false;
                    return(entity);
                }

                string _fileType     = "";
                string _DownloadType = "";
                switch (kbn)
                {
                case DataReport.geReportKbn.OutPut:
                    _fileType     = "PDF";
                    _DownloadType = "出力";

                    if (rptMgr.ReportToPdf(ds, pgId) == true)
                    {
                        entity.ret = true;
                    }
                    else
                    {
                        entity.MESSAGE = CommonUtl.gstrErrMsg;
                        entity.ret     = false;
                    }
                    break;

                case DataReport.geReportKbn.Download:
                    _fileType     = "PDF";
                    _DownloadType = "ダウンロード";

                    if (rptMgr.ReportToPdf(ds, pgId) == true)
                    {
                        entity.ret = true;
                    }
                    else
                    {
                        entity.MESSAGE = CommonUtl.gstrErrMsg;
                        entity.ret     = false;
                    }
                    break;

                case DataReport.geReportKbn.Csv:
                    _fileType     = "CSV";
                    _DownloadType = "ダウンロード";

                    if (rptMgr.DataTableToCsv(ds.Tables[0]) == true)
                    {
                        entity.ret = true;
                    }
                    else
                    {
                        entity.MESSAGE = CommonUtl.gstrErrMsg;
                        entity.ret     = false;
                    }
                    break;

                default:
                    break;
                }

                //entity.downLoadFilePath = @"d:\HostingSpaces\Users\EW20121725\Sales.system-innovation.net\wwwroot\temp\顧客マスタ一覧.csv";
                //System.IO.FileInfo fi = new System.IO.FileInfo(entity.downLoadFilePath);
                //entity.downLoadFileSize = fi.Length.ToString();
                if (reportSizeUser < ExCast.zCDbl(entity.downLoadFileSize) / 1000000)
                {
                    entity.MESSAGE = _fileType + "ファイルのサイズが" + reportSizeUser.ToString() + "Mバイトを超える為、" + _DownloadType + "できません。";
                    return(entity);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".ReportOut", ex);
                entity         = new EntityReport();
                entity.MESSAGE = CLASS_NM + ".ReportOut : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message.ToString();
                return(entity);
            }

            return(entity);
        }