Esempio n. 1
0
        public void ServerValidation_InvokeOperation()
        {
            TestDomainServices.TestProvider_Scenarios ctxt = new TestDomainServices.TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);

            // Validate using an action so we can assert state for each of the 3 different
            // completion patterns; callback, event, and polling
            Action <InvokeOperation <bool> > validate = (io) =>
            {
                Assert.IsNotNull(io.Error);
                Assert.AreEqual(typeof(DomainOperationException), io.Error.GetType());
                Assert.AreEqual(OperationErrorStatus.ValidationFailed, ((DomainOperationException)io.Error).Status);
                Assert.AreEqual(string.Format(Resource.DomainContext_InvokeOperationFailed_Validation, "InvokeOperationWithParamValidation"), io.Error.Message);
                Assert.AreEqual(1, io.ValidationErrors.Count(),
                                "There should be 1 validation error.");
                ValidationResult error = io.ValidationErrors.Single();
                Assert.AreEqual("Server validation exception thrown!", error.ErrorMessage);
                io.MarkErrorAsHandled();
            };

            InvokeOperation <bool> op = ctxt.InvokeOperationWithParamValidation(5, "ex", new CityWithCacheData(), validate, null);

            op.Completed += (sender, e) =>
            {
                validate((InvokeOperation <bool>)sender);
            };

            this.EnqueueCompletion(() => op);
            EnqueueCallback(delegate
            {
                validate(op);
            });

            EnqueueTestComplete();
        }
Esempio n. 2
0
 //获取用户模块子模块完成,回调
 private void OnGetSubModuleCompleted(InvokeOperation <List <SystemModule> > obj)
 {
     if (Utility.Utility.CheckInvokeOperation(obj)) //检查操作是否正确执行
     {
         LinksStackPanel.Children.Clear();          //
         var navUrl = string.Empty;
         foreach (SystemModule module in obj.Value)
         {
             if (string.IsNullOrEmpty(navUrl))
             {
                 navUrl = module.NavigateUri;                               //模块中的导航地址是否为空
             }
             var btn = new HyperlinkButton();
             btn.Style       = Application.Current.Resources["SubLinkStyle"] as Style; //设置为子链接类型
             btn.Content     = module.ModuleName;                                      //设置模块名称
             btn.DataContext = module;                                                 //绑定模块数据
             if (!string.IsNullOrEmpty(module.NavigateUri))
             {
                 btn.NavigateUri = new Uri(module.NavigateUri, UriKind.Relative);
             }
             btn.TargetName = "ContentFrame";
             LinksStackPanel.Children.Add(btn);  //添加到StackPanel中
         }
         //由ContentFrame导航到相对地址,并显示
         if (!string.IsNullOrEmpty(navUrl))
         {
             ContentFrame.Navigate(new Uri(navUrl, UriKind.Relative));
         }
     }
 }
Esempio n. 3
0
        void oper_Completed(object sender, EventArgs e)
        {
            InvokeOperation <bool> oper = sender as InvokeOperation <bool>;

            if (!oper.HasError)
            {
                GlobalStatus.Current.IsError = false;
                if (OrdersContext.Current.LastUpdate.AddMinutes(10) < DateTime.Now)
                {
                    GlobalStatus.Current.NeedRefresh = true;
                }
                if (oper.Value || GlobalStatus.Current.NeedRefresh)
                {
                    if (GlobalStatus.Current.CanRefresh)
                    {
                        OrdersContext.Current.RefreshOrders(true);
                    }
                    else
                    {
                        GlobalStatus.Current.NeedRefresh = true;
                    }
                }
            }
            else
            {
                GlobalStatus.Current.IsError = true;
                oper.MarkErrorAsHandled();
            }
        }
Esempio n. 4
0
        private void user_listCallBack(InvokeOperation <string> e)
        {
            if (!e.HasError)
            {
                ReturnInfo returnInfo = new ReturnInfo(e.Value);

                if (returnInfo.IsSuccess)
                {
                    if (User_InsertDataSuccess != null)    //成功事件
                    {
                        User_InsertDataSuccess(e.UserState, new ConstsEventArgs()
                        {
                        });
                    }
                }
                else
                {
                    if (User_InsertDataFailure != null)    //失败事件
                    {
                        User_InsertDataFailure(e.UserState, new ConstsEventArgs()
                        {
                            IsResult = false, obj_Args_one = returnInfo.Message
                        });
                    }
                }
            }
        }
        /// <summary>
        /// 转换成Task异步,并且把压缩数据反序列化成指定的类型
        /// </summary>
        /// <typeparam name="T">要反序列化的类型</typeparam>
        /// <param name="q"></param>
        /// <returns></returns>
        public static Task <T> ResultAsync <T>(this InvokeOperation <byte[]> q) where T : class
        {
            return(Task.Run(() =>
            {
                try
                {
                    System.Threading.AutoResetEvent auto = new System.Threading.AutoResetEvent(false);
                    q.Completed += (a, b) => auto.Set();
                    auto.WaitOne();
                    auto.Dispose();
                    byte[] result = Decompress(q.Value);
                    if (result != null && result.Length > 0)
                    {
#if (DEBUG)
                        string xml = System.Text.Encoding.UTF8.GetString(result);
#endif
                        using (MemoryStream stream = new MemoryStream())
                        {
                            DataContractSerializer serializer = new DataContractSerializer(typeof(T));
                            stream.Write(result, 0, result.Length);
                            stream.Position = 0;// (0L);
                            return (serializer.ReadObject(stream) as T);
                        }
                    }
                    else
                    {
                        return null;
                    }
                }
                catch (Exception e)
                {
                    return null;
                }
            }));
        }
