Exemple #1
0
        /// <summary>Takes a payload string and has it broken into chunks of equal or less size than the provided chunk size.</summary>
        /// <returns>xml payload containing the name of the file where chunk pieces were stored on the server.</returns>
        private static string UploadSheetChunks(string payload, int chunkSize)
        {
            List <string> listChunks = MiscUtils.CutStringIntoSimilarSizedChunks(payload, chunkSize);
            string        fileName   = "";

            foreach (string chunk in listChunks)
            {
                List <PayloadItem> listChunkPayloadItems = new List <PayloadItem> {
                    new PayloadItem(fileName, "FileName"),
                    new PayloadItem(chunk, "ChunkData")
                };
                string chunkPayload = PayloadHelper.CreatePayloadContent(listChunkPayloadItems);
                string result       = SheetsSynchProxy.GetWebServiceInstance().UploadSheetDefChunk(chunkPayload);
                PayloadHelper.CheckForError(result);
                fileName = WebSerializer.DeserializeTag <string>(result, "FileName");
            }
            return(PayloadHelper.CreatePayloadContent(fileName, "FileName"));
        }
Exemple #2
0
        private void ButOK_Click(object sender, EventArgs e)
        {
            if (textKey.Text == "")
            {
                MsgBox.Show(this, "Please enter an API key.");
                return;
            }
            string officeData = PayloadHelper.CreatePayload(PayloadHelper.CreatePayloadContent(textKey.Text, "APIKey"), eServiceCode.FHIR);
            string result;

            try {
                Cursor = Cursors.WaitCursor;
                result = WebServiceMainHQProxy.GetWebServiceMainHQInstance().AssignFHIRAPIKey(officeData);
                PayloadHelper.CheckForError(result);
            }
            catch (Exception ex) {
                MsgBox.Show(ex.Message);
                Cursor = Cursors.Default;
                return;
            }
            MsgBox.Show(this, WebSerializer.DeserializeTag <string>(result, "Response"));
            DialogResult = DialogResult.OK;
        }
        private void ButDisable_Click(object sender, EventArgs e)
        {
            FHIRKeyStatus newStatus;
            DateTime      dateDisabled;

            if (_apiKeyCur.KeyStatus.In(FHIRKeyStatus.Enabled, FHIRKeyStatus.EnabledReadOnly))
            {
                newStatus    = FHIRKeyStatus.DisabledByCustomer;
                dateDisabled = DateTime.Now;
            }
            else              //DisabledByCustomer
            {
                newStatus    = FHIRKeyStatus.Enabled;
                dateDisabled = DateTime.MinValue;
            }
            string officeData = PayloadHelper.CreatePayload(PayloadHelper.CreatePayloadContent(new List <PayloadItem> {
                new PayloadItem(textKey.Text, "APIKey"),
                new PayloadItem(newStatus.ToString(), "FHIRKeyStatus"),
            }), eServiceCode.FHIR);
            string result;

            try {
                Cursor = Cursors.WaitCursor;
                result = WebServiceMainHQProxy.GetWebServiceMainHQInstance().UpdateFHIRKeyStatus(officeData);
                PayloadHelper.CheckForError(result);
            }
            catch (Exception ex) {
                MsgBox.Show(ex.Message);
                Cursor = Cursors.Default;
                return;
            }
            HasChanged              = true;
            Cursor                  = Cursors.Default;
            _apiKeyCur.KeyStatus    = newStatus;
            _apiKeyCur.DateDisabled = dateDisabled;
            FillForm();
        }
        ///<summary>Send a summary of eConnector statistics to OD HQ. This should only be called from the eConnector.</summary>
        public static void UpdateEConnectorStats()
        {
            EConnectorStatistics eConnStats = new EConnectorStatistics()
            {
                ListEServiceSignals = new List <EServiceSignal>(),
                ListEServicePrefs   = new List <Pref>(),
            };

            eConnStats.EConnectorComputerName   = Environment.MachineName;
            eConnStats.EConnectorDomainUserName = Environment.UserName;
            eConnStats.EConnectorIP             = ODEnvironment.GetLocalIPAddress();
            eConnStats.HasClinicsEnabled        = PrefC.HasClinicsEnabled;
            if (PrefC.HasClinicsEnabled)
            {
                eConnStats.CountActiveClinics   = OpenDentBusiness.Clinics.GetCount();
                eConnStats.CountInactiveClinics = OpenDentBusiness.Clinics.GetCount() - eConnStats.CountActiveClinics;
            }
            else
            {
                eConnStats.CountActiveClinics   = 0;
                eConnStats.CountInactiveClinics = OpenDentBusiness.Clinics.GetCount();
            }
            if (DateTime.Now.Hour == 0)            //These are heavy queries so only run them once a day around midnight.
            {
                eConnStats.CountActivePatients    = OpenDentBusiness.Procedures.GetCountPatsComplete(DateTime.Today.AddYears(-2), DateTime.Today);
                eConnStats.CountNonactivePatients = OpenDentBusiness.Patients.GetPatCountAll() - eConnStats.CountActivePatients;
                eConnStats.ListEServiceSignals    = OpenDentBusiness.EServiceSignals.GetServiceHistory(eServiceCode.ListenerService, DateTime.Today.AddDays(-30),
                                                                                                       DateTime.Today, 30);
            }
            eConnStats.DateTimeNow = DateTime.Now;
            foreach (PrefName prefName in Enum.GetValues(typeof(PrefName)))
            {
                if (prefName.In(
                        PrefName.RegistrationKey,
                        PrefName.ProgramVersion,
                        PrefName.DataBaseVersion,
                        PrefName.TextingDefaultClinicNum,
                        PrefName.WebServiceServerName,
                        PrefName.SendEmailsInDiffProcess,
                        PrefName.EmailAlertMaxConsecutiveFails,
                        PrefName.AutoCommNumClinicsParallel,
                        PrefName.AutomaticCommunicationTimeStart,
                        PrefName.AutomaticCommunicationTimeEnd) ||
                    prefName.ToString().StartsWith("WebSched") ||
                    prefName.ToString().StartsWith("ApptConfirm") ||
                    prefName.ToString().StartsWith("ApptRemind") ||
                    prefName.ToString().StartsWith("ApptEConfirm") ||
                    prefName.ToString().StartsWith("Recall") ||
                    prefName.ToString().StartsWith("PatientPortal") ||
                    prefName.ToString().StartsWith("Sms"))
                {
                    try {
                        eConnStats.ListEServicePrefs.Add(Prefs.GetPref(prefName.ToString()));
                    }
                    catch (Exception ex) {
                        ex.DoNothing();
                    }
                }
            }
            List <EConnectorStatistics> listStatsToSend = new List <EConnectorStatistics> {
                eConnStats
            };
            string dbStats = PrefC.GetString(PrefName.EConnectorStatistics);
            List <EConnectorStatistics> listDbStats = DeserializeListFromJson(dbStats) ?? new List <EConnectorStatistics>();
            bool doCreateAlert = false;

            foreach (EConnectorStatistics stats in listDbStats)
            {
                //If a different eConnector is saving stats, add that one to the list to be sent to HQ.
                if (!AreSameEConnector(eConnStats, stats) && (eConnStats.DateTimeNow - stats.DateTimeNow).TotalHours < 23)
                {
                    stats.ListEServicePrefs   = new List <Pref>();               //To save on bandwidth
                    stats.ListEServiceSignals = new List <EServiceSignal>();
                    listStatsToSend.Add(stats);
                    if ((eConnStats.DateTimeNow - stats.DateTimeNow).TotalHours < 3)
                    {
                        doCreateAlert = true;
                    }
                }
            }
            if (doCreateAlert && AlertItems.RefreshForType(AlertType.MultipleEConnectors).Count == 0)
            {
                AlertItem alert = new AlertItem {
                    Actions     = ActionType.MarkAsRead | ActionType.Delete,
                    Description = Lans.g("EConnectorStats", "eConnector services are being run on these computers:") + " "
                                  + string.Join(", ", listStatsToSend.Select(x => x.EConnectorComputerName)),
                    Severity = SeverityType.High,
                    Type     = AlertType.MultipleEConnectors,
                };
                AlertItems.Insert(alert);
            }
            string statsStr = SerializeToJson(listStatsToSend);

            OpenDentBusiness.Prefs.UpdateString(PrefName.EConnectorStatistics, statsStr);
            string payload = PayloadHelper.CreatePayload(PayloadHelper.CreatePayloadContent(statsStr, "EConnectorStatsStr"),
                                                         eServiceCode.ListenerService);

            WebServiceMainHQProxy.GetWebServiceMainHQInstance().SetEConnectorStatsAsync(payload);
        }
