Пример #1
0
        public LoginViewModel(INavigationService navService, ApiService apiService)
        {
            _navService = navService;
            _apiService = apiService;

            RegisterMessaging();
            CreateCommands();
        }
Пример #2
0
        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += PrintUnhandledException;

            _client = GetSoapClient();

            PrintAllCampaigns();
            PrintEmptyLine();
            PrintAllAddressBooks();
        }
Пример #3
0
        public ProcessMsg CancleStored(List<string> trayIds)
        {
            using (TransactionScope trans = new TransactionScope())
            {
                using (IUnitOfWork unit = MSSqlHelper.DataContext())
                {
                    ProcessMsg msg = new ProcessMsg() { result = true };
                    try
                    {
                        ITraysRep tr = new TraysRep(unit);
                        List<Trays> tis = tr.GetByIds(trayIds);
                        bool all_synced = true;
                        foreach (Trays ts in tis)
                        {
                            bool synced = false;
                            try
                            {
                                synced = new ApiService().SyncUnStoreContainer(ts.trayId, config.Get("WAREHOUSE"));
                            }
                            catch
                            {
                                all_synced = false;
                            }

                            if (synced == false) { all_synced = false; }
                            ts.sync = synced;
                            ts.status = (int)TrayStatus.Cancled;
                        }
                        unit.Submit();
                        trans.Complete();
                        if (all_synced)
                        {
                            msg.AddMessage(ReturnCode.OK, "入库取消成功!");
                        }
                        else
                        {
                            msg.AddMessage(ReturnCode.OK, "入库取消成功!");
                            msg.AddMessage(ReturnCode.Warning, "入库取消成功,但WMS同步失败,请稍候重新同步!");
                        }
                        msg.result = true;
                    }
                    catch (Exception e)
                    {
                        msg.result = false;
                        msg.AddMessage(ReturnCode.Error, "错误:" + e.Message + "\n请联系程序管理员!");
                    }
                    finally
                    {
                        trans.Dispose();
                    }
                    return msg;
                }
            }
        }
        public CreateRegistrationViewModel(INavigationService navService, ApiService apiService)
        {
            _navService = navService;
            _apiService = apiService;

            Projects = new ObservableCollection<Project>();
            Tasks = new ObservableCollection<Task>();

            RegisterMessaging();
            CreateCommands();
        }
Пример #5
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += PrintUnhandledException;

            _client = GetSoapClient();

            DateTime firstDayOfMonth = GetFirstDayOfMonth();
            IEnumerable<ApiCampaign> campaigns = GetAllCampaignWithActivity(firstDayOfMonth);

            PrintCampaigns(campaigns);
        }
Пример #6
0
 public MainWindow()
 {
     var service = new ApiService();
     _apiService = service;
     Cef.Initialize(new CefSettings()
     {
         CachePath = service.CachePath,
         LogFile = service.LogFile
     }, true, true);
     InitializeComponent();
     collector = new ClientDataCollector(_apiService);
     selfHostedBrowser.RegisterJsObject(nameof(ClientDataCollector), collector);
 }
Пример #7
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += PrintUnhandledException;

            _client = GetSoapClient();

            ApiContact contact = CreateContact();
            PrintContact(contact);

            contact = UpdateEmail(contact);
            PrintContact(contact);

            DeleteContact(contact.Id);
        }
Пример #8
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += PrintUnhandledException;

            _client = GetSoapClient();

            ApiAddressBook addressBook = CreateAddressBook();
            AddContactToAddressBook(addressBook);

            ApiCampaign campaign = CreateCampaign();

            ApiCampaignSend sendResult = SendCampaignToAddressBook(campaign, addressBook);
            WaitUntilSendFinishes(sendResult);

            PrintCampaingSummary(campaign);
        }
Пример #9
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += PrintUnhandledException;

            _client = GetSoapClient();

            byte[] contacts = GetContactsForImport();
            ApiContactImport contactImport = _client.ImportContactsToAddressBook(AddressBookId, true, contacts, "csv");
            ApiContactImport contactImportResult = WaitUntilImportFinishes(contactImport);
            PrintContactImport(contactImportResult);

            ApiContactImportReport contactImportReport = _client.GetContactImportReport(contactImportResult.Id);
            PrintContactImportReport(contactImportReport);

            string csvReport = GetContactImportFaults(contactImportResult.Id);
            PrintCsvReport(csvReport);
        }
