示例#1
0
        public static void startupNotifications()
        {
            var today    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            var database = new SqliteDataService();

            database.Initialize();
            var courses     = database.GetAllCourses();
            var assessments = database.GetAllAssessments();

            courses.ForEach(course =>
            {
                if (course.EnableNotifications && new DateTime(course.StartDate.Year, course.StartDate.Month, course.StartDate.Day) == today)
                {
                    CrossLocalNotifications.Current.Show("Course Start", $"{course.Title} is starting today");
                }
                if (course.EnableNotifications && new DateTime(course.EndDate.Year, course.EndDate.Month, course.EndDate.Day) == today)
                {
                    CrossLocalNotifications.Current.Show("Course End", $"{course.Title} is ending today");
                }
            });
            assessments.ForEach(test =>
            {
                if (test.EnableNotifications && new DateTime(test.StartDate.Year, test.StartDate.Month, test.StartDate.Day) == today)
                {
                    CrossLocalNotifications.Current.Show("Assessment Start", $"{test.Title} due date start is today");
                }
                if (test.EnableNotifications && new DateTime(test.EndDate.Year, test.EndDate.Month, test.EndDate.Day) == today)
                {
                    CrossLocalNotifications.Current.Show("Assessment End", $"{test.Title} due date end is today");
                }
            });
            database.Close();
        }
