Ejemplo n.º 1
0
    private void CreateCSV(WorkflowBinding bWorkflow)
    {
        Response.ContentType = "text/pain";
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + DateTime.Now.ToString("yyyyMMdd") + Server.UrlEncode(ddfForm.SelectedItem.Text + ".csv"));
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("shift-jis");

        KiwiDemandInformation dInfo = new KiwiDemandInformation();

        //対象区分
        string targetCategory = string.Empty;
        //対象コード
        string targetCode = string.Empty;
        //管理種別
        string Category = string.Empty;
        //処理区分
        string ProcessingCategory = string.Empty;
        //対象名称
        string targetName = string.Empty;
        //対象金額
        string targetPrice = string.Empty;
        //精算期間
        string Period = string.Empty;
        //精算区分
        string AdjustmentCode = string.Empty;
        //期初月
        string BeginningMonth = string.Empty;
        //精算条件
        string Adjustment = string.Empty;
        //精算方法
        string AdjustmentMethod = string.Empty;
        //開始日付
        string StartDay = string.Empty;
        //打切日付
        string EndDay = string.Empty;
        //精算条件コードを新規登録するかどうか
        string NewAdjustment = string.Empty;
        //支払予定日(月ずれ)
        string PaymentMonth = string.Empty;
        //支払予定日(日付)
        string PaymentDay = string.Empty;
        //変更日付
        string ChangeDay = string.Empty;
        //メーカーコード
        string Maker = string.Empty;
        //メーカー名
        string MakerName = string.Empty;


        //タイトル
        List<string> lstTitle = new List<string>();
        //値引・リベート申請の明細行
        List<string> lstLine = new List<string>();
        //通常申請のアイテム
        List<string> lstItem = new List<string>();
        //決済情報
        List<string> lstProcess = new List<string>();

        //1申請目だけタイトル行をつける
        int nDemand = 0;

        foreach (XMLElement element in bWorkflow.arrayReturns)
        {
            //申請情報
            if (element.Name.Equals("application") && element.NodeType == XmlNodeType.Element)
            {
                for (int i = 0; i < element.arrayAttributes.Count; i++)
                {
                    XMLAttribute attribute = (XMLAttribute)element.arrayAttributes[i];

                    if (attribute.Name.Equals("date"))
                    {
                        dInfo.DemandDate = attribute.Value;
                    }
                    else if (attribute.Name.Equals("number"))
                    {
                        dInfo.DemandNumber = attribute.Value;
                    }
                }
            }
            //申請者情報
            else if (element.Name.Equals("applicant"))
            {
                for (int i = 0; i < element.arrayAttributes.Count; i++)
                {
                    XMLAttribute attribute = (XMLAttribute)element.arrayAttributes[i];

                    if (attribute.Name.Equals("name"))
                    {
                        dInfo.Operator = attribute.Value;
                    }
                }
            }
            //申請内容
            else if (element.Name.Equals("item"))
            {
                switch (ddfForm.SelectedItem.Text)
                {
                    case "値引申請":
                        AnalyzeDiscountItem(element, ref dInfo, ref targetCategory, ref targetCode, ref Category, ref ProcessingCategory, lstLine);
                        break;
                    case "サロンリベート登録申請":
                        AnalyzeSalonRebateItem(element, ref dInfo, ref targetCategory, ref targetCode, ref targetName, ref targetPrice, ref Period, ref BeginningMonth, ref Adjustment, ref AdjustmentMethod, ref AdjustmentCode, ref StartDay, ref EndDay, ref ProcessingCategory, ref NewAdjustment, ref PaymentMonth, ref PaymentDay, lstLine); //追加抽出項目を追加する
                        break;
                    //case "セルアウトリベート登録申請":
                        //AnalyzeSelloutRebateItemOld(element, ref dInfo, ref targetCategory, ref targetCode, ref targetName, ref targetPrice, ref Period, ref BeginningMonth, ref Adjustment, ref AdjustmentMethod, ref StartDay, ref EndDay, ref ProcessingCategory, lstLine);
                        //break;
                    case "セルアウトリベート登録申請":
                        AnalyzeSelloutRebateItem(element, ref dInfo, ref targetCategory, ref targetCode, ref targetName, ref targetPrice, ref Period, ref BeginningMonth, ref Adjustment, ref AdjustmentMethod, ref StartDay, ref EndDay, ref ProcessingCategory, ref Maker, ref MakerName, lstLine);
                        break;
                    case "担当変更申請":
                        AnalyzeChangeOfPersonItem(element, ref dInfo, ref ChangeDay, lstLine);
                        break;
                    default:
                        lstItem.Add("\"" + ((XMLAttribute)element.arrayAttributes[1]).Value + "\"");
                        if (nDemand == 0)
                        {
                            lstTitle.Add(((XMLAttribute)element.arrayAttributes[0]).Value);
                        }

                        break;
                }
            }
            //決済情報
            else if (element.Name.Equals("processor") && element.NodeType == XmlNodeType.Element)
            {
                string strDate = string.Empty;
                string strProcessor = string.Empty;
                string strResult = string.Empty;

                for (int i = 0; i < element.arrayAttributes.Count; i++)
                {
                    XMLAttribute attribute = (XMLAttribute)element.arrayAttributes[i];

                    switch (attribute.Name)
                    {
                        case "date":
                            strDate = attribute.Value;
                            break;
                        case "processor_name":
                            strProcessor = attribute.Value;
                            break;
                        case "result":
                            strResult = attribute.Value;
                            break;
                    }
                }

                if (nDemand == 0)
                {
                    lstTitle.Add("決済者,決済日付,結果");
                }
                lstProcess.Add(strProcessor + "," + strDate + "," + strResult);
            }
            //申請終了
            else if (element.Name.Equals("application") && element.NodeType == XmlNodeType.EndElement)
            {
                switch (ddfForm.SelectedItem.Text)
                {
                    case "値引申請":
                    case "サロンリベート登録申請":
                    case "セルアウトリベート登録申請":
                    //case "セルアウトリベート登録申請(NEW)":
                    case "担当変更申請":
                    foreach (string strLine in lstLine)
                        {
                            string line = strLine;

                            foreach (string strProcess in lstProcess)
                            {
                                line += "," + strProcess;
                            }
                            Response.Write(line);
                            Response.Write("\r\n");
                        }
                        break;
                    default:
                        string swLine = string.Empty;
                        string TitleLine = string.Empty;

                        foreach (string strItem in lstItem)
                        {
                            swLine += strItem + ",";
                        }

                        for (int i = 0; i < lstProcess.Count; i++)
                        {
                            swLine += lstProcess[i];

                            if (i < lstProcess.Count - 1)
                            {
                                swLine += ",";
                            }
                        }

                        if (nDemand == 0)
                        {
                            Response.Write("申請番号,申請日,申請者,所属");
                            foreach (string title in lstTitle)
                            {
                                Response.Write("," + title);
                            }
                            Response.Write(System.Environment.NewLine);
                        }

                        Response.Write(dInfo.DemandNumber + "," + dInfo.DemandDate + "," + dInfo.Operator + "," + dInfo.Division + "," + swLine);
                        Response.Write("\r\n");

                        nDemand++;
                        break;
                }

                lstLine.Clear();
                lstProcess.Clear();
                lstItem.Clear();
            }
        }

        Response.Flush();
        Response.End();

        string scriptStr = "<script type='text/javascript'>";
        scriptStr += "window.open('about:blank','_self').close();";
        scriptStr += "</script>";

        ClientScript.RegisterClientScriptBlock(GetType(), "closewindow", scriptStr);
    }