Пример #10
0
 public NamesViewModel()
 {
     this.LoadFuncionarios();
     this.apiService = new ApiService();
 }
Пример #11
0
 private static ApiService GetSoapClient()
 {
     ApiService client = new ApiService();
     client.Credentials = new NetworkCredential(UserName, Password);
     return client;
 }
Пример #12
0
 public ElementoViewModel()
 {
     this.apiService = new ApiService();
     this.LoadELemento();
 }
        public void DeleteTimesheets_Test()
        {
            ExpectDelete <Timesheet>(EndpointName.Timesheets);

            ApiService.DeleteTimesheets(DummyEntities);
        }
        internal OverviewViewModel()
        {
            var rPort = KanColleGame.Current.Port;

            var rPortPCEL = PropertyChangedEventListener.FromSource(rPort);

            rPortPCEL.Add(nameof(rPort.Ships), (s, e) => ShipCount                     = rPort.Ships.Count);
            rPortPCEL.Add(nameof(rPort.Equipment), (s, e) => EquipmentCount            = rPort.Equipment.Count);
            rPortPCEL.Add(nameof(rPort.RepairDocks), (s, e) => RepairDocks             = rPort.RepairDocks.Values.Select(r => new RepairDockViewModel(r)).ToList());
            rPortPCEL.Add(nameof(rPort.ConstructionDocks), (s, e) => ConstructionDocks = rPort.ConstructionDocks.Values.Select(r => new ConstructionDockViewModel(r)).ToList());
            rPortPCEL.Add(nameof(rPort.Admiral), delegate
            {
                if (!r_IsAdmiralInitialized)
                {
                    var rAdmiral     = rPort.Admiral;
                    var rAdmiralPCEL = PropertyChangedEventListener.FromSource(rAdmiral);
                    rAdmiralPCEL.Add(nameof(rAdmiral.MaxShipCount), (s, e) => CheckShipCapacity());
                    rAdmiralPCEL.Add(nameof(rAdmiral.MaxEquipmentCount), (s, e) => CheckEquipmentCapacity());

                    r_IsAdmiralInitialized = true;
                }

                CheckCapacity();
            });

            AirBase = new AirBaseViewModel();

            r_AirBasePCEL = PropertyChangedEventListener.FromSource(rPort.AirBase);
            r_AirBasePCEL.Add(nameof(rPort.AirBase.AllGroups), delegate
            {
                if (rPort.AirBase.Table.Count == 0)
                {
                    return;
                }

                DispatcherUtil.UIDispatcher.InvokeAsync(() =>
                {
                    if (RightTabs == null)
                    {
                        RightTabs = new ObservableCollection <ModelBase>();
                        OnPropertyChanged(nameof(RightTabs));
                    }

                    RightTabs.Add(AirBase);
                });

                r_AirBasePCEL.Dispose();
                r_AirBasePCEL = null;
            });

            ApiService.Subscribe("api_req_map/next", delegate
            {
                var rSortie = SortieInfo.Current;
                if (rSortie != null)
                {
                    ShipCount = rPort.Ships.Count + rSortie.PendingShipCount;
                }
            });

            ShowShipOverviewWindowCommand      = new DelegatedCommand(() => WindowService.Instance.Show <ShipOverviewWindow>());
            ShowEquipmentOverviewWindowCommand = new DelegatedCommand(() => WindowService.Instance.Show <EquipmentOverviewWindow>());
        }
