Beispiel #1
0
        private static bool ValidateParameters(NpgsqlCommand command)
        {
            Collection <string> commandTextParameters = GetCommandTextParameterCollection(command.CommandText);

            foreach (NpgsqlParameter npgsqlParameter in command.Parameters)
            {
                bool match = false;

                foreach (string commandTextParameter in commandTextParameters)
                {
                    if (npgsqlParameter.ParameterName.Equals(commandTextParameter))
                    {
                        match = true;
                    }
                }

                if (!match)
                {
                    throw new InvalidOperationException(string.Format(CultureManager.GetCurrentUICulture(),
                                                                      Warnings.InvalidParameterName, npgsqlParameter.ParameterName));
                }
            }

            return(true);
        }
Beispiel #2
0
        public static string GetLocalDateTimeString(string timeZone, DateTime utc)
        {
            TimeZoneInfo zone = TimeZoneInfo.FindSystemTimeZoneById(timeZone);
            DateTime     time = TimeZoneInfo.ConvertTimeFromUtc(utc, zone);

            return(String.Format(CultureManager.GetCurrentUICulture(), "{0} {1} {2}", time.ToLongDateString(), time.ToLongTimeString(), zone.DisplayName));
        }
Beispiel #3
0
        public static string ParseExpression(string expression, Collection <DataTable> dataTableCollection)
        {
            if (string.IsNullOrWhiteSpace(expression))
            {
                return(string.Empty);
            }


            string logo = GetLogo();

            expression = expression.Replace("{LogoPath}",
                                            PageUtility.GetCurrentDomainName() + PageUtility.ResolveUrl(logo));
            //Or else logo will not be exported into excel.
            expression = expression.Replace("{PrintDate}", DateTime.Now.ToString(CultureManager.GetCurrentUICulture()));

            foreach (var match in Regex.Matches(expression, "{.*?}"))
            {
                string word = match.ToString();

                if (word.StartsWith("{CurrentOffice.", StringComparison.OrdinalIgnoreCase))
                {
                    string sessionKey = RemoveBraces(word);
                    sessionKey = sessionKey.Replace("CurrentOffice.", "");
                    sessionKey = sessionKey.Trim();

                    string value = GetDictionaryValue(sessionKey);

                    expression = expression.Replace(word, value);
                }
                else if (word.StartsWith("{Resources.", StringComparison.OrdinalIgnoreCase))
                {
                    string   res      = RemoveBraces(word);
                    string[] resource = res.Split('.');

                    string key = resource[2];

                    expression = expression.Replace(word, ResourceManager.GetString(resource[1], key));
                }
                else if (word.StartsWith("{DataSource", StringComparison.OrdinalIgnoreCase) &&
                         word.ToLower(CultureInfo.InvariantCulture).Contains("runningtotalfieldvalue"))
                {
                    string   res      = RemoveBraces(word);
                    string[] resource = res.Split('.');

                    int dataSourceIndex =
                        Conversion.TryCastInteger(
                            resource[0].ToLower(CultureInfo.InvariantCulture)
                            .Replace("datasource", "")
                            .Replace("[", "")
                            .Replace("]", ""));
                    int index =
                        Conversion.TryCastInteger(
                            resource[1].ToLower(CultureInfo.InvariantCulture)
                            .Replace("runningtotalfieldvalue", "")
                            .Replace("[", "")
                            .Replace("]", ""));

                    if (dataSourceIndex >= 0 && index >= 0)
                    {
                        if (dataTableCollection != null && dataTableCollection[dataSourceIndex] != null)
                        {
                            expression = expression.Replace(word,
                                                            GetSum(dataTableCollection[dataSourceIndex], index)
                                                            .ToString(CultureInfo.InvariantCulture));
                        }
                    }
                }
                else if (word.StartsWith("{Barcode", StringComparison.OrdinalIgnoreCase))
                {
                    string res          = RemoveBraces(word).Replace("Barcode(", "").Replace(")", "");
                    string barCodeValue = res;

                    if (res.StartsWith("DataSource"))
                    {
                        barCodeValue = ParseDataSource("{" + res + "}", dataTableCollection);
                    }

                    string barCodeFormat          = ConfigurationHelper.GetReportParameter("BarCodeFormat");
                    string barCodeDisplayValue    = ConfigurationHelper.GetReportParameter("BarCodeDisplayValue");
                    string barCodeFontSize        = ConfigurationHelper.GetReportParameter("BarCodeFontSize");
                    string barCodeWidth           = ConfigurationHelper.GetReportParameter("BarCodeWidth");
                    string barCodeHeight          = ConfigurationHelper.GetReportParameter("BarCodeHeight");
                    string barCodeQuite           = ConfigurationHelper.GetReportParameter("BarCodeQuite");
                    string barCodeFont            = ConfigurationHelper.GetReportParameter("BarCodeFont");
                    string barCodeTextAlign       = ConfigurationHelper.GetReportParameter("BarCodeTextAlign");
                    string barCodeBackgroundColor = ConfigurationHelper.GetReportParameter("BarCodeBackgroundColor");
                    string barCodeLineColor       = ConfigurationHelper.GetReportParameter("BarCodeLineColor");

                    string imageSource =
                        "<img class='reportEngineBarCode' data-barcodevalue='{0}' alt='{0}' value='{0}' data-barcodeformat='{1}' data-barcodedisplayvalue='{2}' data-barcodefontsize='{3}' data-barcodewidth='{4}' data-barcodeheight='{5}' data-barcodefont='{6}' data-barcodetextalign='{7}' data-barcodebackgroundcolor='{8}' data-barcodelinecolor='{9}' data-barcodequite={10} />";
                    imageSource = string.Format(CultureInfo.InvariantCulture, imageSource, barCodeValue,
                                                barCodeFormat, barCodeDisplayValue, barCodeFontSize, barCodeWidth, barCodeHeight,
                                                barCodeFont, barCodeTextAlign, barCodeBackgroundColor, barCodeLineColor, barCodeQuite);
                    expression = expression.Replace(word, imageSource).ToString(CultureInfo.InvariantCulture);
                }
                else if (word.StartsWith("{QRCode", StringComparison.OrdinalIgnoreCase))
                {
                    string res         = RemoveBraces(word).Replace("QRCode(", "").Replace(")", "");
                    string qrCodeValue = res;

                    if (res.StartsWith("DataSource"))
                    {
                        qrCodeValue = ParseDataSource("{" + res + "}", dataTableCollection);
                    }

                    string qrCodeRender          = ConfigurationHelper.GetReportParameter("QRCodeRender");
                    string qrCodeBackgroundColor = ConfigurationHelper.GetReportParameter("QRCodeBackgroundColor");
                    string qrCodeForegroundColor = ConfigurationHelper.GetReportParameter("QRCodeForegroundColor");
                    string qrCodeWidth           = ConfigurationHelper.GetReportParameter("QRCodeWidth");
                    string qrCodeHeight          = ConfigurationHelper.GetReportParameter("QRCodeHeight");
                    string qrCodeTypeNumber      = ConfigurationHelper.GetReportParameter("QRCodeTypeNumber");

                    string qrCodeDiv =
                        "<div class='reportEngineQRCode' data-qrcodevalue={0} data-qrcoderender='{1}' data-qrcodebackgroundcolor='{2}' data-qrcodeforegroundcolor='{3}' data-qrcodewidth='{4}' data-qrcodeheight='{5}' data-qrcodetypenumber='{6}'></div>";
                    qrCodeDiv = string.Format(CultureInfo.InvariantCulture, qrCodeDiv, qrCodeValue, qrCodeRender,
                                              qrCodeBackgroundColor, qrCodeForegroundColor, qrCodeWidth, qrCodeHeight, qrCodeTypeNumber);
                    expression = expression.Replace(word, qrCodeDiv).ToString(CultureInfo.InvariantCulture);
                }
            }

            return(expression);
        }