Ejemplo n.º 2
0
    protected void Search_Click(object sender, EventArgs e)
    {
        try
        {
            ActiveDirectoryBoundary adBoundary = new ActiveDirectoryBoundary();
            StringCollection scGroupList = adBoundary.SearchGroup(txtUser.Text, txtPassword.Text);

            if (!CheckAccess(scGroupList))
            {
                MessageLabel.Text = "検索結果がありません。";
                return;
            }

            //ワークフローAPIのバウンダリ
            WorkflowBinding bWorkflow = new WorkflowBinding();

            //IDとパスワードの設定
            bWorkflow.strUserName = "******";
            bWorkflow.strPassword = "******";

            RequestManageFormType[] resFormType;
            WorkflowGetRequestsRequestType reqType = new WorkflowGetRequestsRequestType();
            reqType.manage_request_parameter = new WorkflowGetRequestType();

            //ワークフローの申請フォームIDの設定
            reqType.manage_request_parameter.request_form_id = ddfForm.SelectedItem.Value;
            //決済完了日の設定
            reqType.manage_request_parameter.start_approval_date = DateTime.Parse(StartYear.Text + "/" + StartMonth.Text + "/" + StartDay.Text);
            reqType.manage_request_parameter.start_approval_dateSpecified = true;
            reqType.manage_request_parameter.end_approval_date = DateTime.Parse(EndYear.Text + "/" + EndMonth.Text + "/" + EndDay.Text).AddDays(1);
            reqType.manage_request_parameter.end_approval_dateSpecified = true;
            //完了区分の設定
            reqType.manage_request_parameter.filter = WorkflowGetManageRequestFilter.Complete;
            reqType.manage_request_parameter.filterSpecified = true;

            //申請ID一覧の取得
            resFormType = bWorkflow.WorkflowGetRequests(reqType);

            List<string> lstRequests = new List<string>();

            foreach (XMLElement element in bWorkflow.arrayReturns)
            {
                if (element.Name.Equals("manage_item_detail") && element.NodeType == XmlNodeType.Element)
                {
                    XMLAttribute attrPid = (XMLAttribute)element.arrayAttributes[0];
                    lstRequests.Add(attrPid.Value);
                }
            }

            string[] strRequests = lstRequests.ToArray();

            //バウンダリの結果情報を消去
            bWorkflow.arrayReturns.Clear();

            if (strRequests.Length > 0)
            {
                //申請IDごとにデータ取得
                WorkflowApplicationType[] resApplicationType;
                resApplicationType = bWorkflow.WorkflowGetRequestById(strRequests);

                //結果を値引データCSVへ出力
                CreateCSV(bWorkflow);
            }
            else
            {
                MessageLabel.Text = "検索結果がありません。";
            }
        }
        catch (Exception exception)
        {
            MessageLabel.Text = exception.Message;
        }
    }