Ejemplo n.º 1
0
        ///<summary>This method can throw an exception. Tries to upload a sheet def to HQ.</summary>
        ///<param name="sheetDef">The SheetDef object to be uploaded.</param>
        public static void TryUploadSheetDef(SheetDef sheetDef)
        {
            string             regKey           = PrefC.GetString(PrefName.RegistrationKey);
            List <PayloadItem> listPayloadItems = new List <PayloadItem> {
                new PayloadItem(regKey, "RegKey"),
                new PayloadItem(sheetDef, "SheetDef")
            };
            string payload = PayloadHelper.CreatePayloadWebHostSynch(regKey, listPayloadItems.ToArray());
            string result  = SheetsSynchProxy.GetWebServiceInstance().UpLoadSheetDef(payload);

            PayloadHelper.CheckForError(result);
        }
Ejemplo n.º 2
0
        /// <summary>Takes a provided webSheetDefId and sheetDef and packages them. The package is then broken into chunks of equal or lesser size
        /// than the provided chunkSize. Size is measured in bytes.</summary>
        public static bool UpdateSheetDefChunked(long webSheetDefId, SheetDef sheetDef, int chunkSize)
        {
            string             regKey           = PrefC.GetString(PrefName.RegistrationKey);
            List <PayloadItem> listPayloadItems = new List <PayloadItem> {
                new PayloadItem(regKey, "RegKey"),
                new PayloadItem(webSheetDefId, "WebSheetDefID"),
                new PayloadItem(sheetDef, "SheetDef")
            };
            string payload         = PayloadHelper.CreatePayloadWebHostSynch(regKey, listPayloadItems.ToArray());
            string fileNamePayload = UploadSheetChunks(payload, chunkSize);
            string result          = SheetsSynchProxy.GetWebServiceInstance().UpdateSheetDefFromFile(fileNamePayload);

            PayloadHelper.CheckForError(result);
            return(true);
        }
Ejemplo n.º 3
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"));
        }
Ejemplo n.º 4
0
 /// <summary>Returns true if able to successfully delete the sheets. Returns false otherwise.</summary>
 /// <param name="regKey"></param>
 /// <param name="listSheetNums"></param>
 public static bool DeleteSheetData(List <long> listSheetNums, string regKey = null)
 {
     if (string.IsNullOrEmpty(regKey))
     {
         regKey = PrefC.GetString(PrefName.RegistrationKey);
     }
     try {
         List <PayloadItem> listPayloadItems = new List <PayloadItem> {
             new PayloadItem(regKey, "RegKey"),
             new PayloadItem(listSheetNums, "SheetNumsForDeletion")
         };
         string payload = PayloadHelper.CreatePayloadWebHostSynch(regKey, listPayloadItems.ToArray());
         string result  = SheetsSynchProxy.GetWebServiceInstance().DeleteSheetData(payload);
         PayloadHelper.CheckForError(result);
         return(true);
     }
     catch (Exception ex) {
         ex.DoNothing();
         return(false);
     }
 }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
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);
        }