Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //TODO: HTTP 401 or Redirect
            if (!RequestAuthentication.Authenticate(Request))
            {
                Logger.AddToLogger(Server.MapPath("."), "AddRequest.aspx ERROR: Request failed authentication.");
                return;
            }

            var requestValidator = new RequestValidator(error =>
                                                        Logger.AddToLogger(Server.MapPath("."), "AddRequest.aspx ERROR: " + error));

            var propertiesToValidate = new List <string>
            {
                "TransactionGUID", "CountryIDFrom", "CompanyVATFrom", "CountryIDTo", "CompanyVATTo",
                "Data", "CompanySerialNumber"
            };

            //TODO: HTTP 404 or Redirect
            if (!requestValidator.ValidateDataFieldsInRequest(Request, propertiesToValidate))
            {
                return;
            }

            DBLayer dblayer = new DBLayer();

            dblayer.CreateConnectionString(Server.MapPath("."));

            var countryIDFrom       = Request["CountryIDFrom"];
            var companyVATFrom      = Request["CompanyVATFrom"];
            var countryIDTo         = Request["CountryIDTo"];
            var companyVATTo        = Request["CompanyVATTo"];
            var data                = Request["Data"];
            var companySerialNumber = Request["CompanySerialNumber"];
            var transactionGUID     = Request["TransactionGUID"];

            if (dblayer.IsCompanyBlocked(countryIDFrom, companyVATFrom, countryIDTo, companyVATTo))
            {
                return;
            }

            Company company = dblayer.GetCompany(countryIDTo, companyVATTo);

            if (company == null || !company.Active)
            {
                return;
            }

            var success = dblayer.AddData(transactionGUID, countryIDFrom, companyVATFrom,
                                          countryIDTo, companyVATTo, data, company.WriteCode);

            if (success)
            {
                //Billing billing = dblayer.GetBilling(CompanySerialNumber, Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day) + 1).ToShortDateString()));
                //if (billing == null)
                //{
                //    billing = new Billing();
                //    billing.CompanySerialNumber = CompanySerialNumber;
                //    billing.DateMonth = Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day) + 1).ToShortDateString());
                //    billing.InCounter = 1;
                //    billing.OutCounter = 0;
                //    dblayer.AddBilling(billing);
                //}
                //else
                //{
                //    billing.InCounter++;
                //    dblayer.UpdateBilling(billing, Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day) + 1).ToShortDateString()));
                //}
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool bUploaded = false;

            //TODO: HTTP 401 or Redirect
            if (!RequestAuthentication.Authenticate(Request))
            {
                Logger.AddToLogger(Server.MapPath("."), "AddData.aspx ERROR: Request failed authentication.");
                return;
            }

            Action <string> loggingAction = error =>
                                            Logger.AddToLogger(Server.MapPath("."), "AddData.aspx ERROR: " + error);

            var requestValidator = new RequestValidator(loggingAction);

            var propertiesToValidate = new List <string>
            {
                "TransactionGUID", "CountryIDFrom", "CompanyVATFrom", "CountryIDTo", "CompanyVATTo",
                "WriteCode", "Data", "CompanySerialNumber"
            };

            //TODO: HTTP 404 or Redirect
            if (!requestValidator.ValidateDataFieldsInRequest(Request, propertiesToValidate))
            {
                return;
            }

            DBLayer dblayer = new DBLayer();

            dblayer.CreateConnectionString(Server.MapPath("."));

            var countryIDFrom       = Request["CountryIDFrom"];
            var companyVATFrom      = Request["CompanyVATFrom"];
            var countryIDTo         = Request["CountryIDTo"];
            var companyVATTo        = Request["CompanyVATTo"];
            var data                = Request["Data"];
            var companySerialNumber = Request["CompanySerialNumber"];
            var transactionGUID     = Request["TransactionGUID"];
            var writeCode           = Request["WriteCode"];

            if (dblayer.IsCompanyBlocked(countryIDFrom, companyVATFrom, countryIDTo, companyVATTo))
            {
                return;
            }

            // TODO: WTF?
            data = data.Replace("\"\"", "\"");
            data = data.Replace("''", "'");
            data = data.Replace("\"", "\"\"");
            data = data.Replace("'", "''");

            var success = dblayer.AddData(transactionGUID, countryIDFrom, companyVATFrom, countryIDTo,
                                          companyVATTo, data, writeCode);

            if (success)
            {
                Billing billing = dblayer.GetBilling(companySerialNumber,
                                                     Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day) + 1).ToShortDateString()));

                if (billing == null)
                {
                    billing = new Billing
                    {
                        CompanySerialNumber = companySerialNumber,
                        DateMonth           = Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day) + 1).ToShortDateString()),
                        InCounter           = 1,
                        OutCounter          = 0
                    };

                    dblayer.AddBilling(billing);
                }
                else
                {
                    billing.InCounter++;
                    dblayer.UpdateBilling(billing,
                                          Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day) + 1).ToShortDateString()));
                }

                UploadFile uf = new UploadFile();
                bUploaded = uf.Upload(Request, loggingAction, Server.MapPath("."), transactionGUID);
            }

            //Response.Write(transactionGUID + ", " + countryIDFrom + ", " + companyVATFrom + ", " + countryIDTo + ", " + companyVATTo + ", " + data + ", " + writeCode + ", bUploaded" + bUploaded);
            Response.Write("Uploaded: " + bUploaded);
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //http://212.150.1.51/GlobalInfoProtocol/AddData.aspx?CountryIDFrom=117&CompanyVATFrom=513638346&CountryIDTo=117&CompanyVATTo=513638346&WriteCode=123456789&Data=KT|024444|0303/12/2012|0503/12/2012|0603/12/2012|07אדירים|08513638346|09xxx|10|111|12|13222|14חז&LoginKey=xezp3avnniqyjf45wso0ot45
            //http://212.150.1.51/GlobalInfoProtocol/AddData.aspx?
            //CountryIDFrom=117&CompanyVATFrom=513638346&CountryIDTo=117
            //&CompanyVATTo=513638346&WriteCode=123456789&
            //Data=KT|024444|0303/12/2012|0503/12/2012|0603/12/2012|07אדירים|08513638346|09xxx|10|111|12|13222|14חז
            //&LoginKey=xezp3avnniqyjf45wso0ot45

            //http://212.150.1.51/GlobalInfoProtocol/AddData.aspx?
            //CountryIDFrom=117
            //&CompanyVATFrom=513638346
            //&CountryIDTo=117
            //&CompanyVATTo=513638346
            //&WriteCode=123456789&
            //Data=KT|02222|0303/12/2012|0503/12/2012|0603/12/2012|07אדירים|08513638346|09ww|10|111|12|13333|14חז
            //&LoginKey=xezp3avnniqyjf45wso0ot45
            DBLayer dblayer = new DBLayer();

            dblayer.CreateConnectionString(Server.MapPath("."));

            String LoginKey = Request["LoginKey"];

            String TransactionGUID = Request["TransactionGUID"];

            String CountryIDFrom  = Request["CountryIDFrom"];
            String CompanyVATFrom = Request["CompanyVATFrom"];

            String CountryIDTo  = Request["CountryIDTo"];
            String CompanyVATTo = Request["CompanyVATTo"];

            //String WriteCode = Request["WriteCode"];

            String Data = Request["Data"];
            String CompanySerialNumber = Request["CompanySerialNumber"];

            if ((LoginKey != null) && (LoginKey == "xezp3avnniqyjf45wso0ot45"))
            {
                if ((TransactionGUID != null) && (TransactionGUID != ""))
                {
                    //if ((WriteCode != null) && (WriteCode != ""))
                    //{
                    if ((CountryIDFrom != null) && (CountryIDFrom != ""))
                    {
                        if ((CompanyVATFrom != null) && (CompanyVATFrom != ""))
                        {
                            if ((CountryIDTo != null) && (CountryIDTo != ""))
                            {
                                if ((CompanyVATTo != null) && (CompanyVATTo != ""))
                                {
                                    if ((Data != null) && (Data != ""))
                                    {
                                        if ((CompanySerialNumber != null) && (CompanySerialNumber != ""))
                                        {
                                            if (!dblayer.IsCompanyBlocked(CountryIDFrom, CompanyVATFrom, CountryIDTo, CompanyVATTo))
                                            {
                                                Company company = dblayer.GetCompany(CountryIDTo, CompanyVATTo);
                                                if ((company != null) && (company.Active))
                                                {
                                                    if (dblayer.AddData(TransactionGUID, CountryIDFrom, CompanyVATFrom, CountryIDTo, CompanyVATTo, Data, company.WriteCode))
                                                    {
                                                        //Billing billing = dblayer.GetBilling(CompanySerialNumber, Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day) + 1).ToShortDateString()));
                                                        //if (billing == null)
                                                        //{
                                                        //    billing = new Billing();
                                                        //    billing.CompanySerialNumber = CompanySerialNumber;
                                                        //    billing.DateMonth = Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day) + 1).ToShortDateString());
                                                        //    billing.InCounter = 1;
                                                        //    billing.OutCounter = 0;
                                                        //    dblayer.AddBilling(billing);
                                                        //}
                                                        //else
                                                        //{
                                                        //    billing.InCounter++;
                                                        //    dblayer.UpdateBilling(billing, Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day) + 1).ToShortDateString()));
                                                        //}
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }