示例#1
0
        /// <summary>
        /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" />
        /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" />
        /// collection.
        /// </summary>
        /// <param name="context">The action rendering context.</param>
        /// <remarks>
        /// <note>
        /// It is perfectly reasonable for an action to render no actions to the
        /// context or to render multiple actions based on its properties.
        /// </note>
        /// </remarks>
        public override void Render(ActionRenderingContext context)
        {
            var reasonString = SwitchHelper.GetSwitchHangupReasonString(reason);
            int delaySeconds = SwitchHelper.GetScheduleSeconds(delay);

            if (context.IsDialplan)
            {
                if (delaySeconds <= 0)
                {
                    context.Actions.Add(new SwitchExecuteAction("hangup", reasonString));
                }
                else
                {
                    context.Actions.Add(new SwitchExecuteAction("sched_hangup", "+{0} {1}", delaySeconds, reasonString));
                }
            }
            else
            {
                CheckCallID();

                if (delaySeconds <= 0)
                {
                    context.Actions.Add(new SwitchExecuteAction(CallID, "hangup", reasonString));
                }
                else
                {
                    context.Actions.Add(new SwitchExecuteAction(CallID, "sched_hangup", "+{0} {1}", delaySeconds, reasonString));
                }
            }
        }
示例#2
0
        /// <summary>
        /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" />
        /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" />
        /// collection.
        /// </summary>
        /// <param name="context">The action rendering context.</param>
        /// <remarks>
        /// <note>
        /// It is perfectly reasonable for an action to render no actions to the
        /// context or to render multiple actions based on its properties.
        /// </note>
        /// </remarks>
        public override void Render(ActionRenderingContext context)
        {
            var delaySeconds = SwitchHelper.GetScheduleSeconds(Delay);
            var legString    = TransferBothLegs ? "-both" : "-bleg";

            if (delaySeconds <= 0)
            {
                if (context.IsDialplan)
                {
                    context.Actions.Add(new SwitchExecuteAction("transfer", "{0} {1} XML {2}", legString, extension, context));
                }
                else
                {
                    context.Actions.Add(new SwitchExecuteAction("uuid_transfer", "{0:D} {1} {2} XML {3}", CallID, legString, extension, DialplanContext));
                }
            }
            else
            {
                if (context.IsDialplan)
                {
                    context.Actions.Add(new SwitchExecuteAction("sched_transfer", "+{0} {1} {2} XML {3}", delaySeconds, legString, extension, DialplanContext));
                }
                else
                {
                    context.Actions.Add(new SwitchExecuteAction("sched_transfer", "+{0} {1:D} {2} {3} XML {4}", delaySeconds, CallID, legString, extension, DialplanContext));
                }
            }
        }
示例#3
0
        /// <summary>
        /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" />
        /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" />
        /// collection.
        /// </summary>
        /// <param name="context">The action rendering context.</param>
        /// <remarks>
        /// <note>
        /// It is perfectly reasonable for an action to render no actions to the
        /// context or to render multiple actions based on its properties.
        /// </note>
        /// </remarks>
        public override void Render(ActionRenderingContext context)
        {
            int    delaySeconds = SwitchHelper.GetScheduleSeconds(delay);
            string legString;

            switch (legs)
            {
            case CallLeg.A:

                legString = "aleg";
                break;

            case CallLeg.B:

                legString = "bleg";
                break;

            default:
            case CallLeg.Both:

                legString = "both";
                break;
            }

            if (context.IsDialplan)
            {
                context.Actions.Add(new SwitchExecuteAction("sched_broadcast", "+{0} '{1}' {2}", delaySeconds, Switch.ExpandFilePath(filePath), legString));
            }
            else
            {
                context.Actions.Add(new SwitchExecuteAction(CallID, "sched_broadcast", "+{0} '{1}' {2}", delaySeconds, Switch.ExpandFilePath(filePath), legString));
            }
        }
