Esempio n. 1
0
 private int UploadFileToBase(string fileName, byte[] _bytes)
 {
     int DataBlockId = -1;
     try
     {
         string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
         DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
         int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
         dataBlock.OpenConnection();
         dataBlock.AddData(orgId, _bytes, fileName);
         dataBlock.CloseConnection();
         DataBlockId = dataBlock.GET_DATA_BLOCK_ID();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return DataBlockId;
 }
Esempio n. 2
0
    protected void Upload_PLFFile(object Sender, EventArgs e)
    {
        SelectPLFDriver.Visible = false;
        FileList.Visible = false;

        UploadPanel.Visible = true;

        string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
        DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        try
        {
            int orgId = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            dataBlock.OpenConnection();
            dataBlock.OpenTransaction();
            if (SelectPLFDriver.SelectedIndex == 0)
            {
                return;
            }
            else
            {
                List<filenameAndBytesStruct> fileUpload = new List<filenameAndBytesStruct>();
                fileUpload = (List<filenameAndBytesStruct>)Session["FileUpload"];
                List<int> CardIdsList = new List<int>();
                CardIdsList = (List<int>)Session["CardIdsList"];

                foreach (filenameAndBytesStruct curFile in fileUpload)
                {
                    if (curFile.isPLF)
                        dataBlock.AddPlfTypeData(orgId, curFile._bytes, curFile.filename, CardIdsList[SelectPLFDriver.SelectedIndex]);
                    else
                        dataBlock.AddData(orgId, curFile._bytes, curFile.filename);
                }

                Session["FileUpload"] = "";
            }
            dataBlock.CommitTransaction();
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            dataBlock.RollbackConnection();
            dataBlock.CloseConnection();

            ErrorMessage.Text = "Ошибка: " + ex.Message;
            //show error block
            ErrorMessageBlock.Visible = true;
        }
        finally
        {
            SelectPLFDriver.Visible = false;
            FileList.Visible = false;

            UploadPanel.Visible = true;

            StatusUpdatePanel.Update();
        }
    }