Пример #15
0
        internal FateRecords(SQLiteConnection rpConnection) : base(rpConnection)
        {
            DisposableObjects.Add(ApiService.SubscribeOnlyOnBeforeProcessStarted("api_req_kaisou/powerup", r =>
            {
                var rConsumedShips     = r.Parameters["api_id_items"].Split(',').Select(rpID => KanColleGame.Current.Port.Ships[int.Parse(rpID)]).ToArray();
                var rConsumedEquipment = rConsumedShips.SelectMany(rpShip => rpShip.EquipedEquipment).ToArray();

                AddShipFate(rConsumedShips, Fate.ConsumedByModernization);
            }));
            DisposableObjects.Add(ApiService.SubscribeOnlyOnBeforeProcessStarted("api_req_kousyou/destroyship", r =>
            {
                var rShip = KanColleGame.Current.Port.Ships[int.Parse(r.Parameters["api_ship_id"])];

                AddShipFate(rShip, Fate.Dismantled);
            }));
            DisposableObjects.Add(ApiService.SubscribeOnlyOnBeforeProcessStarted("api_req_kousyou/destroyitem2", r =>
            {
                var rEquipmentIDs = r.Parameters["api_slotitem_ids"].Split(',').Select(int.Parse);

                AddEquipmentFate(rEquipmentIDs.Select(rpID => KanColleGame.Current.Port.Equipment[rpID]), Fate.Scrapped);
            }));
            DisposableObjects.Add(ApiService.SubscribeOnlyOnBeforeProcessStarted("api_req_kousyou/remodel_slot", r =>
            {
                var rData = (RawImprovementResult)r.Data;
                if (rData.ConsumedEquipmentID != null)
                {
                    var rConsumedEquipment = rData.ConsumedEquipmentID.Select(rpID => KanColleGame.Current.Port.Equipment[rpID]).ToArray();

                    RecordService.Instance?.Fate?.AddEquipmentFate(rConsumedEquipment, Fate.ConsumedByImprovement);
                }
            }));

            var rFirstStages = new[]
            {
                "api_req_sortie/battle",
                "api_req_battle_midnight/sp_midnight",
                "api_req_sortie/airbattle",
                "api_req_sortie/ld_airbattle",
                "api_req_combined_battle/airbattle",
                "api_req_combined_battle/battle",
                "api_req_combined_battle/battle_water",
                "api_req_combined_battle/sp_midnight",
                "api_req_combined_battle/ld_airbattle",
                "api_req_combined_battle/ec_battle",
                "api_req_combined_battle/each_battle",
                "api_req_combined_battle/each_battle_water",
            };

            DisposableObjects.Add(ApiService.Subscribe(rFirstStages, ProcessBattle));

            var rBattleResultApis = new[]
            {
                "api_req_sortie/battleresult",
                "api_req_combined_battle/battleresult",
            };

            DisposableObjects.Add(ApiService.Subscribe(rBattleResultApis, ProcessBattleResult));

            DisposableObjects.Add(ApiService.Subscribe("api_port/port", delegate
            {
                if (r_SunkShips.Count == 0)
                {
                    return;
                }

                var rAliveShips = r_SunkShips.Intersect(KanColleGame.Current.Port.Ships.Values);
                DeleteShipFate(rAliveShips);

                r_SunkShips.Clear();
            }));
        }
Пример #16
0
 public FloorballManager(ApiService service)
 {
     apiService = service;
 }
 public PagarCompraViewModels(string idCom)
 {
     this.idCompra   = idCom;
     this.apiService = new ApiService();
     this.Pagar();
 }
Пример #18
0
        public ActionResult DelFileAndTableRelated(int id)
        {
            var data = ApiService.DelFileAndTableRelated(id);

            return(RedirectToAction("ListFile", "QualityMusic"));
        }
Пример #19
0
 public MainViewModel()
 {
     instance        = this;
     this.apiService = new ApiService();
     this.LoadMenu();
 }
Пример #20
0
 public ActionResult ListFile()
 {
     ViewBag.listFile = ApiService.GetAllQM();
     return(View());
 }
 public EditProfileYoutubeViewModel(int _ProfileMSId)
 {
     apiService = new ApiService();
     GetProfile(_ProfileMSId);
 }
 public ObtenerDatosIotViewModel()
 {
     this.apiService = new ApiService();
     this.LoadPagos();
 }
Пример #23
0
 public RouteItemViewModel()
 {
     this.apiService = new ApiService();
 }
Пример #24
0
 public ProductsViewModel()
 {
     apiService = new ApiService();
     LoadProducts();
 }
Пример #25
0
 public ProductsViewModel()
 {
     this.apiService = new ApiService();
     this.LoadProducts();
 }
