public MainWindow()
        {
            this.InitializeComponent();

            Transaction.RunVoid(() =>
            {
                STextBox word           = new STextBox(string.Empty);
                CellLoop <bool> enabled = new CellLoop <bool>();
                SButton button          = new SButton(enabled)
                {
                    Content = "look up"
                };
                Stream <string> sWord = button.SClicked.Snapshot(word.Text);
                IsBusy <string, IMaybe <string> > ib = new IsBusy <string, IMaybe <string> >(Lookup, sWord);
                Stream <string> sDefinition          = ib.SOut.Map(o => o.Match(v => v, () => "ERROR!"));
                Cell <string> definition             = sDefinition.Hold(string.Empty);
                Cell <string> output = definition.Lift(ib.Busy, (def, bsy) => bsy ? "Looking up..." : def);
                enabled.Loop(ib.Busy.Map(b => !b));
                STextBox outputArea = new STextBox(Operational.Value(output), string.Empty, enabled)
                {
                    TextWrapping = TextWrapping.Wrap, AcceptsReturn = true
                };
                this.TextBoxPlaceholder.Child = word;
                this.ButtonPlaceholder.Child  = button;
                this.OutputPlaceholder.Child  = outputArea;
            });
        }
Exemple #2
0
        public Action SaveCommand()
        {
            if (_saveCommand == null)
            {
                _saveCommand = delegate()
                {
                    List <QuoteDetail> dirtyCollection = new List <QuoteDetail>();
                    // Add new/changed items
                    foreach (Entity item in this.Lines.Data)
                    {
                        if (item != null && item.EntityState != EntityStates.Unchanged)
                        {
                            dirtyCollection.Add((QuoteDetail)item);
                        }
                    }
                    // Add deleted items
                    if (this.Lines.DeleteData != null)
                    {
                        foreach (Entity item in this.Lines.DeleteData)
                        {
                            if (item.EntityState == EntityStates.Deleted)
                            {
                                dirtyCollection.Add((QuoteDetail)item);
                            }
                        }
                    }

                    int itemCount = dirtyCollection.Count;
                    if (itemCount == 0)
                    {
                        return;
                    }

                    bool confirmed = Script.Confirm(String.Format("Are you sure that you want to save the {0} quote lines in the Grid?", itemCount));
                    if (!confirmed)
                    {
                        return;
                    }

                    IsBusy.SetValue(true);

                    List <string> errorMessages = new List <string>();
                    SaveNextRecord(dirtyCollection, errorMessages, delegate()
                    {
                        if (errorMessages.Count > 0)
                        {
                            Script.Alert("One or more records failed to save.\nPlease contact your System Administrator.\n\n" + errorMessages.Join(","));
                        }
                        if (Lines.DeleteData != null)
                        {
                            Lines.DeleteData.Clear();
                        }
                        Lines.Refresh();
                        IsBusy.SetValue(false);
                    });
                };
            }
            return(_saveCommand);
        }
Exemple #3
0
 private void ReportError(Exception ex)
 {
     Script.Literal("debugger");
     Script.Alert("There was a problem saving. Please contact your system administrator.\n\n" + ex.Message);
     IsBusy.SetValue(false);
     JobsViewModel.Reset();
     JobsViewModel.Refresh();
 }
