Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (currentUser.UserRole.Id == ApplicationConstants.ROLE_BUSINESS_ADMINISTATOR)
         {
             //check if RemoveAnnualBudget button has been hit
             if (!string.IsNullOrEmpty(hdnRemoveAnnualBudget.Value))
             {
                 string[] pars = hdnRemoveAnnualBudget.Value.Split(",".ToCharArray());
                 if (pars.Length == 2)
                 {
                     int year     = int.Parse(pars[0]);
                     int idImport = int.Parse(pars[1]);
                     ConnectionManager = SessionManager.GetConnectionManager(this);
                     DBAnnualImports dbImport = new DBAnnualImports(ConnectionManager);
                     AnnualImports   import   = new AnnualImports(ConnectionManager);
                     import.IdImport = idImport;
                     object rez = dbImport.ExecuteScalar("impRemoveAnnualImport", import);
                 }
             }
         }
     }
     catch (IndException ex)
     {
         ShowError(ex);
         return;
     }
     catch (Exception ex)
     {
         ShowError(new IndException(ex));
         return;
     }
 }
Пример #2
0
    private void LogProcessErrorToDataBase(int idImport, string message, string fileName)
    {
        AnnualImports annualImports = new AnnualImports(SessionManager.GetConnectionManager(this.Page));

        annualImports.IdImport = idImport;
        annualImports.Message  = message;
        annualImports.FileName = fileName;
        annualImports.ProcessErrorsToLogTables();
    }
Пример #3
0
    private void LogErrorToDataBase(string message, string fileName)
    {
        AnnualImports annualImports = new AnnualImports(SessionManager.GetConnectionManager(this.Page));

        annualImports.FileName    = fileName;
        annualImports.Message     = message;
        annualImports.IdAssociate = currentUser.IdAssociate;
        annualImports.UploadErrorsToLogTables();
    }
    private void CreateNewFile(DataSet dsNewFile)
    {
        AnnualImports imp = new AnnualImports(CurrentConnectionManager);

        imp.IdImport = IdImport;
        DataSet ds = imp.GetAll(true);

        if (ds == null)
        {
            return;
        }

        if (ds.Tables.Count == 0)
        {
            return;
        }

        //if file name is bigger than 4 -- (.extension)
        if (ds.Tables[0].Rows[0]["FileName"].ToString().Length <= 4)
        {
            return;
        }

        string dirUrlProcessed  = ConfigurationManager.AppSettings["UploadFolderAnnual"];//@"UploadDirectoriesAnnual\InProcess";
        string dirPathProcessed = Server.MapPath(@"..\..\" + dirUrlProcessed);
        string fileName         = ds.Tables[0].Rows[0]["FileName"].ToString().Substring(0, ds.Tables[0].Rows[0]["FileName"].ToString().Length - 4);
        string PathToFile       = dirPathProcessed + @"\" + fileName + "_" + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + ".csv";

        string[] filesArr = Directory.GetFiles(dirPathProcessed);
        for (int i = 0; i <= filesArr.Length - 1; i++)
        {
            if (Path.GetExtension(filesArr[i].ToString()) != ".csv")
            {
                continue;
            }
            if (filesArr[i].ToString().Contains(fileName))
            {
                File.Delete(filesArr[i].ToString());
            }
        }

        WriteToFile(PathToFile, dsNewFile);
        if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "ButtonUpdateScript"))
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ButtonUpdateScript", "alert('Modifications have been saved! You can retry to process file.');", true);
        }
    }