Пример #26
0
        private async void Login()
        {
            if (IsBusy)
            {
                return;
            }


            if (string.IsNullOrEmpty(Email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    Languages.EmailPlaceHolder,
                    Languages.Accept);

                return;
            }

            if (string.IsNullOrEmpty(Password))
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    Languages.PasswordPlaceHolder,
                    Languages.Accept);

                return;
            }

            IsBusy    = true;
            IsEnabled = false;

            var request = new TokenRequest
            {
                Password = Password,
                Username = Email
            };

            var url      = Application.Current.Resources["UrlAPI"].ToString();
            var response = await ApiService.GetTokenAsync(
                url,
                "/Account",
                "/CreateToken",
                request);

            IsBusy    = false;
            IsEnabled = true;

            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Email o Contraseña incorrecta.",
                    "Aceptar");

                return;
            }

            var token         = (TokenResponse)response.Result;
            var mainViewModel = MainViewModel.GetInstance();

            mainViewModel.Token = token;
            Settings.IsRemember = true;

            Settings.Token = JsonConvert.SerializeObject(token);
            // Settings.User = JsonConvert.SerializeObject(user);

            Application.Current.MainPage = new MainPage();
        }
Пример #27
0
 public DeserterCmd(ApiService apiService)
 {
     api = apiService;
 }