示例#4
0
        public static string QueryOrderDetail(string code)
        {
            try
            {
                ListOrderModel orderModel = new ListOrderModel();
                DataSet        ds         = orderModel.getOrderDetail(code);
                ds.Tables[0].Rows[0]["busitype"] = SwitchHelper.switchValue("busitype", ds.Tables[0].Rows[0]["busitype"].ToString2());

                if (ds.Tables.Count > 1 && ds.Tables[1].Columns.Contains("modifyflag"))
                {
                    foreach (DataRow dr in ds.Tables[1].Rows)
                    {
                        dr["modifyflag"] = SwitchHelper.switchValue("modifyflag", dr["modifyflag"].ToString2());
                    }
                }
                if (ds.Tables.Count > 2 && ds.Tables[2].Columns.Contains("modifyflag"))
                {
                    foreach (DataRow dr in ds.Tables[2].Rows)
                    {
                        dr["modifyflag"] = SwitchHelper.switchValue("modifyflag", dr["modifyflag"].ToString2());
                    }
                }
                IsoDateTimeConverter iso = new IsoDateTimeConverter();//序列化JSON对象时,日期的处理格式
                iso.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                string json = JsonConvert.SerializeObject(ds, iso);
                return(json);
            }
            catch (Exception e)
            {
                LogHelper.Write("MyBusiness_QueryOrderDetail异常:" + e.Message);
                return("");
            }
        }
示例#5
0
        public override TextBuffer ToJava(int indent, BytecodeMappingTracer tracer)
        {
            SwitchHelper.Simplify(this);
            TextBuffer buf = new TextBuffer();

            buf.Append(ExprProcessor.ListToJava(varDefinitions, indent, tracer));
            buf.Append(first.ToJava(indent, tracer));
            if (IsLabeled())
            {
                buf.AppendIndent(indent).Append("label").Append(this.id.ToString()).Append(":").AppendLineSeparator
                    ();
                tracer.IncrementCurrentSourceLine();
            }
            buf.AppendIndent(indent).Append(headexprent[0].ToJava(indent, tracer)).Append(" {"
                                                                                          ).AppendLineSeparator();
            tracer.IncrementCurrentSourceLine();
            VarType switch_type = headexprent[0].GetExprType();

            for (int i = 0; i < caseStatements.Count; i++)
            {
                Statement       stat   = caseStatements[i];
                List <StatEdge> edges  = caseEdges[i];
                List <Exprent>  values = caseValues[i];
                for (int j = 0; j < edges.Count; j++)
                {
                    if (edges[j] == default_edge)
                    {
                        buf.AppendIndent(indent).Append("default:").AppendLineSeparator();
                    }
                    else
                    {
                        buf.AppendIndent(indent).Append("case ");
                        Exprent value = values[j];
                        if (value is ConstExprent)
                        {
                            value = value.Copy();
                            ((ConstExprent)value).SetConstType(switch_type);
                        }
                        if (value is FieldExprent && ((FieldExprent)value).IsStatic())
                        {
                            // enum values
                            buf.Append(((FieldExprent)value).GetName());
                        }
                        else
                        {
                            buf.Append(value.ToJava(indent, tracer));
                        }
                        buf.Append(":").AppendLineSeparator();
                    }
                    tracer.IncrementCurrentSourceLine();
                }
                buf.Append(ExprProcessor.JmpWrapper(stat, indent + 1, false, tracer));
            }
            buf.AppendIndent(indent).Append("}").AppendLineSeparator();
            tracer.IncrementCurrentSourceLine();
            return(buf);
        }
示例#6
0
        /// <summary>
        /// Submits a log entry to the NeonSwitch logging subsystem.
        /// </summary>
        /// <param name="level">The log level.</param>
        /// <param name="message">The log message.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="message" /> is <c>null</c>.</exception>
        public static void Log(SwitchLogLevel level, string message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            Execute("log", "{0} {1}", SwitchHelper.GetSwitchLogLevelString(level), message);
        }
示例#7
0
        /// <summary>
        /// Converts the action to use <b>uuid_broadcast2</b> to execute as dialplan tool.
        /// </summary>
        private void ConvertToBroadcast()
        {
            // This generates a somewhat screwy FreeSwitch syntax for executing
            // an arbitray dialplan tool on a call.

            if (Data == null)
            {
                Data = string.Empty;
            }

            Data        = string.Format("{0:D} {1}::{2}", CallID, Application, SwitchHelper.UrlEncode(Data));
            Application = "uuid_broadcast2";
        }
