Beispiel #1
0
        public static void LoggingRequest(string methodName, string apiName, string apiType, string incomingParameters, int responseBodyLenght, int userId, string apiKey)
        {
            if (BackendHelper.TagToValue("allow_unauth_api_request") == "true")
            {
                return;
            }
            var apiLog = new ApiLog
            {
                MethodName         = methodName,
                ApiName            = apiName,
                ApiType            = apiType,
                IncomingParameters = incomingParameters,
                ResponseBodyLenght = responseBodyLenght,
                UserID             = userId,
                ApiKey             = apiKey,
                UserIP             = OtherMethods.GetIPAddress()
            };

            apiLog.Create();
        }
Beispiel #2
0
        public static string GenerateCsv(string idListString, string invoiceNumber, string invoiceSeries, string invoiceDate)
        {
            var result        = String.Empty;
            var dm            = new DataManager();
            var idListToMySql = idListString.Split('-').ToList().Aggregate(String.Empty, (current, id) => current + "T.ID = " + id + " OR ");

            //читаем старый файл
            if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/OneCSyncArch/")))
            {
                Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/OneCSyncArch/"));
            }

            var dataFile = HttpContext.Current.Server.MapPath("~/OneCSyncArch/" + FileName);
            var reader   = new System.Xml.Serialization.XmlSerializer(typeof(XmlToOneC));
            var xml      = new XmlToOneC
            {
                Invoices = new List <Invoice>()
            };

            if (File.Exists(dataFile))
            {
                var fileReaded = new StreamReader(dataFile);
                xml = (XmlToOneC)reader.Deserialize(fileReaded);
                fileReaded.Close();
            }
            //читаем старый файл

            var invoices = new Invoice
            {
                InvoiceNumber = invoiceNumber,
                InvoiceSeries = invoiceSeries,
                InvoiceDate   = invoiceDate,
                CustomOrders  = new List <CustomOrderToOneC>()
            };
            var fullSqlString = "SELECT * FROM `tickets` as T " +
                                "WHERE ((" + idListToMySql.Remove(idListToMySql.Length - 3) +
                                ") AND T.PrintNakl = '1' AND T.NotPrintInPril2 ='0') ";
            var rows = dm.QueryWithReturnDataSet(fullSqlString).Tables[0].Rows;

            foreach (DataRow row in rows)
            {
                var customOrderCost = row["AssessedCost"].ToString();
                if (!String.IsNullOrEmpty(row["AgreedCost"].ToString()) && Convert.ToInt32(row["AgreedCost"]) != 0)
                {
                    customOrderCost = row["AgreedCost"].ToString();
                }
                if (!String.IsNullOrEmpty(row["Pril2Cost"].ToString()) && Convert.ToInt32(row["Pril2Cost"]) != 0)
                {
                    customOrderCost = row["Pril2Cost"].ToString();
                }

                var customOrder = new CustomOrderToOneC
                {
                    CustomOrderSecureId = row["SecureID"].ToString(),
                    CustomOrderCost     = Convert.ToDecimal(customOrderCost),
                    CustomOrderDate     = OtherMethods.DateConvertWithDot(row["AdmissionDate"].ToString())
                };
                invoices.CustomOrders.Add(customOrder);
            }

            xml.Invoices.Add(invoices);

            var writer     = new System.Xml.Serialization.XmlSerializer(typeof(XmlToOneC));
            var fileWriter = File.Create(dataFile);

            writer.Serialize(fileWriter, xml);
            fileWriter.Close();


            return(result);
        }