Exemple #4
0
        public Action DeleteCommand()
        {
            if (_deleteCommand == null)
            {
                _deleteCommand = delegate()
                {
                    // Delete all selected jobs in grid
                    SelectedRange[] ranges = JobsViewModel.GetSelectedRows();
                    List <int>      rows   = DataViewBase.RangesToRows(ranges);

                    bool confirmed = Script.Confirm(String.Format("Are you sure you want to delete these {0} job(s)?", rows.Count));
                    if (!confirmed)
                    {
                        return;
                    }



                    IsBusy.SetValue(true);
                    DelegateItterator.CallbackItterate(delegate(int index, Action nextCallback, ErrorCallBack errorCallBack)
                    {
                        dev1_ScheduledJob job = (dev1_ScheduledJob)this.JobsViewModel.GetItem(rows[index]);
                        // First delete the scheduled jobs associated
                        DeleteBulkDeleteJobs(job.dev1_ScheduledJobId, delegate(){
                            OrganizationServiceProxy.BeginDelete(dev1_ScheduledJob.EntityLogicalName, job.dev1_ScheduledJobId, delegate(object result)
                            {
                                try
                                {
                                    OrganizationServiceProxy.EndDelete(result);
                                    IsBusyProgress.SetValue((index / rows.Count) * 100);
                                    nextCallback();
                                }
                                catch (Exception ex)
                                {
                                    errorCallBack(ex);
                                }
                            });
                        });
                    },
                                                       rows.Count,
                                                       delegate()
                    {
                        // Completed
                        IsBusy.SetValue(false);
                        JobsViewModel.Reset();
                        JobsViewModel.Refresh();
                    },
                                                       delegate(Exception ex)
                    {
                        // Error
                        ReportError(ex);
                    });
                };
            }
            return(_deleteCommand);
        }
 public void Reset()
 {
     IsBusy.Reset();
     IsNotBusy.Reset();
     CurrentBranchUpdated.Reset();
     GitAheadBehindStatusUpdated.Reset();
     GitStatusUpdated.Reset();
     GitLocksUpdated.Reset();
     GitLogUpdated.Reset();
     LocalBranchesUpdated.Reset();
     RemoteBranchesUpdated.Reset();
 }
Exemple #6
0
        public void SaveCommand()
        {
            bool contactIsValid = ((IValidatedObservable)this).IsValid();

            if (!contactIsValid)
            {
                ((IValidatedObservable)this).Errors.ShowAllMessages(true);
                return;
            }

            IsBusy.SetValue(true);

            Contact contact = new Contact();

            string accountId = string.Empty;

            if (ParentPage.Ui != null)
            {
                string guid = ParentPage.Data.Entity.GetId();
                if (guid != null)
                {
                    accountId = guid.Replace("{", "").Replace("}", "");
                }
            }


            //Asociamos los datos de la entidad contacto
            contact.ParentCustomerId           = new EntityReference(new Guid(accountId), "account", null);
            contact.CreditLimit                = CreditLimit.GetValue();
            contact.firstname                  = FirstName.GetValue();
            contact.LastName                   = LastName.GetValue();
            contact.PreferredContactMethodCode = PreferredContactMethodCode.GetValue();

            OrganizationServiceProxy.BeginCreate(contact, delegate(object state) {
                try
                {
                    ContactId.SetValue(OrganizationServiceProxy.EndCreate(state));
                    OnSaveComplete(null);
                    ((IValidatedObservable)this).Errors.ShowAllMessages(false);
                }
                catch (Exception ex)
                {
                    OnSaveComplete(ex.Message);
                }
                finally
                {
                    IsBusy.SetValue(false);
                    AddNewVisible.SetValue(false);
                }
            });
        }
        public Action SaveCommand()
        {
            if (_saveCommand == null)
            {
                _saveCommand = delegate()
                {
                    List <Contact> dirtyCollection = new List <Contact>();
                    foreach (Entity item in this.Contacts.Data)
                    {
                        if (item != null && item.EntityState != EntityStates.Unchanged)
                        {
                            dirtyCollection.Add((Contact)item);
                        }
                    }
                    int itemCount = dirtyCollection.Count;
                    if (itemCount == 0)
                    {
                        return;
                    }

                    bool confirmed = Script.Confirm(String.Format("Are you sure that you want to save the {0} records edited in the Grid?", itemCount));
                    if (!confirmed)
                    {
                        return;
                    }

                    IsBusy.SetValue(true);

                    string errorMessage = "";
                    SaveNextRecord(dirtyCollection, errorMessage, delegate()
                    {
                        if (errorMessage.Length > 0)
                        {
                            Script.Alert("One or more records failed to save.\nPlease contact your System Administrator.\n\n" + errorMessage);
                        }
                        else
                        {
                            Script.Alert("Save Complete!");
                        }
                        Contacts.Refresh();
                        IsBusy.SetValue(false);
                    });
                };
            }
            return(_saveCommand);
        }