示例#8
0
        /// <summary>
        /// Collects DTMF digits for the duration specified or until the timeout to receive
        /// an individual digit has been exceeded.
        /// </summary>
        /// <param name="timeout">The time to wait for the digits to be collected.</param>
        /// <param name="digitTimeout">The maximum time to wait for any single digit.</param>
        /// <remarks>
        /// <para>
        /// You'll need to subscribe to the <see cref="DtmfReceived" /> event
        /// to actually receive these DTMF digits and the duration that they were pressed.
        /// </para>
        /// <note>
        /// This method blocks the current thread for the duration of the timeout constraints
        /// or until the <see cref="DtmfReceived"/> event handler sets
        /// <see cref="DtmfInputEventArgs"/>.<see cref="DtmfInputEventArgs.Break"/> to <c>true</c>.
        /// </note>
        /// </remarks>
        public void CollectDigits(TimeSpan timeout, TimeSpan digitTimeout)
        {
            int timeoutSeconds      = SwitchHelper.GetScheduleSeconds(timeout);
            int digitTimeoutSeconds = SwitchHelper.GetScheduleSeconds(digitTimeout);
            var sb = new StringBuilder();

            if (timeoutSeconds <= 0 || digitTimeoutSeconds <= 0)
            {
                return;
            }

            session.CollectDigits(timeoutSeconds, digitTimeoutSeconds);
        }
示例#9
0
        private void SwitchIfSelectedItemExistsInItemsElseInvalidate(object originalSelectedItem)
        {
            InvalidateIfSelectedItemDoesNotExistInItems();
            if (EvaluateIfSelectedItemExistInItems())
            {
                var switchHelper = new SwitchHelper(originalSelectedItem, _selectedItem);

                _itemQue.Enqueue(switchHelper);
                if (_itemQue.Count == 1)
                {
                    SwitchItem(switchHelper);
                }
            }
        }
示例#10
0
        public static string QuerySubscribeInfo(string subscribestart, string subscribeend, string busiunit, string istigger, string busitype, string ordercode, string cusno,
                                                string divideno, string contract, string submitstart, string submitend, int pagesize, int lastnum)
        {
            string   sum  = "0";
            WGUserEn user = (WGUserEn)HttpContext.Current.Session["user"];

            if (user == null || user.GwyUserID <= 0)
            {
                return("");
            }
            DataTable infodt = SubscribeModel.getNewSubscribeInfo_Order(subscribestart, subscribeend, busiunit, istigger, busitype, ordercode, cusno, divideno, contract,
                                                                        submitstart, submitend, pagesize, lastnum, user.GwyUserID, out sum);

            //DataTable infodt = SubscribeModel.getNewSubscribeInfo_Order(subscribestart, subscribeend, busiunit, istigger, busitype, ordercode, cusno, divideno, contract,
            //    submitstart, submitend, pagesize, lastnum, 1124, out sum);
            if (infodt == null || infodt.Rows.Count == 0)
            {
                return("");
            }
            try
            {
                foreach (DataRow dr in infodt.Rows)
                {
                    if (string.IsNullOrEmpty(dr["divideno"].ToString2()))
                    {
                        dr["divideno"] = "";
                    }
                    if (string.IsNullOrEmpty(dr["logisticsname"].ToString2()))
                    {
                        dr["logisticsname"] = "";
                    }
                    if (string.IsNullOrEmpty(dr["contractno"].ToString2()))
                    {
                        dr["contractno"] = "";
                    }
                    dr["declstatus"] = SwitchHelper.switchValue("declstatus", dr["declstatus"].ToString2());
                    dr["inspstatus"] = SwitchHelper.switchValue("inspstatus", dr["inspstatus"].ToString2());
                    dr["sum"]        = sum;
                }
                IsoDateTimeConverter iso = new IsoDateTimeConverter();//序列化JSON对象时,日期的处理格式
                iso.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                string json = JsonConvert.SerializeObject(infodt, iso);
                return(json);
            }
            catch (Exception e)
            {
                LogHelper.Write("MyBusiness_QueryData:" + e.Message);
                return("");
            }
        }