示例#2
0
 /// <summary>
 /// 将所有需要异步上传的数据都加入此队列
 /// </summary>
 /// <param name="obj"></param>
 private bool EnqueueUploadData(object obj)
 {
     if (UploadServer.GetInstance().CurrentUploadQueue.Count > 199)
     {
         MetroMessageBox.Show(this, "装箱数据上传队列已满,请检查网络环境,以确保数据能正常上传", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return(false);
     }
     if (obj.GetType() == typeof(EbBoxErrorRecordInfo))
     {
         if (Cache.Instance[CacheKey.ERROR_RECORD] != null)
         {
             (Cache.Instance[CacheKey.ERROR_RECORD] as List <EbBoxErrorRecordInfo>).Add(obj as EbBoxErrorRecordInfo);
         }
     }
     else if (obj.GetType() == typeof(EbBoxCheckRecordInfo))
     {
         if (Cache.Instance[CacheKey.CHECK_RECORD] != null)
         {
             (Cache.Instance[CacheKey.CHECK_RECORD] as List <EbBoxCheckRecordInfo>).Add(obj as EbBoxCheckRecordInfo);
         }
         AddCheckRecord(obj as EbBoxCheckRecordInfo);
     }
     else if (obj.GetType() == typeof(UploadEbBoxInfo))
     {
         SqliteDataService.InsertUploadData(obj as UploadEbBoxInfo);
     }
     UploadServer.GetInstance().CurrentUploadQueue.Push(obj);
     return(true);
 }
示例#3
0
 private void timer1_uploadStatus_Tick(object sender, EventArgs e)
 {
     Invoke(new Action(() =>
     {
         dmButton_uploadlist.Text = string.Format("上传列表({0})", SqliteDataService.GetUnUploadCountFromSqlite());
     }));
 }
示例#4
0
        public void saveData(CDianShangBox box)
        {
            if (box == null)
            {
                return;
            }
            try
            {
                CUploadData data = saveToSqlite(box);
                //uplad to sap
                string sapRe  = "";
                string sapMsg = "";
                SAPDataService.uploadDianShangBox(box, ref sapRe, ref sapMsg);
                box.sapRe  = sapRe;
                box.sapMsg = sapMsg;

                if (sapRe == SUCCESS)
                {
                    //save to local
                    LocalDataService.saveDianShangBox(box);

                    SqliteDataService.delUploadFromSqlite(data.Guid);
                }
                else
                {
                    SqliteDataService.updateMsgToSqlite(data.Guid, sapMsg);
                }
            }
            catch (Exception ex)
            {
                Log4netHelper.LogError(ex);
            }
        }
示例#5
0
        /// <summary>
        /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条
        /// </summary>
        public void Upload()
        {
            CUploadData task = null;

            if (CurrentUploadQueue.Count > 0)
            {
                lock (_lockObject)
                {
                    // 取出任务上传
                    task = CurrentUploadQueue.Dequeue() as CUploadData;
                }
            }

            if (task != null)
            {
                //upload
                SapResult re = SAPDataService.UploadJianHuoData(task.Data as CJianHuoUpload);
                if (re.SUCCESS)
                {
                    SqliteDataService.delUploadFromSqlite(task.Guid);
                }
                else
                {
                    SqliteDataService.updateMsgToSqlite(task.Guid, re.MSG);
                    OnUploaded?.Invoke(task.Data as CJianHuoUpload, re);
                }
            }
        }
示例#6
0
        private void InventoryFormNew_Shown(object sender, EventArgs e)
        {
            restoreGrid();
            UpdateTotalInfo();

            SqliteDataService.delOldData();
        }
示例#7
0
        private void savingDataThreadFunc()
        {
            while (true)
            {
                try
                {
                    if (mCancel)
                    {
                        return;
                    }

                    CUploadData ud = getQueueData();

                    if (ud != null)
                    {
                        YKBoxInfo upData = ud.Data as YKBoxInfo;
                        if (upData != null)
                        {
                            //upload
                            string uploadRe = "";
                            string sapMsg   = "";

                            SapResult result = SAPDataService.UploadYKBoxInfo(SysConfig.LGNUM, upData);
                            uploadRe = result.STATUS;
                            sapMsg   = result.MSG;

                            if (uploadRe == "E")
                            {
                                SqliteDataService.updateMsgToSqlite(ud.Guid, sapMsg);
                                playSoundWarn();
                            }
                            else
                            {
                                SqliteDataService.delUploadFromSqlite(ud.Guid);
                            }

                            upData.SapRemark = result.MSG;
                            upData.SapStatus = result.STATUS;

                            //save
                            YKBoxService.SaveBox(upData);

                            if (upData.Status == "S" && uploadRe == "S")
                            {
                                updateBoxList(upData);
                                UpdateTotalInfo();
                            }

                            updateUploadCount();
                            updateExpButton();
                        }
                    }
                    Thread.Sleep(500);
                }
                catch (Exception)
                {
                    //LogHelper.WriteLine(ex.Message + "\r\n" + ex.StackTrace.ToString());
                }
            }
        }
示例#8
0
        public void uploadSAP(CCancelUpload uploadData, out string sapRe, out string sapMsg)
        {
            sapRe  = "";
            sapMsg = "";

            CUploadData ud = new CUploadData();

            ud.Guid       = Guid.NewGuid().ToString();
            ud.Data       = uploadData;
            ud.IsUpload   = 0;
            ud.CreateTime = DateTime.Now;
            SqliteDataService.saveToSqlite(ud);

            //upload
            SAPDataService.UploadCancelData(uploadData, ref sapRe, ref sapMsg);

            if (sapRe != "S")
            {
                SqliteDataService.updateMsgToSqlite(ud.Guid, sapMsg);
                playSoundWarn();
            }
            else
            {
                SqliteDataService.delUploadFromSqlite(ud.Guid);
            }
        }
示例#9
0
        public static void addAssessmentToAssessmentCollection(Assessment assessment)
        {
            var database = new SqliteDataService();

            database.Initialize();
            database.AddAssessment(assessment);
            Assessments.Add(assessment);
            database.Close();
        }
示例#10
0
        public static void addCourseToCourseCollection(Course course)
        {
            var database = new SqliteDataService();

            database.Initialize();
            database.AddCourse(course);
            Courses.Add(course);
            database.Close();
        }
示例#11
0
        void updateUploadCount()
        {
            int count = SqliteDataService.GetUnUploadCountFromSqlite();

            Invoke(new Action(() =>
            {
                dmButton1_upload.Text = string.Format("上传列表({0})", count);
            }));
        }
示例#12
0
        public static void deleteAssessmentFromAssessmentCollection(Assessment assessment)
        {
            var database = new SqliteDataService();

            database.Initialize();
            database.DeleteAssessment(assessment);
            Assessments.Remove(assessment);
            database.Close();
        }
示例#13
0
        public static void deleteCourseFromCourseCollection(Course course)
        {
            var database = new SqliteDataService();

            database.Initialize();
            database.DeleteCourse(course);
            Courses.Remove(course);
            database.Close();
        }
示例#14
0
        public static void deleteTermFromTermCollection(Term term)
        {
            var database = new SqliteDataService();

            database.Initialize();
            database.DeleteTerm(term);
            Terms.Remove(term);
            database.Close();
        }
示例#15
0
        public static void addTermToTermCollection(Term term)
        {
            var database = new SqliteDataService();

            database.Initialize();
            database.AddTerm(term);
            Terms.Add(term);
            database.Close();
        }
示例#16
0
        public DisplaySingleRecipeViewModel(INavigationService navigationService, IRecipeService recipeService, IPageDialogService pageDialog, ILocalDataService localDataService)
            : base(navigationService)
        {
            recipe             = new Recipe();
            _pageDialog        = pageDialog;
            _navigationService = navigationService;

            DeleteRecipe = new Command(deleterecipe_execute);
            db           = new SqliteDataService();
        }
示例#17
0
        public static void initializeTermsCollection()
        {
            var database = new SqliteDataService();

            database.Initialize();
            var terms = database.GetAllTerms();

            terms.ForEach(term => Terms.Add(term));
            database.Close();
        }
示例#18
0
        void restoreUpload()
        {
            List <CUploadData> up = SqliteDataService.GetAllUploadFromSqlite <YKBoxInfo>();

            foreach (var v in up)
            {
                SqliteDataService.delUploadFromSqlite(v.Guid);
                addToSavingQueue(v.Data as YKBoxInfo);
            }
        }
示例#19
0
        public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService)
            : base(navigationService)
        {
            Title     = "Main Page";
            AddRecipe = new Command(navigate_execute);
            //FoodPage = new Command(navigate_can_execute);

            db      = new SqliteDataService();
            Recipes = db.GetRecipes();
        }