Пример #28
0
		static async void Run()
		{
			IApiService api = new ApiService(new RequestService(), new ApiLogger(), HOST);

			string passwd = ComputePasswordHash("rose");
			UserStatusCode result = await api.RegisterUserAsync("india", "*****@*****.**", passwd);

			Console.WriteLine("Result Code {0}", result);
			
			result = await api.LoginUserAsync("india", passwd);

			Console.WriteLine("Result Code {0}", result);

			UserInfo badUserInfo = new UserInfo {Login = "******", Password = "******"};
			UserInfo userInfo = new UserInfo{Login = "******", Password = passwd};
			DeviceStatusCode dResult = await api.CreateDeviceAsync(badUserInfo, "test123");
			Console.WriteLine("Create bad device : {0}", dResult);
			dResult = await api.CreateDeviceAsync(userInfo, "test123");
			Console.WriteLine("Create good device : {0}", dResult);

			ApiResult<DeviceStatusCode, List<DeviceResponse>> deviceListResult = await api.ListDevicesAsync(userInfo);
			Console.WriteLine("Display devices : {0}", deviceListResult.Status);
			deviceListResult.Content.ForEach(x => Console.WriteLine("\t{0}", x.Name));

			dResult = await api.RenameDeviceAsync(userInfo, "test123", "test456");
			Console.WriteLine("Rename device : {0}", dResult);

			deviceListResult = await api.ListDevicesAsync(userInfo);
			Console.WriteLine("Display devices : {0}", deviceListResult.Status);
			deviceListResult.Content.ForEach(x => Console.WriteLine("\t{0}", x.Name));

			DeviceInfo device = new DeviceInfo
			{
				Name = "test456"
			};
			var sResult = await api.GetLastSettingsAsync(userInfo, device);
			Console.WriteLine("Get Settings : {0}", sResult.Status);
			if (sResult.Content != null)
			{
				Console.WriteLine("\tDate : {0}", sResult.Content.Date);
				Console.WriteLine("\tVersion : {0}", sResult.Content.Version);
				Console.WriteLine("\tData : {0}", sResult.Content.Settings);
			}

			var updateResult = await api.UpdateSettingsAsync(userInfo, device, "test settings v1");
			Console.WriteLine("update settings : {0}", updateResult);

			sResult = await api.GetLastSettingsAsync(userInfo, device);
			Console.WriteLine("Get Settings : {0}", sResult.Status);
			if (sResult.Content != null)
			{
				Console.WriteLine("\tDate : {0}", sResult.Content.Date);
				Console.WriteLine("\tVersion : {0}", sResult.Content.Version);
				Console.WriteLine("\tData : {0}", sResult.Content.Settings);
			}

			var slResult = await api.GetSettingsListAsync(userInfo, device);
			Console.WriteLine("Get list of settings => {0}", slResult.Status);
			if (slResult.Content != null)
			{
				foreach (var settings in slResult.Content)
				{
					Console.WriteLine("\tDate : {0}", settings.Date);
					Console.WriteLine("\tVersion : {0}", settings.Version);
					Console.WriteLine("\tData : {0}", settings.Settings);
				}
				Console.WriteLine();
			}
			Console.WriteLine();


			sResult = await api.GetVersionSettingsAsync(userInfo, device, 2);
			Console.WriteLine("Get Settings for version 2: {0}", sResult.Status);
			if (sResult.Content != null)
			{
				Console.WriteLine("\tDate : {0}", sResult.Content.Date);
				Console.WriteLine("\tVersion : {0}", sResult.Content.Version);
				Console.WriteLine("\tData : {0}", sResult.Content.Settings);
			}
			
			//Console.WriteLine("Got result {0}", result);

			var vResult = await api.GetVersions(userInfo, device);
			Console.WriteLine("GetVersions : {0}", vResult.Status);
			if (vResult.Content != null)
			{
				foreach (var v in vResult.Content)
				{
					Console.WriteLine("\tVersion : {0}\n\tDate : {1}", v.Version, v.Date);
				}
			}

			vResult = await api.GetVersions(userInfo, device, 2);
			Console.WriteLine("GetVersionsFrom(2) : {0}", vResult.Status);
			if (vResult.Content != null)
			{
				foreach (var v in vResult.Content)
				{
					Console.WriteLine("\tVersion : {0}\n\tDate : {1}", v.Version, v.Date);
				}
			}

			var vCreateResult = await api.CreateVersion(userInfo, device);
			Console.WriteLine("CreateVersion : {0}", vCreateResult.Status);
			if (vCreateResult.Content != null)
			{
				var v = vCreateResult.Content;
				Console.WriteLine("\tVersion : {0}\n\tDate : {1}", v.Version, v.Date);
			}
			else
			{
				return;
			}

			var iCreateResult = await api.UpdateIndiagram(userInfo, device, new IndiagramRequest
			{
				Id = -1,
				IsCategory = false,
				IsEnabled = false,
				ParentId = -1,
				Position = 1,
				Text = "Test image",
				Version = vCreateResult.Content.Version
			});
			Console.WriteLine("Create indiagram : {0}", iCreateResult.Status);
			if (iCreateResult.Content != null)
			{
				IndiagramResponse i = iCreateResult.Content;
				Console.WriteLine("\tDatabaseId : {0}", i.DatabaseId);
				Console.WriteLine("\tIsCategory : {0}", i.IsCategory);
				Console.WriteLine("\tIsEnabled : {0}", i.IsEnabled);
				Console.WriteLine("\tText : {0}", i.Text);
				Console.WriteLine("\tPosition : {0}", i.Position);
				Console.WriteLine("\tHasImage : {0}", i.HasImage);
				Console.WriteLine("\tHasSound : {0}", i.HasSound);
				Console.WriteLine("\tImageHash : {0}", i.ImageHash);
				Console.WriteLine("\tSoundHash : {0}", i.SoundHash);
				Console.WriteLine("\tImageFile : {0}", i.ImageFile);
				Console.WriteLine("\tSoundFile : {0}", i.SoundFile);
			}
			else
			{
				return;
			}

			var uploadResult = await api.UploadImage(userInfo, device, iCreateResult.Content.DatabaseId, vCreateResult.Content.Version, "robot.png", ReadImage());
			Console.WriteLine("Upload image : {0}", uploadResult);

			iCreateResult = await api.GetIndiagram(userInfo, device, iCreateResult.Content.DatabaseId);
			Console.WriteLine("Get indiagram : {0}", iCreateResult.Status);
			if (iCreateResult.Content != null)
			{
				IndiagramResponse i = iCreateResult.Content;
				Console.WriteLine("\tDatabaseId : {0}", i.DatabaseId);
				Console.WriteLine("\tIsCategory : {0}", i.IsCategory);
				Console.WriteLine("\tIsEnabled : {0}", i.IsEnabled);
				Console.WriteLine("\tText : {0}", i.Text);
				Console.WriteLine("\tPosition : {0}", i.Position);
				Console.WriteLine("\tHasImage : {0}", i.HasImage);
				Console.WriteLine("\tHasSound : {0}", i.HasSound);
				Console.WriteLine("\tImageHash : {0}", i.ImageHash);
				Console.WriteLine("\tSoundHash : {0}", i.SoundHash);
				Console.WriteLine("\tImageFile : {0}", i.ImageFile);
				Console.WriteLine("\tSoundFile : {0}", i.SoundFile);
			}
			else
			{
				return;
			}

			var downloadResult = await api.GetImage(userInfo, device, iCreateResult.Content.DatabaseId, vCreateResult.Content.Version);
			Console.WriteLine("Download image : {0}", downloadResult.Status);
			if (downloadResult.Content != null)
			{
				File.WriteAllBytes(string.Format("output-{0}", downloadResult.Content.FileName), downloadResult.Content.Content);
				Console.WriteLine("Image output write to output-{0}", downloadResult.Content.FileName);
			}
		}