Esempio n. 6
0
 private void PerformAuthenticationCompleted(InvokeOperation<VocUser> operation)
 {
     HandleInvokeOperation(operation, () =>
     {
         IsBusy = false;
         VocUser user = operation.Value;
         if (user != null)
         {
             if (user.IsCoordinatorOrSuperior || user.IsBorderAgentOrSuperior)
             {
                 //Get the list of entry points
                 StaticReferences.GetEntryPoints(() =>
                 {
                     App.CurrentUser = operation.Value;
                     if (ChangeScreen != null)
                         ChangeScreen(this, new EventArgs());
                 });
             }
             else
             {
                 MessageBox.Show(Strings.NonAuthorizedMessage);
             }
         }
         else
         {
             MessageBox.Show(Strings.NonAuthorizedMessage);
         }
     });
 }
 private void OnGetSystemRoleCompleted(InvokeOperation <List <SystemRole> > obj)
 {
     if (Utility.Utility.CheckInvokeOperation(obj))
     {
         SysRoleGrid.ItemsSource = obj.Value;
     }
 }
 /// <summary>
 /// Completion handler for the registration operation. If there was an error, an
 /// <see cref="ErrorWindow"/> is displayed to the user. Otherwise, this triggers
 /// a login operation that will automatically log in the just registered user.
 /// </summary>
 private void RegistrationOperation_Completed(InvokeOperation <CreateUserStatus> operation)
 {
     if (!operation.IsCanceled)
     {
         if (operation.HasError)
         {
             ErrorWindow.CreateNew(operation.Error);
             operation.MarkErrorAsHandled();
         }
         else if (operation.Value == CreateUserStatus.Success)
         {
             this.registrationData.CurrentOperation = WebContext.Current.Authentication.Login(this.registrationData.ToLoginParameters(), this.LoginOperation_Completed, null);
             this.parentWindow.AddPendingOperation(this.registrationData.CurrentOperation);
         }
         else if (operation.Value == CreateUserStatus.DuplicateUserName)
         {
             this.registrationData.ValidationErrors.Add(new ValidationResult(ErrorResources.CreateUserStatusDuplicateUserName, new string[] { "UserName" }));
         }
         else if (operation.Value == CreateUserStatus.DuplicateEmail)
         {
             this.registrationData.ValidationErrors.Add(new ValidationResult(ErrorResources.CreateUserStatusDuplicateEmail, new string[] { "Email" }));
         }
         else
         {
             ErrorWindow.CreateNew(ErrorResources.ErrorWindowGenericError);
         }
     }
 }
Esempio n. 9
0
 public void Md5EncryptOldPwdComplete(object sender, InvokeOperation <string> e)
 {
     if (e.HasError == false)
     {
         ReturnInfo ri = new ReturnInfo(e.Value);
         if (ri.IsSuccess == true)
         {
             string password = string.Empty;
             password = ri.Message;
             if (EventMd5EncryptComplete != null)
             {
                 EventMd5EncryptComplete(password, null);
             }
         }
         else
         {
             CommonFunction.ShowMessage(ri.Message);
             return;
         }
     }
     else
     {
         CommonFunction.ShowException("密码加密失败。", e.Error);
         return;
     }
 }
Esempio n. 10
0
        public void InvokeOperation_ReturnsIDictionary()
        {
            TestProvider_Scenarios   provider   = new TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);
            Dictionary <string, int> dictionary = new Dictionary <string, int>();

            foreach (var i in new[] { 1, 2, 3 })
            {
                dictionary.Add(i.ToString(), i);
            }

            InvokeOperation invoke = provider.ReturnsDictionary(dictionary, TestHelperMethods.DefaultOperationAction, null);

            EnqueueConditional(() => invoke.IsComplete);
            EnqueueCallback(delegate
            {
                object returnValue = invoke.Value;
                Assert.IsNotNull(invoke.Value);

                Dictionary <string, int> returnValueAsDictonary = returnValue as Dictionary <string, int>;
                Assert.IsNotNull(returnValueAsDictonary);

                foreach (var kvp in dictionary)
                {
                    Assert.IsTrue(returnValueAsDictonary.ContainsKey(kvp.Key));
                    Assert.AreEqual(kvp.Value, returnValueAsDictonary[kvp.Key]);
                }
            });
            EnqueueTestComplete();
        }
