Esempio n. 1
0
    private static List<Driver> LoadAllDriversLists(int cardId)
    {
        List<Driver> driversStructureList = new List<Driver>();
        int number = 0;
        string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        Driver driversStructureTemp;
        List<int> dataBlockIds = new List<int>();
        try
        {
            dataBlock.OpenConnection();
            dataBlockIds = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardId);
            int cardType;
            List<DateTime> startEnd = new List<DateTime>();
            foreach (int dataBlockId in dataBlockIds)
            {
                number++;
                driversStructureTemp = new Driver();
                driversStructureTemp.DataBlockId = dataBlockId;
                driversStructureTemp.Number = number;
                driversStructureTemp.Name = dataBlock.GetDataBlock_FileName(dataBlockId);
                driversStructureTemp.RecordsCount = dataBlock.GetDataBlock_RecorsCount(dataBlockId);
                driversStructureTemp.CreationTime = dataBlock.GetDataBlock_EDate(dataBlockId);
                cardType = dataBlock.GetDataBlock_CardType(dataBlockId);
                driversStructureTemp.CardTypeName = dataBlock.GetCardTypeName(dataBlockId);
                if (cardType == 0)
                {
                    startEnd = dataBlock.cardUnitInfo.Get_StartEndPeriod(dataBlockId);
                    driversStructureTemp.setFromDate(startEnd[0]);
                    driversStructureTemp.setToDate(startEnd[1]);
                }
                else
                    if (cardType == 2)
                    {
                        driversStructureTemp.setFromDate(dataBlock.plfUnitInfo.Get_START_PERIOD(dataBlockId));
                        driversStructureTemp.setToDate(dataBlock.plfUnitInfo.Get_END_PERIOD(dataBlockId));
                    }
                    else
                    {
                        driversStructureTemp.setFromDate(new DateTime());
                        driversStructureTemp.setToDate(new DateTime());
                    }

                driversStructureList.Add(driversStructureTemp);
            }
            dataBlock.CloseConnection();

            return driversStructureList;
        }
        catch (Exception ex)
        {
            dataBlock.CloseConnection();
            return null;
        }
    }
    public void LoadAllDriversDateStatistics(List<int> dataBlockIds)
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);

        try
        {
            DateTime mindate = DateTime.Now;
            DateTime maxdate = new DateTime();
            List<DateTime> startEndPeriod = new List<DateTime>();
            List<int> selectedIds = new List<int>();
            bool isDDD = IsDDDFile();
            dataBlock.OpenConnection();

            Session["AllDataBlockIds"] = dataBlockIds;
            int fileType = 0;
            foreach (int id in dataBlockIds)
            {
                fileType = dataBlock.GetDataBlock_CardType(id);
                if (isDDD == true)//DDD
                    if (fileType == 2 || fileType == 1)//2-PLF, 1-vehicle
                        continue;
                    else
                    {
                        selectedIds.Add(id);
                        startEndPeriod = dataBlock.cardUnitInfo.Get_StartEndPeriod(id);
                    }
                else//PLF
                    if (fileType == 0 || fileType == 1)//0 - drivers DDD; 1 for vehicle
                        continue;
                    else
                    {
                        selectedIds.Add(id);
                        startEndPeriod = new List<DateTime>();
                        startEndPeriod.Add(dataBlock.plfUnitInfo.Get_START_PERIOD(id));
                        startEndPeriod.Add(dataBlock.plfUnitInfo.Get_END_PERIOD(id));
                    }

                if (mindate > startEndPeriod[0])
                    mindate = startEndPeriod[0];
                if (maxdate < startEndPeriod[1])
                    maxdate = startEndPeriod[1];
            }

            Session["StatisticsDataBlockIds"] = selectedIds;
            List<int> yearsList = GetYearList(mindate, maxdate);

            if (isDDD)
            {
                LoadAllForDDDDriver(dataBlock, selectedIds, yearsList);
            }
            else
            {
                LoadAllForPLFFile(dataBlock, selectedIds, yearsList);
            }
            Status.Text = "";
            YearsGrid.SelectedIndex = 0;
            MonthGrid.SelectedIndex = 0;
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
        }
        finally
        {
            dataBlock.CloseConnection();
            DateUpdate.Update();
        }
    }
