예제 #1
0
        private void button_ClientsList_Click(object sender, EventArgs e)
        {
            // Запрос наличия счета
            if (CheckSession(false))
            {
                string API     = "YH69EER";
                string AccFile = WorkPath + @"SP-SCH.acc";
                if (File.Exists(AccFile))
                {
                    try
                    {
                        // Create an instance of StreamReader to read from a file.
                        // The using statement also closes the StreamReader.
                        using (StreamReader sr = new StreamReader(AccFile))
                        {
                            string line;
                            while ((line = sr.ReadLine()) != null)
                            {
                                StringBuilder sb_input = new StringBuilder(0);
                                sb_input = sb_input.Append(EQGateDLL.InsertSpaces(textBox_YH69EER_HZEAN.Text, 20)); //
                                sb_input = sb_input.Append(" ");                                                    // Код внешней системы А(1)
                                sb_input = sb_input.Append(EQGateDLL.InsertSpaces("", 11));                         // Зарезервировано А(11)

                                if (EQGateDLL.Request(API, sb_input, EQGateAPI.EQGateClassAPI.GetAPIAttribute(API, "type")) != true)
                                {
                                    ShowErrorsWarnings(true); // Ошибки/Предупреждения
                                    return;
                                }
                                string ToFile      = WorkPath + @"SP-SCH.txt";
                                string temp        = String.Empty;
                                int    FieldsCount = 0;
                                using (StreamWriter sw = File.CreateText(ToFile))
                                {
                                    FieldsCount = EQGateAPI.EQGateClassAPI.GetFieldsCount(API, "");
                                    temp        = EQGateDLL.GetRequestOutputItem(Convert.ToInt32(Convert.ToDouble(EQGateAPI.EQGateClassAPI.GetFieldValue(API, "", 0, "size", ""))));
                                    for (int i = 1; i < FieldsCount; i++)
                                    {
                                        string Size = EQGateAPI.EQGateClassAPI.GetFieldValue(API, "", i, "size", "");
                                        temp = EQGateDLL.GetRequestOutputItem(Convert.ToInt32(Convert.ToDouble(Size)));
                                        sw.Write(temp.Trim());
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        // Let the user know what went wrong.
                        //Console.WriteLine("The file could not be read:");
                        //Console.WriteLine(exc.Message);
                        Logger.Log.SaveLog("", exc.ToString(), "err");
                    }
                    textBox_Session_Info.ForeColor = Color.FromName("Green");
                    textBox_Session_Info.Text      = "Готово";


                    int ListCount = 1;

                    FillListView(listView_YH69EER, ListCount, "YH69EER", WorkPath + @"YH69EER.txt", false);
                }
            }
        }
예제 #2
0
        private void FillListView(ListView lv, int Count, string api, string ToFile, bool AppendResult)
        {
            if (Count < 1)
            {
                return;
            }

            /*
             * if ((EQGateDLL.RequestOutput.Length / Count) < EQGateAPI.EQGateClassAPI.GetFieldsSize(api, ""))
             * {
             *  MessageBox.Show("Размер выходных данных меньше общего размера API!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             *  return;
             * }
             * // */
            //
            toolStripProgressBar.Value   = 0;
            toolStripProgressBar.Maximum = toolStripProgressBar.Step * Count;
            toolStripProgressBar.Visible = true;
            if (EQGateDLL.RequestOutput.Length == 0)
            {
                return;
            }
            if ((!AppendResult) && (File.Exists(ToFile)))
            {
                File.Delete(ToFile);
            }

            string temp = String.Empty;


            int FieldsCount = 0;

            FieldsCount = EQGateAPI.EQGateClassAPI.GetFieldsCount(api, "");

            if (lv.Columns.Count < FieldsCount)
            {
                lv.Columns.Clear();
                for (int iCounter = 0; iCounter < FieldsCount; iCounter++)
                {
                    ColumnHeader columnHeader = new ColumnHeader();
                    columnHeader.Text  = EQGateAPI.EQGateClassAPI.GetFieldValue(api, "", iCounter, "description", "");
                    columnHeader.Width = Convert.ToInt32(EQGateAPI.EQGateClassAPI.GetFieldValue(api, "", iCounter, "width", ""));

                    // Add the column headers to listView_Events.
                    lv.Columns.AddRange(new ColumnHeader[] { columnHeader });
                }
            }

            //int ListCount = ( sb_mcs.ToString(5, 4) as int );
            string ResultFileDivider = "^";

            //Divider = "|";

            using (StreamWriter sw = new StreamWriter(ToFile, AppendResult, Encoding.GetEncoding(866)))
            {
                for (int iCounter = 0; iCounter < Count; iCounter++)
                {
                    string        Size = String.Empty;
                    StringBuilder sb   = new StringBuilder();
                    ListViewItem  item = new ListViewItem();
                    for (int i = 0; i < FieldsCount; i++)
                    {
                        Size = EQGateAPI.EQGateClassAPI.GetFieldValue(api, "", i, "size", "");
                        temp = EQGateDLL.GetRequestOutputItem(Convert.ToInt32(Convert.ToDouble(Size)));
                        temp = temp.Replace(ResultFileDivider, " ");
                        if (EQGateAPI.EQGateClassAPI.GetFieldValue(api, "", i, "type", "") == "A")
                        {
                            sb.Append(temp.Trim());
                        }
                        if (EQGateAPI.EQGateClassAPI.GetFieldValue(api, "", i, "type", "") == "D")
                        {
                            sb.Append(EQGateDLL.ConvertDateToFormat(temp, ""));
                        }
                        if (EQGateAPI.EQGateClassAPI.GetFieldValue(api, "", i, "type", "") == "U")
                        {
                            sb.Append(EQGateDLL.ConvertToCurrency(temp, "U", Size));
                        }
                        if (EQGateAPI.EQGateClassAPI.GetFieldValue(api, "", i, "type", "") == "S")
                        {
                            sb.Append(EQGateDLL.ConvertToCurrency(temp, "S", Size));
                        }
                        if (EQGateAPI.EQGateClassAPI.GetFieldValue(api, "", i, "type", "") == "B")
                        {
                            if (temp == "Y")
                            {
                                sb.Append("Истина");
                            }
                            if (temp == "N")
                            {
                                sb.Append("Ложь");
                            }
                        }
                        if (i == 0)
                        {
                            item.Text = temp;
                        }
                        else
                        {
                            item.SubItems.Add(temp);
                        }
                        //sb.Append(temp);
                        sb.Append(ResultFileDivider);
                    }
                    lv.Items.AddRange(new ListViewItem[] { item });
                    sw.Write(sb.ToString());
                    //toolStripProgressBar.Value += 1;
                    sw.Write("\r\n");
                }
            }

            /*
             * if (File.Exists(ToFile + ".tmp"))
             * {
             *  File.Copy(ToFile + ".tmp", ToFile, true);
             *  File.Delete(ToFile + ".tmp");
             * } //*/
            //toolStripProgressBar.Visible = false;
        }