Exemple #8
0
    public void SelectModel (TEntityAction action)
    {
      if (action.NotNull ()) {
        // DO NOT CHANGE THIS ORDER
        ExtensionModel.SelectModel (action);
        ComponentModel.SelectModel (action);

        IsBusy = action.ModelAction.ComponentStatusModel.Busy;

        BusyVisibility = IsBusy ? Visibility.Visible : Visibility.Collapsed;
        IsComponentModelEnabled = IsBusy.IsFalse ();

        Id = action.Id;

        IsEnabledApply = string.IsNullOrEmpty (Name.Trim ()).IsFalse ();
        IsEnabledCancel = Id.NotEmpty ();
      }
    }
        public void SaveCommand()
        {
            bool isValid = ((IValidatedObservable)this).IsValid();

            if (!isValid)
            {
                ((IValidatedObservable)this).Errors.ShowAllMessages(true);
                return;
            }
            IsBusy.SetValue(true);
            AddNewVisible.SetValue(false);

            Contact contact = new Contact();

            contact.FirstName                  = FirstName.GetValue();
            contact.LastName                   = LastName.GetValue();
            contact.ParentCustomerId           = ParentCustomerId.GetValue();
            contact.PreferredContactMethodCode = PreferredContactMethodCode.GetValue();
            contact.CreditLimit                = CreditLimit.GetValue();

            OrganizationServiceProxy.BeginCreate(contact, delegate(object state)
            {
                try
                {
                    ContactId.SetValue(OrganizationServiceProxy.EndCreate(state));
                    OnSaveComplete(null);
                    FirstName.SetValue(null);
                    LastName.SetValue(null);
                    PreferredContactMethodCode.SetValue(null);
                    CreditLimit.SetValue(null);
                    ((IValidatedObservable)this).Errors.ShowAllMessages(false);
                }
                catch (Exception ex)
                {
                    OnSaveComplete(ex.Message);
                }
                finally
                {
                    IsBusy.SetValue(false);
                }
            });
        }
 public void WaitForNotBusy(int seconds = 1)
 {
     IsBusy.WaitOne(TimeSpan.FromSeconds(seconds));
     IsNotBusy.WaitOne(TimeSpan.FromSeconds(seconds));
 }
Exemple #11
0
        public Action SaveCommand()
        {
            if (_saveCommand == null)
            {
                _saveCommand = delegate()
                {
                    bool confirmed = Script.Confirm(String.Format("Are you sure save these sessions?"));
                    if (!confirmed)
                    {
                        return;
                    }

                    try
                    {
                        IsBusy.SetValue(true);
                        IsBusyProgress.SetValue(0);
                        IsBusyMessage.SetValue("Saving...");
                        // Create a an array of sessions to be saved
                        List <dev1_session> editedSessions = SessionDataView.GetEditedSessions();


                        DelegateItterator.CallbackItterate(delegate(int index, Action nextCallback, ErrorCallBack errorCallBack)
                        {
                            dev1_session session = editedSessions[index];
                            IsBusyProgress.SetValue((index / editedSessions.Count) * 100);
                            // Create/Update the session
                            if (session.dev1_sessionId == null)
                            {
                                OrganizationServiceProxy.BeginCreate(session, delegate(object result)
                                {
                                    IsBusyProgress.SetValue((index / editedSessions.Count) * 100);
                                    try
                                    {
                                        session.dev1_sessionId = OrganizationServiceProxy.EndCreate(result);
                                        session.EntityState    = EntityStates.Unchanged;
                                        session.RaisePropertyChanged("EntityState");
                                        nextCallback();
                                    }
                                    catch (Exception ex)
                                    {
                                        // TODO: Mark error row
                                        Script.Alert(ex.Message);
                                        nextCallback();
                                    }
                                });
                            }
                            else
                            {
                                OrganizationServiceProxy.BeginUpdate(session, delegate(object result)
                                {
                                    try
                                    {
                                        OrganizationServiceProxy.EndUpdate(result);
                                        session.EntityState = EntityStates.Unchanged;
                                        session.RaisePropertyChanged("EntityState");
                                        nextCallback();
                                    }
                                    catch (Exception ex)
                                    {
                                        // TODO: Mark error row
                                        Script.Alert(ex.Message);
                                        nextCallback();
                                    }
                                });
                            }
                        },
                                                           editedSessions.Count,
                                                           delegate()
                        {
                            // Completed
                            IsBusyProgress.SetValue(100);
                            IsBusy.SetValue(false);
                        },
                                                           delegate(Exception ex)
                        {
                            // Error
                            ReportError(ex);
                        });
                    }
                    catch (Exception ex)
                    {
                        ReportError(ex);
                    }
                };
            }
            return(_saveCommand);
        }