Пример #29
0
 public LoginViewModel()
 {
     this.apiService   = new ApiService();
     this.IsEnabled    = true;
     this.IsRemembered = true;
 }
Пример #30
0
        protected async Task LockAsync()
        {
            await ApiService.PostAsJsonAsync($"api/public/topics/lock-topic/{Model.Forum.Id}/{Model.Topic.Id}", !Model.Topic.Locked);

            Model.Topic.Locked = !Model.Topic.Locked;
        }
Пример #31
0
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            Model = await ApiService.GetFromJsonAsync <IndexPageModel>("api/public/index-model");
        }
Пример #32
0
        protected async Task PinAsync()
        {
            await ApiService.PostAsJsonAsync($"api/public/topics/pin-topic/{Model.Forum.Id}/{Model.Topic.Id}", !Model.Topic.Pinned);

            Model.Topic.Pinned = !Model.Topic.Pinned;
        }
 public LatestProductsGridViewComponent(ApiService apiService)
 {
     _apiService = apiService;
 }
 public InventoryViewModel()
 {
     this.apiService = new ApiService();
     this.LoadCategories();
 }
Пример #35
0
        protected override async Task OnInitializedAsync()
        {
            Model = await ApiService.GetFromJsonAsync <SettingsPageModel>("api/admin/sites/settings");

            CurrentLanguage = Model.Site.Language;
        }
Пример #36
0
 public AddBandSPageViewModel()
 {
     this.apiService  = new ApiService();
     this.IsEnabled   = true;
     this.imageSource = "business";
 }
Пример #37
0
 public LandsViewModel()
 {
     this.apiService = new ApiService();
     this.LoadLands();
 }
Пример #38
0
        protected async Task DeleteTopicAsync(MouseEventArgs e)
        {
            await ApiService.DeleteAsync($"api/public/topics/delete-topic/{Model.Forum.Id}/{Model.Topic.Id}");

            Navigation.NavigateTo(Url.Forum(Model.Forum.Slug));
        }
        /// <summary>
        /// We succeeded in registering for notifications
        /// </summary>
        /// <param name="application"></param>
        /// <param name="deviceToken"></param>
        public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            // Get current device token
            var deviceTokenDesc = deviceToken.Description;
            if (!string.IsNullOrWhiteSpace(deviceTokenDesc))
            {
                deviceTokenDesc = deviceTokenDesc.Trim('<').Trim('>').Replace(" ", "");
            }

            UserDialogs.Instance.Alert(deviceTokenDesc);

            // Has the token changed?
            if (!string.IsNullOrEmpty(deviceTokenDesc))
            {
                //Register the user on your server
                DeviceToken apiToken = new DeviceToken
                {
                    Token = deviceTokenDesc,
                    Device = Device.OS.ToString()
                };
                ApiService apiService = new ApiService();
                apiService.PostAsync<DeviceToken>("Devices/Post", apiToken);

            }
        }
        public AllMyConversationsViewModel()
        {
            this.apiService = new ApiService();

            this.LoadConversations();
        }
