Example #1
0
        public List <Spools> GetSpools(inf_assignment_type assignment_Type)
        {
            try
            {
                using (var cn = new SQLiteConnection(dbPath))
                {
                    cn.CreateTable <SpoolJoints>();
                    cn.CreateTable <SpoolItem>();
                    cn.CreateTable <Spools>();
                }

                Console.WriteLine("############S#################");
                List <Spools> lstObjs;
                switch (assignment_Type)
                {
                case inf_assignment_type.Pending:
                    using (var cn = new SQLiteConnection(dbPath))
                    {
                        lstObjs = cn.GetAllWithChildren <Spools>(x => x.cStatus == "P");
                    }
                    Console.WriteLine("############P#################");
                    return(lstObjs);

                case inf_assignment_type.UnderFabrication:
                    using (var cn = new SQLiteConnection(dbPath))
                    {
                        lstObjs = cn.GetAllWithChildren <Spools>(x => x.cStatus == "F");
                    }
                    Console.WriteLine("#############F################");
                    return(lstObjs);

                case inf_assignment_type.UnderWelding:
                    using (var cn = new SQLiteConnection(dbPath))
                    {
                        lstObjs = cn.GetAllWithChildren <Spools>(x => x.cStatus == "W");
                    }
                    Console.WriteLine("##############W###############");
                    return(lstObjs);

                case inf_assignment_type.Completed:
                    using (var cn = new SQLiteConnection(dbPath))
                    {
                        lstObjs = cn.GetAllWithChildren <Spools>(x => x.cStatus == "C");
                    }
                    Console.WriteLine("############C#################");
                    return(lstObjs);

                default:
                    Console.WriteLine("############N#################");
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("############E#################");
                Console.WriteLine("############" + ex.Message + "#################");
                npcc_services.inf_mobile_exception_managerAsync(ex.Message);
                return(null);
            }
        }
Example #2
0
        public async Task <bool> RefreshSpoolAsync(inf_assignment_type assignment_Type)
        {
            try
            {
                string              url;
                List <Spools>       lstObjs;
                inf_spool_list_type obj_spool_list_type = new inf_spool_list_type();
                DBRepository        dBRepository        = new DBRepository();
                UserInfo            user = dBRepository.GetUserInfo();
                obj_spool_list_type.group = user.group;

                using (var cn = new SQLiteConnection(dbPath))
                {
                    cn.CreateTable <SpoolJoints>();
                    cn.CreateTable <SpoolItem>();
                    cn.CreateTable <Spools>();
                }
                switch (assignment_Type)
                {
                case inf_assignment_type.Pending:
                    Console.WriteLine("####################");
                    obj_spool_list_type.assignment_type = inf_assignment_type.Pending;

                    url     = "https://webapps.npcc.ae/ApplicationWebServices/api/paperless/SpoolsList";
                    lstObjs = await npcc_services.inf_CallWebServiceAsync <List <Spools>, inf_spool_list_type>(inf_method.Post, url, obj_spool_list_type);

                    Console.WriteLine("####################" + lstObjs.Count + "#########" + obj_spool_list_type.group);
                    using (var cn = new SQLiteConnection(dbPath))
                    {
                        cn.DeleteAll(cn.GetAllWithChildren <Spools>(x => x.cStatus == "P"));
                        cn.InsertAllWithChildren(lstObjs);
                    }

                    break;

                case inf_assignment_type.UnderFabrication:
                    obj_spool_list_type.assignment_type = inf_assignment_type.UnderFabrication;

                    url     = "https://webapps.npcc.ae/ApplicationWebServices/api/paperless/SpoolsList";
                    lstObjs = await npcc_services.inf_CallWebServiceAsync <List <Spools>, inf_spool_list_type>(inf_method.Post, url, obj_spool_list_type);

                    using (var cn = new SQLiteConnection(dbPath))
                    {
                        cn.DeleteAll(cn.GetAllWithChildren <Spools>(x => x.cStatus == "F"));
                        cn.InsertAllWithChildren(lstObjs);
                    }

                    break;

                case inf_assignment_type.UnderWelding:
                    obj_spool_list_type.assignment_type = inf_assignment_type.UnderWelding;

                    url     = "https://webapps.npcc.ae/ApplicationWebServices/api/paperless/SpoolsList";
                    lstObjs = await npcc_services.inf_CallWebServiceAsync <List <Spools>, inf_spool_list_type>(inf_method.Post, url, obj_spool_list_type);

                    using (var cn = new SQLiteConnection(dbPath))
                    {
                        cn.DeleteAll(cn.GetAllWithChildren <Spools>(x => x.cStatus == "W"));
                        cn.InsertAllWithChildren(lstObjs);
                    }

                    break;

                case inf_assignment_type.Completed:
                    obj_spool_list_type.assignment_type = inf_assignment_type.Completed;

                    url     = "https://webapps.npcc.ae/ApplicationWebServices/api/paperless/SpoolsList";
                    lstObjs = await npcc_services.inf_CallWebServiceAsync <List <Spools>, inf_spool_list_type>(inf_method.Post, url, obj_spool_list_type);

                    using (var cn = new SQLiteConnection(dbPath))
                    {
                        cn.DeleteAll(cn.GetAllWithChildren <Spools>(x => x.cStatus == "C"));
                        cn.InsertAllWithChildren(lstObjs);
                    }

                    break;
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("########" + ex.Message + "############");
                npcc_services.inf_mobile_exception_managerAsync(ex.Message);
                return(false);
            }
        }