Exemple #12
0
 private void ReportError(Exception ex)
 {
     Script.Literal("debugger");
     Script.Alert("There was a problem with your request. Please contact your system administrator.\n\n" + ex.Message);
     IsBusy.SetValue(false);
 }
Exemple #13
0
        public Action DeleteCommand()
        {
            if (_deleteCommand == null)
            {
                _deleteCommand = delegate()
                {
                    List <int> selectedRows = DataViewBase.RangesToRows(this.SessionDataView.GetSelectedRows());
                    if (selectedRows.Count == 0)
                    {
                        return;
                    }

                    bool confirmed = Script.Confirm(String.Format("Are you sure you want to delete the {0} selected sessions?", selectedRows.Count));
                    if (!confirmed)
                    {
                        return;
                    }


                    IsBusyMessage.SetValue("Deleting Sessions...");
                    IsBusyProgress.SetValue(0);
                    IsBusy.SetValue(true);

                    // Get each item to remove
                    List <dev1_session> itemsToDelete = new List <dev1_session>();
                    for (int i = 0; i < selectedRows.Count; i++)
                    {
                        itemsToDelete.Add((dev1_session)this.SessionDataView.GetItem(i));
                    }
                    DelegateItterator.CallbackItterate(delegate(int index, Action nextCallback, ErrorCallBack errorCallBack)
                    {
                        dev1_session session = itemsToDelete[index];
                        IsBusyProgress.SetValue((index / selectedRows.Count) * 100);
                        OrganizationServiceProxy.BeginDelete(session.LogicalName, session.dev1_sessionId, delegate(object result)
                        {
                            try
                            {
                                OrganizationServiceProxy.EndDelete(result);
                                this.SessionDataView.RemoveItem(session);
                                this.SessionDataView.Refresh();
                                nextCallback();
                            }
                            catch (Exception ex)
                            {
                                Script.Alert(ex.Message);
                                nextCallback();
                            }
                        });
                    },
                                                       selectedRows.Count,
                                                       delegate()
                    {
                        // Complete
                        IsBusyProgress.SetValue(100);
                        IsBusy.SetValue(false);
                        SessionDataView.Refresh();
                        Days.ReCalculate();
                    },
                                                       delegate(Exception ex)
                    {
                        ReportError(ex);
                    }
                                                       );
                };
            }
            return(_deleteCommand);
        }
