コード例 #1
0
        /// <summary>
        /// Параметры функции
        /// PARAM_OBJECT_ID - идентификатор объекта
        /// PARAM_OBJECT_KEY - ключ объекта
        /// PARAM_LOCALE - локаль клиентского устройства
        /// </summary>
        /// <param name="Parameters">Параметры</param>
        /// <returns></returns>
        public override CFunctionResult Execute(Dictionary<string, object> Parameters)
        {
            CFunctionResult Result = new CFunctionResult();
            CultureInfo ClientCulture = (Parameters.ContainsKey(CServerFunctionParams.CONST_FUNC_PARAM_LOCALE) ? CultureInfo.GetCultureInfo((int)Parameters[CServerFunctionParams.CONST_FUNC_PARAM_LOCALE]) : CultureInfo.CurrentCulture);

            CFunctionExecutionEnvironment.CurrentUser.GetPolicies(CFunctionExecutionEnvironment.sGetCurrentProvider());
            CFunctionExecutionEnvironment.CurrentUser.GetSecurityRecords(CFunctionExecutionEnvironment.sGetCurrentProvider());

            decimal ObjectKey = (Parameters.ContainsKey(CServerFunctionParams.CONST_FUNC_PARAM_OBJECT_KEY) ? (decimal)Parameters[CServerFunctionParams.CONST_FUNC_PARAM_OBJECT_KEY] : -1);
            string ObjectID = (Parameters.ContainsKey(CServerFunctionParams.CONST_FUNC_PARAM_OBJECT_ID) ? (string)Parameters[CServerFunctionParams.CONST_FUNC_PARAM_OBJECT_ID] : "");

            if (ObjectID == "" && ObjectKey == -1)
                return this._compileResult(EnFunctionResultType.EError, Parameters, CGlobalizationHelper.sGetStringResource("ERROR_MSG_KEY_ID_NULL", ClientCulture));
            if (!CFunctionExecutionEnvironment.CurrentUser.PolicyAllowViewOrdersList())
                return this._compileResult(EnFunctionResultType.EError, Parameters, CGlobalizationHelper.sGetStringResource("ERROR_MSG_USER_UNABLE_TO_VIEW_ORDERS", ClientCulture));

            CMenuServiceOrder Order = new CMenuServiceOrder();
            if (ObjectKey != -1)
            {
                Order.Key = ObjectKey;
                Order.OrderGetByKey(CFunctionExecutionEnvironment.sGetCurrentProvider());
                if (Order.ID == Guid.Empty)
                    return this._compileResult(EnFunctionResultType.EError, Parameters, CGlobalizationHelper.sGetStringResource("ERROR_MSG_ORDER_NULL", ClientCulture));
            }
            if (ObjectID != "")
            {
                Order.ID = Guid.Parse(ObjectID);
                Order.OrderGetByID(CFunctionExecutionEnvironment.sGetCurrentProvider());
                if (Order.Key == -1)
                    return this._compileResult(EnFunctionResultType.EError, Parameters, CGlobalizationHelper.sGetStringResource("ERROR_MSG_ORDER_NULL", ClientCulture));
            }

            Result.ErrorCode = -1;
            Result.ResultType = EnFunctionResultType.ESuccess;
            Result.InputParameters = Parameters;
            Result.Message = CGlobalizationHelper.sGetStringResource("ERROR_MSG_SUCCESS", ClientCulture);
            Result.Content = Order;

            return Result;
        }
コード例 #2
0
        public static List<CMenuServiceOrder> sGetOrdersByDates(DateTime StartDate, DateTime EndDate, IDatabaseProvider Provider)
        {
            List<CMenuServiceOrder> R = new List<CMenuServiceOrder>();

            Hashtable Params = new Hashtable();
            Params.Add(CDBConst.CONST_TABLE_FIELD_ORDERS_DT + "_START", StartDate);
            Params.Add(CDBConst.CONST_TABLE_FIELD_ORDERS_DT + "_END", EndDate);

            var SQL = "SELECT " + CDBConst.CONST_TABLE_FIELD_ORDERS_KEY + ", " + CDBConst.CONST_TABLE_FIELD_ORDERS_ID + ", " + CDBConst.CONST_TABLE_FIELD_ORDERS_SESSION_KEY + ", " + CDBConst.CONST_TABLE_FIELD_ORDERS_DT + ", " + CDBConst.CONST_TABLE_FIELD_ORDERS_DEADLINE;
            SQL += " FROM " + CDBConst.CONST_TABLE_ORDERS;
            SQL += " WHERE " + CDBConst.CONST_TABLE_FIELD_ORDERS_DT + " >= " + CDBConst.CONST_TABLE_FIELD_ORDERS_DT + "_START";
            SQL += " AND " + CDBConst.CONST_TABLE_FIELD_ORDERS_DT + " <= " + CDBConst.CONST_TABLE_FIELD_ORDERS_DT + "_END";

            var T = Provider.QueryGetData(SQL, false, null);
            for (int i = 0; i < T.Rows.Count; i++)
            {
                var Order = new CMenuServiceOrder();
                Order.Key = T.Rows[i][0].PostProcessDatabaseValue<decimal>();
                Order.ID = Guid.Parse(T.Rows[i][1].PostProcessDatabaseValue<string>());
                Order.SessionKey = T.Rows[i][2].PostProcessDatabaseValue<decimal>();
                Order.Date = T.Rows[i][3].PostProcessDatabaseValue<DateTime>();
                Order.Deadline = T.Rows[i][4].PostProcessDatabaseValue<DateTime>();
                R.Add(Order);
            }

            return R;
        }
コード例 #3
0
        public static List<CMenuServiceOrder> sGetAllOrders(IDatabaseProvider Provider)
        {
            List<CMenuServiceOrder> R = new List<CMenuServiceOrder>();

            var SQL = "SELECT " + CDBConst.CONST_TABLE_FIELD_ORDERS_KEY + ", " + CDBConst.CONST_TABLE_FIELD_ORDERS_ID + ", " + CDBConst.CONST_TABLE_FIELD_ORDERS_SESSION_KEY + ", " + CDBConst.CONST_TABLE_FIELD_ORDERS_DT + ", " + CDBConst.CONST_TABLE_FIELD_ORDERS_DEADLINE;
            SQL += " FROM " + CDBConst.CONST_TABLE_ORDERS;

            var T = Provider.QueryGetData(SQL, false, null);
            for (int i = 0; i < T.Rows.Count; i++)
            {
                var Order = new CMenuServiceOrder();
                Order.Key = T.Rows[i][0].PostProcessDatabaseValue<decimal>();
                Order.ID = Guid.Parse(T.Rows[i][1].PostProcessDatabaseValue<string>());
                Order.SessionKey = T.Rows[i][2].PostProcessDatabaseValue<decimal>();
                Order.Date = T.Rows[i][3].PostProcessDatabaseValue<DateTime>();
                Order.Deadline = T.Rows[i][4].PostProcessDatabaseValue<DateTime>();
                R.Add(Order);
            }
            
            return R;
        }