Beispiel #4
0
 public static int GetWeekStartDay()
 {
     return((int)CultureManager.GetCurrentUICulture().DateTimeFormat.FirstDayOfWeek);
 }
Beispiel #5
0
 public static string GetDatePickerLocale()
 {
     return(CultureManager.GetCurrentUICulture().TwoLetterISOLanguageName);
 }
Beispiel #6
0
        public static string GetDatePickerFormat()
        {
            string datePattern = CultureManager.GetCurrentUICulture().DateTimeFormat.ShortDatePattern;

            return(ConvertDateFormat(datePattern));
        }
Beispiel #7
0
        private void ShowVerificationStatus(string tranId, Label label)
        {
            if (this.HideVerificationMessage)
            {
                return;
            }

            if (this.IsNonGlTransaction)
            {
                return;
            }

            long transactionMasterId = Conversion.TryCastLong(tranId);

            if (transactionMasterId <= 0)
            {
                return;
            }

            Entities.Transactions.Models.VerificationModel model = Status.GetVerificationStatus(this.Catalog, transactionMasterId, this.IsStockTransferRequest);

            if (model == null)
            {
                return;
            }

            switch (model.VerificationStatusId)
            {
            case -3:
                label.CssClass = "ui block message red";
                label.Text     = string.Format(CultureManager.GetCurrent(), Labels.TransactionRejectedDetails, model.VerifierName, model.VerifiedDate.ToString(CultureManager.GetCurrentUICulture()), model.VerificationReason);
                break;

            case -2:
                label.CssClass = "ui block message yellow";
                label.Text     = string.Format(CultureManager.GetCurrent(), Labels.TransactionClosedDetails, model.VerifierName, model.VerifiedDate.ToString(CultureManager.GetCurrentUICulture()), model.VerificationReason);
                break;

            case -1:
                label.Text     = string.Format(CultureManager.GetCurrent(), Labels.TransactionWithdrawnDetails, model.VerifierName, model.VerifiedDate.ToString(CultureManager.GetCurrentUICulture()), model.VerificationReason);
                label.CssClass = "ui block message yellow";
                break;

            case 0:
                label.Text     = Labels.TransactionAwaitingVerification;
                label.CssClass = "ui block message blue";
                break;

            case 1:
                label.Text     = string.Format(CultureManager.GetCurrent(), Labels.TransactionAutoApprovedDetails, model.VerifierName, model.VerifiedDate.ToString(CultureManager.GetCurrentUICulture()));
                label.CssClass = "ui block message green";
                break;

            case 2:
                label.Text     = string.Format(CultureManager.GetCurrent(), Labels.TransactionApprovedDetails, model.VerifierName, model.VerifiedDate.ToString(CultureManager.GetCurrentUICulture()));
                label.CssClass = "ui block message green";
                break;
            }
        }