Пример #1
0
        public void ConstructUrl(AutomationEntry automation)
        {
            if (string.IsNullOrEmpty(this._url))
            {
                return;
            }

            // CHECK MobileOperator
            string mobileOperator = "";

            if (automation.MobileOperator != null)
            {
                if (this._url.Contains("mno"))
                {
                    this._url = this._url.Replace(string.Format("mno={0}", this.GetValue("mno")), string.Format("mno={0}", automation.MobileOperator.ID));
                }
                else
                {
                    mobileOperator = string.Format("&mno={0}", automation.MobileOperator.ID);
                }
            }
            else if (this._url.Contains("mno"))
            {
                this._url = this._url.Replace(string.Format("mno={0}", this.GetValue("mno")), string.Empty);
            }


            // Add lock
            if (this._url.Contains("cpkl="))
            {
                this._url = this._url.Replace(string.Format("cpkl={0}", this.GetValue("cpkl")), string.Format("cpkl={0}", automation.TransactionLimit));
            }
            else
            {
                char starting = this._url.Contains('?') ? '&' : '?';
                this._url += starting + "cpkl=" + automation.TransactionLimit + mobileOperator;
            }
        }
        public static List <AutomationEntry> Load(MobilePaywallDatabase database, List <AutomationGroupEntry> groups)
        {
            List <AutomationEntry> result = new List <AutomationEntry>();

            if (groups == null || groups.Count == 0)
            {
                return(result);
            }

            string ids = "";

            foreach (AutomationGroupEntry ge in groups)
            {
                if (!ids.Equals(""))
                {
                    ids += ",";
                }
                ids += ge.ID;
            }

            DataTable table = database.Load(AutomationEntry.SqlCommand.Replace(AutomationEntry.SqlIndexWildcard, ids));

            if (table == null)
            {
                return(result);
            }

            foreach (DataRow row in table.Rows)
            {
                AutomationEntry entry = new AutomationEntry();

                entry.ID   = Int32.Parse(row[(int)AutomationEntry.Columns.ID].ToString());
                entry.Name = row[(int)AutomationEntry.Columns.Name].ToString();

                ServiceEntry service = new ServiceEntry();
                service.ID          = Int32.Parse(row[(int)AutomationEntry.Columns.ServiceID].ToString());
                service.Name        = row[(int)AutomationEntry.Columns.ServiceName].ToString();
                service.Description = row[(int)AutomationEntry.Columns.ServiceDescription].ToString();
                entry.Service       = service;

                MobileOperatorEntry mobileOperator = null;
                if (row[(int)AutomationEntry.Columns.MobileOperatorID] != DBNull.Value)
                {
                    mobileOperator      = new MobileOperatorEntry();
                    mobileOperator.ID   = Int32.Parse(row[(int)AutomationEntry.Columns.MobileOperatorID].ToString());
                    mobileOperator.Name = row[(int)AutomationEntry.Columns.MobileOperatorID].ToString();
                }
                entry.MobileOperator = mobileOperator;


                entry.AutomationGroupID = Int32.Parse(row[(int)AutomationEntry.Columns.AutomationGroupID].ToString());
                entry.TransactionLimit  = Int32.Parse(row[(int)AutomationEntry.Columns.Limit].ToString());
                entry.ExternalOfferName = row[(int)AutomationEntry.Columns.ExternalOfferName].ToString();
                entry.IsActive          = (bool)row[(int)AutomationEntry.Columns.IsActive];
                entry.Index             = Int32.Parse(row[(int)AutomationEntry.Columns.Index].ToString());
                entry.Comment           = row[(int)AutomationEntry.Columns.Comment].ToString();
                entry.Created           = row[(int)AutomationEntry.Columns.Created].ToString();

                result.Add(entry);
            }

            return(result);
        }