Пример #41
0
        public ProcessMsg SyncStore()
        {
            using (TransactionScope trans = new TransactionScope())
            {
                using (IUnitOfWork unit = MSSqlHelper.DataContext())
                {
                    ProcessMsg msg = new ProcessMsg() { result = true };
                    try
                    {
                        ITraysRep tr = new TraysRep(unit);
                        List<Trays> tis = tr.GetUnsync();
                        ITrayItemRep tir = new TrayItemRep(unit);
                        bool all_synced = true;
                        bool error_loged = false;

                        string error_log = DateTime.Now.ToString("yyyyMMddHHmmsss") + ".txt";
                        string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ErrorLog", error_log);
                        using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
                        {
                            using (StreamWriter sw = new StreamWriter(fs))
                            {
                                foreach (Trays ts in tis)
                                {
                                    bool synced = false;
                                    try
                                    {
                                        if (ts.status == (int)TrayStatus.Cancled)
                                        {
                                            synced = new ApiService().SyncUnStoreContainer(ts.trayId, GetWhouse());
                                        }
                                        else
                                        {
                                            List<SinglePackage> singlePackages = tir.GetSPByTrayId(ts.trayId);
                                            synced = new ApiService().SyncStoreContainer(GenContainers(ts, singlePackages, GetWhouse()));
                                        }
                                    }
                                    catch (ApiException ae)
                                    {
                                        sw.WriteLine(ae.Message);
                                        error_loged = true;
                                        synced = false;
                                    }
                                    catch
                                    {
                                        synced = false;
                                    }
                                    ts.sync = synced;
                                    if (synced == false) { all_synced = false; }
                                }
                            }
                        }
                        unit.Submit();
                        trans.Complete();
                        msg.result = all_synced;
                        if (all_synced)
                        {
                            msg.AddMessage(ReturnCode.OK, "WMS同步成功!");
                        }
                        else
                        {
                            if (error_loged)
                            {
                                msg.AddMessage(ReturnCode.Warning, "WMS同步失败,查看错误日志:" + error_log + "请稍候重新同步!\n或联系程序管理员!");
                            }
                            else
                            {
                                msg.AddMessage(ReturnCode.Warning, "WMS同步失败,请检查网络,稍候重新同步!\n或联系程序管理员!");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        msg.result = false;
                        msg.AddMessage(ReturnCode.Error, "错误:" + e.Message + "\n请联系程序管理员!");
                    }
                    finally
                    {
                        trans.Dispose();
                    }
                    return msg;
                }
            }
        }
Пример #42
0
        private async Task LoadProject()
        {
            var url = $"projects/{Id}";

            project = await ApiService.GetAsync <ProjectModel>(url);
        }
Пример #43
0
        public ProcessMsg CompleteStore(List<string> packageIds, string whouse, string posi)
        {
            using (TransactionScope trans = new TransactionScope())
            {
                using (IUnitOfWork unit = MSSqlHelper.DataContext())
                {
                    ProcessMsg msg = new ProcessMsg();
                    try
                    {
                        string trayId = "T" + DateTime.Now.ToString("yyyyMMddHHmmssfff");

                        ITraysRep tr = new TraysRep(unit);
                        ITrayItemRep tir = new TrayItemRep(unit);
                        ISinglePackageRep spr = new SinglePackageRep(unit);

                        Trays ts = new Trays()
                        {
                            trayId = trayId,
                            createTime = DateTime.Now,
                            warehouse = whouse,
                            position = posi,
                            status = (int)TrayStatus.Stored,
                            rowguid = Guid.NewGuid()
                        };

                        List<TrayItem> tis = new List<TrayItem>();
                        foreach (string pid in packageIds)
                        {
                            tis.Add(new TrayItem()
                            {
                                itemId = Guid.NewGuid(),
                                trayId = ts.trayId,
                                packageId = pid,
                                rowguid = Guid.NewGuid()
                            });
                        }
                        bool synced = false;
                        // sync container data
                        try
                        {
                            List<SinglePackage> singlePackages = spr.GetListByIds(packageIds);
                            synced = new ApiService().SyncStoreContainer(GenContainers(ts, singlePackages, GetWhouse()));

                        }
                        catch (ApiException ae)
                        {
                            msg.AddMessage(ReturnCode.Warning, ae.Message);
                            synced = false;
                        }
                        catch {
                            synced = false;
                        }
                        ts.sync = synced;

                        tr.AddSingle(ts);
                        tir.AddMuti(tis);
                        unit.Submit();
                        trans.Complete();
                        msg.result = true;
                        if (synced)
                        {
                            msg.AddMessage(ReturnCode.OK, ts.trayId);
                        }
                        else
                        {
                            msg.AddMessage(ReturnCode.OK, ts.trayId);
                            msg.AddMessage(ReturnCode.Warning, "托盘生成成功,但WMS同步失败,请检查网络,稍候重新同步!");
                        }
                    }
                    catch (Exception e)
                    {
                        msg.result = false;
                        msg.AddMessage(ReturnCode.Error, "错误:" + e.Message + "\n请联系程序管理员!");
                    }
                    finally
                    {
                        trans.Dispose();
                    }
                    return msg;
                }
            }
        }
Пример #44
0
 private void SetInitialData()
 {
     apiService = new ApiService();
     userId     = Intent.GetStringExtra("userId");
 }