示例#11
0
        /// <summary>
        /// Submits a formatted log entry to the NeonSwitch logging subsystem.
        /// </summary>
        /// <param name="level">The log level.</param>
        /// <param name="format">The format string.</param>
        /// <param name="args">The arguments.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="format" /> or <paramref name="args"/> is <c>null</c>.</exception>
        public static void Log(SwitchLogLevel level, string format, params object[] args)
        {
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }

            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            Execute("log", "{0} {1}", SwitchHelper.GetSwitchLogLevelString(level), string.Format(format, args));
        }
示例#12
0
        /// <summary>
        /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" />
        /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" />
        /// collection.
        /// </summary>
        /// <param name="context">The action rendering context.</param>
        /// <exception cref="NotSupportedException">Thrown if the action is being rendered outside of a dialplan.</exception>
        /// <remarks>
        /// <note>
        /// It is perfectly reasonable for an action to render no actions to the
        /// context or to render multiple actions based on its properties.
        /// </note>
        /// </remarks>
        public override void Render(ActionRenderingContext context)
        {
            string logLevelString = SwitchHelper.GetSwitchLogLevelString(level);

            if (context.IsDialplan)
            {
                context.Actions.Add(new SwitchExecuteAction("session_loglevel", logLevelString));
            }
            else
            {
                CheckCallID();
                context.Actions.Add(new SwitchExecuteAction(CallID, "session_loglevel", logLevelString));
            }
        }
示例#13
0
        /// <summary>
        /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" />
        /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" />
        /// collection.
        /// </summary>
        /// <param name="context">The action rendering context.</param>
        /// <remarks>
        /// <note>
        /// It is perfectly reasonable for an action to render no actions to the
        /// context or to render multiple actions based on its properties.
        /// </note>
        /// </remarks>
        public override void Render(ActionRenderingContext context)
        {
            var intervalSeconds = SwitchHelper.GetScheduleSeconds(interval);

            if (context.IsDialplan)
            {
                context.Actions.Add(new SwitchExecuteAction("uuid_session_heartbeat", "${{Unique-ID}} {0}", intervalSeconds));
            }
            else
            {
                CheckCallID();
                context.Actions.Add(new SwitchExecuteAction(CallID, "uuid_session_heartbeat", "{0}", intervalSeconds));
            }
        }
示例#14
0
    // Use this for initialization
    void Start()
    {
        anim           = GetComponent <Animator>();
        audioSource    = GetComponents <AudioSource>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        SwitchHelper.Switch(anim, player);

        horizontal    = "Horizontal" + player;
        vertical      = "Vertical" + player;
        joyHorizontal = "JoyHorizontal" + player;
        joyVertical   = "JoyVertical" + player;
        jump          = "Jump" + player;
        joyJump       = "JoyJump" + player;
    }
示例#15
0
        /// <summary>
        /// Collects DTMF digits pressed by the caller until the maximum number of digis is
        /// received, one of a set of terminator digits is pressed, or the overall operation
        /// timeout has been exceeded.
        /// </summary>
        /// <param name="maxDigits">The maximum number of digits to be collected.</param>
        /// <param name="terminators">Zero or more terminating DTMF digits or <c>null</c>.</param>
        /// <param name="timeout">The overall operation timeout.</param>
        /// <returns>The collected digits.</returns>
        public string GetDigits(int maxDigits, string terminators, TimeSpan timeout)
        {
            int timeoutSeconds = SwitchHelper.GetScheduleSeconds(timeout);

            if (maxDigits <= 0 || timeoutSeconds <= 0)
            {
                return(string.Empty);    // Nothing to do
            }
            if (terminators == null)
            {
                terminators = string.Empty;
            }

            return(session.GetDigits(maxDigits, terminators, timeoutSeconds));
        }
