Exemple #1
0
        /// <summary>
        /// Main private helper method that uploads a form template to the specified data row
        /// </summary>
        /// <param name="AFormCode">Form Code</param>
        /// <param name="AFormName">Form name</param>
        /// <param name="ALanguageCode">language code</param>
        /// <param name="ATemplateText">The template as a base64 string</param>
        /// <param name="AUserID">User ID who is doing the upload</param>
        /// <param name="AUploadDateTime">Loacal date and time from the user PC that is doing the upload</param>
        /// <param name="ATemplateFileExtension">File extension of template file (eg docx)</param>
        /// <returns>True if the table record was modified successfully</returns>
        private static bool UploadFormTemplate(String AFormCode, String AFormName, String ALanguageCode, String ATemplateText,
                                               String AUserID, DateTime AUploadDateTime, String ATemplateFileExtension)
        {
            TDBTransaction Transaction  = null;
            bool           SubmissionOK = false;

            string strSQL = String.Format("UPDATE PUB_{0} SET ", PFormTable.GetTableDBName());

            strSQL += String.Format("{0}='{1}', ", PFormTable.GetTemplateDocumentDBName(), ATemplateText);
            strSQL += String.Format("{0}='{1}', ", PFormTable.GetTemplateUploadedByUserIdDBName(), AUserID);
            strSQL += String.Format("{0}='{1}', ", PFormTable.GetTemplateUploadDateDBName(), AUploadDateTime.ToString("yyyy-MM-dd"));
            strSQL += String.Format("{0}={1}, ", PFormTable.GetTemplateUploadTimeDBName(),
                                    Convert.ToInt32((AUploadDateTime - new DateTime(AUploadDateTime.Year, AUploadDateTime.Month, AUploadDateTime.Day)).TotalSeconds));
            strSQL += String.Format("{0}='{1}', ", PFormTable.GetTemplateFileExtensionDBName(), ATemplateFileExtension);
            strSQL += String.Format("{0}='TRUE' ", PFormTable.GetTemplateAvailableDBName());
            strSQL += "WHERE ";
            strSQL += String.Format("{0}='{1}' AND ", PFormTable.GetFormCodeDBName(), AFormCode);
            strSQL += String.Format("{0}='{1}' AND ", PFormTable.GetFormNameDBName(), AFormName);
            strSQL += String.Format("{0}='{1}'", PFormTable.GetFormLanguageDBName(), ALanguageCode);

            DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable,
                                                       ref Transaction,
                                                       ref SubmissionOK,
                                                       delegate
            {
                int nRowsAffected = DBAccess.GDBAccessObj.ExecuteNonQuery(strSQL, Transaction, null, true);
                SubmissionOK      = (nRowsAffected == 1);
            });

            return(SubmissionOK);
        }
Exemple #2
0
        /// <summary>
        /// Main private method to return a table with forms for partner or finance
        /// </summary>
        /// <param name="AFormCode">Form Code Filter</param>
        /// <param name="AFormTypeCode">Form Type Code Filter, ignore this filter if empty string</param>
        /// <returns>Result Form Table.  Note: only those where the template is 'available' are returned</returns>
        private static PFormTable GetForms(String AFormCode, String AFormTypeCode)
        {
            PFormTable ResultTable = new PFormTable();
            PFormRow   TemplateRow = ResultTable.NewRowTyped(false);

            // Check for a valid form code
            if ((AFormCode == MCommonConstants.FORM_CODE_PARTNER) ||
                (AFormCode == MCommonConstants.FORM_CODE_PERSONNEL) ||
                (AFormCode == MCommonConstants.FORM_CODE_CHEQUE) ||
                (AFormCode == MCommonConstants.FORM_CODE_RECEIPT) ||
                (AFormCode == MCommonConstants.FORM_CODE_REMITTANCE) ||
                (AFormCode == MCommonConstants.FORM_CODE_CONFERENCE))
            {
                TemplateRow.FormCode          = AFormCode;
                TemplateRow.TemplateAvailable = true;

                if (AFormTypeCode != "")
                {
                    TemplateRow.FormTypeCode = AFormTypeCode;
                }

                TDBTransaction Transaction = null;

                DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                          TEnforceIsolationLevel.eilMinimum,
                                                                          ref Transaction,
                                                                          delegate
                {
                    // This method only needs some of the columns - and definitely not the template itself!
                    StringCollection fieldList = new StringCollection();
                    fieldList.Add(PFormTable.GetFormCodeDBName());
                    fieldList.Add(PFormTable.GetFormTypeCodeDBName());
                    fieldList.Add(PFormTable.GetFormLanguageDBName());
                    fieldList.Add(PFormTable.GetFormNameDBName());
                    fieldList.Add(PFormTable.GetFormDescriptionDBName());
                    fieldList.Add(PFormTable.GetTemplateFileExtensionDBName());
                    fieldList.Add(PFormTable.GetAddressLayoutCodeDBName());
                    fieldList.Add(PFormTable.GetFormalityLevelDBName());

                    // Probably don't need these on the client
                    fieldList.Add(PFormTable.GetMinimumAmountDBName());
                    fieldList.Add(PFormTable.GetOptionsDBName());

                    ResultTable = PFormAccess.LoadUsingTemplate(TemplateRow, fieldList, Transaction);
                });
            }

            return(ResultTable);
        }