示例#20
0
        /// <summary>
        /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条
        /// </summary>
        public void Upload()
        {
            lock (_lockObject)
            {
                if (isbusy)
                {
                    return;
                }
                else
                {
                    isbusy = true;
                }

                if (CurrentUploadQueue.Count > 0)
                {
                    // 取出任务上传
                    object o = CurrentUploadQueue.Pop();

                    if (o.GetType() == typeof(UploadEbBoxInfo))
                    {
                        UploadEbBoxInfo box      = o as UploadEbBoxInfo;
                        bool            isUpload = SAPDataService.UploadEbBoxInfo(box.LGNUM, box.EQUIP_HLA, box.HU, box.ChangeTime, box.InventoryResult, box.ErrorMsg, box.SubUser, box.TagDetailList);
                        if (isUpload)
                        {
                            SqliteDataService.DeleteUploaded(box.Guid);  //删除已上传成功的数据
                        }
                        else
                        {
                            box.RetryTimes++;
                            if (box.RetryTimes < 3) //最多重试3次
                            {
                                CurrentUploadQueue.Push(o);
                            }
                            else
                            {
                                SqliteDataService.DeleteUploaded(box.Guid);            //删除超过3次上传失败的数据
                                LogHelper.WriteLine(JsonConvert.SerializeObject(box)); //并记录日志,防止将来还需要使用
                            }
                        }
                    }
                    else if (o.GetType() == typeof(EbBoxCheckRecordInfo))
                    {
                        EbBoxCheckRecordInfo record = o as EbBoxCheckRecordInfo;
                        LocalDataService.InsertEbCheckRecord(record, HLACommonLib.Model.ENUM.CheckType.电商收货复核);
                    }
                    else if (o.GetType() == typeof(EbBoxErrorRecordInfo))
                    {
                        EbBoxErrorRecordInfo record = o as EbBoxErrorRecordInfo;
                        LocalDataService.InsertEbBoxErrorRecord(record, HLACommonLib.Model.ENUM.CheckType.电商收货复核);
                    }
                }
                isbusy = false;
            }
        }
示例#21
0
        public static void initializeCoursesCollection(int termId)
        {
            Courses.Clear();
            var database = new SqliteDataService();

            database.Initialize();
            var courses = database.GetCoursesByTermId(termId);

            courses.ForEach(course => Courses.Add(course));
            database.Close();
        }
示例#22
0
        public static void initializeAssessmentCollection(int courseId)
        {
            Assessments.Clear();
            var database = new SqliteDataService();

            database.Initialize();
            var courses = database.GetAssessmentsByCourseId(courseId);

            courses.ForEach(assessment => Assessments.Add(assessment));
            database.Close();
        }
示例#23
0
        public CUploadData saveToSqlite(CDianShangBox data)
        {
            CUploadData cu = new CUploadData();

            cu.Guid       = Guid.NewGuid().ToString();
            cu.IsUpload   = 0;
            cu.Data       = data;
            cu.CreateTime = DateTime.Now;
            SqliteDataService.saveToSqlite(cu);
            return(cu);
        }
