Beispiel #1
0
        internal void DictionarySerialization(
            ContractTypeSerializer serializer,
            UpdateServices original,
            JObject json,
            UpdateServices deserialized
            )
        {
            GIVEN["a contract type serializer"] = () => serializer = CreateSerializer();

            WHEN["serializing a message"] = () => json = SerializeJson(
                serializer,
                original = new UpdateServicesBuilder {
                Status =
                {
                    { ID.NewID(), new StatusDOBuilder {
                          Name = "Status 1"
                      }.Build() },
                    { ID.NewID(), new StatusDOBuilder {
                          Name = "Status 2"
                      }.Build() }
                }
            }.Build());
            THEN["the serialized JSON equals the expected"] = () => json.Should().BeEquivalentTo(original.GetExpectedJson());

            WHEN["deserializing the JSON"] = () => deserialized = DeserializeJson <UpdateServices>(serializer, json);
            THEN["the deserialized JSON equals the original"] = () => deserialized.Should().BeEquivalentTo(original);
        }
Beispiel #2
0
        /// <summary>
        /// 在后台检查更新,当需要强制更新时才返回True
        /// </summary>
        public async Task <bool> CheckUpdates()
        {
            if (Button_Update.Content.ToString() == "检查更新")
            {
                Button_Update.Content = "检查中"; Button_Update.IsEnabled = false;
                try
                {
                    if (await UpdateServices.Check())
                    {
                        if (!UpdateServices.Force)
                        {
                            return(false);
                        }
                        Text_Describe.Text = $"最新版本:{UpdateServices.RemoteVersion}({UpdateServices.RemoteUpdated.ToString("yyyy.MM.dd")})";
                        var logStr = await UpdateServices.GetUpdateLog();

                        TextBox_Log.Visibility = Visibility.Visible;
                        TextBox_Log.Text       = logStr;
                        Button_Update.Content  = "下载中";
                        await UpdateServices.Download();

                        Button_Update.Content = "立即更新"; Button_Update.IsEnabled = true;
                        return(true);
                    }
                }
                catch
                {
                    Button_Update.Content   = "检查更新";
                    Button_Update.IsEnabled = true;
                }
            }
            return(false);
        }
Beispiel #3
0
 /// <summary>
 /// Главная точка входа для приложения.
 /// </summary>
 public static void Main()
 {
     UpdateServices.Start();
     Console.WriteLine("для остановки приложения нажмите любую клавищу...");
     Console.ReadKey();
     UpdateServices.Stop();
 }
 public UpdateServices(UpdateServices source) : base()
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     Status = source.Status;
 }
Beispiel #5
0
        private async void Button_Update_Click(object sender, RoutedEventArgs e)
        {
            if (Button_Update.Content.ToString() == "检查更新")
            {
                Button_Update.Content = "检查中"; Button_Update.IsEnabled = false;
                try
                {
                    if (await UpdateServices.Check())
                    {
                        Text_Describe.Text = $"最新版本:{UpdateServices.RemoteVersion}({UpdateServices.RemoteUpdated.ToString("yyyy.MM.dd")})";
                        var logStr = await UpdateServices.GetUpdateLog();

                        TextBox_Log.Visibility = Visibility.Visible;
                        TextBox_Log.Text       = logStr;
                        Button_Update.Content  = "下载中";
                        await UpdateServices.Download();

                        Button_Update.Content = "立即更新"; Button_Update.IsEnabled = true;
                    }
                    else
                    {
                        Text_Describe.Text    = "当前已经是最新版本";
                        Button_Update.Content = "检查更新"; Button_Update.IsEnabled = true;
                    }
                }
                catch (Exception ex)
                {
                    MainWindow.ShowMessageDialog("错误", ex.Message);
                    Button_Update.Content = "检查更新"; Button_Update.IsEnabled = true;
                }
                return;
            }
            if (Button_Update.Content.ToString() == "立即更新")
            {
                try
                {
                    string exeFile = Path.Combine(UserSettings.AppDataDir, "AutoUpdate.exe");
                    File.WriteAllBytes(exeFile, CommonServices.GetCompressResBytes("SimpleRemote.Lib.AutoUpdate.exe.Compress"));
                    string updateFile = Path.Combine(UserSettings.AppDataDir, "Update.zip");
                    string unzipPath  = AppDomain.CurrentDomain.BaseDirectory;
                    Process.Start(exeFile, $"{updateFile} {unzipPath} {Assembly.GetEntryAssembly().Location}");
                    Application.Current.MainWindow.Close();
                }
                catch (Exception ex)
                {
                    MainWindow.ShowMessageDialog("错误", ex.Message);
                    Button_Update.Content = "检查更新"; Button_Update.IsEnabled = true;
                }
            }
        }
        public JsonResult UpdateProduct(tblSupplier model)
        {
            var service = new UpdateServices();
            var res     = service.SaveChangesSupplier(model);

            if (res)
            {
                return(Json(new { success = true }));
            }

            else
            {
                return(Json(new { success = false }));
            }
        }
        public JsonResult UpdateWarehouse(tblWarehouse model)
        {
            var service = new UpdateServices();
            var res     = service.SaveChangesWarehouse(model);

            if (res)
            {
                return(Json(new { success = true }));
            }

            else
            {
                return(Json(new { success = false }));
            }
        }
        public JsonResult UpdateClient(tblClient model)
        {
            var service = new UpdateServices();
            var res     = service.SaveChangesClient(model);

            if (res)
            {
                return(Json(new { success = true }));
            }

            else
            {
                return(Json(new { success = false }));
            }
        }
Beispiel #9
0
        public JsonResult UpdateReport(tblReport model)
        {
            var service = new UpdateServices();
            var res     = (bool)service.SaveChangesReport(model);

            if (res)
            {
                return(Json(new { success = true }));
            }

            else
            {
                return(Json(new { success = false }));
            }
        }
Beispiel #10
0
        public JsonResult UpdateInventory(tblInventory model)
        {
            var service = new UpdateServices();
            var res     = service.SaveChangesInventory(model);

            if (res)
            {
                return(Json(new { success = true }));
            }

            else
            {
                return(Json(new { success = false }));
            }
        }
Beispiel #11
0
 protected override void OnStop()
 {
     UpdateServices.Stop();
 }
Beispiel #12
0
 protected override void OnStart(string[] args)
 {
     UpdateServices.Start();
 }