示例#16
0
        public static string NewQuerySubscribeInfo()
        {
            WGUserEn user = (WGUserEn)HttpContext.Current.Session["user"];

            if (user == null || user.GwyUserID <= 0)
            {
                return("");
            }
            DataTable infodt = SubscribeModel.getNewSubscribeInfo_Order(user.GwyUserID);

            //DataTable infodt = SubscribeModel.getNewSubscribeInfo_Order(1124);

            if (infodt == null || infodt.Rows.Count == 0)
            {
                return("");
            }
            try
            {
                foreach (DataRow dr in infodt.Rows)
                {
                    if (string.IsNullOrEmpty(dr["divideno"].ToString2()))
                    {
                        dr["divideno"] = "";
                    }
                    if (string.IsNullOrEmpty(dr["logisticsname"].ToString2()))
                    {
                        dr["logisticsname"] = "";
                    }
                    if (string.IsNullOrEmpty(dr["contractno"].ToString2()))
                    {
                        dr["contractno"] = "";
                    }
                    dr["declstatus"] = SwitchHelper.switchValue("declstatus", dr["declstatus"].ToString2());
                    dr["inspstatus"] = SwitchHelper.switchValue("inspstatus", dr["inspstatus"].ToString2());
                }
                IsoDateTimeConverter iso = new IsoDateTimeConverter();//序列化JSON对象时,日期的处理格式
                iso.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                string json = JsonConvert.SerializeObject(infodt, iso);
                return(json);
            }
            catch (Exception e)
            {
                LogHelper.Write("MyBusiness_QueryData:" + e.Message);
                return("");
            }
        }
示例#17
0
        /// <summary>
        /// Switches the specified application.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="activeDocument">The active document.</param>
        /// <returns></returns>
        public bool DoSwitch(DTE2 application, Document activeDocument)
        {
            //  Do we have a file with or without an 'I'?
            var basePath = activeDocument.FullName;
            var implPath = Path.Combine(Path.GetDirectoryName(basePath), Path.GetFileName(basePath).Substring(1));
            var intPath  = Path.Combine(Path.GetDirectoryName(basePath), "I" + Path.GetFileName(basePath));

            if (File.Exists(implPath))
            {
                return(SwitchHelper.TryOpenDocument(application, implPath));
            }

            if (File.Exists(intPath))
            {
                return(SwitchHelper.TryOpenDocument(application, intPath));
            }

            return(false);
        }
示例#18
0
        /// <summary>
        /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" />
        /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" />
        /// collection.
        /// </summary>
        /// <param name="context">The action rendering context.</param>
        /// <exception cref="NotSupportedException">Thrown if the action is being rendered outside of a dialplan.</exception>
        /// <remarks>
        /// <note>
        /// It is perfectly reasonable for an action to render no actions to the
        /// context or to render multiple actions based on its properties.
        /// </note>
        /// </remarks>
        public override void Render(ActionRenderingContext context)
        {
            var expandedPath = Switch.ExpandFilePath(path);
            var limitString  = string.Empty;

            if (start && limit.HasValue)
            {
                limitString = " " + SwitchHelper.GetScheduleSeconds(limit.Value).ToString();
            }

            if (context.IsDialplan)
            {
                context.Actions.Add(new SwitchExecuteAction("uuid_record", "${{Unique-ID}} {0} '{1}'{2}", start ? "start" : "stop", limitString));
            }
            else
            {
                CheckCallID();
                context.Actions.Add(new SwitchExecuteAction("uuid_record", "{0} {1} '{2}'{3}", start ? "start" : "stop", limitString));
            }
        }
示例#19
0
        /// <summary>
        /// Sends a simulated event.
        /// </summary>
        /// <param name="serverConnection">The switch connection.</param>
        /// <param name="eventCode">The event code.</param>
        /// <param name="text">The content text.</param>
        /// <param name="args">Additional name/values to be added to the event.</param>
        private void SendEvent(SwitchConnection serverConnection, SwitchEventCode eventCode, string text, params NameValue[] args)
        {
            var properties = new ArgCollection(ArgCollectionType.Unconstrained);
            var sb         = new StringBuilder();

            byte[] data = Helper.ASCIIEncoding.GetBytes(text);
            byte[] content;

            properties["Event-Name"]     = SwitchHelper.GetEventCodeString(eventCode);
            properties["Content-Type"]   = "text";
            properties["Content-Length"] = data.Length.ToString();

            foreach (var pair in args)
            {
                properties[pair.Name] = pair.Value;
            }

            foreach (var key in properties)
            {
                sb.AppendFormat("{0}: {1}\n", key, Helper.UrlEncode(properties[key]));
            }

            sb.Append('\n');

            content = Helper.Concat(Helper.ASCIIEncoding.GetBytes(sb.ToString()), data);

            properties = new ArgCollection(ArgCollectionType.Unconstrained);
            properties["Content-Type"]   = "text/event-plain";
            properties["Content-Length"] = content.Length.ToString();

            sb.Clear();

            foreach (var key in properties)
            {
                sb.AppendFormat("{0}: {1}\n", key, Helper.UrlEncode(properties[key]));
            }

            sb.Append('\n');

            serverConnection.Send(Helper.Concat(Helper.ASCIIEncoding.GetBytes(sb.ToString()), content));
        }