示例#24
0
        /// <summary>
        /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条
        /// </summary>
        public void Upload()
        {
            lock (_lockObject)
            {
                if (isbusy)
                {
                    return;
                }
                else
                {
                    isbusy = true;
                }
                try
                {
                    if (CurrentUploadQueue.Count > 0)
                    {
                        // 取出任务上传
                        object o = CurrentUploadQueue.Pop();
                        if (o.GetType() == typeof(SqliteUploadDataInfo))
                        {
                            UploadBoxInfo box    = (o as SqliteUploadDataInfo).Data;
                            SapResult     result = new SapResult();
                            //if (box.Box.RESULT == "S")
                            //{
                            result = SAPDataService.UploadPackingBox(box.LGNUM, box.Box.HU, box.EQUIP_HLA, box.Box.RESULT, box.Box.MSG, box.Box.MX, box.LOUCENG, box.SUBUSER, box.Box.Details);

                            //(box.LGNUM, box.Box.HU, box.EQUIP_HLA, box.LOUCENG, box.SUBUSER, box.Box.Details);
                            box.Box.PACKMSG    = result.MSG;
                            box.Box.PACKRESULT = result.STATUS;
                            //if (!result.SUCCESS) box.Box.RESULT = "SE";
                            //if (!result.SUCCESS && OnUploadError != null) OnUploadError();
                            //}
                            if (result.STATUS == "E")
                            {
                                box.Box.Details.Clear();
                            }
                            bool xdSaveResult = PackingBoxService.SaveBox(box.Box);
                            SqliteDataService.DeleteUploaded((o as SqliteUploadDataInfo).Guid);
                            if (OnUploaded != null)
                            {
                                OnUploaded(box.Box);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
                }

                isbusy = false;
            }
        }
示例#25
0
        private void Form1_Shown(object sender, EventArgs e)
        {
            SqliteDataService.delOldData();

            if (SysConfig.IsTest)
            {
                List <CTagSumDif> d = new List <CTagSumDif>();
                for (int i = 0; i < 30; i++)
                {
                    CTagSumDif dif = new CTagSumDif("123", "123", "456", "zsa", "zcol", "zgui", 1, 0, i + 1, 0);
                    d.Add(dif);
                }
                printErrorLabelMulti("123", "345", d);
            }
        }
示例#26
0
        /// <summary>
        /// 开始上传线程,检查是否还有未上传的信息,如果有,则弹出对话框问是否显示
        /// </summary>
        /// <returns>true 表示有未上传信息,需要提示;false 表示没有未上传信息</returns>
        public void Start()
        {
            List <UploadEbBoxInfo> list = SqliteDataService.GetUnUploadEbBox();

            if (list != null && list.Count > 0)
            {
                foreach (UploadEbBoxInfo item in list)
                {
                    CurrentUploadQueue.Push(item);
                }
            }
            // 开始定时上传
            uploadTimer.Elapsed += UploadTimer_Elapsed;
            uploadTimer.Start();
        }
示例#27
0
        public AddRecipePageViewModel(INavigationService navigationService, IRecipeService recipeService, IPageDialogService pageDialog, ILocalDataService localDataService)
            : base(navigationService)
        {
            Title = "Add Recipe";
            _navigationService = navigationService;
            _recipeService     = recipeService;
            _localDataService  = localDataService;
            _pageDialog        = pageDialog;

            SubmitRecipe      = new Command(submitrecipe_execute, submitRecipe_canexecute);
            AddIngredient     = new Command(addIngredient_execute, addIngredient_canexecute);
            recipe            = new Recipe();
            db                = new SqliteDataService();
            ListOfIngredients = new ObservableCollection <Ingredient>();
        }
示例#28
0
        private void btnReupload_Click(object sender, EventArgs e)
        {
            List <DataGridViewRow> rows = GetCheckedRows();

            if (rows != null && rows.Count > 0)
            {
                foreach (DataGridViewRow row in rows)
                {
                    CUploadData box = row.Tag as CUploadData;
                    SqliteDataService.delUploadFromSqlite(box.Guid);
                    mParent.addToSavingQueue(box.Data as YKBoxInfo);
                }
                MetroMessageBox.Show(this, "成功加入上传队列", "提示");
                initData();
            }
        }
示例#29
0
        public void updateSAP(YKBoxInfo uploadData)
        {
            CUploadData ud = new CUploadData();

            ud.Guid       = Guid.NewGuid().ToString();
            ud.Data       = uploadData;
            ud.IsUpload   = 0;
            ud.CreateTime = DateTime.Now;
            SqliteDataService.saveToSqlite(ud);

            YKBoxInfo upData = ud.Data as YKBoxInfo;

            if (upData == null)
            {
                return;
            }

            string uploadRe = "";
            string sapMsg   = "";

            SapResult result = SAPDataService.UploadYKBoxInfo(SysConfig.LGNUM, upData);

            uploadRe = result.STATUS;
            sapMsg   = result.MSG;

            if (uploadRe == "E")
            {
                SqliteDataService.updateMsgToSqlite(ud.Guid, sapMsg);
            }
            else
            {
                SqliteDataService.delUploadFromSqlite(ud.Guid);
            }

            upData.SapRemark = result.MSG;
            upData.SapStatus = result.STATUS;

            //save
            YKBoxService.SaveBox(upData);

            if (upData.Status == "S" && uploadRe == "S")
            {
                updateBoxList(upData);
                UpdateTotalInfo();
            }
        }
示例#30
0
        private void btnReupload_Click(object sender, EventArgs e)
        {
            List <DataGridViewRow> rows = GetCheckedRows();

            if (rows != null && rows.Count > 0)
            {
                foreach (DataGridViewRow row in rows)
                {
                    CUploadData data = row.Tag as CUploadData;
                    SqliteDataService.delUploadFromSqlite(data.Guid);
                    CJJBox box = data.Data as CJJBox;
                    mParent.saveAndUpdate(box);
                    mParent.addgrid(box);
                }
                initData();
            }
        }