Exemple #5
0
        ///<summary>Processes a PaySimple ACH payment via the PaySimple API.</summary>
        private PaySimple.ApiResponse ProcessPaymentACH()
        {
            PaySimple.ApiResponse retVal = null;
            string accountNumber         = textCheckSaveNumber.Text;

            //if the user has chosen to store CC tokens and the stored CC has a token and the token is not expired,
            //then use it instead of the CC number and CC expiration.
            if (!checkOneTimePaymentACH.Checked &&
                _creditCardCur != null &&               //if the user selected a saved CC
                !string.IsNullOrWhiteSpace(_creditCardCur.PaySimpleToken) &&                 //there is a stored token for this card
                _creditCardCur.CCSource == CreditCardSource.PaySimpleACH)
            {
                accountNumber = _creditCardCur.PaySimpleToken;
            }
            else if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, PaySimple.PropertyDescs.PaySimplePreventSavingNewCC, _clinicNum)))
            {
                MsgBox.Show(this, "Cannot add a new ACH payment.");
                return(null);
            }
            try {
                if (_isAddingCard)
                {
                    retVal = PaySimple.AddACHAccount(_patCur, textRoutingNumber.Text, textCheckSaveNumber.Text, textBankName.Text, radioCheckings.Checked, _clinicNum);
                }
                else
                {
                    retVal = PaySimple.MakePaymentACH(_patCur, _creditCardCur, PIn.Decimal(textAmountACH.Text), textRoutingNumber.Text, textCheckSaveNumber.Text,
                                                      textBankName.Text, radioCheckings.Checked, checkOneTimePaymentACH.Checked, _clinicNum);
                    try {
                        string result = WebServiceMainHQProxy.GetWebServiceMainHQInstance()
                                        .InsertPaySimpleACHId(PayloadHelper.CreatePayload(
                                                                  PayloadHelper.CreatePayloadContent(retVal.RefNumber.ToString(), "PaymentId"), eServiceCode.PaySimple));
                        PayloadHelper.CheckForError(result);
                    }
                    catch (Exception ex) {
                        FriendlyException.Show("Unable to register for ACH Settled event", ex);
                    }
                }
            }
            catch (PaySimpleException ex) {
                MessageBox.Show(ex.Message);
                if (ex.ErrorType == PaySimpleError.CustomerDoesNotExist && MsgBox.Show(this, MsgBoxButtons.OKCancel,
                                                                                       "Delete the link to the customer id for this patient?"))
                {
                    PatientLinks.DeletePatNumTos(ex.CustomerId, PatientLinkType.PaySimple);
                }
                return(null);
            }
            catch (ODException ex) {
                MessageBox.Show(ex.Message);                //This should have already been Lans.g if applicable.
                return(null);
            }
            catch (Exception ex) {
                FriendlyException.Show(Lan.g(this, "Error:") + " " + ex.Message, ex);
                return(null);
            }
            if (!_isAddingCard)
            {
                retVal.BuildReceiptString(accountNumber, -1, -1, _patCur?.GetNameFL(), _clinicNum, wasSwiped: false, isACH: true);
                PrintReceipt(retVal.TransactionReceipt);
            }
            if (checkOneTimePaymentACH.Checked)             //not storing the account token
            {
                return(retVal);
            }
            UpsertCreditCard(retVal, textCheckSaveNumber.Text.Right(4).PadLeft(textCheckSaveNumber.Text.Length, '*'), CreditCardSource.PaySimpleACH,
                             DateTime.MinValue);
            return(retVal);
        }