示例#20
0
        public static string getInfo(string code)
        {
            Declare   model = new Declare();
            DataTable dt    = model.getSubsInfo(code);

            IsoDateTimeConverter iso = new IsoDateTimeConverter();//序列化JSON对象时,日期的处理格式

            try
            {
                foreach (DataRow dr in dt.Rows)
                {
                    dr["ischeck"]     = dr["ischeck"].ToString2() == "1" ? "海关查验" : "";
                    dr["checkpic"]    = dr["checkpic"].ToString2() == "1" ? "含查验图片" : "";
                    dr["inspischeck"] = dr["inspischeck"].ToString2() == "1" ? "国检查验" : "";
                    dr["lawflag"]     = dr["lawflag"].ToString2() == "1" ? "含法检" : "";
                    dr["declstatus"]  = SwitchHelper.switchValue("declstatus", dr["declstatus"].ToString2());
                    dr["inspstatus"]  = SwitchHelper.switchValue("inspstatus", dr["inspstatus"].ToString2());
                    if (string.IsNullOrEmpty(dr["divideno"].ToString2()))
                    {
                        dr["divideno"] = "";
                    }
                    if (string.IsNullOrEmpty(dr["logisticsstatus"].ToString2()))
                    {
                        dr["logisticsstatus"] = "";
                    }
                    if (string.IsNullOrEmpty(dr["contractno"].ToString2()))
                    {
                        dr["contractno"] = "";
                    }
                }
            }
            catch (Exception e)
            {
                LogHelper.Write("BusiSubsDetail:" + e.Message);
            }

            iso.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            string json = JsonConvert.SerializeObject(dt, iso);

            return(json);
        }
        // GET: LibraryItem
        public ActionResult Index(string sortOrder)
        {
            ViewBag.CategorySortParm = String.IsNullOrEmpty(sortOrder) ? "categoryName_desc" : "";
            ViewBag.TypeSortParm     = sortOrder == "Type" ? "type_desc" : "Type";

            var libraryItems = db.LibraryItem.Include(l => l.Category);

            libraryItems = SwitchHelper.SortOrder(sortOrder, libraryItems);
            var size = libraryItems.Count();

            string[] acronyms = new string[size];

            var libraryItemsList = libraryItems.ToList();

            acronyms = StringHelper.CreateAccronyms(acronyms, libraryItemsList, size);

            var viewModel = new ViewModel {
                listOfLibraryItems = libraryItemsList, titleAcronyms = acronyms
            };

            return(View(viewModel));
        }
示例#22
0
 /// <summary>
 /// 新增订阅信息
 /// </summary>
 /// <param name="type"></param>
 /// <param name="status"></param>
 /// <param name="cusno"></param>
 /// <param name="declarationcode"></param>
 /// <param name="cusno"></param>
 /// <param name="userid"></param>
 /// <param name="username"></param>
 /// <param name="openid"></param>
 /// <param name="codetype"></param>
 /// <returns></returns>
 public static bool insertSubscribe(string type, string[] status, string cusno, string declarationcode, int userid, string username, string openid, string codetype, string ordercode)
 {
     try
     {
         string        sql  = @"insert into wechat_subscribe(id,cusno,declarationcode,userid,username,substime,substype,status,openid,statusvalue,codetype,ordercode) 
         values(wechat_subscribe_id.nextval,'{0}','{1}','{2}','{3}',sysdate,'{4}','{5}','{6}','{7}','{8}','{9}')";
         List <string> sqls = new List <string>();
         for (int i = 0; i < status.Length; i++)
         {
             string statusvalue = SwitchHelper.switchValue(type, status[i]);
             sqls.Add(string.Format(sql, cusno, declarationcode, userid, username, type, status[i], openid, statusvalue, codetype, ordercode));
         }
         using (DBSession db = new DBSession())
         {
             return(db.ExecuteBatch(sqls) > 0 ? true : false);
         }
     }
     catch (Exception ex)
     {
         LogHelper.Write("SubscribeModel_insertSubscribe:" + ex.Message + "——code:" + cusno + declarationcode);
         return(false);
     }
 }