Exemple #14
0
        public void UpdatePerceptions(RolePlayCharacterAsset rpc)
        {
            /*
             * Find every InSight, InInventory, and IsEquipped belief and set them to false
             * */
            CleanBeliefs(rpc);

            /*
             * Update the KB with the new beliefs
             * */
            string bv = rpc.GetBeliefValue("Hunger(" + rpc.CharacterName.ToString() + ")");

            if (bv == null || !bv.Equals(Hunger.ToString()))
            {
                Debug.WriteLine("Hunger: " + bv + " -> " + Hunger.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Hunger(" + rpc.CharacterName.ToString() + ")", Hunger.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Health(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Health.ToString()))
            {
                Debug.WriteLine("Health: " + bv + " -> " + Health.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Health(" + rpc.CharacterName.ToString() + ")", Health.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Sanity(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Sanity.ToString()))
            {
                Debug.WriteLine("Sanity: " + bv + " -> " + Sanity.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Sanity(" + rpc.CharacterName.ToString() + ")", Sanity.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsFreezing(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsFreezing.ToString()))
            {
                Debug.WriteLine("IsFreezing: " + bv + " -> " + IsFreezing.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsFreezing(" + rpc.CharacterName.ToString() + ")", IsFreezing.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsOverheating(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsOverheating.ToString()))
            {
                Debug.WriteLine("IsOverheating: " + bv + " -> " + IsOverheating.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsOverheating(" + rpc.CharacterName.ToString() + ")", IsOverheating.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Moisture(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Moisture.ToString()))
            {
                Debug.WriteLine("Moisture: " + bv + " -> " + Moisture.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Moisture(" + rpc.CharacterName.ToString() + ")", Moisture.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Temperature(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Temperature.ToString()))
            {
                Debug.WriteLine("Temperature: " + bv + " -> " + Temperature.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Temperature(" + rpc.CharacterName.ToString() + ")", Temperature.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsBusy(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsBusy.ToString()))
            {
                Debug.WriteLine("IsBusy: " + bv + " -> " + IsBusy.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsBusy(" + rpc.CharacterName.ToString() + ")", IsBusy.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("PosX(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(PosX.ToString()))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosX(" + rpc.CharacterName.ToString() + ")", PosX.ToString(), rpc.CharacterName.ToString()));
            }

            /*
             * The Y-axis is always equal to zero, no need to save it in the knowledge base
             * */
            //bv = rpc.GetBeliefValue("PosY(" + rpc.CharacterName.ToString() + ")");
            //if (bv == null || !bv.Equals(PosY.ToString()))
            //    rpc.Perceive(EventHelper.PropertyChange("PosY(" + rpc.CharacterName.ToString() + ")", PosY.ToString(), rpc.CharacterName.ToString()));

            bv = rpc.GetBeliefValue("PosZ(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(PosZ.ToString()))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosZ(" + rpc.CharacterName.ToString() + ")", PosZ.ToString(), rpc.CharacterName.ToString()));
            }


            foreach (Item i in Vision)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("InSight(" + i.GUID + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("InSight(" + i.GUID + ")", "True", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            foreach (Item i in ItemSlots)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("InInventory(" + i.GUID + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("InInventory(" + i.GUID + ")", "TRUE", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            foreach (EquippedItems i in EquipSlots)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("IsEquipped(" + i.GUID + "," + i.Slot + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("IsEquipped(" + i.GUID + "," + i.Slot + ")", "TRUE", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            rpc.Update();
        }
Exemple #15
0
        private void CreateBulkDeleteJobs(ScheduledJob job)
        {
            IsBusyMessage.SetValue("Creating new schedule...");
            IsBusyProgress.SetValue(0);
            // Convert bulk delete fetch into QueryExpression
            string fetchxml = "<fetch distinct='false' no-lock='false' mapping='logical'><entity name='lead'><attribute name='fullname' /><attribute name='statuscode' /><attribute name='createdon' /><attribute name='subject' /><attribute name='leadid' /><filter type='and'><condition attribute='ownerid' operator='eq-userid' /><condition attribute='statecode' operator='eq' value='0' /><condition attribute='address1_county' operator='eq' value='deleteme' /></filter><order attribute='createdon' descending='true' /></entity></fetch>";
            FetchXmlToQueryExpressionRequest convertRequest = new FetchXmlToQueryExpressionRequest();

            convertRequest.FetchXml = fetchxml;
            OrganizationServiceProxy.BeginExecute(convertRequest, delegate(object state)
            {
                FetchXmlToQueryExpressionResponse response = (FetchXmlToQueryExpressionResponse)OrganizationServiceProxy.EndExecute(state);

                List <BulkDeleteRequest> bulkDeleteRequests = new List <BulkDeleteRequest>();

                // If the recurrance is minutely, hourly, weekly we need to schedule multiple jobs
                if (job.Recurrance.GetValue().Value != RecurranceFrequencyNames.DAILY)
                {
                    DateTime startDate = DateTimeEx.UTCToLocalTimeFromSettings(job.StartDate.GetValue(), OrganizationServiceProxy.GetUserSettings());

                    DateInterval interval = DateInterval.Days;
                    int incrementAmount   = 1;
                    int dayInterval       = 1;
                    int recurranceCount   = 0;
                    int totalCount        = 0;
                    string freq           = RecurranceFrequencyNames.DAILY;

                    switch (job.Recurrance.GetValue().Value)
                    {
                    case RecurranceFrequencyNames.MINUTELY:
                        interval        = DateInterval.Minutes;
                        incrementAmount = job.RecurEvery.GetValue();
                        dayInterval     = 1;
                        recurranceCount = (60 * 24) / incrementAmount;
                        break;

                    case RecurranceFrequencyNames.HOURLY:
                        interval        = DateInterval.Hours;
                        incrementAmount = job.RecurEvery.GetValue();
                        dayInterval     = 1;
                        recurranceCount = 24 / incrementAmount;
                        break;

                    case RecurranceFrequencyNames.WEEKLY:
                    case RecurranceFrequencyNames.YEARLY:
                        // To schedule weekly, me must create a job per week day for the whole year, and set recurrance to every 365 days
                        // but this doesn't deal with leap years, so we can't do it!
                        throw new Exception("The selected schedule interval is currently not supported due to the limitation of bulk delete");
                    }

                    if (incrementAmount < 0)
                    {
                        throw new Exception("Invalid schedule");
                    }

                    // Increment in the recurrency frequence
                    for (int i = 0; i < recurranceCount; i++)
                    {
                        BulkDeleteRequest request     = new BulkDeleteRequest();
                        request.QuerySet              = response.Query.Replace(@"<d:anyType ", @"<d:anyType xmlns:e=""http://www.w3.org/2001/XMLSchema"" ");
                        request.SendEmailNotification = false;
                        request.StartDateTime         = startDate;
                        request.RecurrencePattern     = "FREQ=DAILY;INTERVAL=" + dayInterval.ToString();
                        request.JobName = "Scheduled Job " + i.Format("0000") + " " + job.ScheduledJobId.GetValue().Value;
                        ArrayEx.Add(bulkDeleteRequests, request);
                        startDate = DateTimeEx.DateAdd(interval, incrementAmount, startDate);
                    }
                }
                else
                {
                    // Just a single request
                    BulkDeleteRequest request     = new BulkDeleteRequest();
                    request.QuerySet              = response.Query.Replace(@"<d:anyType ", @"<d:anyType xmlns:e=""http://www.w3.org/2001/XMLSchema"" ");
                    request.SendEmailNotification = false;
                    request.StartDateTime         = job.StartDate.GetValue();
                    request.RecurrencePattern     = RecurrancePatternMapper.Serialise(job);
                    request.JobName = "Scheduled Job " + job.ScheduledJobId.GetValue().Value;
                    ArrayEx.Add(bulkDeleteRequests, request);
                }

                BatchCreateBulkDeleteJobs(bulkDeleteRequests, delegate()
                {
                    IsBusy.SetValue(false);
                    JobsViewModel.Reset();
                    JobsViewModel.Refresh();
                });
            });
        }
Exemple #16
0
        public Action SaveCommand()
        {
            if (_saveCommand == null)
            {
                _saveCommand = delegate()
                {
                    if (!((IValidatedObservable)SelectedJob).IsValid())
                    {
                        ValidationErrors validationResult = ValidationApi.Group(SelectedJob.GetValue());
                        validationResult.ShowAllMessages(true);
                        return;
                    }

                    bool confirmed = Script.Confirm(String.Format("Are you sure you want to save this schedule?"));
                    if (!confirmed)
                    {
                        return;
                    }


                    IsBusy.SetValue(true);
                    IsBusyProgress.SetValue(0);
                    IsBusyMessage.SetValue("Saving...");



                    // Create a new Scheduled Job
                    dev1_ScheduledJob jobToSave = new dev1_ScheduledJob();
                    ScheduledJob      job       = this.SelectedJob.GetValue();
                    jobToSave.dev1_Name         = job.Name.GetValue();
                    jobToSave.dev1_StartDate    = job.StartDate.GetValue();
                    jobToSave.dev1_WorkflowName = job.WorkflowId.GetValue().Name;

                    jobToSave.dev1_RecurrancePattern = RecurrancePatternMapper.Serialise(job);

                    if (job.ScheduledJobId.GetValue() == null)
                    {
                        // Create the schedule

                        OrganizationServiceProxy.BeginCreate(jobToSave, delegate(object createJobResponse)
                        {
                            try
                            {
                                job.ScheduledJobId.SetValue(OrganizationServiceProxy.EndCreate(createJobResponse));
                                CreateBulkDeleteJobs(job);
                            }
                            catch (Exception ex)
                            {
                                ReportError(ex);
                            }
                        });
                    }
                    else
                    {
                        jobToSave.dev1_ScheduledJobId = job.ScheduledJobId.GetValue();
                        // Update the schedule
                        OrganizationServiceProxy.BeginUpdate(jobToSave, delegate(object createJobResponse)
                        {
                            try
                            {
                                OrganizationServiceProxy.EndUpdate(createJobResponse);
                                DeleteBulkDeleteJobs(job.ScheduledJobId.GetValue(), delegate()
                                {
                                    // Create new jobs
                                    CreateBulkDeleteJobs(job);
                                });
                            }
                            catch (Exception ex)
                            {
                                ReportError(ex);
                            }
                        });
                    }
                };
            }

            return(_saveCommand);
        }
Exemple #17
0
        public MainPageViewModel(INavigationService navigationService)
            : base(navigationService)
        {
            Title = "HOME";

            ImageMarkerInfo.Subscribe(imageInfo =>
            {
                ImageMarkerPath.Value = null;
                ImageMarkerPath.Value = imageInfo.ImagePath;
            }).AddTo(this.Disposable);

            ImageNodeInfo.Subscribe(imageInfo =>
            {
                ImageNodePath.Value = null;
                ImageNodePath.Value = imageInfo.ImagePath;
            }).AddTo(this.Disposable);

            ChangeImageCommand = IsBusy.Inverse().ToAsyncReactiveCommand <string>();
            ChangeImageCommand.Subscribe(async(param) =>
            {
                IsBusy.Value  = true;
                var imagePath = await Common.GetImagePath();
                var imageInfo = new ImageInfo();

                if (param.Equals(MarkerStr))
                {
                    imageInfo.ImagePath   = File.Exists(imagePath) ? imagePath : ImageMarkerFileName;
                    imageInfo.IsAsset     = !File.Exists(imagePath);
                    ImageMarkerInfo.Value = imageInfo;
                }
                else if (param.Equals(NodeStr))
                {
                    imageInfo.ImagePath = File.Exists(imagePath) ? imagePath : ImageNodeFileName;
                    imageInfo.IsAsset   = !File.Exists(imagePath);
                    ImageNodeInfo.Value = imageInfo;
                }
                IsBusy.Value = false;
            }).AddTo(this.Disposable);

            TakePhotoCommand = IsBusy.Inverse().ToAsyncReactiveCommand <string>();
            TakePhotoCommand.Subscribe(async(param) =>
            {
                IsBusy.Value  = true;
                var imagePath = await Common.TakePhoto();
                var imageInfo = new ImageInfo();

                if (param.Equals(MarkerStr))
                {
                    imageInfo.ImagePath   = File.Exists(imagePath) ? imagePath : ImageMarkerFileName;
                    imageInfo.IsAsset     = !File.Exists(imagePath);
                    ImageMarkerInfo.Value = imageInfo;
                }
                else if (param.Equals(NodeStr))
                {
                    imageInfo.ImagePath = File.Exists(imagePath) ? imagePath : ImageNodeFileName;
                    imageInfo.IsAsset   = !File.Exists(imagePath);
                    ImageNodeInfo.Value = imageInfo;
                }
                IsBusy.Value = false;
            }).AddTo(this.Disposable);

            ExecuteARCommand = IsBusy.Inverse().ToAsyncReactiveCommand <string>();
            ExecuteARCommand.Subscribe(async(param) =>
            {
                if (string.IsNullOrEmpty(ApiKey.KudanARApiKey))
                {
                    await UserDialogs.Instance.AlertAsync("KudanARのAPIキー取得に失敗しました", $"{AppInfo.Name}", "OK");
                    await Xamarin.Forms.DependencyService.Get <IKudanARService>().Init();
                    return;
                }

                if (param.Equals("MarkerAR"))
                {
                    IsBusy.Value = true;
                    await Xamarin.Forms.DependencyService.Get <IKudanARService>().StartMarkerARActivityAsync();
                }
                else if (param.Equals("MarkerlessAR_Floor"))
                {
                    IsBusy.Value = true;
                    await Xamarin.Forms.DependencyService.Get <IKudanARService>().StartMarkerlessARActivityAsync();
                }
                else if (param.Equals("MarkerlessAR_Wall"))
                {
                    IsBusy.Value = true;
                    await Xamarin.Forms.DependencyService.Get <IKudanARService>().StartMarkerlessWallActivityAsync();
                }
                // Activity側でビジーフラグ変更
                //IsBusy.Value = false;
            }).AddTo(this.Disposable);

            SettingCommand = IsBusy.Inverse().ToAsyncReactiveCommand();
            SettingCommand.Subscribe(async() =>
            {
                await this.NavigationService.NavigateAsync("SettingPage");
            }).AddTo(this.Disposable);
        }