Exemplo n.º 1
0
        private void DataLoad()
        {
            try
            {
                conObj = new SqlConnection(ConfigurationManager.ConnectionStrings["ConCGI"].ConnectionString);
            }
            catch (SqlException ex)
            {
                Response.Redirect("Error.aspx?Error=" + "We are currently working on...Please try again latter");
                DataManager.ErrorLog(ex);
            }

            SqlCommand cmdObj = new SqlCommand("select * from Product", conObj);

            if (conObj.State == ConnectionState.Closed)
            {
                conObj.Open();
            }
            SqlDataAdapter adapter = new SqlDataAdapter(cmdObj);
            DataSet        ds      = new DataSet();

            adapter.Fill(ds, "Product");
            DataUpload.DataSource = ds.Tables["Product"];
            DataUpload.DataBind();
        }
Exemplo n.º 2
0
        protected void lnlElectronics_Click(object sender, EventArgs e)
        {
            LinkButton lbkButton = (LinkButton)sender;
            string     category  = lbkButton.Text;

            try
            {
                conObj = new SqlConnection(ConfigurationManager.ConnectionStrings["ConCGI"].ConnectionString);
            }
            catch (SqlException ex)
            {
                Response.Redirect("Error.aspx?Error=" + "We are currently working on...Please try again latter");
                DataManager.ErrorLog(ex);
            }
            SqlCommand cmdObj = new SqlCommand("select * from Product where Category=@category or SubCategory=@category", conObj);

            cmdObj.Parameters.AddWithValue("@category", category);
            if (conObj.State == ConnectionState.Closed)
            {
                conObj.Open();
            }
            SqlDataAdapter adapter = new SqlDataAdapter(cmdObj);
            DataSet        ds      = new DataSet();

            adapter.Fill(ds, "Product");
            DataUpload.DataSource = ds.Tables["Product"];
            DataUpload.DataBind();
        }
        /// <summary>
        /// Get and save metadata of all files from input folder
        /// </summary>
        /// <param name="folderPath"></param>
        /// <param name="appStartPath"></param>
        public void SaveMetadataOfAllImages(string folderPath, string appStartPath)
        {
            try
            {
                _blobWrapper   = new DataUpload();
                _faceDetection = new FaceDetection(appStartPath);
                _imgGrabber    = new ImageGrabber();
                DirectoryInfo directory = new DirectoryInfo(folderPath);
                List <DataLayer.EntityModel.Image> imageList = new List <DataLayer.EntityModel.Image>();
                String[]      files        = GetFilesFrom(folderPath, imageFilters, true);
                List <string> fileNameList = new List <string>();
                fileNameList = GetUniqueImages(files.ToList());

                foreach (var fileObj in fileNameList)
                {
                    //Get metadata of file and save it
                    imageList.Add(GetImageMetadata(fileObj, appStartPath));
                    //Upload file to file to azure blob
                    _blobWrapper.UploadFile(fileObj);
                }

                new DataLayer.ModelClasses.Image().SaveUpdateMetadata(imageList);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        public byte[] DownloadFile(string downloadFileName)
        {
            DataUpload _blobWrapper = new DataUpload();

            byte[] data = _blobWrapper.DownloadFileFromBlob(downloadFileName);
            return(data);
        }
        /// <summary>
        /// Get and save metadata of file
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="appStartPath"></param>
        public void SaveMetadataOfImage(string filePath, string appStartPath)
        {
            try
            {
                _blobWrapper   = new DataUpload();
                _faceDetection = new FaceDetection(appStartPath);
                _imgGrabber    = new ImageGrabber();
                List <DataLayer.EntityModel.Image> imageList = new List <DataLayer.EntityModel.Image>();
                String[] files = new string[1];
                files[0] = filePath;
                List <string> fileNameList = new List <string>();
                fileNameList = GetUniqueImages(files.ToList());

                foreach (var fileObj in fileNameList)
                {
                    //Get metadata of file and save it
                    imageList.Add(GetImageMetadata(fileObj, appStartPath));
                    //Upload file to file to azure blob
                    _blobWrapper.UploadFile(fileObj);
                }

                new DataLayer.ModelClasses.Image().SaveUpdateMetadata(imageList);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 6
0
        public IHttpActionResult Post(long cashRegisterId, int uploadTypeId, [FromBody] byte[] compressedData)
        {
            try
            {
                _logger.Debug($"UploadCashRegisterData: cashRegisterId={ cashRegisterId }, dataLength={ compressedData.Length } starting...");

                // var uploadType = _uploadTypeService.List().First(u => u.Name == "CashRegister");
                var status = _statusService.Find("New");
                // _logger.Debug($"1, cashRegisterId : {cashRegisterId}");
                var dataUpload = new DataUpload
                {
                    Event          = _parameterReader.ReadEventId("StoreDataUpload", 1),
                    Organization   = OTApplication.Context.Organization.Id,
                    UploadDate     = DateTime.Now,
                    UploadType     = uploadTypeId,
                    CompressedData = compressedData,
                    SourceRef      = cashRegisterId.ToString(),
                    Status         = status.StatusId
                };
                // _logger.Debug($"2, cashRegisterId : {cashRegisterId}");
                _dataUploadService.Create(dataUpload);

                _logger.Debug($"UploadCashRegisterData: cashRegisterId={ cashRegisterId }, dataLength={ compressedData.Length } completed.");
                return(base.Ok());
            }
            catch (Exception ex)
            {
                _logger.Error($"UploadCashRegisterData failed. cashRegisterId : {cashRegisterId} uploadTypeId : {uploadTypeId}", ex);
                return(Content(HttpStatusCode.InternalServerError, ex.ToString()));
            }
        }
Exemplo n.º 7
0
    private void addToTypedTable(DataUpload.ModelDataTable dt, string[] fields, string strategyId)
    {
        DataUpload.ModelRow row = dt.NewModelRow();

        row.GUID = Guid.NewGuid();
        row.StrategyID = strategyId;
        AssetClass assetClass = null;
        assetClasses.TryGetValue(fields[2], out assetClass);

        if (assetClass == null)
            throw new Exception(String.Format("Upload Error: Asset Class '{0}' not recognized.", fields[2]));

        row.AssetClassID = assetClass.ID;
        row.SEDOL = fields[0];
        row.InvestmentName = fields[1];
        row.WeightingHNW = Convert.ToDecimal(fields[3]);

        if (strategyId == "TC") {
            row.ExpectedYield = Convert.ToDecimal(fields[4]);
            row.PurchaseCharge = Convert.ToDecimal(fields[5]);
            row.WeightingAffluent = 0;
        } else {
            row.WeightingAffluent = Convert.ToDecimal(fields[4]);
            row.ExpectedYield = Convert.ToDecimal(fields[5]);
            row.PurchaseCharge = Convert.ToDecimal(fields[6]);
        }

        dt.AddModelRow(row);
    }
Exemplo n.º 8
0
        public void UploadData()
        {
            if (!DataUpload.UploadSalesDay(ref message))
            {
                MessageBox.Show("单日销售明细上传失败:" + message);
            }

            if (!DataUpload.ForSure(ref message))
            {
                MessageBox.Show(message);
            }
        }
Exemplo n.º 9
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            lbTime.Text = DateTime.Now.ToString("yyyy年MM月dd日HH点mm分ss秒");

            //每十分钟自动跟新一次数据,防止交易时没有网络
            try
            {
                int time = Convert.ToInt32(DateTime.Now.ToString("HHmmss")) % 3000;
                if (time == 0)
                {
                    DataUpload.UploadSalesDay(ref message);
                }
            }
            catch
            {
            }
        }
Exemplo n.º 10
0
        //上传指定日期数据
        private void btnUpload_Click(object sender, EventArgs e)
        {
            string date = dtpSalesDay.Value.ToString("yyyyMMdd");

            if (DataUpload.UploadSalesDay(ref message, date))
            {
                MessageBox.Show(date + " 单日销售明细上传成功!");
            }
            else
            {
                MessageBox.Show(date + " 单日销售明细上传失败:" + message);
            }

            if (!DataUpload.ForSure(ref message))
            {
                MessageBox.Show(message);
            }
        }
Exemplo n.º 11
0
        public Form1()
        {
            InitializeComponent();

            InitGraph();

            serialPort1.Open();

            tw = new StreamWriter("data" + System.DateTime.Now.ToFileTime().ToString() + ".txt");

            //Make the new data upload ""thingy""
            _up = new DataUpload();
            //Initialize it with the system name string. ie Jason_House . .no spaces for now
            _up.Init("jason_home2");
            //If you have python and apache installed, you can run it locally
            _up.setLocalDebug(false);
            htVals = new Hashtable();
            htVals.Add(OUTLET_NAME, 0);
        }
Exemplo n.º 12
0
 protected void btnSearch_Click(object sender, EventArgs e)
 {
     try
     {
         conObj = new SqlConnection(ConfigurationManager.ConnectionStrings["ConCGI"].ConnectionString);
         string search = txtSearch.Text;
         conObj = new SqlConnection(ConfigurationManager.ConnectionStrings["ConCGI"].ConnectionString);
         SqlCommand cmdObj = new SqlCommand("select * from Product where Category=@search or SubCategory=@search or ProductName=@search", conObj);
         cmdObj.Parameters.AddWithValue("@search", search);
         if (conObj.State == ConnectionState.Closed)
         {
             conObj.Open();
         }
         SqlDataAdapter adapter = new SqlDataAdapter(cmdObj);
         DataSet        ds      = new DataSet();
         adapter.Fill(ds, "Product");
         DataUpload.DataSource = ds.Tables["Product"];
         DataUpload.DataBind();
     }
     catch (SqlException ex)
     {
         Response.Write("Connection Error");
     }
 }
Exemplo n.º 13
0
        public object Post(DataUpload unused)
        {
            //TODO: Only administrators should be able to do this

            _start = DateTime.Now;
            if (RequestContext.Files.Length == 0)
            {
                return(new HttpResult(HttpStatusCode.BadRequest, "No file was uploaded."));
            }
            var    file = RequestContext.Files[0];
            string data;

            using (var reader = new StreamReader(file.InputStream))
                data = reader.ReadToEnd();

            // Try and process the data as CSV
            List <User> users;

            try {
                Log("CSV Deserialize");
                var tmp = JsonSerializer.DeserializeFromString <List <Dictionary <string, string> > >(CsvToJson(data));

                // The above line executed successfully? Great! Now reassign the data variable
                // to contain the JSON version of its contents and then throw an InvalidDataException
                // to execute the validation code below
                Log("CSV Deserialize success");
                data = tmp.ToJson();
                throw new InvalidDataException();
            } catch (InvalidDataException) {
                try {
                    Log("JSON Deserialize");
                    // It's not a CSV file. Let's try to process it as JSON

                    // First of all, make sure that there aren't any unexpected fields
                    // Start by converting the data from JSON into a string Dictionary
                    var check = JsonSerializer.DeserializeFromString <List <Dictionary <string, string> > >(data);

                    // Don't hardcode any fields here, in case we change any fields in the User class.
                    // instead, convert a plain User object into a Dictionary<string, string>, and compare all keys
                    var testusr = JsonSerializer.DeserializeFromString <Dictionary <string, string> >(new User().ToJson());

                    // data will be invalid if any of the keys in `check` are not in the `testusr` keys.
                    // At the very least however, first name, last name, and student ID are required
                    Log("Check valid");
                    var valid = check.Aggregate(true, (current, ch) => current &
                                                ch.Keys.ContainsAny(false, testusr.Keys.ToArray()) &
                                                ch.Keys.ContainsAll(false, "firstName", "lastName", "studentNumber"));
                    Log("Check valid complete: {0}", valid);
                    if (!valid)
                    {
                        throw new SerializationException();
                    }

                    Log("JSON Deserialize success");

                    users = JsonSerializer.DeserializeFromString <List <User> >(data);
                } catch (SerializationException) {
                    Log("Invalid input");
                    // This isn't a JSON file either. Let's bail out.
                    return(new HttpError(HttpStatusCode.BadRequest, ""));
                }
            }
            Log(users.Dump());

            var output = new List <dynamic>();

            foreach (var u in users)
            {
                dynamic credentials;
                UserDbProvider.Instance.CreateUser(u, out credentials);
                output.Add(credentials);
            }
            Log(output.Dump());

            // Return a list of all of the login names and passwords
            return(output);
        }
Exemplo n.º 14
0
        private async void UploadFile(string filePath)
        {
            DataUpload _blobWrapper = new DataUpload();

            _blobWrapper.UploadFile(filePath);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 结账
        /// </summary>
        private void PayEnd()
        {
            //禁用控件,除了返回键
            foreach (Control control in Controls)
            {
                control.Enabled = false;
            }
            btnReturn.Enabled = true;

            List <OrderItem> order     = new List <OrderItem>();
            BinaryFormatter  formatter = new BinaryFormatter();

            using (Stream input = File.OpenRead(GlobalParams.orderPath))
            {
                if (input.Length > 0)
                {
                    order = (List <OrderItem>)formatter.Deserialize(input);
                }
            }

            //得到销售数据模型 salesList
            List <Sales> salesList = GetSalesListModel(order);

            //测试
            //List<Sales> salesList = GetSalesList(order);
            new DataOperator().UpdateSalesData(salesList);

            #region 打印小票

            //小票模板传参
            Receipt rpt = new Receipt()
            {
                xph         = GetXPH(),
                jh          = ConfigHelper.GetAppConfig("JH").Substring(1, 4),
                syybh       = staff.Staff_no,
                order       = order.Where(o => o.isValid == true).ToList(),
                goodsCount  = sell.GoodsCount,
                moneyTotal  = sell.MoneyTotal,
                yh          = (sell.YH + sell.DZ),//sell.YH,
                zjj         = Zjj,
                actualTotal = ZJ,
                cash        = Convert.ToDecimal(txtPayCash.Text == "" ? "0" : txtPayCash.Text),
                cardPay     = CardPayed,
                change      = Change,
                mcard       = sell.Membercard,
                mName       = mName,
                iniBalance  = mIniBalance,
                endBalance  = mEndBalance,
                printTime   = DateTime.Now
            };

            //增加小票到小票列表,序列化保存
            rList.Add(rpt);
            SerializeReceiptList(rList);

            //更新客显
            UpdateDisplay();

            bool flag = true;
#if DEBUG
            flag = false;
#endif
            //开钱箱,收现金
            if (rpt.cash > 0 && flag)
            {
                ICustomerDisplayer custDisplayer = ObjFactory.CreateCustomerDisplayer();
                if ("TECT10".Equals(custDisplayer.GetTypeID()))
                {
                    ProcessStartInfo startInfo = new ProcessStartInfo("tec_drw.exe");
                    //startInfo.WindowStyle = ProcessWindowStyle.Minimized;
                    Process.Start(startInfo);
                }
            }

            //打印小票
            Print prt = new Print();

            //如果是内部员工卡打印两张一样的小票
            if (sell.Mname != "" || sell.isCash)
            {
                prt.rec = rpt;
                prt.PrintReceipt(false);
                //打印到 txt
                prt.print(false);
            }


            prt.rec = rpt;
            prt.PrintReceipt(false);
            //打印到 txt
            prt.print(false);
            #endregion

            //收银完毕,删除购物单临时文件
            File.Delete(GlobalParams.orderPath);

            //小票号递增,记录格式
            GlobalParams.xph++;
            ConfigHelper.UpdateAppConfig("XPH", DateTime.Now.ToString("yyyyMMdd") + "#" + GlobalParams.xph);

            //前后台交互
            DataUpload.Upload(string.Format("小票号:{0}", GlobalParams.xph - 1));

            #region 导出单次销售明细表数据到 DBF 文件 (废)

            ////服务端是否存在 control.tab
            ////没有,就上传 pos.tab(可能碰到断网),表示前台开始控制
            ////有,意味着 DBF 文件正在被服务端占用,需要延迟上传
            //if (!File.Exists(GlobalParams.ControlTabPath))
            //{
            //    try
            //    {
            //        File.Copy(GlobalParams.PosTabLocalPath, GlobalParams.PosTabServerPath, true);
            //    }
            //    catch (Exception ex)
            //    {
            //        //断网情况会失败
            //        Log.WriteErrorLog(ex.Message, ex.Source, "向服务端放 pos.tab ");
            //    }

            //    //服务端是否存在 DBF 文件:存在意味着服务端还没有读取,需要向其中追加
            //    if (File.Exists(GlobalParams.xsxbServerPath))
            //    {
            //        try
            //        {
            //            //先拷贝到本地
            //            File.Copy(GlobalParams.xsxbServerPath, GlobalParams.xsxbPath, true);

            //            //读取 DBF 文件数据到单次销售明细表(追加)
            //            new DataOperator().DBFtoDB(GlobalParams.xsxbPath, "sales_time");
            //            new SalesBLL().DeleteSalesTime999();
            //        }
            //        catch (Exception ex)
            //        {
            //            Log.WriteErrorLog(ex.Message, ex.Source, "从服务端拷贝 xsxb.dbf 文件 ");
            //        }
            //    }
            //}

            ////备份路径是否存在 DBF 文件:存在意味着上次上传失败或延迟上传
            //if (File.Exists(GlobalParams.xsxbBackupsPath))
            //{
            //    //如果服务端存在DBF文件,复制到本地后,判断和备份文件是否一致
            //    //不一致才追加备份文件
            //    //先拷贝到本地
            //    File.Copy(GlobalParams.xsxbServerPath, GlobalParams.xsxbPath, true);

            //    if (!DataOperator.CompareFile(GlobalParams.xsxbBackupsPath, GlobalParams.xsxbPath))
            //    {
            //        //读取备份 DBF 文件数据到单次销售明细表(追加)
            //        new DataOperator().DBFtoDB(GlobalParams.xsxbBackupsPath, "sales_time");
            //        new SalesBLL().DeleteSalesTime999();

            //        //删除备份 DBF 文件
            //        File.Delete(GlobalParams.xsxbBackupsPath);
            //    }
            //}

            ////复制原始文件到单次销售明细 dbf 文件本地保存路径(覆盖)
            ////dbf文件无法真正删除老数据,每次上传前先使用比较小的原始文件
            //File.Copy(GlobalParams.xsxbIniPath, GlobalParams.xsxbPath, true);

            ////导出单次销售明细数据到本地 DBF 文件
            ////new DataOperator().SalesTimetoDBF();

            ////服务端是否有pos.tab:有意味着是正常上传,没有意味着要延迟到下次上传(可能断网了)
            //if (File.Exists(GlobalParams.PosTabServerPath))
            //{
            //    //上传本地 DBF 文件到服务端
            //    if (File.Exists(GlobalParams.xsxbPath))
            //    {
            //        try
            //        {
            //            File.Copy(GlobalParams.xsxbPath, GlobalParams.xsxbServerPath, true);
            //        }
            //        catch (Exception ex)
            //        {
            //            Log.WriteErrorLog(ex.Message, ex.Source, "上传本地 DBF 文件到服务端");
            //        }
            //    }

            //    //判断本地和服务端的文件是否一致,不一致说明上传失败,保存本地 DBF 文件到备份路径
            //    //有一种可能要排除:刚才上传成功了,但是突然断网了,现在再去对比,由于服务器的文件访问不了,也是不一致
            //    //此时会备份文件,断网了也删不掉服务器上的文件
            //    //到下次读取备份文件时,要先对比下是否和服务器上的文件是否一致,一致的话就不用追加到单次明细里了
            //    if (!(File.Exists(GlobalParams.xsxbServerPath)
            //        && DataOperator.CompareFile(GlobalParams.xsxbPath, GlobalParams.xsxbServerPath)))
            //    {
            //        File.Copy(GlobalParams.xsxbPath, GlobalParams.xsxbBackupsPath);
            //        Log.WriteNormalLog("","服务端与本地文件对比失败,复制到备份路径","");

            //        //服务端如果存在dbf文件,因为此时是上传失败的,所以它是老文件
            //        //老文件的数据已经添加到本地的备份文件中,所以要删除掉老文件防止重复数据
            //        if (File.Exists(GlobalParams.xsxbServerPath))
            //        {
            //            try
            //            {
            //                File.Delete(GlobalParams.xsxbServerPath);
            //                Log.WriteNormalLog("", "删除服务端老的单次销售明细数据", "");
            //            }
            //            catch (Exception ex)
            //            {
            //                Log.WriteErrorLog(ex.Message, ex.Source, "删除服务端老的单次销售明细数据");
            //            }
            //        }
            //    }

            //    //删除服务端 pos.tab
            //    try
            //    {
            //        File.Delete(GlobalParams.PosTabServerPath);
            //    }
            //    catch (Exception ex)
            //    {
            //        Log.WriteErrorLog(ex.Message, ex.Source, "上传后删除服务端的 pos.tab");
            //    }
            //}
            //else
            //{
            //    File.Copy(GlobalParams.xsxbPath, GlobalParams.xsxbBackupsPath);
            //    Log.WriteNormalLog("","延迟上传单次销售明细数据,复制到备份路径","");
            //}

            ////删掉本地的DBF文件
            //File.Delete(GlobalParams.xsxbPath);

            #endregion

            //更新商品变化主档
            DataOperator.UpdateSpit();

            //找零时,暂停3秒
            if (Change > 0)
            {
                Thread.Sleep(3000);
            }
            sell.isCash = false;
            sell.Show();
            this.Dispose();
        }
Exemplo n.º 16
0
        public object Post(DataUpload unused)
        {
            //TODO: Only administrators should be able to do this

            _start = DateTime.Now;
            if (RequestContext.Files.Length == 0) return new HttpResult(HttpStatusCode.BadRequest, "No file was uploaded.");
            var file = RequestContext.Files[0];
            string data;
            using (var reader = new StreamReader(file.InputStream))
                data = reader.ReadToEnd();

            // Try and process the data as CSV
            List<User> users;
            try {
                Log("CSV Deserialize");
                var tmp = JsonSerializer.DeserializeFromString<List<Dictionary<string, string>>>(CsvToJson(data));

                // The above line executed successfully? Great! Now reassign the data variable
                // to contain the JSON version of its contents and then throw an InvalidDataException
                // to execute the validation code below
                Log("CSV Deserialize success");
                data = tmp.ToJson();
                throw new InvalidDataException();
            } catch (InvalidDataException) {
                try {
                    Log("JSON Deserialize");
                    // It's not a CSV file. Let's try to process it as JSON

                    // First of all, make sure that there aren't any unexpected fields
                    // Start by converting the data from JSON into a string Dictionary
                    var check = JsonSerializer.DeserializeFromString<List<Dictionary<string, string>>>(data);

                    // Don't hardcode any fields here, in case we change any fields in the User class.
                    // instead, convert a plain User object into a Dictionary<string, string>, and compare all keys
                    var testusr = JsonSerializer.DeserializeFromString<Dictionary<string, string>>(new User().ToJson());

                    // data will be invalid if any of the keys in `check` are not in the `testusr` keys.
                    // At the very least however, first name, last name, and student ID are required
                    Log("Check valid");
                    var valid = check.Aggregate(true, (current, ch) => current &
                                                                       ch.Keys.ContainsAny(false, testusr.Keys.ToArray()) &
                                                                       ch.Keys.ContainsAll(false, "firstName", "lastName", "studentNumber"));
                    Log("Check valid complete: {0}", valid);
                    if (!valid) throw new SerializationException();

                    Log("JSON Deserialize success");

                    users = JsonSerializer.DeserializeFromString<List<User>>(data);
                } catch (SerializationException) {
                    Log("Invalid input");
                    // This isn't a JSON file either. Let's bail out.
                    return new HttpError(HttpStatusCode.BadRequest, "");
                }
            }
            Log(users.Dump());

            var output = new List<dynamic>();
            foreach (var u in users) {
                dynamic credentials;
                UserDbProvider.Instance.CreateUser(u, out credentials);
                output.Add(credentials);
            }
            Log(output.Dump());

            // Return a list of all of the login names and passwords
            return output;
        }