示例#23
0
        /// <summary>
        /// Switches the specified document.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="activeDocument">The active document.</param>
        /// <returns>
        /// True if switched successfully.
        /// </returns>
        public bool DoSwitch(DTE2 application, Document activeDocument)
        {
            //  Get the doc path.
            var path = activeDocument.FullName;

            //  If there's no from path then we can't continue.
            if (path.EndsWith(From) == false)
            {
                return(false);
            }

            //  Replace the path 'from' with the part 'to'.
            if (path.Length < From.Length)
            {
                return(false);
            }

            //  Map the path.
            var mappedPath = path.Substring(0, path.Length - From.Length) + To;

            //  Try and open the mapped path.
            return(SwitchHelper.TryOpenDocument(application, mappedPath));
        }
 // Use this for initialization
 void Start()
 {
     anim           = GetComponent <Animator>();
     spriteRenderer = GetComponent <SpriteRenderer>();
     SwitchHelper.Switch(anim, Tile);
 }
示例#25
0
 private void SwitchItem(SwitchHelper switchHelper)
 {
     _uniformItemsControl.HideItem(switchHelper.ItemToShrink);
     _uniformItemsControl.GrowItem(switchHelper.ItemToGrow, OnGrowItemCompleted);
 }
示例#26
0
 /// <summary>
 /// Constructs an action to echo audio with a delay for the
 /// current call on an executing dialplan.
 /// </summary>
 /// <param name="delay">The echo delay.</param>
 public EchoAction(TimeSpan delay)
 {
     this.delaySeconds = SwitchHelper.GetScheduleSeconds(delay);
 }
示例#27
0
 private void SwitchItem(SwitchHelper switchHelper)
 {
     _uniformItemsControl.HideItem(switchHelper.ItemToShrink);
     _uniformItemsControl.GrowItem(switchHelper.ItemToGrow, OnGrowItemCompleted);
 }
示例#28
0
 /// <summary>
 /// Constructs an action to echo audio with a delay for
 /// a specific call.
 /// </summary>
 /// <param name="callID">The target call ID.</param>
 /// <param name="delay">The echo delay.</param>
 public EchoAction(Guid callID, TimeSpan delay)
 {
     this.CallID       = callID;
     this.delaySeconds = SwitchHelper.GetScheduleSeconds(delay);
 }