Beispiel #3
0
        public static string OldNewValueToRuss(string tableName, string propertyName, string value)
        {
            #region таблица заявок
            if (tableName == "tickets")
            {
                if (propertyName == "CourseRUR" ||
                    propertyName == "CourseUSD" ||
                    propertyName == "CourseEUR" ||
                    propertyName == "DeliveryCost" ||
                    propertyName == "AssessedCost" ||
                    propertyName == "AgreedCost" ||
                    propertyName == "ReceivedUSD" ||
                    propertyName == "ReceivedEUR" ||
                    propertyName == "ReceivedEUR" ||
                    propertyName == "ReceivedBLR" ||
                    propertyName == "GruzobozCost")
                {
                    return(MoneyMethods.MoneySeparator(value));
                }

                if (propertyName == "DriverID")
                {
                    return(DriversHelper.DriverIDToFioToPrint(value));
                }

                if (propertyName == "StatusIDOld" || propertyName == "StatusID")
                {
                    return(OtherMethods.TicketStatusToText(value));
                }

                if (propertyName == "CityID")
                {
                    return(CityHelper.CityIDToCityNameWithotCustom(value));
                }

                if (propertyName == "TrackIDUser")
                {
                    return(OtherMethods.TrackToText(Convert.ToInt32(value)));
                }

                if (propertyName == "DeliveryDate")
                {
                    return(value.Remove(value.Length - 8));
                }

                if (propertyName == "Comment")
                {
                    return(WebUtility.HtmlDecode(value));
                }

                if (propertyName == "PrintNakl" ||
                    propertyName == "PrintNaklInMap" ||
                    propertyName == "IsExchange" ||
                    propertyName == "WithoutMoney" ||
                    propertyName == "CheckedOut" ||
                    propertyName == "Phoned")
                {
                    return(value == "0" ? "нет" : "да");
                }

                if (propertyName == "OvDateFrom" || propertyName == "OvDateTo")
                {
                    return(String.IsNullOrEmpty(value) ? String.Empty : Convert.ToDateTime(value).ToString("HH:mm"));
                }
            }
            #endregion

            #region таблица пользователей
            if (tableName == "users")
            {
                if (propertyName == "SpecialClient" || propertyName == "IsCourse" || propertyName == "AllowApi")
                {
                    return(value == "0" ? "нет" : "да");
                }

                if (propertyName == "Status")
                {
                    return(UsersHelper.UserStatusToText(Convert.ToInt32(value)));
                }

                if (propertyName == "Role")
                {
                    return(UsersHelper.RoleToRuss(value));
                }

                if (propertyName == "Discount")
                {
                    return(String.Format("{0}%", value));
                }

                if (propertyName == "Password")
                {
                    return(String.Empty);
                }

                if (propertyName == "Validity" && value.Length >= 8)
                {
                    return(value.Remove(value.Length - 8));
                }

                if (propertyName == "BirthDay" && value.Length >= 8)
                {
                    return(value.Remove(value.Length - 8));
                }

                if (propertyName == "DateOfIssue" && value.Length >= 8)
                {
                    return(value.Remove(value.Length - 8));
                }
            }
            #endregion

            #region таблица грузов
            if (tableName == "goods")
            {
                if (propertyName == "Cost")
                {
                    return(MoneyMethods.MoneySeparator(value));
                }

                if (propertyName == "WithoutAkciza")
                {
                    return(value == "0" ? "нет" : "да");
                }
            }
            #endregion

            #region таблица профилей
            if (tableName == "usersprofiles")
            {
                if (propertyName == "StatusID")
                {
                    return(UsersProfilesHelper.UserProfileStatusToText(Convert.ToInt32(value)));
                }
            }
            #endregion

            #region таблица водителй
            if (tableName == "drivers")
            {
                if (propertyName == "StatusID" && !String.IsNullOrEmpty(value))
                {
                    return(DriversHelper.DriverStatusToText(Convert.ToInt32(value)));
                }

                if (value.Length >= 8 && (propertyName == "DateOfIssue" ||
                                          propertyName == "Validity" ||
                                          propertyName == "BirthDay" ||
                                          propertyName == "DriverPassportDateOfIssue" ||
                                          propertyName == "DriverPassportValidity" ||
                                          propertyName == "MedPolisDateOfIssue" ||
                                          propertyName == "MedPolisValidity"))
                {
                    return(value.Remove(value.Length - 8));
                }
            }
            #endregion

            #region таблица авто
            if (tableName == "cars")
            {
                if (propertyName == "TypeID" && !String.IsNullOrEmpty(value))
                {
                    return(CarsHelper.CarTypeToFullString(Convert.ToInt32(value)));
                }
            }
            #endregion

            #region таблица категорий
            if (tableName == "category")
            {
                if (propertyName == "Name")
                {
                    return(value);
                }
            }
            #endregion

            return(value);
        }