Esempio n. 3
0
    public static List<PLFFilesTreeItem> GetPLFFilesTree(String OrgID)
    {
        string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);

        int orgId = Convert.ToInt32(OrgID);
        List<string> names = new List<string>();
        List<string> numbers = new List<string>();
        List<int> IDs = new List<int>();
        List<int> PLFs = new List<int>();

        dataBlock.OpenConnection();

        IDs = dataBlock.cardsTable.GetAllCardIds(orgId, dataBlock.cardsTable.driversCardTypeId);
        names = dataBlock.cardsTable.GetCardNames(IDs);
        numbers = dataBlock.cardsTable.GetCardNumbers(IDs);

        List<PLFFilesTreeItem> PLFFilesTreeItems = new List<PLFFilesTreeItem>();

        const int CARD_TYPE_DRIVER=0;
        const int CARD_TYPE_PLF=2;

        for (int i = 0; i < names.Count;i++)
        {
            PLFFilesTreeItem treeItem=new PLFFilesTreeItem ();
            treeItem.ID=IDs[i];
            treeItem.Name=names[i];
            treeItem.Number=numbers[i];

            PLFFilesTreeItems.Add(treeItem);

            PLFs= dataBlock.cardsTable.GetAllDataBlockIds_byCardId(IDs[i]);
            if (PLFs != null)
            {
                foreach (int plf in PLFs)
                {
                    int cardType; //0 - driver, 2 - plf
                    cardType = dataBlock.GetDataBlock_CardType(plf);

                    if (cardType == CARD_TYPE_PLF)
                    {
                        string vehicle = dataBlock.plfUnitInfo.Get_VEHICLE(plf);
                        string deviceID = dataBlock.plfUnitInfo.Get_ID_DEVICE(plf);
                        string period = "(" + dataBlock.plfUnitInfo.Get_START_PERIOD(plf).ToShortDateString() +
                                        " - " +
                                        dataBlock.plfUnitInfo.Get_END_PERIOD(plf).ToShortDateString() + ")";

                        bool exist=false;
                        foreach(PLFFilesTreeItem item in PLFFilesTreeItems)
                        {
                            foreach(PLFItem PLFItem in item.PLFItems)
                            {
                                if(PLFItem.DeviceID.Equals(vehicle)&&PLFItem.Equals(deviceID)){
                                    PLFItem.PLFs.Add(new MapItem(plf.ToString(), period));
                                    exist=true;
                                    break;
                                }
                            }
                        }
                        if(!exist)
                        {
                            PLFItem PLFItem = new PLFItem();
                            PLFItem.Vehicle = vehicle;
                            PLFItem.DeviceID = deviceID;
                            PLFItem.PLFs.Add(new MapItem(plf.ToString(), period));

                            treeItem.PLFItems.Add(PLFItem);
                        }
                    }
                }
            }
        }
        dataBlock.CloseConnection();

        return PLFFilesTreeItems;
    }
    protected void ReloadStats_Click(object s, EventArgs e)
    {
        string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);

        try
        {
            bool isDDD = IsDDDFile();
            List<int> selectedIds = new List<int>();
            selectedIds = (List<int>)Session["StatisticsDataBlockIds"];
            int yearVal = Convert.ToInt32(YearsGrid.SelectedRow.Cells[0].Text);
            int monthNumber = MonthGrid.SelectedIndex+1;
            dataBlock.OpenConnection();

            if (isDDD)
            {
                if (dataBlock.GetDataBlock_CardType(selectedIds[0]) == 0)//dddDriverCard
                {
                    MonthGrid_Values.DataSource = GetDDDMonthValuesDataTable(dataBlock, selectedIds, yearVal);
                    DaysGrid.DataSource = GetDDDDayValuesDataTable(dataBlock, selectedIds, yearVal, monthNumber);
                }
                else//DDDVehicleCard
                {
                    MonthGrid_Values.DataSource = GetVehicleMonthValuesDataTable(dataBlock, selectedIds, yearVal);
                    DaysGrid.DataSource = GetVehicleDayValuesDataTable(dataBlock, selectedIds, yearVal, monthNumber);
                }
            }
            else
            {
                MonthGrid_Values.DataSource = GetPLFMonthValuesDataTable(dataBlock, selectedIds, yearVal);
                DaysGrid.DataSource = GetPLFDayValuesDataTable(dataBlock, selectedIds, yearVal, monthNumber);
            }
            MonthGrid_Values.DataBind();
            DaysGrid.DataBind();

            dataBlock.CloseConnection();
            DateUpdate.Update();
        }
        catch (Exception ex)
        {
            Status.Text = ex.Message;
            DateUpdate.Update();
        }
        finally
        {
            dataBlock.CloseConnection();
        }
    }