示例#29
0
        /// <summary>
        /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" />
        /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" />
        /// collection.
        /// </summary>
        /// <param name="context">The action rendering context.</param>
        /// <exception cref="NotSupportedException">Thrown for parameters that are not supported for the current execution context.</exception>
        /// <remarks>
        /// <note>
        /// It is perfectly reasonable for an action to render no actions to the
        /// context or to render multiple actions based on its properties.
        /// </note>
        /// </remarks>
        public override void Render(ActionRenderingContext context)
        {
            if (callID1 != Guid.Empty && callID2 != Guid.Empty)
            {
                context.Actions.Add(new SwitchExecuteAction("uuid_bridge", "{0:D} {1:D}", callID1, callID2));
                return;
            }

            // Special case FreeSWITCH style dialstrings.

            if (dialstring != null)
            {
                if (context.IsDialplan)
                {
                    context.Actions.Add(new SwitchExecuteAction("bridge", dialstring));
                }
                else
                {
                    context.Actions.Add(new SwitchExecuteAction(CallID, "bridge", dialstring));
                }

                return;
            }

            if (endpoints.Count == 0)
            {
                throw new InvalidOperationException("Attempt to render a BridgeAction with no endpoints.");
            }

            // Add an action queue any DTMF digits.

            if (queuedDtmfDigits != null && queuedDtmfDigits.Length > 0)
            {
                var duration = ToneDuration;

                if (duration < Switch.MinDtmfDuration)
                {
                    duration = Switch.MinDtmfDuration;
                }
                else if (duration > Switch.MaxDtmfDuration)
                {
                    duration = Switch.MaxDtmfDuration;
                }

                if (context.IsDialplan)
                {
                    context.Actions.Add(new SwitchExecuteAction("queue_dtmf", "{0}@{1}", queuedDtmfDigits, (int)duration.TotalMilliseconds));
                }
                else
                {
                    context.Actions.Add(new SwitchExecuteAction(CallID, "queue_dtmf", "{0}@{1}", queuedDtmfDigits, (int)duration.TotalMilliseconds));
                }
            }

            // Add any propety variables to the variables collection.

            if (AnswerTimeout.HasValue)
            {
                Variables["call_timeout"] = SwitchHelper.GetScheduleSeconds(AnswerTimeout.Value).ToString();
            }

            if (BypassMedia.HasValue)
            {
                Variables["bypass_media"] = BypassMedia.Value ? "true" : "false";
            }

            if (Ringback.HasValue && Ringback.Value)
            {
                Variables["ringback"] = "${us-ring}";
            }

            if (CallerIDName != null)
            {
                Variables["effective_caller_id_name"] = CallerIDName;
            }

            if (CallerIDNumber != null)
            {
                Variables["effective_caller_id_number"] = CallerIDNumber;
            }

            // I'm not going to use the FreeSWITCH global channel variable syntax {..} at the beginning of
            // the dialstring since this is really just a human friendly shortcut.  Instead, I'm going
            // to explicitly add any global variables that aren't overridden to each endpoint.

            if (Variables.Count > 0)
            {
                foreach (var endpoint in Endpoints)
                {
                    foreach (var variable in Variables)
                    {
                        if (!endpoint.Variables.ContainsKey(variable.Key))
                        {
                            endpoint.Variables[variable.Key] = variable.Value;
                        }
                    }
                }
            }

            // Render the dialstring if there's only one endpoint.

            if (endpoints.Count == 1)
            {
                if (context.IsDialplan)
                {
                    context.Actions.Add(new SwitchExecuteAction("bridge", endpoints[0].ToString()));
                }
                else
                {
                    context.Actions.Add(new SwitchExecuteAction(CallID, "bridge", endpoints[0].ToString()));
                }

                return;
            }

            // We have multiple endpoints so we need to render based on the bridge mode.

            var sb = new StringBuilder();

            switch (Mode)
            {
            case BridgeMode.LinearHunt:

                foreach (var endpoint in endpoints)
                {
                    sb.AppendFormat("{0},", endpoint);
                }

                break;

            case BridgeMode.RandomHunt:

                endpoints.Shuffle();
                foreach (var endpoint in endpoints)
                {
                    sb.AppendFormat("{0},", endpoint);
                }

                break;

            case BridgeMode.RingAll:

                foreach (var endpoint in endpoints)
                {
                    sb.AppendFormat("{0}|", endpoint);
                }

                break;
            }

            if (sb.Length > 0)
            {
                sb.Length--;
            }

            if (context.IsDialplan)
            {
                context.Actions.Add(new SwitchExecuteAction("bridge", sb.ToString()));
            }
            else
            {
                context.Actions.Add(new SwitchExecuteAction(CallID, "bridge", sb.ToString()));
            }
        }
示例#30
0
 /// <summary>
 /// Constructs an action that logs text at the specified level.
 /// </summary>
 /// <param name="level">The new log level.</param>
 /// <param name="text">The text to be logged.</param>
 public LogAction(SwitchLogLevel level, string text)
     : base("log", string.Format("{0} {1}", SwitchHelper.GetSwitchLogLevelString(level), text))
 {
 }
示例#31
0
 public static SwitchHelper <T> Switch <T>(this T value, SwitchHelper <T> .SwitchBehavior behavior = SwitchHelper <T> .SwitchBehavior.OneCase) => new SwitchHelper <T>(value, behavior);
示例#32
0
        private void SwitchIfSelectedItemExistsInItemsElseInvalidate(object originalSelectedItem)
        {
            InvalidateIfSelectedItemDoesNotExistInItems();
            if(EvaluateIfSelectedItemExistInItems())
            {
                var switchHelper = new SwitchHelper(originalSelectedItem, _selectedItem);

                _itemQue.Enqueue(switchHelper);
                if(_itemQue.Count == 1)
                {
                    SwitchItem(switchHelper);
                }
            }
        }