Esempio n. 11
0
        public void InvokeOperation_TestPropertyChangeNotifications()
        {
            CityDomainContext cities        = new CityDomainContext(TestURIs.Cities);
            InvokeOperation   invoke        = null;
            List <string>     notifications = new List <string>();

            // verify with userstate
            EnqueueCallback(delegate
            {
                invoke = cities.Echo("hello", TestHelperMethods.DefaultOperationAction, "my user state");

                ((System.ComponentModel.INotifyPropertyChanged)invoke).PropertyChanged += (s, e) =>
                {
                    notifications.Add(e.PropertyName);
                };
            });
            EnqueueConditional(() => invoke.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.IsFalse(invoke.HasError);
                Assert.AreEqual("Echo: hello", invoke.Value);

                Assert.AreEqual(3, notifications.Count);
                Assert.AreEqual("IsComplete", notifications[0]);
                Assert.AreEqual("CanCancel", notifications[1]);
                Assert.AreEqual("Value", notifications[2]);
            });

            EnqueueTestComplete();
        }
Esempio n. 12
0
        public void InvokeOperation_Basic()
        {
            CityDomainContext cities = new CityDomainContext(TestURIs.Cities);
            InvokeOperation   invoke = null;

            // verify with userstate
            EnqueueCallback(delegate
            {
                invoke = cities.Echo("hello", TestHelperMethods.DefaultOperationAction, "my user state");
            });
            EnqueueConditional(() => invoke.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.IsNull(invoke.Error);
                Assert.AreEqual("Echo", invoke.OperationName);
                Assert.AreEqual(1, invoke.Parameters.Count);
                Assert.AreSame("hello", invoke.Parameters["msg"]);
                Assert.AreEqual("Echo: hello", invoke.Value);
                Assert.AreEqual("my user state", invoke.UserState);
            });

            // verify without userstate
            EnqueueCallback(delegate
            {
                invoke = cities.Echo("hello");
            });
            EnqueueConditional(() => invoke.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.AreEqual(invoke.Value, "Echo: hello");
                Assert.IsNull(invoke.UserState);
            });

            EnqueueTestComplete();
        }
 /// <summary>
 /// Creates a new <see cref="LoginRegistrationWindow"/> instance.
 /// </summary>
 public PrintAddressStickers()
 {
     InitializeComponent();
     var ctx = new RadiographyContext();
     operation = ctx.GetAddressStickerTemplates();
     operation.Completed += new EventHandler(operation_Completed);
 }
 private void OnGetUserCountCompleted(InvokeOperation <int> obj)
 {
     if (Utility.Utility.CheckInvokeOperation(obj))
     {
         SysUserPager.BindSource(obj.Value, SysUserPager.PageSize);
     }
 }
        public void Invoke_ValidationErrors()
        {
            var mockDomainClient = new CitiesMockDomainClient();

            ValidationResult[] validationErrors = new ValidationResult[] { new ValidationResult("Foo", new string[] { "Bar" }) };
            mockDomainClient.InvokeCompletedResult = Task.FromResult(new InvokeCompletedResult(null, validationErrors));
            Cities.CityDomainContext ctx = new Cities.CityDomainContext(mockDomainClient);
            string myState = "Test User State";

            InvokeOperation invoke = ctx.Echo("TestInvoke", TestHelperMethods.DefaultOperationAction, myState);

            this.EnqueueCompletion(() => invoke);
            EnqueueCallback(delegate
            {
                Assert.IsNotNull(invoke.Error);
                Assert.AreSame(myState, invoke.UserState);

                CollectionAssert.AreEqual(validationErrors, (ICollection)invoke.ValidationErrors);

                // verify the exception properties
                var ex = (DomainOperationException)invoke.Error;
                Assert.AreEqual(OperationErrorStatus.ValidationFailed, ex.Status);
                CollectionAssert.AreEqual(validationErrors, (ICollection)ex.ValidationErrors);
                Assert.AreEqual(string.Format(Resource.DomainContext_InvokeOperationFailed_Validation, "Echo"), ex.Message);
            });

            EnqueueTestComplete();
        }
