コード例 #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        //{
        //    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        //    conn.Open();
        //    string insertQuery = "insert into [Table] ([name],[account],[amount]) values (@name1,@account1,@amount1)";
        //    SqlCommand com = new SqlCommand(insertQuery, conn);
        //    com.Parameters.AddWithValue("@name1", TextBox3.Text);
        //    com.Parameters.AddWithValue("@account1", TextBox1.Text);
        //    com.Parameters.AddWithValue("@amount1", TextBox2.Text);
        //    com.ExecuteNonQuery();
        //    Response.Redirect("manage.aspx");
        //    Response.Write("Transfer Successfull");
        //    conn.Close();
        //}

        //catch (Exception ex)
        //{
        //    Response.Write("Error:"+ex.ToString());
        //}
        if (FileUpload1.HasFile)
        {
            try
            {
                string filename = Path.GetFileName(FileUpload1.FileName);
                FileUpload1.SaveAs(Server.MapPath("~/") + filename);
                STATUS.Text = "Upload status: File uploaded!";
                if (Session["AdminFlag"] != null)
                {
                    VIEW_STATUS.Visible = Visible;
                    VIEW_STATUS.Text = "View All Transactions";

                }
                else
                {
                    VIEW_STATUS.Visible = Visible;
                }
                System.Diagnostics.Debug.WriteLine("Transfer Operation");
                System.Diagnostics.Debug.WriteLine("UserName:"******"New"].ToString());
                System.Diagnostics.Debug.WriteLine("User GUID:" + Session["SESSIONID"].ToString());
                System.Diagnostics.Debug.WriteLine("Session ID:" + HttpContext.Current.Session.SessionID);

                string file = Server.MapPath("~/ ") + filename;
                TParser parse = new TParser(file);
                TransactionBuilder build = new TransactionBuilder();
                int BatchId = parse.Parse(build);
                TransactionQueue queue = build.SetBatch(BatchId);
                TransactionService service = new TransactionService();
                service.Start(queue);

            }
            catch (Exception ex)
            {
                STATUS.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
            }
        }
    }
コード例 #2
0
ファイル: TParser.cs プロジェクト: MehdiMirakhorli/SWEN-755
        public int Parse(TransactionBuilder build)
        {
            StreamReader stream = new StreamReader(FileLocation);
            string line = string.Empty;
            int count = 0;
            int GBI = 0;
            while ((line = stream.ReadLine()) != null)
            {
                if (count != 0)
                {
                    string[] charArray = line.Split(';').ToArray<string>();

                    AccountService service = new AccountService();
                    if (count == 1)
                    {
                        GBI = Int32.Parse(charArray[0]);
                    }
                    string TransactionID = charArray[1];
                    string AccountPayer = charArray[2];
                    string PayerAccountID = charArray[3];
                    string AccountPayee = charArray[4];
                    string PayeeAccountID = charArray[5];
                    string transactiondetails = charArray[6];
                    decimal amount = decimal.Parse(charArray[7].Replace("$", ""));
                    Account PayerAccount = service.GetAccount(PayerAccountID);
                    Account PayeeAccount = service.GetAccount(PayeeAccountID);
                    if (PayerAccount != null && PayeeAccount != null)
                    {
                        build.Add(TransactionID, PayerAccount, PayeeAccount, transactiondetails, amount);
                    }
                }
                count++;
            }
            stream.Close();
            return GBI;
        }
コード例 #3
0
ファイル: TParser.cs プロジェクト: MehdiMirakhorli/SWEN-755
 public int Parse(TransactionBuilder build,string fileLocation)
 {
     FileLocation = fileLocation;
     return this.Parse(build);
 }
コード例 #4
0
 public int Parse(TransactionBuilder build, string fileLocation)
 {
     FileLocation = fileLocation;
     return(this.Parse(build));
 }