예제 #1
0
    public static bool ParseDataBlocks(String OrgID, String UserName)
    {
        string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        PLFUnit.PLFUnitClass plfForXml = new PLFUnit.PLFUnitClass();
        List<int> dataBlockIDs = new List<int>();
        int filesCounter = 0;
        object parsedObject;

        try
        {
            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);
            int orgId = int.Parse(OrgID);
            dataBlockIDs = dataBlock.GetAllUnparsedDataBlockIDs(orgId);
            if (dataBlockIDs.Count == 0)
            {
                return true;
            }
            string output = "";
            foreach (int blockId in dataBlockIDs)
            {
                dataBlock.SetDataBlockIdForParse(blockId);
                dataBlock.SetOrgIdForParse(orgId);
                string state = dataBlock.GetDataBlockState(blockId);
                if (state.Equals("Not parsed"))
                {
                    output = HttpContext.Current.Server.MapPath("~/XML_PLF") + "\\";
                    parsedObject = dataBlock.ParseRecords(true, output, userId);
                    filesCounter++;
                }
            }
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();

            return true;
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();
            throw ex;
            //return false;
        }
    }
예제 #2
0
    protected void Parse_Click(object Sender, EventArgs e)
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        PLFUnit.PLFUnitClass plfForXml = new PLFUnit.PLFUnitClass();
        List<int> dataBlockIDs = new List<int>();
        int cardType = 0;
        int filesCounter = 0;
        object parsedObject;

        try
        {
            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            int userId = dataBlock.usersTable.Get_UserID_byName(User.Identity.Name);
            int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            dataBlockIDs = dataBlock.GetAllUnparsedDataBlockIDs(orgId);
            if (dataBlockIDs.Count == 0)
                throw new Exception("Отсутствуют данные для разбора.");

            string output = "";
            foreach (int blockId in dataBlockIDs)
            {
                dataBlock.SetDataBlockIdForParse(blockId);
                dataBlock.SetOrgIdForParse(orgId);
                //dataBlock = new DataBlock(connectionString, blockId, ConfigurationManager.AppSettings["language"], orgId);
                if (dataBlock.GetDataBlockState(blockId) == "Not parsed")
                {
                    output = Server.MapPath("~/XML_PLF") + "\\";
                    parsedObject = dataBlock.ParseRecords(true, output, userId);
                    filesCounter++;
                }
                else
                    continue;

            }
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();
            LoadAllLists();
            if (filesCounter > 0)
                Status.Text = "Файлы разобраны успешно! Разобрано " + filesCounter.ToString() + " файлов.";
            else
                Status.Text = "Не разобрано ни одного файла.";
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();
            LoadAllLists();
            Status.Text = "Ошибка: " + ex.Message;
        }
        finally
        {
            StatusUpdatePanel.Update();
            ModalPopupExtender1.Hide();
        }
    }