Esempio n. 16
0
        private void BindFileSystemEntityList(InvokeOperation <List <FileSystemEntity> > obj)
        {
            BusyIndicator1.IsBusy = false;
            if (Utility.Utility.CheckInvokeOperation(obj))
            {
                FileBrowseListBox.ItemsSource = obj.Value;

                var selectedItem = UserFoldersTree.SelectedItem as TreeViewItem;
                if (selectedItem != null)
                {
                    selectedItem.Items.Clear();
                    foreach (var item in obj.Value)
                    {
                        if (item.Type == FileSystemEntityType.Folder)
                        {
                            selectedItem.Items.Add(new TreeViewItem
                            {
                                Header = new Label
                                {
                                    Content    = item.Name,
                                    Foreground = new SolidColorBrush(Colors.White)
                                },
                                DataContext = item
                            });
                        }
                    }
                    selectedItem.IsExpanded = true;
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Reads Filter string
        /// </summary>
        /// <param name="filterList"></param>
        /// <param name="dsName"></param>
        /// <param name="completed"></param>
        public void ReadFilterString(List <EwavDataFilterCondition> filterList, List <EwavRule_Base> rules, string tableName, string dsName, Action <string, Exception> completed)
        {
            _completed4 = completed;
            InvokeOperation <string> Results = datasourceCtx.ReadFilterString(filterList, rules, tableName, dsName);

            Results.Completed += new EventHandler(Results4_Completed);
        }
Esempio n. 18
0
        /// <summary>
        /// Reads the specified ds id.
        /// </summary>
        /// <param name="dsId">The ds id.</param>
        /// <param name="completed">The completed.</param>
        public void Read(int orgId, Action <System.Collections.Generic.List <DTO.DatasourceDto>, Exception> completed)
        {
            _readCompleted = completed;
            dsCtx          = new AdminDatasourcesDomainContext();
            InvokeOperation <List <DatasourceDto> > readResult = dsCtx.ReadDatasource(orgId);

            readResult.Completed += new EventHandler(readResult_Completed);
        }
Esempio n. 19
0
        public void LoadData()
        {
            //documentManagerContext
            IsBusy = true;
            InvokeOperation <int> lDocumentTotal = documentManagerContext.GetTaxpayerDocumentCount();

            lDocumentTotal.Completed += DocumentTotal_Completed;
        }
 private void OnGetPagedUserCompleted(InvokeOperation <List <SystemUser> > obj)
 {
     BusyIndicator1.IsBusy = false;
     if (Utility.Utility.CheckInvokeOperation(obj))
     {
         SysUserGrid.ItemsSource = obj.Value;
     }
 }
 private void OnGetOrgnizationTreeCompleted(InvokeOperation <Organization> obj)
 {
     if (Utility.Utility.CheckInvokeOperation(obj))
     {
         organizationTree       = obj.Value;
         SysOrgTree.ItemsSource = organizationTree.Children;
     }
 }
Esempio n. 22
0
        /// <summary>
        /// Tests the data.
        /// </summary>
        /// <param name="connectionInfo">The connection info.</param>
        /// <param name="completed">The completed.</param>
        public void TestData(Connection connectionInfo, Action <bool, Exception> completed)
        {
            _testDataCompleted = completed;
            dsCtx = new AdminDatasourcesDomainContext();
            InvokeOperation <bool> testData = dsCtx.TestData(connectionInfo);

            testData.Completed += new EventHandler(testData_Completed);
        }
Esempio n. 23
0
        /// <summary>
        /// Gets columns from Domain Service
        /// </summary>
        /// <param name="DataSourceName"></param>
        /// <param name="TableName"></param>
        /// <param name="completed"></param>
        //public void GetColumns(string DataSourceName, string TableName, Action<List<EwavColumn>, Exception> completed)
        //{
        //    _completed = completed;
        //    LinearRegressionDomainContext linrCtx = new LinearRegressionDomainContext();
        //    InvokeOperation<List<EwavColumn>> linrCtxColumnResults = linrCtx.GetColumns(DataSourceName, TableName);
        //    linrCtxColumnResults.Completed += new EventHandler(linrCtxColumnResults_Completed);
        //}

        /// <summary>
        /// Gets the regression table results from Domain service
        /// </summary>
        /// <param name="DatasourceName"></param>
        /// <param name="TableName"></param>
        /// <param name="gadgetOptions"></param>
        /// <param name="columnNames"></param>
        /// <param name="inputDtoList"></param>
        /// <param name="completed"></param>
        public void GetRegressionResults(GadgetParameters gadgetOptions, List <string> columnNames, List <DictionaryDTO> inputDtoList, Action <LinRegressionResults, Exception> completed)
        {
            _rresultsCompleted = completed;
            LinearRegressionDomainContext          linrCtx           = new LinearRegressionDomainContext();
            InvokeOperation <LinRegressionResults> linrCtxRegResults = linrCtx.GetRegressionResult(gadgetOptions, columnNames, inputDtoList, ApplicationViewModel.Instance.EwavDatafilters, ApplicationViewModel.Instance.EwavDefinedVariables, ApplicationViewModel.Instance.AdvancedDataFilterString);

            linrCtxRegResults.Completed += new EventHandler(linrCtxRegResults_Completed);
        }
Esempio n. 24
0
        public void ReadAllUsersInMyOrg(int orgId, Action <DatatableBag, Exception> completed)
        {
            _readUsersCompleted = completed;
            canvasCtx           = new CanvasDomainContext();
            InvokeOperation <DatatableBag> readResults = canvasCtx.ReadAllUsersInMyOrg(orgId);

            readResults.Completed += new EventHandler(readResults_Completed);
        }
Esempio n. 25
0
        public void LoadCanvasForUserList(int UserId, Action <DatatableBag, Exception> completed)
        {
            _userListLoadCompleted = completed;
            canvasCtx = new CanvasDomainContext();
            InvokeOperation <DatatableBag> results = canvasCtx.LoadCanvasListForUser(UserId);

            results.Completed += new EventHandler(results_Completed);
        }
Esempio n. 26
0
 private void CancelUploadCallback(InvokeOperation <Guid> io)
 {
     if (!io.HasError)
     {
         App.Session.Add(SessionKey.JobCode, io.Value);
         NavigationService.Navigate("/ParticipantMI/JobQueueMonitor");
     }
 }
Esempio n. 27
0
        public void GetCombinedFrequencyResults(EwavCombinedFrequencyGadgetParameters combinedParameters, string groupVar, GadgetParameters gadgetParameters, IEnumerable <EwavDataFilterCondition> ewavDataFilters, List <EwavRule_Base> rules, string filterString, Action <DatatableBag, Exception> completed)
        {
            _freqCompleted = completed;
            freqCtx        = new CombinedFrequencyDomainContext();
            InvokeOperation <DatatableBag> freqResults = freqCtx.GenerateCombinedFrequency(combinedParameters, groupVar, gadgetParameters, ewavDataFilters, rules, filterString);

            freqResults.Completed += new EventHandler(freqTableResults_Completed);
        }
Esempio n. 28
0
        /// <summary>
        /// Tests the DB connection.
        /// </summary>
        /// <param name="con">The con.</param>
        /// <param name="completed">The completed.</param>
        public void TestDBConnection(Connection con, Action <bool, Exception> completed)
        {
            _testDBCompleted = completed;
            dsCtx            = new AdminDatasourcesDomainContext();
            InvokeOperation <bool> testDBResult = dsCtx.TestDBConnection(con);

            testDBResult.Completed += new EventHandler(testDBResult_Completed);
        }
Esempio n. 29
0
        public void GetBinomialStatCalc(string txtNumerator, string txtObserved, string txtExpected, Action <Web.Services.BinomialStatCalcDTO, Exception> completed)
        {
            this.completed = completed;
            dCtx           = new BinomialDomainContext();
            InvokeOperation <BinomialStatCalcDTO> dResults = dCtx.GenerateBinomial(txtNumerator, txtObserved, txtExpected);

            dResults.Completed += new EventHandler(dResults_Completed);
        }
Esempio n. 30
0
        /// <summary>
        /// Updates the specified dto.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <param name="completed">The completed.</param>
        public void Update(DTO.DatasourceDto dto, Action <bool, Exception> completed)
        {
            _updCompleted = completed;
            dsCtx         = new AdminDatasourcesDomainContext();
            InvokeOperation <bool> updResult = dsCtx.UpdateDatasource(dto);

            updResult.Completed += new EventHandler(updResult_Completed);
        }
Esempio n. 31
0
        /// <summary>
        /// Creates a new <see cref="LoginRegistrationWindow"/> instance.
        /// </summary>
        public PrintAddressStickers()
        {
            InitializeComponent();
            var ctx = new RadiographyContext();

            operation            = ctx.GetAddressStickerTemplates();
            operation.Completed += new EventHandler(operation_Completed);
        }
Esempio n. 32
0
        public void GetColumns(string DataSourceName, string TableName, Action <List <BAL.EwavColumn>, Exception> completed)
        {
            _completed = completed;
            FrequencyDomainContext freqCtx = new FrequencyDomainContext();
            InvokeOperation <List <EwavColumn> > freqColumnResults = freqCtx.GetColumns(DataSourceName, TableName);

            freqColumnResults.Completed += new EventHandler(freqColumnResults_Completed);
        }
Esempio n. 33
0
 private void GetPharmacyID()
 {
     _inv = _pharmacyDomainContext.GetPharmacyID(_authorizationService.User.Id);
     _inv.Completed += (s, e) =>
     {
         SelectedPharmacy = _inv.Value + "";
         this.LoadPharmacies();
     };
 }
Esempio n. 34
0
		private void OnSendEmailCompleted(InvokeOperation operation)
		{
			x_OK.IsEnabled = true;
			string errorStatus = operation.CheckErrorStatus();
			if (errorStatus != null)
			{
				x_ErrorStatus.Text = errorStatus;
				return;
			}

			x_ErrorStatus.Text = null;
			DialogResult = MessageBoxResult.OK;
		}
Esempio n. 35
0
 private void CallBack_GetMessage(InvokeOperation<string> getMessageOperation)
 {
     if (getMessageOperation.HasError)
     {
         MessageBox.Show(String.Format("Error found!\n {0}.\nStackTrace\n{1}", getMessageOperation.Error.Message, getMessageOperation.Error.StackTrace));
     }
     else
     {
         this.Message.Text = String.Format("{0}The server response is:\t\n{1}\n{2}",
             this.Message.Text,
             getMessageOperation.Value,
             string.Format("[Client Got its Callback At]{0}", DateTime.Now));
     }
 }
Esempio n. 36
0
        /// <summary>
        /// If a class needs the timezones and the list is not already populated they will call the RIA method to populate the list.
        /// </summary>
        public static void GetTimeZonesCompleted(InvokeOperation<IEnumerable<string>> op)
        {
            if (op.HasError)
            {
                op.MarkErrorAsHandled();
            }
            else
            {
                TimeZones = op.Value.ToList();

                if (op.UserState != null && op.UserState is Action)
                {
                    ((Action)op.UserState)();
                }
            }
        }
Esempio n. 37
0
 private void AccountSignupOperation_Completed(InvokeOperation<CreateAccountStatus> operation)
 {
     if (!operation.IsCanceled)
     {
         if (operation.HasError)
         {
             ErrorWindow.CreateNew(operation.Error);
             operation.MarkErrorAsHandled();
         }
         else if (operation.Value == CreateAccountStatus.Success)
         {
             MessageBox.Show("Success!");
         }
         else
         {
             MessageBox.Show("Failure! " + operation.Value.ToString());
         }
     }
 }
Esempio n. 38
0
 /// <summary>
 /// Callback method for ApproveCertificateList
 /// </summary>
 /// <param name="operation">Operation</param>
 private void ApproveCertificateListCompleted(InvokeOperation<List<ValidationMessage>> operation)
 {
     HandleInvokeOperation(operation, delegate
     {
         List<ValidationMessage> messages = operation.Value;
         showMultipleActionResult(messages, Strings.ActionTypeApproved);
         Refresh();
     });
 }
Esempio n. 39
0
 /// <summary>
 /// Method is executed when UnCloseCertificateList is completed
 /// </summary>
 /// <param name="operation"></param>
 private void UnCloseCertificateListCompleted(InvokeOperation<List<ValidationMessage>> operation)
 {
     HandleInvokeOperation(operation, () =>
     {
         List<ValidationMessage> messages = operation.Value;
         showMultipleActionResult(messages, Strings.ActionTypeUnclosed);
         Refresh();
     });
 }
Esempio n. 40
0
 /// <summary>
 /// Callback method of PublisUnpublishCertificateList
 /// </summary>
 /// <param name="operation">Operation</param>
 private void PublishUnplishCertificateCompleted(InvokeOperation<List<ValidationMessage>> operation)
 {
     HandleInvokeOperation(operation, delegate
     {
         bool isPublished = bool.Parse(operation.UserState.ToString());
         List<ValidationMessage> messages = operation.Value;
         showMultipleActionResult(messages, isPublished ? Strings.ActionTypePublished : Strings.ActionTypeUnpublished);
         Refresh();
     });
 }
Esempio n. 41
0
 /// <summary>
 /// On done getting document
 /// </summary>
 /// <param name="operation">Operation result</param>
 private void GetDocumentDone(InvokeOperation<Document> operation)
 {
     HandleInvokeOperation(operation, () =>
     {
         CertificateViewModel certificateViewModel = new CertificateViewModel();
         certificateViewModel.Initialize(_context);
         certificateViewModel.Certificate = operation.UserState as Certificate;
         certificateViewModel.DisplayCertificateFile(operation.Value);
     });
 }
Esempio n. 42
0
		private void OnResetPasswordCompleted(InvokeOperation<bool> operation)
		{
			x_Reset.IsEnabled = true;
			string errorStatus = operation.CheckErrorStatus();
			if (errorStatus != null)
			{
				x_ResetErrorStatus.Text = errorStatus;
				x_ResetErrorStatus.Visibility = Visibility.Visible;
				return;
			}

			App.Model.UserServices.Login(ResetUserName, ResetPassword, true/*isPersistent*/, OnResetPasswordCompletedStep2, null/*userState*/);

			x_ResetErrorStatus.Text = null;
			x_ResetErrorStatus.Visibility = Visibility.Collapsed;
			DialogResult = MessageBoxResult.OK;
		}
 private void ProductProvinceGroup_Deleted(InvokeOperation op)
 {
     if (op.Error == null)
     {
         SaveAll(GroupingNameTbx.Text, _groups, GetSelectedProductsIds());
     }
 }
Esempio n. 44
0
		private void OnRegisterCompletedStep4(InvokeOperation operation)
		{
			string errorStatus = operation.CheckErrorStatus();
			if (errorStatus != null)
			{
				MessageBoxEx.ShowError("Register account", errorStatus, null);
				return;
			}
		}
Esempio n. 45
0
 private void OnInvokeDownloadFileCompleted(InvokeOperation<string> invokeOperation)
 {
     var guid = (string)invokeOperation.UserState;
     var fileName = invokeOperation.Value;
     var uri = new Uri(Application.Current.Host.Source, new Uri("../temp/" + guid + "/" + fileName, UriKind.Relative));
     System.Windows.Browser.HtmlPage.Window.Navigate(uri, "_blank");
     _laboratoryDomainContext.DeleteDirectory(guid);
 }
 public InvokeOperationEventArgs(InvokeOperation invokeOp)
     : base(null)
 {
     InvokeOp = invokeOp;
 }
Esempio n. 47
0
 /// <summary>
 /// Completion handler for the registration operation. If there was an error, an
 /// <see cref="ErrorWindow"/> is displayed to the user. Otherwise, this triggers
 /// a login operation that will automatically log in the just registered user.
 /// </summary>
 private void RegistrationOperation_Completed(InvokeOperation<CreateUserStatus> operation)
 {
     if (!operation.IsCanceled)
     {
         if (operation.HasError)
         {
             ErrorWindow.CreateNew(operation.Error);
             operation.MarkErrorAsHandled();
         }
         else if (operation.Value == CreateUserStatus.Success)
         {
             this.DialogResult = true;
         }
         else if (operation.Value == CreateUserStatus.DuplicateUserName)
         {
             this.registrationData.ValidationErrors.Add(new ValidationResult(ErrorResources.CreateUserStatusDuplicateUserName, new string[] { "UserName" }));
         }
         else if (operation.Value == CreateUserStatus.DuplicateEmail)
         {
             this.registrationData.ValidationErrors.Add(new ValidationResult(ErrorResources.CreateUserStatusDuplicateEmail, new string[] { "Email" }));
         }
         else
         {
             ErrorWindow.CreateNew(ErrorResources.ErrorWindowGenericError);
         }
     }
 }
Esempio n. 48
0
		private void OnValidateResetPasswordCompleted(InvokeOperation<string> operation)
		{
			string errorStatus = operation.CheckErrorStatus();
			string userName = (errorStatus != null ? null : operation.Value);
			if (userName != null)
			{
				AuthenticationDialog dialog = new AuthenticationDialog(AuthenticationDialog.DialogType.ResetPassword);
				dialog.ResetUserName = userName;
				dialog.ResetPasswordCode = m_ResetPasswordCode;
			}
			else
			{
				AuthenticationDialog dialog = new AuthenticationDialog(AuthenticationDialog.DialogType.RecoverSignIn);
				dialog.RecoverErrorStatus = "Sorry but the link you clicked on is no longer valid.  Enter your email address again and we will send you a new recovery email.";
			}
		}
Esempio n. 49
0
		private void OnDeleteCompleted(InvokeOperation<bool> operation)
		{
			x_Delete.IsEnabled = true;
			string errorStatus = operation.CheckErrorStatus();
			bool deleted = (errorStatus == null && operation.Value == true);
			if (!deleted)
			{
				x_DeleteErrorStatus.Text = (errorStatus != null ? errorStatus : g_AccountNotDeleted);
				x_DeleteErrorStatus.Visibility = Visibility.Visible;
				return;
			}

			App.Model.UserServices.Logout(null, null);
			x_DeleteErrorStatus.Text = null;
			x_DeleteErrorStatus.Visibility = Visibility.Collapsed;
			DialogResult = (deleted ? MessageBoxResult.OK : MessageBoxResult.Cancel);
		}
Esempio n. 50
0
		private void OnChangePasswordCompleted(InvokeOperation<bool> operation)
		{
			x_Change.IsEnabled = true;
			string errorStatus = operation.CheckErrorStatus();
			bool changed = (errorStatus == null && operation.Value == true);
			if (!changed)
			{
				x_ChangeErrorStatus.Text = (errorStatus != null ? errorStatus : g_PasswordNotChanged);
				x_ChangeErrorStatus.Visibility = Visibility.Visible;
				return;
			}

			x_ChangeErrorStatus.Text = null;
			x_ChangeErrorStatus.Visibility = Visibility.Collapsed;
			x_ChangeCurrentPassword.Password = "";
			x_ChangeNewPassword.Password = "";
			DialogResult = (changed ? MessageBoxResult.OK : MessageBoxResult.Cancel);
		}
Esempio n. 51
0
        private void UploadCallback(InvokeOperation<int> result)
        {
            var file = result.UserState as ImageUploadModel;
            if (file.IsDeleted)
            {
                return;
            }
            if (file.IsDeleting)
            {
                Delete(file);
                return;
            }

            if (!result.HasError && result.Value == 0)
            {
                var finished = Math.Min(BUFFER_SIZE, file.FileSize - file.Ready);
                file.Ready += finished;
                TotalReady += finished;
                Upload(file);
            }
            else
            {
                file.IsFailed = true;
                TotalReady += file.FileSize - file.Ready;
            }

            var failedCount = _items.Count(f => f.IsFailed);
            if (TotalReady == TotalSize)
            {
                Result = "图片都已上传成功!";
                ResultBrush = new SolidColorBrush(Colors.Blue);
                _isCompleted = true;
            }
            else if (failedCount == _items.Count)
            {
                Result = _items.Count == 1 ? "图片上传失败" : "图片全部上传失败!";
                ResultBrush = new SolidColorBrush(Colors.Red);
                _isCompleted = true;
            }
            else if(_items.Count(f => !f.IsCompleted && !f.IsFailed) == 0)
            {
                Result = string.Format("成功上传{0}张,失败{1}张,中途取消{2}张", _items.Count - failedCount, failedCount, _removeCount);
                ResultBrush = new SolidColorBrush(Colors.Red);
                _isCompleted = true;
            }
        }
Esempio n. 52
0
 /// <summary>
 /// Completion handler for the registration operation. If there was an error, an
 /// <see cref="ErrorWindow"/> is displayed to the user. Otherwise, this triggers
 /// a login operation that will automatically log in the just registered user.
 /// </summary>
 private void RegistrationOperation_Completed(InvokeOperation<CreateUserStatus> operation)
 {
     if (!operation.IsCanceled)
     {
         if (operation.HasError)
         {
             ErrorWindow.CreateNew(operation.Error);
             operation.MarkErrorAsHandled();
         }
         else if (operation.Value == CreateUserStatus.Success)
         {
             this.registrationData.CurrentOperation = WebContext.Current.Authentication.Login(this.registrationData.ToLoginParameters(), this.LoginOperation_Completed, null);
             this.parentWindow.AddPendingOperation(this.registrationData.CurrentOperation);
         }
         else if (operation.Value == CreateUserStatus.DuplicateUserName)
         {
             this.registrationData.ValidationErrors.Add(new ValidationResult(ErrorResources.CreateUserStatusDuplicateUserName, new string[] { "UserName" }));
         }
         else if (operation.Value == CreateUserStatus.DuplicateEmail)
         {
             this.registrationData.ValidationErrors.Add(new ValidationResult(ErrorResources.CreateUserStatusDuplicateEmail, new string[] { "Email" }));
         }
         else
         {
             ErrorWindow.CreateNew(ErrorResources.ErrorWindowGenericError);
         }
     }
 }
Esempio n. 53
0
		private void OnDeleteUserCompleted(InvokeOperation<bool> operation)
		{
			x_Signin.IsEnabled = true;
			string errorStatus = operation.CheckErrorStatus();
			bool deleted = (errorStatus == null && operation.Value == true);
			x_SignInErrorStatus.Text = string.Format("User account '{0}' was{1} deleted", SignInUserName, (deleted ? "" : " NOT"));
			x_SignInErrorStatus.Visibility = Visibility.Visible;
		}
 private void LoadResultsIntoGrid(InvokeOperation<IEnumerable<Task>> op)
 {
     this.TaskGrid.ItemsSource = op.Value;
 }
Esempio n. 55
0
        /// <summary>
        /// Completed method for GetAllCertificates
        /// </summary>
        /// <param name="operation">Operation result</param>
        private void ExportCertificatesToExcelCompleted(InvokeOperation<string> operation)
        {
            HandleInvokeOperation(operation, delegate
            {
                string path= operation.Value.ToString();
                IsBusy = false;
                DownloadCertificateExcelFile(path);

            });
        }
Esempio n. 56
0
		private void OnRecoverCompleted(InvokeOperation operation)
		{
			x_Recover.IsEnabled = true;
			string errorStatus = operation.CheckErrorStatus();
			if (errorStatus != null)
			{
				x_RecoverErrorStatus.Text = errorStatus;
				x_RecoverErrorStatus.Visibility = Visibility.Visible;
				return;
			}

			x_RecoverErrorStatus.Text = null;
			x_RecoverErrorStatus.Visibility = Visibility.Collapsed;
			base.Closed += OnRecoverDialogClosed;
			DialogResult = MessageBoxResult.OK;
		}
Esempio n. 57
0
 /// <summary>
 /// Call back method for SynchronizeWithComdivList
 /// </summary>
 /// <param name="operation"></param>
 private void CompletedExecuteSendComdivCommand(InvokeOperation<List<ValidationMessage>> operation)
 {
     HandleInvokeOperation(operation, () =>
     {
         List<ValidationMessage> messages = operation.Value;
         showMultipleActionResult(messages, Strings.ActionTypeSyncComdiv);
         Refresh();
     });
 }
Esempio n. 58
0
        /// <summary>
        /// Execute when a user was been validated
        /// </summary>
        /// <param name="operation">Operation result</param>
        private void UserAlreadyExistCompleted(InvokeOperation operation)
        {
            HandleInvokeOperation(operation, () =>
            {
                if ((bool)operation.Value == true)
                {
                    AlertDisplay(Strings.UserAlreadyExists);
                    return;
                }

                if (_user.EntityState == EntityState.Detached)
                {
                    _context.UserProfiles.Add(_user);
                    _user.UserInRoles.Add(new UserInRole { RoleId = _roleIdSelected.Value });
                }
                else
                    if (!_user.UserInRoles.Any(x => x.RoleId == _roleIdSelected))
                    {
                        foreach (var role in _user.UserInRoles)
                        {
                            _user.UserInRoles.Remove(role);
                            _context.UserInRoles.Remove(role);
                        }
                        _context.UserInRoles.Add(new UserInRole { UserId = _user.UserId, RoleId = _roleIdSelected.Value });
                    }
                _context.SubmitChanges(SaveCompleted, null);

            });
        }
 public InvokeOperationEventArgs(InvokeOperation invokeOp, Exception ex)
     : base(ex)
 {
     InvokeOp = invokeOp;
 }
Esempio n. 60
0
 /// <summary>
 /// Callback method for GetUserInformationByEmail
 /// </summary>
 /// <param name="operation"></param>
 private void GetUserInformationByEmailCompleted(InvokeOperation<UserProfile> operation)
 {
     HandleInvokeOperation(operation, delegate
     {
         //set the information
         if (operation.Value != null)
         {
             User.FirstName = operation.Value.FirstName;
             User.LastName = operation.Value.LastName;
             User.UserName = operation.Value.UserName;
             OnPropertyChanged("User");
             OnPropertyChanged("UserName");
         }
         else
         {
             // When the user is not found we don't need to blank any field, just display an alert message.
             AlertDisplay(Strings.UserNotFoundByEmail);
         }
         IsBusy = false;
     });
 }