示例#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
    public static List<DataBlockID> GetUnparsedDataBlocks(String OrgID)
    {
        try
        {
            string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);

            int orgId = Convert.ToInt32(OrgID);

            List<DataBlockID> dataBlockIDList = new List<DataBlockID>();
            DataBlockID dataBlockIDItem;
            List<int> dataBlockIDs = new List<int>();
            int number = 0;

            dataBlock.OpenConnection();
            dataBlockIDs = dataBlock.GetAllUnparsedDataBlockIDs(orgId);
            foreach (int id in dataBlockIDs)
            {
                number++;
                dataBlockIDItem = new DataBlockID();
                dataBlockIDItem.ID = id;
                dataBlockIDItem.Number = number;
                dataBlockIDItem.Name = dataBlock.GetDataBlock_FileName(id);
                dataBlockIDItem.State = dataBlock.GetDataBlockState(id);
                dataBlockIDItem.ByteSize = Convert.ToInt32(dataBlock.GetDataBlock_BytesCount(id));

                dataBlockIDList.Add(dataBlockIDItem);
            }

            dataBlock.CloseConnection();

            return dataBlockIDList;
        }
        catch (Exception ex)
        {
            throw ex;
            //return null;
        }
    }
示例#3
0
    private List<DeleteStructure> LoadAllDeleteLists()
    {
        try
        {
            int userId = 0;
            List<DeleteStructure> deleteStructureList = new List<DeleteStructure>();
            int i = 0;
            string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            DeleteStructure deleteStructureTemp;
            List<int> dataBlockIds = new List<int>();
            dataBlock.OpenConnection();
            dataBlockIds = dataBlock.GetAllParsedDataBlockIDs(userId);
            foreach (int dataBlockId in dataBlockIds)
            {
                i++;
                deleteStructureTemp = new DeleteStructure();
                deleteStructureTemp.dataBlockId = dataBlockId;
                deleteStructureTemp.number = i;
                deleteStructureTemp.name = dataBlock.GetDriversNameOrVehiclesNumberByBlockId(dataBlockId);
                deleteStructureTemp.cardTypeName = dataBlock.GetCardTypeName(dataBlockId);
                deleteStructureTemp.recordsCount = dataBlock.GetDataBlock_RecorsCount(dataBlockId);
                deleteStructureTemp.createTime = dataBlock.GetDataBlock_EDate(dataBlockId);
                deleteStructureTemp.dataBlockState = dataBlock.GetDataBlockState(dataBlockId);

                deleteStructureList.Add(deleteStructureTemp);
            }
            if (dataBlockIds.Count == 0)
                Status.Text = "Нет записей для отображения";

            AddGrid.DataSource = CreateDeleteDataSource(deleteStructureList);
            AddGrid.DataBind();
            dataBlock.CloseConnection();
            return deleteStructureList;
        }
        catch (Exception ex)
        {
            Status.Text = "Произошла ошибка: " + ex.Message + " Возможо просто нету данных в БД. Исправление в след. версии";
            return null;
        }
        finally
        {
        }
    }
示例#4
0
    private List<AddStructure> LoadAllLists()
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        try
        {
            int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            List<AddStructure> addStructureList = new List<AddStructure>();
            int i = 0;

            AddStructure addStructureTemp;
            List<int> dataBlockIds = new List<int>();

            dataBlock.OpenConnection();
            dataBlockIds = dataBlock.GetAllUnparsedDataBlockIDs(orgId);
            foreach (int dataBlockId in dataBlockIds)
            {
                i++;
                addStructureTemp = new AddStructure();
                addStructureTemp.dataBlockId = dataBlockId;
                addStructureTemp.number = i;
                addStructureTemp.name = dataBlock.GetDataBlock_FileName(dataBlockId);
                addStructureTemp.state = dataBlock.GetDataBlockState(dataBlockId);
                addStructureTemp.byteSize = Convert.ToInt32(dataBlock.GetDataBlock_BytesCount(dataBlockId));

                addStructureList.Add(addStructureTemp);
            }
            if (dataBlockIds.Count == 0)
            {
                Parse_Button.Enabled = false;
                Status.Text = "Нет записей для отображения";
            }
            else
            {
                Parse_Button.Enabled = true;
                Status.Text = "";
            }

            AddGrid.DataSource = CreateDataSource(addStructureList);
            AddGrid.DataBind();
            SetDelColVisible(true);
            setParseButtonVisible(true);
            dataBlock.CloseConnection();
            return addStructureList;
        }
        catch (Exception ex)
        {
            dataBlock.CloseConnection();
            Status.Text = "Произошла ошибка: " + ex.Message;
            return null;
        }
        finally
        {
            StatusUpdatePanel.Update();
        }
    }
示例#5
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();
        }
    }