예제 #1
0
        /// <summary>
        /// Parse a message value.
        /// </summary>
        /// <param name="name">Name of header being parsed.</param>
        /// <param name="reader">Reader containing the string that should be parsed.</param>
        /// <returns>Newly created header.</returns>
        /// <exception cref="ParseException">Header value is malformed.</exception>
        /// <example>
        /// Authorization: Digest username="******",
        ///                 realm="biloxi.com",
        ///                 nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
        ///                 uri="sip:[email protected]",
        ///                 qop=auth,
        ///                 nc=00000001,
        ///                 cnonce="0a4f113b",
        ///                 response="6629fae49393a05397450978507c4ef1",
        ///                 opaque="5ccc069c403ebaf9f0171e9517f40e41"
        /// </example>
        public IHeader Parse(string name, ITextReader reader)
        {
            reader.ConsumeWhiteSpaces();
            string digest = reader.ReadWord().ToLower();
            if (digest != "digest")
                throw new ParseException("Authorization header is not digest authentication");

            reader.ConsumeWhiteSpaces();
            var parameters = new KeyValueCollection();
            UriParser.ParseParameters(parameters, reader, ',');

            var header = new Authorization(name)
                             {
                                 UserName = parameters["username"],
                                 Realm = parameters["realm"],
                                 Nonce = parameters["nonce"],
                                 Qop = parameters["qop"],
                                 ClientNonce = parameters["cnonce"],
                                 Opaque = parameters["opaque"],
                                 Response = parameters["response"],
                                 Uri = UriParser.Parse(parameters["uri"])
                             };

            try
            {
                header.NonceCounter = int.Parse(parameters["nc"]);
            }
            catch (Exception err)
            {
                throw new ParseException("Failed to parse 'nc' in Authorization header.", err);
            }

            return header;
        }
예제 #2
0
파일: TaskExecutor.cs 프로젝트: hkiaipc/C3
        /// <summary>
        /// 
        /// </summary>
        /// <param name="device"></param>
        /// <param name="operaName"></param>
        /// <param name="keyValues"></param>
        public ExecuteResult Execute(IDevice device, string operaName, KeyValueCollection keyValues)
        {
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }

            if (keyValues == null)
            {
                keyValues = new KeyValueCollection();
            }

            if (!(device.Station.CommuniPort != null
                && device.Station.CommuniPort.IsOpened ))
            {
                return ExecuteResult.CreateFailExecuteResult("not connected");
            }

            IOpera opera = device.Dpu.OperaFactory.Create(device.GetType().Name,
                operaName);

            foreach (KeyValue kv in keyValues)
            {
                opera.SendPart[kv.Key] = kv.Value;
            }

            TimeSpan timeout = TimeSpan.FromMilliseconds(device.Station.CommuniPortConfig.TimeoutMilliSecond );
            this.Task = new Task(device, opera, Strategy.CreateImmediateStrategy(), timeout, 1);

            device.TaskManager.Tasks.Enqueue(this.Task);

            return ExecuteResult.CreateSuccessExecuteResult();
        }
예제 #3
0
		private KeyValueCollection ExtendedProperties(IDatabase db, string schema, string entitytype, string entity, string column) 
		{
			KeyValueCollection hash = new KeyValueCollection();
			Recordset rs = db.ExecuteSql(
				String.Format(QUERY, 
				"'" + schema + "'",
				"'" + entitytype + "'",
				"'" + entity + "'", 
				((column == null) ? "null" : "'column'"), 
				((column == null) ? "null" : "'" + column + "'")
				)
				);
			
			if (rs != null) 
			{
				rs.MoveFirst();

				while (!rs.EOF && !rs.BOF)
				{
					hash.AddKeyValue( rs.Fields["name"].Value.ToString(), rs.Fields["value"].Value.ToString());
					rs.MoveNext();
				}
				rs.Close();
				rs = null;
			}
			return hash;
		}
예제 #4
0
        private void TestParameters()
        {
            var collection = new KeyValueCollection();

            UriParser.ParseParameters(collection, new StringReader(";welcome;lr=true"));
            Assert.Equal(string.Empty, collection["welcome"]);
            Assert.Equal("true", collection["lr"]);

            collection.Clear();
            UriParser.ParseParameters(collection, new StringReader(";welcome"));
            Assert.Equal(string.Empty, collection["welcome"]);

            collection.Clear();
            UriParser.ParseParameters(collection, new StringReader(";welcome;"));
            Assert.Equal(string.Empty, collection["welcome"]);

            collection.Clear();
            UriParser.ParseParameters(collection, new StringReader(";welcome=world"));
            Assert.Equal("world", collection["welcome"]);

            collection.Clear();
            UriParser.ParseParameters(collection, new StringReader(";welcome=world;"));
            Assert.Equal("world", collection["welcome"]);

            collection.Clear();
            UriParser.ParseParameters(collection, new StringReader(";welcome=world;yes"));
            Assert.Equal("world", collection["welcome"]);
            Assert.Equal(string.Empty, collection["yes"]);

            collection.Clear();
            UriParser.ParseParameters(collection, new StringReader(";welcome=world;yes;"));
            Assert.Equal("world", collection["welcome"]);
            Assert.Equal(string.Empty, collection["yes"]);
        }
예제 #5
0
        /// <summary>
        /// Parse a message value.
        /// </summary>
        /// <param name="name">Name of header being parsed.</param>
        /// <param name="reader">Reader containing the string that should be parsed.</param>
        /// <returns>Newly created header.</returns>
        /// <exception cref="ParseException">Header value is malformed.</exception>
        /// <example>
        /// Digest realm="atlanta.com",
        /// domain="sip:boxesbybob.com", qop="auth",
        /// nonce="f84f1cec41e6cbe5aea9c8e88d359",
        /// opaque="", stale=FALSE, algorithm=MD5
        /// </example>
        public IHeader Parse(string name, ITextReader reader)
        {
            reader.ConsumeWhiteSpaces();
            string digest = reader.ReadWord().ToLower();
            if (digest != "digest")
                throw new ParseException("Authorization header is not digest authentication");

            reader.ConsumeWhiteSpaces();
            var parameters = new KeyValueCollection();
            UriParser.ParseParameters(parameters, reader, ',');

            var header = new Authenticate(name)
                             {
                                 Algortihm = parameters["algorithm"],
                                 Domain = UriParser.Parse(parameters["domain"]),
                                 Realm = parameters["realm"],
                                 Nonce = parameters["nonce"],
                                 Qop = parameters["qop"],
                                 Opaque = parameters["opaque"]
                             };

            try
            {
                header.Stale = bool.Parse(parameters["stale"]);
            }
            catch (Exception err)
            {
                throw new ParseException("Failed to parse 'stale' in WWW-Authenticate header.", err);
            }

            return header;
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="vLogs.Objects.KeyValuePayload"/> class with the specified key/value collection.
        /// </summary>
        /// <param name="col"></param>
        /// <exception cref="System.ArgumentNullException">Thrown when the given collection is null.</exception>
        /// <exception cref="System.ArgumentException">Thrown when the given collection is not locked (read-only).</exception>
        public KeyValuePayload(KeyValueCollection col)
        {
            if (col == null)
                throw new ArgumentNullException("col");
            if (!col.IsReadOnly)
                throw new ArgumentException("The given key/value collection must be locked (read-only) to assure the immutability of the payload.", "col");

            this.Collection = col;
        }
예제 #7
0
파일: frmDataQuery.cs 프로젝트: hkiaipc/qa
        private KeyValueCollection GetStationNameKeyValues()
        {
            KeyValueCollection kvs = new KeyValueCollection();
            DataTable tbl = DBI.GetStationDataTable("scl6");
            foreach (DataRow row in tbl.Rows)
            {
                kvs.Add(new KeyValue(row["StationName"].ToString().Trim(), row));
            }

            return kvs;
        }
예제 #8
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="flags">Message flags.</param>
        public IMAP_t_MsgFlags(params string[] flags)
        {
            m_pFlags = new KeyValueCollection<string,string>();

            if(flags != null){
                foreach(string flag in flags){
                    if(!string.IsNullOrEmpty(flag)){
                        m_pFlags.Add(flag.ToLower(),flag);
                    }
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="vLogs.Objects.KeyValues.KeyValuePair"/> class with the specified key and collection value.
        /// </summary>
        /// <remarks>
        /// The given collection must be locked (read-only).
        /// </remarks>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <exception cref="System.ArgumentNullException">Thrown when the given key or value are null.</exception>
        /// <exception cref="System.ArgumentException">Thrown when the given collection is not locked (read-only).</exception>
        public KeyValuePair(string key, KeyValueCollection value)
        {
            if (key == null)
                throw new ArgumentNullException("key");
            if (value == null)
                throw new ArgumentNullException("value");

            if (!value.IsReadOnly)
                throw new ArgumentException("The given key/value collection must be locked (read-only) to assure the immutability of the object.", "value");

            this._key = key;
            this._type = KvpValueType.Collection;
            this._col = value;
        }
예제 #10
0
 public static KeyValueCollection CreateDataSource()
 {
     KeyValueCollection kvs = new KeyValueCollection();
     kvs = new KeyValueCollection();
     kvs.Add(new KeyValue("编号", "Serial"));
     kvs.Add(new KeyValue("单位名称", "CompanyName"));
     kvs.Add(new KeyValue("单位地址", "CompanyAddress"));
     kvs.Add(new KeyValue("联系人", "Contact"));
     kvs.Add(new KeyValue("联系电话", "Phone"));
     kvs.Add(new KeyValue("电子邮箱", "Email"));
     kvs.Add(new KeyValue("年申请取水量", "AskingAmount"));
     //_kvs.Add(new KeyValue("水源地点", ""));
     kvs.Add(new KeyValue("年取水量", "GwAmount"));
     kvs.Add(new KeyValue("退水量", "BwAmount"));
     return kvs;
 }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="userName">User login name.</param>
        /// <param name="requestUri">OAuth request URI.</param>
        /// <param name="requestUriParameters">OAuth request URI parameters.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>userName</b>,<b>requestUri</b> or <b>requestUriParameters</b> is null reference.</exception>
        public AUTH_SASL_Client_XOAuth(string userName,string requestUri,KeyValueCollection<string,string> requestUriParameters)
        {
            if(userName == null){
                throw new ArgumentNullException("userName");
            }
            if(requestUri == null){
                throw new ArgumentNullException("requestUri");
            }
            if(requestUriParameters == null){
                throw new ArgumentNullException("requestUriParameters");
            }

            m_UserName              = userName;
            m_RequestUri            = requestUri;
            m_pRequestUriParameters = requestUriParameters;
        }
예제 #12
0
파일: UCCondition.cs 프로젝트: hkiaipc/jsb
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public KeyValueCollection GetConditionKeyValues()
 {
     KeyValueCollection kvs = new KeyValueCollection();
     for (int i = 1; i <= _conditionCount; i++)
     {
         ComboBox cmb = (ComboBox)this.Controls.Find(_cmbBaseName + i, false)[0];
         TextBox txt = (TextBox)this.Controls.Find(_txtBaseName + i, false)[0];
         if (txt.Text.Trim().Length > 0)
         {
             if (!ExistKey(kvs, cmb.SelectedValue.ToString()))
             {
                 kvs.Add(new KeyValue(cmb.SelectedValue.ToString(), txt.Text.Trim()));
             }
         }
     }
     return kvs;
 }
예제 #13
0
파일: DBIForHZ.cs 프로젝트: hkiaipc/C3
        /// <summary>
        /// 
        /// </summary>
        /// <param name="deviceID"></param>
        /// <param name="data"></param>
        public virtual object InsertHeatData(int deviceID, HeatData data)
        {
            string s =
                "insert into tblHeatData(deviceid, dt, instantFlux, sum, IH, SH, GT, BT) " +
                "values(@deviceid, @dt, @instantFlux, @sum, @IH, @SH, @GT, @BT)" ;

            KeyValueCollection kvs = new KeyValueCollection();

            kvs.Add("deviceid", deviceID);
            kvs.Add("dt", data.DT);
            kvs.Add("instantFlux", data.InstantFlux);
            kvs.Add("sum", data.Sum);
            kvs.Add("IH", data.InstantHeat);
            kvs.Add("SH", data.SumHeat);
            kvs.Add("GT", data.GT);
            kvs.Add("BT", data.BT);

            return this.ExecuteScalar(s, kvs);
        }
예제 #14
0
		/// <summary>
		/// Parses HTML-content and returns a KeyValueCollection with values from the HTMLs Input-fields
		/// </summary>
		/// <param name="html"></param>
		/// <returns></returns>
		public static KeyValueCollection ParseInputFieldsFromHtmlResponse(string html) {
            if (string.IsNullOrEmpty(html)) { return new KeyValueCollection(); }

			var dictionary = new KeyValueCollection();

			HtmlTagReader htmlTagReader = new HtmlTagReader(html, "input");

			while (htmlTagReader.GetNextTag()) {
				string tagHtml = htmlTagReader.CurrentTag.Content;
				string name = HtmlTagReader.GetAttributeValueInTag(tagHtml, "name"); ;
				string value = HtmlTagReader.GetAttributeValueInTag(tagHtml, "value");

                if (!string.IsNullOrEmpty(name))
                {
					dictionary.Add(name, value ?? string.Empty);
				}
			}

			return dictionary;
		}
예제 #15
0
파일: DBI.cs 프로젝트: hkiaipc/C3
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="data"></param>
        internal void InsertXD1100Data(int id, XD1100Data data)
        {
            KeyValueCollection kvs = new KeyValueCollection();
            SqlCommand cmd = new SqlCommand();

            string s = " INSERT INTO tblGRData(DT, GT1, BT1, GT2, BT2, OT, GTBase2, GP1, BP1, WL, GP2, BP2, I1, I2, IR, S1, S2, SR, OD, PA2, IH1, SH1, CM1, CM2, CM3, RM1, RM2, DeviceID)" +
                " VALUES(@dt, @gt1, @BT1, @GT2, @BT2, @OT, @GTBase2, @GP1, @BP1, @WL, @GP2, @BP2, @I1, @I2, @IR, @S1, @S2, @SR, @OD, @PA2, @IH1, @SH1, @CM1, @CM2, @CM3, @RM1, @RM2, @DeviceID)";

            cmd.CommandText = s;
            SqlParameterCollection p = cmd.Parameters ;

            AddSqlParameter(p, "DT", data.DT);
            AddSqlParameter(p, "GT1", data.GT1);
            AddSqlParameter(p, "BT1", data.BT1);
            AddSqlParameter(p, "GT2", data.GT2);
            AddSqlParameter(p, "BT2", data.BT2);
            AddSqlParameter(p, "OT", data.OT);
            AddSqlParameter(p, "GTBase2", data.GTBase2);
            AddSqlParameter(p, "GP1", data.GP1);
            AddSqlParameter(p, "BP1", data.BP1);
            AddSqlParameter(p, "WL", data.WL);
            AddSqlParameter(p, "GP2", data.GP2);
            AddSqlParameter(p, "BP2", data.BP2);
            AddSqlParameter(p, "I1", data.I1);
            AddSqlParameter(p, "I2", data.I2);
            AddSqlParameter(p, "IR", data.IR);
            AddSqlParameter(p, "S1", data.S1);
            AddSqlParameter(p, "S2", data.S2);
            AddSqlParameter(p, "SR", data.SR);
            AddSqlParameter(p, "OD", data.OD);
            AddSqlParameter(p, "PA2", data.PA2);
            AddSqlParameter(p, "IH1", data.IH1);
            AddSqlParameter(p, "SH1", data.SH1);

            AddSqlParameter(p, "CM1", data.CM1.PumpStatusEnum);
            AddSqlParameter(p, "CM2", data.CM2.PumpStatusEnum);
            AddSqlParameter(p, "CM3", data.CM3.PumpStatusEnum);
            AddSqlParameter(p, "RM1", data.RM1.PumpStatusEnum);
            AddSqlParameter(p, "RM2", data.RM2.PumpStatusEnum);
            AddSqlParameter(p, "DeviceID", id);

            ExecuteScalar(cmd);

            InsertGRAlarmData(id, data.DT, data.Warn.WarnList);
        }
예제 #16
0
        int PrepareBiblioRecord(
            out string strError)
        {
            strError = "";
            int  nRet = 0;
            long lRet = 0;

            // string strOutputPath = "";

            if (string.IsNullOrEmpty(this.RecPath) == true)
            {
                return(0);   // 此时无法进行初始化
            }
            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            string         strBiblioXml = "";
            LibraryChannel channel      = sessioninfo.GetChannel(true);

            try
            {
                // string strBiblioState = "";

                byte[]   timestamp = null;
                string[] formats   = new string[1];
                formats[0] = "xml";

                string[] results = null;
                lRet = // sessioninfo.Channel.
                       channel.GetBiblioInfos(
                    null,
                    this.RecPath,
                    "",
                    formats,
                    out results,
                    out timestamp,
                    out strError);
                if (lRet == -1)
                {
                    strError = "获得书目记录 '" + this.RecPath + "' 时出错: " + strError;
                    goto ERROR1;
                }
                if (lRet == 0)
                {
                    strError = "书目记录 '" + this.RecPath + "' 不存在";
                    goto ERROR1;
                }
                if (results == null || results.Length < 1)
                {
                    strError = "results error {A9217775-645E-42F1-8307-22B26C0E1D69}";
                    goto ERROR1;
                }

                strBiblioXml  = results[0];
                this.m_strXml = strBiblioXml;

                this.Timestamp     = ByteArray.GetHexTimeStampString(timestamp);
                this.BiblioRecPath = this.RecPath;
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }

            if (app.SearchLog != null)
            {
                SearchLogItem log = new SearchLogItem();
                log.IP       = this.Page.Request.UserHostAddress.ToString();
                log.Query    = "";
                log.Time     = DateTime.UtcNow;
                log.HitCount = 1;
                log.Format   = "biblio";
                log.RecPath  = this.RecPath;
                app.SearchLog.AddLogItem(log);
            }

            string strMarc = "";

            // 转换为MARC
            {
                string strOutMarcSyntax = "";

                // 将MARCXML格式的xml记录转换为marc机内格式字符串
                // parameters:
                //		bWarning	==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换
                //		strMarcSyntax	指示marc语法,如果=="",则自动识别
                //		strOutMarcSyntax	out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值
                nRet = MarcUtil.Xml2Marc(strBiblioXml,
                                         true,
                                         "", // this.CurMarcSyntax,
                                         out strOutMarcSyntax,
                                         out strMarc,
                                         out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                this.m_strMARC = strMarc;
            }

            bool bAjax = true;

            if (this.DisableAjax == true)
            {
                bAjax = false;
            }
            else
            {
                if (app != null &&
                    app.WebUiDom != null &&
                    app.WebUiDom.DocumentElement != null)
                {
                    XmlNode nodeBiblioControl = app.WebUiDom.DocumentElement.SelectSingleNode(
                        "biblioControl");
                    if (nodeBiblioControl != null)
                    {
                        DomUtil.GetBooleanParam(nodeBiblioControl,
                                                "ajax",
                                                true,
                                                out bAjax,
                                                out strError);
                    }
                }
            }

            if (bAjax == false)
            {
                string strBiblio       = "";
                string strBiblioDbName = StringUtil.GetDbName(this.RecPath);

                // 需要从内核映射过来文件
                string strLocalPath = "";
                nRet = app.MapKernelScriptFile(
                    // null,   // sessioninfo,
                    strBiblioDbName,
                    "./cfgs/opac_biblio.fltx",  // OPAC查询固定认这个角色的配置文件,作为公共查询书目格式创建的脚本。而流通前端,创建书目格式的时候,找的是loan_biblio.fltx配置文件
                    out strLocalPath,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                // 将种记录数据从XML格式转换为HTML格式
                KeyValueCollection result_params = null;

                // 2006/11/28 changed
                string strFilterFileName = strLocalPath;    // app.CfgDir + "\\biblio.fltx";
                nRet = app.ConvertBiblioXmlToHtml(
                    strFilterFileName,
                    strBiblioXml,
                    this.RecPath,
                    out strBiblio,
                    out result_params,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                // TODO: Render的时候设置,已经晚了半拍
                // 要想办法在全部Render前得到题名和进行设置
                if (this.AutoSetPageTitle == true &&
                    result_params != null && result_params.Count > 0)
                {
                    string strTitle = result_params["title"].Value;
                    if (string.IsNullOrEmpty(strTitle) == false)
                    {
                        this.Page.Title = strTitle;
                    }

                    bool bHasDC = false;
                    // 探测一下,是否有至少一个DC.开头的 key ?
                    foreach (KeyValue item in result_params)
                    {
                        if (StringUtil.HasHead(item.Key, "DC.") == true)
                        {
                            bHasDC = true;
                            break;
                        }
                    }

                    if (bHasDC == true)
                    {
                        // <header profile="http://dublincore.org/documents/2008/08/04/dc-html/">
                        this.Page.Header.Attributes.Add("profile", "http://dublincore.org/documents/2008/08/04/dc-html/");

                        // DC rel
                        //
                        HtmlLink link = new HtmlLink();
                        link.Href = "http://purl.org/dc/elements/1.1/";
                        link.Attributes.Add("rel", "schema.DC");
                        this.Page.Header.Controls.Add(link);

                        // <link rel="schema.DCTERMS" href="http://purl.org/dc/terms/" >
                        link      = new HtmlLink();
                        link.Href = "http://purl.org/dc/terms/";
                        link.Attributes.Add("rel", "schema.DCTERMS");
                        this.Page.Header.Controls.Add(link);

                        foreach (KeyValue item in result_params)
                        {
                            if (StringUtil.HasHead(item.Key, "DC.") == false &&
                                StringUtil.HasHead(item.Key, "DCTERMS.") == false)
                            {
                                continue;
                            }
                            HtmlMeta meta = new HtmlMeta();
                            meta.Name    = item.Key;
                            meta.Content = item.Value;
                            if (StringUtil.HasHead(item.Value, "urn:") == true ||
                                StringUtil.IsHttpUrl(item.Value) == true ||
                                StringUtil.HasHead(item.Value, "info:") == true
                                )
                            {
                                meta.Attributes.Add("scheme", "DCTERMS.URI");
                            }

                            this.Page.Header.Controls.Add(meta);
                        }
                    }
                }

                this.m_strOpacBiblio = strBiblio;
            }
            return(0);

ERROR1:
            return(-1);
        }
예제 #17
0
        public static Contact ParseContact(ITextReader reader)
        {
            /*
                When the header field value contains a display name, the URI
                including all URI parameters is enclosed in "<" and ">".  If no "<"
                and ">" are present, all parameters after the URI are header
                parameters, not URI parameters.  The display name can be tokens, or a
                quoted string, if a larger character set is desired.
             */

            reader.ConsumeWhiteSpaces();

            string name;
            if (reader.Current == '\"')
            {
                name = reader.ReadQuotedString();
                reader.Consume('\t', ' ');
            }
            else
                name = string.Empty;

            SipUri uri;

            bool isEnclosed = reader.Current == '<';
            if (reader.Current != '<' && name != string.Empty)
                throw new FormatException("Expected to find '<' in contact.");

            reader.Consume();
            string uriText = isEnclosed ? reader.ReadToEnd('>') : reader.ReadToEnd(';');
            if (uriText == null)
                throw new FormatException("Failed to find '>' in contact.");
            try
            {
                uri = Parse(uriText);
            }
            catch (FormatException err)
            {
                throw new FormatException("Failed to parse uri in contact.", err);
            }
            reader.Consume('>', '\t', ' ');

            // Read parameters.
            var parameters = new KeyValueCollection();
            ParseParameters(parameters, reader);
            return new Contact(parameters) {Name = name, Uri = uri};
        }
예제 #18
0
 public void MuteTransfer(string OtherDN, string location, KeyValueCollection userData, KeyValueCollection reasons, KeyValueCollection extensions)
 {
     RequestAgentTransfer.MuteTransfer(OtherDN, location, userData, reasons, extensions);
     HoldingFlagStatus(PhoneFunctions.CompleteTransfer);
 }
예제 #19
0
 /// <summary>
 /// Updates the ocs call data.
 /// </summary>
 /// <param name="userData">The user data.</param>
 /// <returns></returns>
 public OutputValues UpdateOCSCallData(KeyValueCollection userData)
 {
     return(RequestUpdateAttachData.DistributeUserEvent(userData));
 }
        /// <summary>
        /// Parses parameters from the specified reader.
        /// </summary>
        /// <param name="reader">MIME reader.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>reader</b> is null reference.</exception>
        public void Parse(MIME_Reader reader)
        {
            if(reader == null){
                throw new ArgumentNullException("reader");
            }

            /* RFC 2231.
                Asterisks ("*") are reused to provide the indicator that language and
                character set information is present and encoding is being used. A
                single quote ("'") is used to delimit the character set and language
                information at the beginning of the parameter value. Percent signs
                ("%") are used as the encoding flag, which agrees with RFC 2047.

                Character set and language information may be combined with the
                parameter continuation mechanism. For example:

                Content-Type: application/x-stuff
                    title*0*=us-ascii'en'This%20is%20even%20more%20
                    title*1*=%2A%2A%2Afun%2A%2A%2A%20
                    title*2="isn't it!"

                Note that:

                (1) Language and character set information only appear at
                    the beginning of a given parameter value.

                (2) Continuations do not provide a facility for using more
                    than one character set or language in the same
                    parameter value.

                (3) A value presented using multiple continuations may
                    contain a mixture of encoded and unencoded segments.

                (4) The first segment of a continuation MUST be encoded if
                    language and character set information are given.

                (5) If the first segment of a continued parameter value is
                    encoded the language and character set field delimiters
                    MUST be present even when the fields are left blank.
            */

            KeyValueCollection<string,_ParameterBuilder> parameters = new KeyValueCollection<string,_ParameterBuilder>();

            // Parse all parameter parts.
            string[] parameterParts = TextUtils.SplitQuotedString(reader.ToEnd(),';');
            foreach(string part in parameterParts){
                if(string.IsNullOrEmpty(part)){
                    continue;
                }

                string[] name_value = part.Trim().Split(new char[]{'='},2);
                string   paramName  = name_value[0].Trim();
                string   paramValue = null;
                if(name_value.Length == 2){
                    paramValue = TextUtils.UnQuoteString(name_value[1].Trim());
                }
                // Valueless parameter.
                //else{

                string[] nameParts = paramName.Split('*');
                int      index     = 0;
                bool     encoded   = nameParts.Length == 3;
                // Get multi value parameter index.
                if(nameParts.Length >= 2){
                    try{
                        index = Convert.ToInt32(nameParts[1]);
                    }
                    catch{
                    }
                }

                // Single value parameter and we already have parameter with such name, skip it.
                if(nameParts.Length < 2 && parameters.ContainsKey(nameParts[0])){
                    continue;
                }

                // Parameter builder doesn't exist for the specified parameter, create it.
                if(!parameters.ContainsKey(nameParts[0])){
                    parameters.Add(nameParts[0],new _ParameterBuilder(nameParts[0]));
                }

                parameters[nameParts[0]].AddPart(index,encoded,paramValue);
            }

            // Build parameters from parts.
            foreach(_ParameterBuilder b in parameters){
                m_pParameters.Add(b.Name,b.GetParamter());
            }

            m_IsModified = false;
        }
예제 #21
0
파일: frmMain.cs 프로젝트: hkiaipc/jsb
        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        /// <param name="kvs"></param>
        /// <returns></returns>
        private bool Match(tblGwl gwl, KeyValueCollection kvs)
        {
            foreach (KeyValue kv in kvs)
            {
                if (Match(gwl, kv.Key, kv.Value.ToString()))
                {

                }
                else
                {
                    return false;
                }
            }
            return true;
        }
예제 #22
0
 private VirtualChangeSet()
 {
     SortedItems = new KeyValueCollection <TObject, TKey>();
     Response    = new VirtualResponse(0, 0, 0);
 }
예제 #23
0
        /// <summary>
        /// 
        /// </summary>
        void BindCycleType()
        {
            KeyValueCollection kvs = new KeyValueCollection();
            kvs.Add(new KeyValue("周", CycleTypeEnum.Week));
            kvs.Add(new KeyValue("自定义", CycleTypeEnum.UserDefine));

            this.cmbCycleType.DisplayMember = "Key";
            this.cmbCycleType.ValueMember = "Value";

            this.cmbCycleType.DataSource = kvs;
        }
예제 #24
0
        private void HandleVoice(iCallData value)
        {
            try
            {
                Type               objType        = null;
                object             obj            = null;
                KeyValueCollection userdata       = null;
                MediaEventHelper   objEventHelper = new MediaEventHelper();
                if (objEventHelper.ConvertVoiceEvent(ref objType, ref obj, ref userdata, value.EventMessage))
                {
                    if (objType != null && obj != null && objURLConfiguration.PostType != null)
                    {
                        if (objURLConfiguration.PostType.ToLower() == "querystring")
                        {
                            SendTextData(objType, obj, userdata, value);
                        }
                        else if (objURLConfiguration.PostType.ToLower() == "json")
                        {
                            SendJsonData(objType, obj, userdata, value);
                        }
                        else if (objURLConfiguration.PostType.ToLower() == "form")
                        {
                            SendFormData(objType, obj, userdata, value);
                        }
                        else if (objURLConfiguration.PostType.ToLower() == "custom" && objURLConfiguration.ApplicationName.ToLower() == "lawson")
                        {
                            PopupLawson(value);
                        }
                        //else if (objURLConfiguration.PostType.ToLower() == "custom" && objURLConfiguration.ApplicationName.ToLower() == "gvas")
                        //    DesktopMessenger.communicateUI.PostDataInGVAS(userdata, objURLConfiguration.ApplicationName, objURLConfiguration.PopupURL);
                        else if (objURLConfiguration.PostType.ToLower() == "custom" && objURLConfiguration.ApplicationName.ToLower() == "gvas")
                        {
                            // Implemented changes for popup multiple URL in GVAS -- 17-11-2015 by sakthikumar
                            // : Start

                            if (!string.IsNullOrEmpty(objURLConfiguration.PopupURL) && objURLConfiguration.PopupURL.Contains(","))
                            {
                                string[] urls = objURLConfiguration.PopupURL.Split(',');
                                if (userdata != null && userdata.ContainsKey("AppName") && urls.Where(x => x.StartsWith(userdata.GetAsString("AppName"))).ToList().Count > 0)
                                {
                                    url = urls.Where(x => x.StartsWith(userdata.GetAsString("AppName"))).SingleOrDefault().Replace(userdata.GetAsString("AppName") + "=", "");
                                }
                            }
                            else
                            {
                                url = objURLConfiguration.PopupURL;
                            }

                            // : End

                            if (!string.IsNullOrEmpty(url))
                            {
                                if (userdata != null && userdata.ContainsKey("AppName") &&
                                    (userdata.GetAsString("AppName").ToUpper() == "VA" || userdata.GetAsString("AppName").ToUpper() == "NVAS"))
                                {
                                    DesktopMessenger.midHandler = this;
                                    DesktopMessenger.communicateUI.PostDataInGVAS(userdata, objURLConfiguration.ApplicationName, url);
                                }
                            }

                            else
                            {
                                logger.Warn("Popup url is not configured.");
                            }
                        }
                        else if (objURLConfiguration.PostType.ToLower() == "custom" && objURLConfiguration.ApplicationName.ToLower() == "evas")
                        {
                            if (userdata != null && userdata.ContainsKey("AppName") && userdata.GetAsString("AppName").ToUpper() == "VA")
                            {
                                if (DesktopMessenger.communicateUI != null)
                                {
                                    DesktopMessenger.midHandler = this;
                                    DesktopMessenger.communicateUI.PostDataToEvas(userdata, objURLConfiguration.ApplicationName, objURLConfiguration.PopupURL);
                                }
                                else
                                {
                                    logger.Warn("The desktop communicator is null.");
                                }
                            }
                        }
                        else if (objURLConfiguration.PostType.ToLower() == "custom" && objURLConfiguration.ApplicationName.ToLower() == "nvas")
                        {
                            if (userdata != null && userdata.ContainsKey("AppName") && userdata.GetAsString("AppName").ToUpper() == "NVAS")
                            {
                                if (DesktopMessenger.communicateUI != null)
                                {
                                    DesktopMessenger.midHandler = this;
                                    DesktopMessenger.communicateUI.PostDataToNvas(userdata, objURLConfiguration.ApplicationName, objURLConfiguration.PopupURL);
                                }
                                else
                                {
                                    logger.Warn("The desktop communicator is null.");
                                }
                            }
                        }
                        else if (objURLConfiguration.PostType.ToLower() == "custom")
                        {
                            SendCustomData(objType, obj, userdata, value);
                        }
                    }
                }
                else
                {
                    logger.Warn("Voice event conversion getting failed");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred as " + generalException.Message);
            }
        }
예제 #25
0
 private void OnLocationChanged(object sender, LocationChangedEventArgs e)
 => parameters = null;
예제 #26
0
        public OutputValues PullInteraction(int tenantId, int proxyClientId, KeyValueCollection interactionIDs)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                RequestPull requestPull = RequestPull.Create();
                requestPull.ViewId         = "_system_";
                requestPull.TenantId       = tenantId;
                requestPull.ProxyClientId  = proxyClientId;
                requestPull.PullParameters = interactionIDs;


                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestPull);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventPulledInteractions.MessageId:
                            logger.Info("------------Pull Interaction-------------");
                            logger.Info("ViewId  :" + requestPull.ViewId);
                            logger.Info("TenantID  :" + requestPull.TenantId);
                            logger.Info("ProxyClientId  :" + requestPull.ProxyClientId);
                            logger.Info("InteractionIds  :" + requestPull.PullParameters.ToString());
                            logger.Info("----------------------------------------------");
                            output.MessageCode = "200";
                            output.IMessage    = message;
                            output.Message     = "Pull interaction Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError = (EventError)message;
                            logger.Info("------------Error on Pull Interaction-------------");
                            logger.Info("ViewId  :" + requestPull.ViewId);
                            logger.Info("TenantID  :" + requestPull.TenantId);
                            logger.Info("ProxyClientId  :" + requestPull.ProxyClientId);
                            logger.Info("InteractionIds  :" + requestPull.PullParameters.ToString());
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventError.ToString());
                            output.MessageCode = "2001";
                            output.Message     = Convert.ToString(eventError.ErrorDescription);
                            logger.Error("Error occurred while pull the  interaction : " + Convert.ToString(eventError.ErrorDescription));
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Pull Interaction UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("TransferInteraction() : Interaction Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while pull the interaction" + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }
예제 #27
0
 private PagedChangeSet()
 {
     SortedItems = new KeyValueCollection <TObject, TKey>();
     Response    = new PageResponse(0, 0, 0, 0);
 }
예제 #28
0
파일: frmMain.cs 프로젝트: hkiaipc/jsb
 /// <summary>
 /// 
 /// </summary>
 /// <param name="list"></param>
 /// <param name="kvs"></param>
 /// <returns></returns>
 private List<tblGwl> Match(List<tblGwl> list, KeyValueCollection kvs)
 {
     List<tblGwl> r = new List<tblGwl>();
     foreach (tblGwl item in list)
     {
         if (Match(item, kvs))
         {
             r.Add(item);
         }
     }
     return r;
 }
예제 #29
0
        private KeyValueCollection Split(string config)
        {
            KeyValueCollection r = new KeyValueCollection();
            string[] kvArray = config.Split(';');
            foreach (string kv in kvArray)
            {
                string[] k_v = kv.Split('=');
                if (k_v.Length == 2)
                {
                    string k = k_v[0];
                    string v = k_v[1];

                    KeyValue newkv = new KeyValue(k, v);
                    r.Add(newkv);
                }
            }
            return r;
        }
        /// <summary>
        /// 实现基类方法
        /// </summary>
        public override void InitConnecton()
        {
            int ii = 0;

            while (!this.IsAvailableConnection && ii <= 3)
            {
                Trace.WriteLine(string.Format("正在尝试第{0}次连接……", ii + 1));
                try
                {
                    //this.ChatServiceInfo = LoadBalancer.GetServiceInfo(CfgAppType.CFGChatServer, "Resources");
                    //if (this.ChatServiceInfo == null) continue;

                    //Trace.WriteLine(string.Format("已分配到服务器。(别名:{0}   地址:{1}:{2})"
                    //    , this.ChatServiceInfo.Alias, this.ChatServiceInfo.Host, this.ChatServiceInfo.Port));

                    //Uri chatRoomURI = new Uri(string.Format("tcp://{0}:{1}", this.ChatServiceInfo.Host, this.ChatServiceInfo.Port));
                    Uri       chatRoomURI  = new Uri("tcp://10.99.36.115:4801");
                    Endpoint  chatEndPoint = new Endpoint(chatRoomURI);
                    ChatParty user         = new ChatParty();
                    user.DisplayName  = this.Customer.DisplayName;
                    user.ChatProtocol = new BasicChatProtocol(chatEndPoint);
                    user.ChatProtocol.AutoRegister = true;
                    user.ChatProtocol.UserType     = UserType.Client;
                    user.ChatProtocol.UserNickname = this.Customer.DisplayName;
                    if (this.Customer.ChatProtocol != null)
                    {
                        user.ChatProtocol.UserData = this.Customer.ChatProtocol.UserData;
                    }
                    // 打开聊天服务
                    try
                    {
                        string        logName = "testLog";
                        Log4NetLogger logger  = new Log4NetLogger(log, logName);
                        user.ThreadInvoker = new SingleThreadInvoker("EventReceivingBrokerService-1", logger);
                        user.ThreadInvoker.EnableLogging(logger);
                        user.EventBroker = new EventReceivingBrokerService(user.ThreadInvoker);
                        user.EventBroker.EnableLogging(logger);
                        user.EventBroker.Register(this.ChatEventsHandler, new MessageFilter(user.ChatProtocol.ProtocolId));
                        user.ChatProtocol.SetReceiver(user.EventBroker);

                        var isOpend = false;
                        lock (ChatLock.LOCK_OPEN)
                        {
                            try
                            {
                                user.ChatProtocol.Open();
                                isOpend = true;
                                System.Threading.Thread.Sleep(50);
                            }
                            catch { }
                        }
                        if (!isOpend)
                        {
                            throw new Exception("连接ChatServer异常,稍候重试。");
                        }

                        this.customer = user;

                        this.InitRoom();
                        this.Room.Partys.Add(this.customer);

                        // 日志
                        ChatLog.GetInstance().LogEvent(ChatEvent.NewClient, this.customer.DisplayName);

                        // 若使用TLS协议
                        if (this.ChatServiceInfo != null &&
                            this.ChatServiceInfo.IsWebApiPortSecured)
                        {
                            KeyValueCollection kvs = new KeyValueCollection();
                            kvs[CommonConnection.TlsKey]          = 1;
                            kvs[CommonConnection.BlockingModeKey] = "true";
                            KeyValueConfiguration cfg = new KeyValueConfiguration(kvs);
                            this.customer.ChatProtocol.Configure(cfg);
                        }
                    }
                    catch (Exception)
                    {
                        if (user.EventBroker != null)
                        {
                            user.EventBroker.Unregister(this.ChatEventsHandler);
                        }
                        this.PartyDispose(user);
                    }
                }
                catch (LoadBalancerException ex)
                {
                    Trace.WriteLine("负载异常:" + ex.Message);
                    ii++;
                    Thread.Sleep(1000);
                }
                catch (Exception ex)
                {
                    ChatLog.GetInstance().LogException(ex);
                    ii++;
                }
            }
        }
예제 #31
0
 public CookieParams(int capacity)
 {
     _cookieCollection = new KeyValueCollection <string, string>(capacity, StringComparer.Ordinal);
 }
예제 #32
0
        public String GetSpecificObjectValue(string genesysObjectName, string genesysObjectType, string propertyToRetrieve, bool subscribeForChanges = false, int dbid = 0)
        {
            try
            {
                CfgObjectType       type  = (CfgObjectType)Enum.Parse(typeof(CfgObjectType), genesysObjectType);
                CfgFilterBasedQuery query = new CfgFilterBasedQuery(type);

                if (dbid != 0) //Then we need to find an object from its dbid rather than its name
                {
                    query.Filter["dbid"] = dbid;
                }
                else
                {
                    query.Filter["name"] = genesysObjectName;
                }

                dynamic dynamicObject = confServiceContract.RetrieveObject(query);

                if (dynamicObject != null)
                {
                    if (subscribeForChanges)
                    {
                        if (!_registeredObjects.Contains(genesysObjectName))
                        {
                            confServiceContract.Subscribe(dynamicObject);
                            _registeredObjects.Add(genesysObjectType);
                            TpsLogManager <ConfigServer> .Debug("Registered for changes against: " + genesysObjectType);
                        }
                    }

                    Type typeOfDynamic = dynamicObject.GetType();

                    //To be used for Calling Lists or other objects to retrieve actual properties of the object
                    if (typeOfDynamic.GetProperties().Any(p => p.Name.Equals(propertyToRetrieve)))
                    {
                        var propertyInfo = dynamicObject.GetType().GetProperty(propertyToRetrieve);
                        var value        = propertyInfo.GetValue(dynamicObject, null);
                        return(value.ToString());
                    }

                    //To get a value from an objects options
                    if (typeOfDynamic.GetProperties().Any(p => p.Name.Equals("Options")))
                    {
                        foreach (var option in dynamicObject.Options)
                        {
                            KeyValueCollection splitValues = (KeyValueCollection)option.Value;

                            foreach (DictionaryEntry eachValue in splitValues)
                            {
                                if (eachValue.Key.ToString() == propertyToRetrieve)
                                {
                                    return(eachValue.Value.ToString());
                                }
                            }
                        }
                    }


                    // To get a value from an objects User Properties
                    if (typeOfDynamic.GetProperties().Any(p => p.Name.Equals("UserProperties")))
                    {
                        foreach (var option in dynamicObject.UserProperties)
                        {
                            KeyValueCollection splitValues = (KeyValueCollection)option.Value;

                            foreach (DictionaryEntry eachValue in splitValues)
                            {
                                if (eachValue.Key.ToString() == propertyToRetrieve)
                                {
                                    return(eachValue.Value.ToString());
                                }
                            }
                        }
                    }
                }
                else
                {
                    TpsLogManager <ConfigServer> .Error("Configuration item could not be retrieved: " + genesysObjectName);
                }
            }
            catch (Exception e)
            {
                TpsLogManager <ConfigServer> .Error(e.Message);
            }

            return("");
        }
예제 #33
0
        /// <summary>
        /// 获取员工(坐席、管理员)、坐席信息、坐席能力
        /// </summary>
        /// <param name="employeeId">员工编号</param>
        public static Person GetPerson(string employeeId)
        {
            var result = new List <Person>();
            var icfg   = OpenCfg();

            try
            {
                CfgPersonQuery qPerson1 = new CfgPersonQuery(icfg);
                qPerson1.TenantDbid = 101;
                qPerson1.State      = CfgObjectState.CFGEnabled;
                qPerson1.IsAgent    = 2;//只有坐席能登录
                qPerson1.EmployeeId = employeeId;
                var persons = qPerson1.Execute();
                foreach (var person1 in persons)
                {
                    var info = new Person();
                    info.DBID       = person1.DBID;
                    info.EmployeeID = person1.EmployeeID;
                    info.FirstName  = person1.FirstName;
                    info.UserName   = person1.UserName;
                    if (person1.AgentInfo != null)
                    {
                        info.AgentInfo.IsInitAgentInfo = true;
                        //坐席信息
                        foreach (var item in person1.AgentInfo.AgentLogins)
                        {
                            if (item.AgentLogin != null && item.AgentLogin.State == CfgObjectState.CFGEnabled)
                            {
                                info.LoginCode = item.AgentLogin.LoginCode;
                                info.AgentInfo.AgentLogins.Add(new AgentLogin()
                                {
                                    DBID      = item.AgentLogin.DBID,
                                    LoginCode = item.AgentLogin.LoginCode,
                                });
                            }
                        }

                        //队列
                        foreach (var item in person1.AgentInfo.SkillLevels)
                        {
                            if (item.Skill != null && item.Skill.State == CfgObjectState.CFGEnabled)
                            {
                                info.AgentInfo.SkillLevels.Add(new SkillLevel()
                                {
                                    DBID = item.Skill.DBID, Level = item.Level
                                });
                            }
                        }
                    }

                    //服务能力
                    if (person1.AgentInfo != null)
                    {
                        info.VOICE = 1;
                        if (person1.AgentInfo.CapacityRule != null)
                        {
                            CfgScript script = person1.AgentInfo.CapacityRule;
                            if (script != null)
                            {
                                KeyValueCollection kv = script.UserProperties;
                                if (kv != null && kv.Get("_CRWizardMediaCapacityList_") != null)
                                {
                                    KeyValueCollection kv1 = (KeyValueCollection)kv.Get("_CRWizardMediaCapacityList_");
                                    foreach (var key in kv1.AllKeys)
                                    {
                                        if (key == "chat")
                                        {
                                            info.CHAT = kv1.GetAsInt(key);
                                        }
                                        //else if (key == "voice")
                                        //{
                                        //    info.VOICE = kv1.GetAsInt(key);
                                        //}
                                    }
                                }
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(info.LoginCode))
                    {
                        info.LoginCode = "";
                    }
                    result.Add(info);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                CloseCfg(icfg);
            }
            if (result.Count > 0)
            {
                var person = result.First();
                var ip     = HttpContext.Current.Request.UserHostAddress;
                using (var db = new Tele.DataLibrary.SPhoneEntities())
                {
                    var ipdn = db.SPhone_IPDN.Where(x => x.PlaceIP == ip).FirstOrDefault();
                    if (ipdn != null)
                    {
                        person.DN    = ipdn.DNNo;
                        person.Place = ipdn.Place;
                    }
                }
                return(person);
            }
            return(null);
        }
예제 #34
0
파일: frmLeaveItem.cs 프로젝트: hkiaipc/fnq
        /// <summary>
        /// 
        /// </summary>
        private void BindDataSources()
        {
            DB db = DBFactory.GetDB();

            this.cmbGroup.DisplayMember = "GroupName";
            this.cmbGroup.ValueMember = "GroupID";
            this.cmbGroup.DataSource = db.tblGroup;

            // leave data source
            //
            KeyValueCollection kvs = new KeyValueCollection();
            kvs.Add(new KeyValue("事假", LeaveEnum.Private));
            kvs.Add(new KeyValue("病假", LeaveEnum.Sick));
            kvs.Add(new KeyValue("休假", LeaveEnum.Vacation));

            this.cmbType.DisplayMember = "Key";
            this.cmbType.ValueMember = "Value";
            this.cmbType.DataSource = kvs;
        }
예제 #35
0
 /// <summary>
 /// Message queue client receiver options
 /// </summary>
 /// <param name="timeoutInSec">Receive timeout in seconds</param>
 /// <param name="parameters">Additional parameters</param>
 public MQClientReceiverOptions(int timeoutInSec, params KeyValue <string, string>[] parameters)
 {
     TimeoutInSec = timeoutInSec;
     Parameters   = new KeyValueCollection(parameters);
 }
예제 #36
0
        /// <summary>
        /// 获取所有员工(坐席)、坐席信息、坐席能力
        /// 此方法效率太慢
        /// </summary>
        /// <returns></returns>
        public static List <Person> GetPersons()
        {
            var result = new List <Person>();
            var icfg   = OpenCfg();

            try
            {
                CfgPersonQuery qPerson1 = new CfgPersonQuery(icfg);
                qPerson1.TenantDbid = 101;
                qPerson1.State      = CfgObjectState.CFGEnabled;
                qPerson1.IsAgent    = 2;
                var persons = qPerson1.Execute();
                foreach (var person1 in persons)
                {
                    var info = new Person();
                    info.DBID       = person1.DBID;
                    info.EmployeeID = person1.EmployeeID;
                    info.FirstName  = person1.FirstName;
                    info.UserName   = person1.UserName;
                    if (person1.AgentInfo != null)
                    {
                        info.AgentInfo.IsInitAgentInfo = true;
                        //坐席信息
                        foreach (var item in person1.AgentInfo.AgentLogins)
                        {
                            if (item.AgentLogin != null && item.AgentLogin.State == CfgObjectState.CFGEnabled)
                            {
                                info.AgentInfo.AgentLogins.Add(new AgentLogin()
                                {
                                    DBID      = item.AgentLogin.DBID,
                                    LoginCode = item.AgentLogin.LoginCode,
                                });
                            }
                        }

                        //队列
                        foreach (var item in person1.AgentInfo.SkillLevels)
                        {
                            if (item.Skill != null && item.Skill.State == CfgObjectState.CFGEnabled)
                            {
                                info.AgentInfo.SkillLevels.Add(new SkillLevel()
                                {
                                    DBID = item.Skill.DBID, Level = item.Level
                                });
                            }
                        }
                    }

                    //服务能力
                    if (person1.AgentInfo != null)
                    {
                        info.VOICE = 1;
                        if (person1.AgentInfo.CapacityRule != null)
                        {
                            CfgScript script = person1.AgentInfo.CapacityRule;
                            if (script != null)
                            {
                                KeyValueCollection kv = script.UserProperties;
                                if (kv != null && kv.Get("_CRWizardMediaCapacityList_") != null)
                                {
                                    KeyValueCollection kv1 = (KeyValueCollection)kv.Get("_CRWizardMediaCapacityList_");
                                    foreach (var key in kv1.AllKeys)
                                    {
                                        if (key == "chat")
                                        {
                                            info.CHAT = kv1.GetAsInt(key);
                                        }
                                        else if (key == "voice")
                                        {
                                            info.VOICE = kv1.GetAsInt(key);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    result.Add(info);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                CloseCfg(icfg);
            }
            return(result);
        }
예제 #37
0
        /// <summary>
        /// Sends Update Log Data
        /// </summary>
        /// <param name="connId"></param>
        /// <param name="sfdcData"></param>
        public void SendUpdateLogData(string connId, SFDCData sfdcData)
        {
            try
            {
                logger.Info("SendUpdateLogData : Collects Update Log data");
                logger.Info("Connection ID : " + connId);

                if (Settings.UpdateSFDCLog.ContainsKey(connId))
                {
                    UpdateLogData updateData = Settings.UpdateSFDCLog[connId];
                    if (updateData != null)
                    {
                        if (sfdcData.LeadData != null)
                        {
                            logger.Info("SendUpdateLogData : Sending Lead Update Log data");
                            sfdcData.LeadData.ActivityRecordID = updateData.LeadActivityId;
                            sfdcData.LeadData.RecordID         = updateData.LeadRecordId;
                        }
                        if (sfdcData.ContactData != null)
                        {
                            logger.Info("SendUpdateLogData : Sending Contact Update Log data");
                            sfdcData.ContactData.ActivityRecordID = updateData.ContactActivityId;
                            sfdcData.ContactData.RecordID         = updateData.ContactRecordId;
                        }
                        if (sfdcData.AccountData != null)
                        {
                            logger.Info("SendUpdateLogData : Sending Account Update Log data");
                            sfdcData.AccountData.ActivityRecordID = updateData.AccountActivityId;
                            sfdcData.AccountData.RecordID         = updateData.AccountRecordId;
                        }
                        if (sfdcData.CaseData != null)
                        {
                            logger.Info("SendUpdateLogData : Sending Case Update Log data");
                            sfdcData.CaseData.ActivityRecordID = updateData.CaseActivityId;
                            sfdcData.CaseData.RecordID         = updateData.CaseRecordId;
                        }
                        if (sfdcData.OpportunityData != null)
                        {
                            logger.Info("SendUpdateLogData : Sending Opportunity Update Log data");
                            sfdcData.OpportunityData.ActivityRecordID = updateData.OpportunityActivityId;
                            sfdcData.OpportunityData.RecordID         = updateData.OpportunityRecordId;
                        }
                        if (sfdcData.UserActivityData != null)
                        {
                            logger.Info("SendUpdateLogData : Sending UserActivity Update Log data");
                            sfdcData.UserActivityData.RecordID = updateData.UserActivityId;
                        }
                        if (sfdcData.CustomObjectData != null && updateData.CustomObject != null)
                        {
                            foreach (CustomObjectData custom in sfdcData.CustomObjectData)
                            {
                                if (updateData.CustomObject.ContainsKey(custom.ObjectName))
                                {
                                    KeyValueCollection collection = updateData.CustomObject[custom.ObjectName];
                                    if (collection != null)
                                    {
                                        logger.Info("SendUpdateLogData : Sending CustomObject Update Log data");
                                        if (collection.ContainsKey("newRecordId"))
                                        {
                                            custom.RecordID = collection["newRecordId"].ToString();
                                        }

                                        if (collection.ContainsKey("activityRecordId"))
                                        {
                                            custom.ActivityRecordID = collection["activityRecordId"].ToString();
                                        }
                                    }
                                }
                            }
                        }
                        SendPopupData(connId, sfdcData);
                    }
                }
                if (!Settings.UpdateSFDCLogFinishedEvent.ContainsKey(connId))
                {
                    Settings.UpdateSFDCLogFinishedEvent.Add(connId, sfdcData);
                }
                else
                {
                    Settings.UpdateSFDCLogFinishedEvent[connId] = sfdcData;
                }
            }
            catch (Exception generalException)
            {
                this.logger.Error("SendUpdateLogData : Error occurred while sending update Log :" + generalException.ToString());
            }
        }
예제 #38
0
        /// <summary>
        /// Does the chat transfer interaction.
        /// </summary>
        /// <param name="interactionId">The interaction identifier.</param>
        /// <param name="agentId">The agent identifier.</param>
        /// <param name="placeId">The place identifier.</param>
        /// <param name="proxyId">The proxy identifier.</param>
        /// <param name="queueName">Name of the queue.</param>
        /// <returns></returns>
        public OutputValues DoChatTransferInteraction(string interactionId, string agentId, string placeId, int proxyId, string queueName, KeyValueCollection userData)
        {
            OutputValues output = OutputValues.GetInstance();

            try
            {
                output = RequestTransferInteraction.TransferChatSession(interactionId, agentId, placeId, proxyId, queueName, userData);
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Do Chat Transfer Interaction " + generalException.ToString());
            }
            return(output);
        }
예제 #39
0
        public void InitiateConference(string otherDn, string location, KeyValueCollection userData, KeyValueCollection reasons, KeyValueCollection extensions)
        {
            //Input Validation
            CheckException.CheckDialValues(otherDn);

            RequestAgentConference.InitiateConference(otherDn, location, userData, reasons, extensions);
            if ((Settings.GetInstance().CallControl == "both" ? Settings.GetInstance().ActiveDN : (Settings.GetInstance().CallControl == "acd" ?
                                                                                                   Settings.GetInstance().ACDPosition : Settings.GetInstance().ExtensionDN)) != otherDn)
            {
                HoldingFlagStatus(PhoneFunctions.IntiateConference);
            }
        }
예제 #40
0
        /// <summary>
        /// Documents the consult chat join.
        /// </summary>
        /// <param name="interactionID">The interaction unique identifier.</param>
        /// <param name="subject">The subject.</param>
        /// <param name="message">The message.</param>
        /// <param name="userData">The user data.</param>
        /// <returns></returns>
        public OutputValues DOConsultChatJoin(string interactionID, string subject, string message, KeyValueCollection userData)
        {
            OutputValues output = OutputValues.GetInstance();

            try
            {
                output = RequestJoinChatSession.JoinConsultChatSession(interactionID, subject, message, userData);
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Do Consult Chat Join " + generalException.ToString());
            }
            return(output);
        }
예제 #41
0
 public void SingleStepConference(string otherDN, string location, KeyValueCollection userData)
 {
     RequestAgentConference.SingleStepConference(otherDN, location, userData);
 }
예제 #42
0
        /// <summary>
        /// Does the reject chat interaction.
        /// </summary>
        /// <param name="ticketID">The ticket identifier.</param>
        /// <param name="interactionID">The interaction identifier.</param>
        /// <param name="proxyID">The proxy identifier.</param>
        /// <returns></returns>
        public OutputValues DoRejectChatInteraction(int ticketID, string interactionID, int proxyID, InteractionServerProtocol ixnProtocol, KeyValueCollection ixnData)
        {
            OutputValues output = OutputValues.GetInstance();

            if (ixnProtocol != null)
            {
                Settings.IxnServerProtocol = ixnProtocol;
            }
            try
            {
                output = RequestRejectInteraction.RejectChatInteraction(ticketID, interactionID, proxyID, ixnData);
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Do Reject Chat Interaction " + generalException.ToString());
            }
            return(output);
        }
예제 #43
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public POP3_Session()
 {
     m_pAuthentications = new Dictionary<string,AUTH_SASL_ServerMechanism>(StringComparer.CurrentCultureIgnoreCase);
     m_pMessages = new KeyValueCollection<string,POP3_ServerMessage>();
 }
예제 #44
0
        public OutputValues DoUpdateCaseDataProperties(string interactionId, int proxyClientID, KeyValueCollection updatedProperties)
        {
            OutputValues output = OutputValues.GetInstance();

            try
            {
                output = RequestToChangeProperties.UpdateProperties(interactionId, proxyClientID, updatedProperties);
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred update case data property " + generalException.ToString());
            }
            return(output);
        }
예제 #45
0
 /// <summary>
 /// Create a new Storage from a KeyValueCollection parameters
 /// </summary>
 /// <param name="parameters">Parameters to create the storage</param>
 /// <returns>Storage instance</returns>
 protected abstract StorageBase CreateStorage(KeyValueCollection parameters);
        /// <summary>
        /// Provides the observer with new data.
        /// </summary>
        /// <param name="value">The current notification information.</param>

        public void OnNext(iCallData value)
        {
            Thread pipeThread = new Thread(delegate()
            {
                try
                {
                    if (value == null || value.EventMessage == null)
                    {
                        logger.Warn("Event detail is null.");
                        return;
                    }

                    if (objConfiguration.MediaType != value.MediaType)
                    {
                        return;
                    }

                    if (objConfiguration.PipeEvent == null || objConfiguration.PipeEvent.Where(x => x == value.EventMessage.Name.ToLower()).ToList().Count == 0)
                    {
                        return;
                    }

                    Type objType = null;
                    object obj   = null;
                    KeyValueCollection userdata = null;

                    // For Convert voice
                    if (value.MediaType == MediaType.Voice)
                    {
                        MediaEventHelper objEventHelper = new MediaEventHelper();
                        if (!objEventHelper.ConvertVoiceEvent(ref objType, ref obj, ref userdata, value.EventMessage))
                        {
                            logger.Warn("Voice event conversion getting failed");
                        }
                    }
                    else if (value.MediaType == MediaType.Email)
                    {
                    }
                    else if (value.MediaType == MediaType.Chat)
                    {
                    }
                    else if (value.MediaType == MediaType.SMS)
                    {
                    }

                    // Functionality to send data in the specified format.
                    if (objType != null && obj != null)
                    {
                        switch (objConfiguration.PipeFormat)
                        {
                        case "text":
                            SendTextData(objType, obj, userdata);
                            break;

                        case "json":
                            SendJsonData(objType, obj, userdata);
                            break;

                        case "xml":
                            SendXMLData(objType, obj, userdata);
                            break;

                        case "custom":
                            SendTextData(objType, obj, userdata);
                            break;

                        default:
                            logger.Warn("The specified format not supported in the pipe integration");
                            break;
                        }
                    }
                    else
                    {
                        logger.Warn("Required data is null.");
                    }
                }
                catch (Exception generalException)
                {
                    logger.Error("Error occurred while writing call data to a file " + generalException.ToString());
                }
            });

            pipeThread.Start();
        }
예제 #47
0
파일: UCCondition.cs 프로젝트: hkiaipc/jsb
 private bool ExistKey(KeyValueCollection kvs, string key)
 {
     foreach (KeyValue kv in kvs)
     {
         if (kv.Key == key)
         {
             return true;
         }
     }
     return false;
 }
예제 #48
0
        /// <summary>
        /// 
        /// </summary>
        void BindCycleDayCount()
        {
            KeyValueCollection kvs = new KeyValueCollection();

            for (int i = 1; i < 11; i++)
            {
                kvs.Add(new KeyValue(string.Format("{0}天", i), i));
            }

            this.cmbCycleDayCount.DisplayMember = "Key";
            this.cmbCycleDayCount.ValueMember = "Value";
            this.cmbCycleDayCount.DataSource = kvs;
        }
예제 #49
0
파일: UCTimeDefine.cs 프로젝트: hkiaipc/fnq
        /// <summary>
        /// 
        /// </summary>
        /// <returns>key value collection, key - name, value - offset</returns>
        private object GetDayOffsetDataSource()
        {
            object ds = null;
            if (this.CycleType == CycleTypeEnum.Week)
            {
                KeyValueCollection kvs = new KeyValueCollection();
                kvs.Add(new KeyValue("星期一", DayOfWeek.Monday));
                kvs.Add(new KeyValue("星期二", DayOfWeek.Tuesday));
                kvs.Add(new KeyValue("星期三", DayOfWeek.Wednesday));
                kvs.Add(new KeyValue("星期四", DayOfWeek.Thursday));
                kvs.Add(new KeyValue("星期五", DayOfWeek.Friday));
                kvs.Add(new KeyValue("星期六", DayOfWeek.Saturday));
                kvs.Add(new KeyValue("星期日", DayOfWeek.Sunday));

                ds = kvs;
            }

            else if (this.CycleType == CycleTypeEnum.UserDefine)
            {
                KeyValueCollection kvs = new KeyValueCollection();
                for (int i = 0; i < this.DayOfCycle; i++)
                {
                    string key = string.Format("第{0}天", i + 1);
                    int value = i;
                    kvs.Add(new KeyValue(key, i));
                }
                ds = kvs;
            }
            return ds;
        }
예제 #50
0
        //#region Field Declaration
        //private Pointel.Logger.Core.ILog logger = Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AID");
        //InteractionAttributes ixnAttributes = null;
        //#endregion


        #region RequestToUpdateInteraction
        public static OutputValues UpdateInteraction(string interactionID, int ownerId, string comment, KeyValueCollection userData, int status, string dtEndDate)
        {
            Pointel.Logger.Core.ILog logger = Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AID");
            OutputValues             output = OutputValues.GetInstance();

            try
            {
                RequestUpdateInteraction requestUpdateInteraction = Genesyslab.Platform.Contacts.Protocols.ContactServer.Requests.RequestUpdateInteraction.Create();
                InteractionAttributes    ixnAttributes            = new InteractionAttributes();
                ixnAttributes.Id = interactionID;
                if (!string.IsNullOrEmpty(comment))
                {
                    ixnAttributes.TheComment = comment;
                }
                if (ownerId != 0)
                {
                    ixnAttributes.OwnerId = ownerId;
                }
                ixnAttributes.TenantId = Settings.tenantDBID;
                if (!string.IsNullOrEmpty(dtEndDate))
                {
                    ixnAttributes.EndDate = dtEndDate;
                }
                requestUpdateInteraction.InteractionAttributes = ixnAttributes;
                if (userData != null)
                {
                    requestUpdateInteraction.InteractionAttributes.AllAttributes = userData;
                }
                requestUpdateInteraction.InteractionAttributes.Status = status.Equals(3) ? Statuses.Stopped : Statuses.InProcess;
                if (Settings.UCSProtocol != null && Settings.UCSProtocol.State == ChannelState.Opened)
                {
                    logger.Info("------------RequestToUpdateInteraction-------------");
                    logger.Info("Id  :" + interactionID);
                    logger.Info("TheComment  : " + comment);
                    logger.Info("---------------------------------------------------");
                    IMessage message = Settings.UCSProtocol.Request(requestUpdateInteraction);
                    if (message != null)
                    {
                        logger.Trace(message.ToString());
                        output.IContactMessage = message;
                        output.MessageCode     = "200";
                        output.Message         = "Update Interaction Successfully";
                    }
                    else
                    {
                        output.IContactMessage = null;
                        output.MessageCode     = "2001";
                        output.Message         = "Don't Update Interaction Successfully";
                    }
                }
                else
                {
                    output.IContactMessage = null;
                    output.MessageCode     = "2001";
                    output.Message         = "Universal Contact Server protocol is Null or Closed";
                    logger.Warn("UpdateInteraction() : Contact Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Request To Update Interaction " + generalException.ToString());
                output.IContactMessage = null;
                output.MessageCode     = "2001";
                output.Message         = generalException.Message;
            }
            return(output);
        }
예제 #51
0
        private void BindQueryStyle()
        {
            KeyValueCollection kvs = new KeyValueCollection();
            kvs.Add(new KeyValue("按站点", QueryStyleEnum.ByStation));
            kvs.Add(new KeyValue("按人员", QueryStyleEnum.ByPerson));

            this.cmbQueryStyle.DisplayMember = "Key";
            this.cmbQueryStyle.ValueMember = "Value";
            this.cmbQueryStyle.DataSource = kvs;
        }
        public void TestClear_EmptyCollection()
        {
            var collection = new KeyValueCollection <string, JackpotLog>(@"TestCollection", _database);

            collection.Clear();
        }
예제 #53
0
 internal Enumerator(KeyValueCollection <string, string> cookieCollection)
 {
     _cookieCollection = cookieCollection;
     _index            = 0;
     _current          = default;
 }
        /// <summary>
        /// Notifies the disposition code event.
        /// </summary>
        /// <param name="mediaType">Type of the media.</param>
        /// <param name="data">The data.</param>
        public void NotifyDispositionCodeEvent(MediaTypes mediaType, DispositionData data)
        {
            var chatMedia = new ChatMedia();

            try
            {
                if (mediaType == MediaTypes.Chat)
                {
                    if (_chatUtil.UserData.ContainsKey(_chatDataContext.DisPositionKeyName))
                    {
                        if (isFirstTimeCall)
                        {
                            isFirstTimeCall = false;
                            Dictionary <string, string> dispositionCode = new Dictionary <string, string>();
                            dispositionCode.Add(_chatDataContext.DisPositionKeyName,
                                                _chatUtil.UserData[_chatDataContext.DisPositionKeyName].ToString());
                            _dispositionUC.ReLoadDispositionCodes(dispositionCode, _interactionID);
                        }
                        else
                        {
                            string originalValue = string.Empty;
                            if (_chatUtil.UserData.ContainsKey(_chatDataContext.DisPositionKeyName))
                            {
                                originalValue = _chatUtil.UserData[_chatDataContext.DisPositionKeyName].ToString();
                            }
                            if (data.DispostionCode != originalValue)
                            {
                                KeyValueCollection caseData = new KeyValueCollection();
                                caseData.Add(_chatDataContext.DisPositionKeyName, data.DispostionCode);
                                OutputValues output = chatMedia.DoUpdateCaseDataProperties(_interactionID, _chatUtil.ProxyId, caseData);
                                if (output.MessageCode == "200")
                                {
                                    _chatUtil.UserData.Remove(_chatDataContext.DisPositionKeyName);
                                    _chatUtil.UserData.Add(_chatDataContext.DisPositionKeyName, data.DispostionCode);
                                    ObservableCollection <Pointel.Interactions.Chat.Helpers.IChatCaseData> tempCaseData = _chatUtil.NotifyCaseData;
                                    int position1 = tempCaseData.IndexOf(tempCaseData.Where(p => p.Key == _chatDataContext.DisPositionKeyName).FirstOrDefault());
                                    _chatUtil.NotifyCaseData.RemoveAt(position1);
                                    _chatUtil.NotifyCaseData.Insert(position1, new ChatCaseData(_chatDataContext.DisPositionKeyName, data.DispostionCode));
                                    NotifyDispositionToSFDC(_chatDataContext.DisPositionKeyName, data.DispostionCode);
                                }
                                caseData.Clear();
                                caseData = null;
                            }
                        }
                    }
                    else
                    {
                        KeyValueCollection caseData = new KeyValueCollection();
                        caseData.Add(_chatDataContext.DisPositionKeyName, data.DispostionCode);
                        OutputValues output = chatMedia.DoAddCaseDataProperties(_interactionID, _chatUtil.ProxyId, caseData);
                        if (output.MessageCode == "200")
                        {
                            _chatUtil.UserData.Add(_chatDataContext.DisPositionKeyName, data.DispostionCode);
                            _chatUtil.NotifyCaseData.Add(new ChatCaseData(_chatDataContext.DisPositionKeyName, data.DispostionCode));
                            NotifyDispositionToSFDC(_chatDataContext.DisPositionKeyName, data.DispostionCode);
                        }
                        caseData.Clear();
                        caseData = null;
                    }
                    if (_chatUtil.UserData.ContainsKey(_chatDataContext.DispositionCollectionKeyName))
                    {
                        string originalValue = _chatUtil.UserData[_chatDataContext.DispositionCollectionKeyName].ToString();
                        if (data.DispostionCode != originalValue)
                        {
                            string result = string.Join("; ", data.DispostionCollection.Select(x => string.Format("{0}:{1}", x.Key, x.Value)).ToArray());
                            if (!string.IsNullOrEmpty(result))
                            {
                                KeyValueCollection caseData = new KeyValueCollection();
                                caseData.Add(_chatDataContext.DispositionCollectionKeyName, result);
                                OutputValues output = chatMedia.DoUpdateCaseDataProperties(_interactionID, _chatUtil.ProxyId, caseData);
                                if (output.MessageCode == "200")
                                {
                                    _chatUtil.UserData.Remove(_chatDataContext.DispositionCollectionKeyName);
                                    _chatUtil.UserData.Add(_chatDataContext.DispositionCollectionKeyName, result);
                                    ObservableCollection <Pointel.Interactions.Chat.Helpers.IChatCaseData> tempCaseData = _chatUtil.NotifyCaseData;
                                    int position1 = tempCaseData.IndexOf(tempCaseData.Where(p => p.Key == _chatDataContext.DispositionCollectionKeyName).FirstOrDefault());
                                    _chatUtil.NotifyCaseData.RemoveAt(position1);
                                    _chatUtil.NotifyCaseData.Insert(position1, new ChatCaseData(_chatDataContext.DispositionCollectionKeyName, result));
                                }
                                caseData.Clear();
                                caseData = null;
                            }
                        }
                    }
                    else
                    {
                        KeyValueCollection caseData = new KeyValueCollection();
                        string             result   = string.Join("; ", data.DispostionCollection.Select(x => string.Format("{0}:{1}", x.Key, x.Value)).ToArray());
                        if (!string.IsNullOrEmpty(result))
                        {
                            caseData.Add(_chatDataContext.DispositionCollectionKeyName, result);
                            OutputValues output = chatMedia.DoAddCaseDataProperties(_interactionID, _chatUtil.ProxyId, caseData);
                            if (output.MessageCode == "200")
                            {
                                _chatUtil.UserData.Add(_chatDataContext.DispositionCollectionKeyName, result);
                                _chatUtil.NotifyCaseData.Add(new ChatCaseData(_chatDataContext.DispositionCollectionKeyName, result));
                            }
                            caseData.Clear();
                            caseData = null;
                        }
                    }
                    if (data.DispostionCode == "None")
                    {
                        _chatUtil.IsDispositionSelected = false;
                    }
                    else
                    {
                        _chatUtil.IsDispositionSelected = true;
                    }
                }
            }
            catch (Exception generalException)
            {
                _logger.Error("Error occurred while NotifyDispositionCodeEvent(): " + generalException.ToString());
                _chatUtil.IsDispositionSelected = false;
            }
            finally
            {
                chatMedia = null;
            }
        }
예제 #55
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="session">Owner RTP multimedia session.</param>
        /// <param name="localEP">Local RTP end point.</param>
        /// <param name="clock">RTP media clock.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>localEP</b>, <b>localEP</b> or <b>clock</b> is null reference.</exception>
        internal RTP_Session(RTP_MultimediaSession session,RTP_Address localEP,RTP_Clock clock)
        {
            if(session == null){
                throw new ArgumentNullException("session");
            }
            if(localEP == null){
                throw new ArgumentNullException("localEP");
            }
            if(clock == null){
                throw new ArgumentNullException("clock");
            }

            m_pSession  = session;
            m_pLocalEP  = localEP;
            m_pRtpClock = clock;

            m_pLocalSources = new List<RTP_Source_Local>();
            m_pTargets = new List<RTP_Address>();
            m_pMembers = new Dictionary<uint,RTP_Source>();
            m_pSenders = new Dictionary<uint,RTP_Source>();
            m_pConflictingEPs = new Dictionary<string,DateTime>();
            m_pPayloads = new KeyValueCollection<int,Codec>();
            
            m_pUdpDataReceivers = new List<UDP_DataReceiver>();
            m_pRtpSocket = new Socket(localEP.IP.AddressFamily,SocketType.Dgram,ProtocolType.Udp);
            m_pRtpSocket.Bind(localEP.RtpEP);
            m_pRtcpSocket = new Socket(localEP.IP.AddressFamily,SocketType.Dgram,ProtocolType.Udp);
            m_pRtcpSocket.Bind(localEP.RtcpEP);
                        
            m_pRtcpTimer = new TimerEx();
            m_pRtcpTimer.Elapsed += new System.Timers.ElapsedEventHandler(delegate(object sender,System.Timers.ElapsedEventArgs e){
                SendRtcp();
            });
            m_pRtcpTimer.AutoReset = false;
        }
        private string GetOpportunityVoiceSearchValue(KeyValueCollection userData, IMessage message, SFDCCallType callType)
        {
            try
            {
                this.logger.Info("GetOpportunityVoiceSearchValue :  Reading Opportunity Popup Data.....");
                this.logger.Info("GetOpportunityVoiceSearchValue :  UserData Name : " + Convert.ToString(userData));
                this.logger.Info("GetOpportunityVoiceSearchValue :  Event Name : " + message.Name);
                this.logger.Info("GetOpportunityVoiceSearchValue :  CallType Name : " + callType.ToString());

                string[] userDataSearchKeys  = null;
                string[] attributeSearchKeys = null;
                string   searchValue         = string.Empty;
                if (callType == SFDCCallType.Inbound)
                {
                    userDataSearchKeys  = (this.opportunityVoiceOptions.InboundSearchUserDataKeys != null) ? this.opportunityVoiceOptions.InboundSearchUserDataKeys.Split(',') : null;
                    attributeSearchKeys = (this.opportunityVoiceOptions.InboundSearchAttributeKeys != null) ? this.opportunityVoiceOptions.InboundSearchAttributeKeys.Split(',') : null;
                }
                else if (callType == SFDCCallType.OutboundSuccess || callType == SFDCCallType.OutboundFailure)
                {
                    userDataSearchKeys  = (this.opportunityVoiceOptions.OutboundSearchUserDataKeys != null) ? this.opportunityVoiceOptions.OutboundSearchUserDataKeys.Split(',') : null;
                    attributeSearchKeys = (this.opportunityVoiceOptions.OutboundSearchAttributeKeys != null) ? this.opportunityVoiceOptions.OutboundSearchAttributeKeys.Split(',') : null;
                }
                else if (callType == SFDCCallType.ConsultSuccess || callType == SFDCCallType.ConsultFailure)
                {
                    return(this.sfdcObject.GetAttributeSearchValues(message, new string[] { "otherdn" }));
                }
                else if (callType == SFDCCallType.ConsultReceived)
                {
                    userDataSearchKeys  = (this.opportunityVoiceOptions.ConsultSearchUserDataKeys != null) ? this.opportunityVoiceOptions.ConsultSearchUserDataKeys.Split(',') : null;
                    attributeSearchKeys = (this.opportunityVoiceOptions.ConsultSearchAttributeKeys != null) ? this.opportunityVoiceOptions.ConsultSearchAttributeKeys.Split(',') : null;
                }

                #region OLD

                //if (opportunityVoiceOptions.SearchPriority == "user-data")
                //{
                //    if (userDataSearchKeys != null)
                //        searchValue = this.sfdcObject.GetUserDataSearchValues(userData, userDataSearchKeys);
                //    else if (attributeSearchKeys != null)
                //        searchValue = this.sfdcObject.GetAttributeSearchValues(message, attributeSearchKeys);
                //}
                //else if (opportunityVoiceOptions.SearchPriority == "attribute")
                //{
                //    searchValue = this.sfdcObject.GetAttributeSearchValues(message, attributeSearchKeys);
                //}
                //else if (opportunityVoiceOptions.SearchPriority == "both")
                //{
                //    searchValue = this.sfdcObject.GetUserDataSearchValues(userData, userDataSearchKeys);
                //    if (searchValue != string.Empty)
                //    {
                //        string temp = this.sfdcObject.GetAttributeSearchValues(message, attributeSearchKeys);
                //        if (temp != string.Empty)
                //        {
                //            searchValue += "," + temp;
                //        }
                //    }
                //    else
                //    {
                //        searchValue = this.sfdcObject.GetAttributeSearchValues(message, attributeSearchKeys);
                //    }
                //}
                //return searchValue;

                #endregion OLD

                if (opportunityVoiceOptions.SearchPriority == "user-data")
                {
                    if (userDataSearchKeys != null && userData != null)
                    {
                        searchValue = this.sfdcObject.GetUserDataSearchValues(userData, userDataSearchKeys);
                        if (!this.sfdcObject.ValidateSearchData(searchValue))
                        {
                            searchValue = this.sfdcObject.GetAttributeSearchValues(message, attributeSearchKeys);
                        }
                    }
                    else if (attributeSearchKeys != null)
                    {
                        searchValue = this.sfdcObject.GetAttributeSearchValues(message, attributeSearchKeys);
                    }
                }
                else if (opportunityVoiceOptions.SearchPriority == "attribute")
                {
                    searchValue = this.sfdcObject.GetAttributeSearchValues(message, attributeSearchKeys);
                    if (!this.sfdcObject.ValidateSearchData(searchValue))
                    {
                        if (userDataSearchKeys != null && userData != null)
                        {
                            searchValue = this.sfdcObject.GetUserDataSearchValues(userData, userDataSearchKeys);
                        }
                    }
                }
                else if (opportunityVoiceOptions.SearchPriority == "both")
                {
                    if (userData != null)
                    {
                        searchValue = this.sfdcObject.GetUserDataSearchValues(userData, userDataSearchKeys);
                    }
                    if (!this.sfdcObject.ValidateSearchData(searchValue))
                    {
                        searchValue = this.sfdcObject.GetAttributeSearchValues(message, attributeSearchKeys);
                    }
                    else
                    {
                        string temp = this.sfdcObject.GetAttributeSearchValues(message, attributeSearchKeys);
                        if (temp != string.Empty)
                        {
                            searchValue += "," + temp;
                        }
                    }
                }
                return(searchValue);
            }
            catch (Exception generalException)
            {
                this.logger.Error("GetOpportunityVoiceSearchValue : Error occurred while reading Opportunity Search value : " + generalException.ToString());
            }
            return(null);
        }
예제 #57
0
        public UserActivityOptions GetSFDCUserActivityVoiceProperties(KeyValueCollection SFDCObject, string objectName)
        {
            try
            {
                this.logger.Info("GetSFDCUserActivityVoiceProperties : Initializing SFDC UserActivity Voice Configurations");
                this.logger.Info("GetSFDCUserActivityVoiceProperties : Object Name : " + objectName);

                UserActivityOptions sfdcOptions = new UserActivityOptions();
                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("object-name")))
                {
                    sfdcOptions.ObjectName = SFDCObject.GetAsString("object-name").Trim();
                }

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.inb.popup-event-names")))
                {
                    sfdcOptions.InboundPopupEvent = SFDCObject.GetAsString("voice.inb.popup-event-names").Trim();
                }
                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.inb.create.activity-log")) &&
                    SFDCObject.GetAsString("voice.inb.create.activity-log").Trim().ToLower() == "false")
                {
                    sfdcOptions.InboundCanCreateLog = false;
                }
                else
                {
                    sfdcOptions.InboundCanCreateLog = true;
                }
                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.inb.update.activity-log")) &&
                    SFDCObject.GetAsString("voice.inb.update.activity-log").Trim().ToLower() == "true")
                {
                    sfdcOptions.InboundCanUpdateLog = true;
                }
                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.inb.update.activity-log.event-names")))
                {
                    sfdcOptions.InboundUpdateEvent = SFDCObject.GetAsString("voice.inb.update.activity-log.event-names").Trim();
                }
                // Outbound Configurations

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.out.popup-event-names")))
                {
                    sfdcOptions.OutboundPopupEvent = SFDCObject.GetAsString("voice.out.popup-event-names").Trim();
                }

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.out.success.create.activity-log")) &&
                    SFDCObject.GetAsString("voice.out.success.create.activity-log").Trim().ToLower() == "false")
                {
                    sfdcOptions.OutboundCanCreateLog = false;
                }
                else
                {
                    sfdcOptions.OutboundCanCreateLog = true;
                }
                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.out.success.update.activity-log")) &&
                    SFDCObject.GetAsString("voice.out.success.update.activity-log").Trim().ToLower() == "true")
                {
                    sfdcOptions.OutboundCanUpdateLog = true;
                }

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.out.success.update.activity-log.event-names")))
                {
                    sfdcOptions.OutboundUpdateEvent = SFDCObject.GetAsString("voice.out.success.update.activity-log.event-names").Trim();
                }

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.out.fail.create.activity-log")) &&
                    SFDCObject.GetAsString("voice.out.fail.create.activity-log").Trim().ToLower() == "false")
                {
                    sfdcOptions.OutboundFailureCanCreateLog = false;
                }
                else
                {
                    sfdcOptions.OutboundFailureCanCreateLog = true;
                }

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.out.fail.create.activity-log.event-names")))
                {
                    sfdcOptions.OutboundFailurePopupEvent = SFDCObject.GetAsString("voice.out.fail.create.activity-log.event-names").Trim();
                }

                // Consult Configurations

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.con.popup-event-names")))
                {
                    sfdcOptions.ConsultPopupEvent = SFDCObject.GetAsString("voice.con.popup-event-names").Trim();
                }

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("chat.con.success.create.activity-log.event-names")))
                {
                    sfdcOptions.ConsultSuccessLogEvent = SFDCObject.GetAsString("voice.con.success.create.activity-log.event-names").Trim();
                }

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.con.success.create.activity-log")) &&
                    SFDCObject.GetAsString("voice.con.success.create.activity-log").Trim().ToLower() == "false")
                {
                    sfdcOptions.ConsultCanCreateLog = false;
                }
                else
                {
                    sfdcOptions.ConsultCanCreateLog = true;
                }

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.con.success.update.activity-log")) &&
                    SFDCObject.GetAsString("voice.con.success.update.activity-log").Trim().ToLower() == "true")
                {
                    sfdcOptions.ConsultCanUpdateLog = true;
                }

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.con.success.update.activity-log.event-names")))
                {
                    sfdcOptions.ConsultUpdateEvent = SFDCObject.GetAsString("voice.con.success.update.activity-log.event-names").Trim();
                }

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.con.fail.create.activity-log")) &&
                    SFDCObject.GetAsString("voice.con.fail.create.activity-log").Trim().ToLower() == "false")
                {
                    sfdcOptions.ConsultFailureCanCreateLog = false;
                }
                else
                {
                    sfdcOptions.ConsultFailureCanCreateLog = true;
                }

                if (!String.IsNullOrEmpty(SFDCObject.GetAsString("voice.con.fail.create.activity-log.event-names")))
                {
                    sfdcOptions.ConsultFailurePopupEvent = SFDCObject.GetAsString("voice.con.fail.create.activity-log.event-names").Trim();
                }
                this.logger.Info("Configuration Read for " + objectName + ": " + sfdcOptions.ToString());
                return(sfdcOptions);
            }
            catch (Exception generalException)
            {
                this.logger.Error("GetSFDCObjectVoiceProperties : Error occurred while reading SFDC Object Configurations:" + generalException.ToString());
            }
            return(null);
        }
예제 #58
0
        /// <summary>
        /// Parses parameters from the specified reader.
        /// </summary>
        /// <param name="reader">MIME reader.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>reader</b> is null reference.</exception>
        public void Parse(MIME_Reader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            /* RFC 2231.
             *  Asterisks ("*") are reused to provide the indicator that language and
             *  character set information is present and encoding is being used. A
             *  single quote ("'") is used to delimit the character set and language
             *  information at the beginning of the parameter value. Percent signs
             *  ("%") are used as the encoding flag, which agrees with RFC 2047.
             *
             *  Character set and language information may be combined with the
             *  parameter continuation mechanism. For example:
             *
             *  Content-Type: application/x-stuff
             *      title*0*=us-ascii'en'This%20is%20even%20more%20
             *      title*1*=%2A%2A%2Afun%2A%2A%2A%20
             *      title*2="isn't it!"
             *
             *  Note that:
             *
             *  (1) Language and character set information only appear at
             *      the beginning of a given parameter value.
             *
             *  (2) Continuations do not provide a facility for using more
             *      than one character set or language in the same
             *      parameter value.
             *
             *  (3) A value presented using multiple continuations may
             *      contain a mixture of encoded and unencoded segments.
             *
             *  (4) The first segment of a continuation MUST be encoded if
             *      language and character set information are given.
             *
             *  (5) If the first segment of a continued parameter value is
             *      encoded the language and character set field delimiters
             *      MUST be present even when the fields are left blank.
             */

            KeyValueCollection <string, _ParameterBuilder> parameters = new KeyValueCollection <string, _ParameterBuilder>();

            // Parse all parameter parts.
            string[] parameterParts = TextUtils.SplitQuotedString(reader.ToEnd(), ';');
            foreach (string part in parameterParts)
            {
                if (string.IsNullOrEmpty(part))
                {
                    continue;
                }

                string[] name_value = part.Trim().Split(new char[] { '=' }, 2);
                string   paramName  = name_value[0].Trim();
                string   paramValue = null;
                if (name_value.Length == 2)
                {
                    paramValue = TextUtils.UnQuoteString(MIME_Utils.UnfoldHeader(name_value[1].Trim()));
                }
                // Valueless parameter.
                //else{

                string[] nameParts = paramName.Split('*');
                int      index     = 0;
                bool     encoded   = nameParts.Length == 3;
                // Get multi value parameter index.
                if (nameParts.Length >= 2)
                {
                    try{
                        index = Convert.ToInt32(nameParts[1]);
                    }
                    catch {
                    }
                }

                // Single value parameter and we already have parameter with such name, skip it.
                if (nameParts.Length < 2 && parameters.ContainsKey(nameParts[0]))
                {
                    continue;
                }

                // Parameter builder doesn't exist for the specified parameter, create it.
                if (!parameters.ContainsKey(nameParts[0]))
                {
                    parameters.Add(nameParts[0], new _ParameterBuilder(nameParts[0]));
                }

                parameters[nameParts[0]].AddPart(index, encoded, paramValue);
            }

            // Build parameters from parts.
            foreach (_ParameterBuilder b in parameters)
            {
                m_pParameters.Add(b.Name, b.GetParamter());
            }

            m_IsModified = false;
        }
예제 #59
0
        // 将种记录数据从XML格式转换为HTML格式
        public int ConvertBiblioXmlToHtml(
            string strFilterFileName,
            string strBiblioXml,
            string strRecPath,
            out string strBiblio,
            out KeyValueCollection result_params,
            out string strError)
        {
            strBiblio = "";
            strError = "";
            result_params = null;

            OpacApplication app = this;

            FilterHost host = new FilterHost();
            host.RecPath = strRecPath;
            host.App = this;
            host.ResultParams = new KeyValueCollection();

            // 如果必要,转换为MARC格式,调用filter

            string strOutMarcSyntax = "";
            string strMarc = "";
            // 将MARCXML格式的xml记录转换为marc机内格式字符串
            // parameters:
            //		bWarning	==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换
            //		strMarcSyntax	指示marc语法,如果=="",则自动识别
            //		strOutMarcSyntax	out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值
            int nRet = MarcUtil.Xml2Marc(strBiblioXml,
                true,
                "", // this.CurMarcSyntax,
                out strOutMarcSyntax,
                out strMarc,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            LoanFilterDocument filter = null;

            nRet = app.PrepareMarcFilter(
                host,
                strFilterFileName,
                out filter,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            try
            {
                nRet = filter.DoRecord(null,
                    strMarc,
                    0,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                strBiblio = host.ResultString;
                result_params = host.ResultParams;
            }
            catch (Exception ex)
            {
                strError = "filter.DoRecord error: " + ExceptionUtil.GetDebugText(ex);
                return -1;
            }
            finally
            {
                // 归还对象
                app.Filters.SetFilter(strFilterFileName, filter);
            }

            return 0;
        ERROR1:
            return -1;
        }
예제 #60
0
        /// <summary>
        /// Parse a message value.
        /// </summary>
        /// <param name="reader">Reader containing the string that should be parsed.</param>
        /// <returns>Newly created header.</returns>
        /// <exception cref="ParseException">Header value is malformed.</exception>
        /// <example>
        /// sip:[email protected]:5060
        /// [email protected]:5060
        /// jonas:[email protected]
        /// sip:[email protected]
        /// mailto:[email protected]
        /// </example>
        public static SipUri Parse(ITextReader reader)
        {
            string first = reader.ReadUntil("@:");
            string scheme = null;
            string userName;
            string password = null;
            string domain;
            int port = 0;
            bool containsAt = reader.Contains('@');

            // scheme:domain:port
            // scheme:domain
            // domain:port
            if (reader.Current == ':' && !containsAt)
            {
                reader.Consume();

                //scheme:domain:port or scheme:domain
                if (IsValidScheme(first))
                {
                    scheme = first;
                    domain = reader.ReadToEnd(":");
                    if (reader.EOF)
                        return new SipUri(scheme, domain, 0);

                    //scheme:domain:port
                    reader.Consume(':');
                    first = reader.ReadToEnd();
                }
                else // domain:port or just domain
                {
                    domain = first;
                    first = reader.ReadToEnd(":");
                }

                if (!int.TryParse(first, out port))
                    throw new ParseException("Port is not a number: " + first);

                return new SipUri(scheme, domain, port);
            }
                // Can either be "scheme:username"
                // or "username:password"
                // or "scheme:username:password"
            else if (reader.Current == ':')
            {
                reader.Consume();

                // Check if we got another colon (scheme:username:password)
                string second = reader.ReadUntil(":@");
                if (reader.Current == ':')
                {
                    scheme = first;
                    userName = second;
                    reader.Consume();
                    password = reader.ReadUntil('@');
                }
                    // it's "scheme:username" or "username:password"
                else
                {
                    //TODO: Create a ProtocolProvider singleton
                    if (first == "tel" || first == "sip" || first == "sips" || first == "mailto")
                    {
                        scheme = first;
                        userName = second;
                    }
                    else
                    {
                        userName = first;
                        password = second;
                    }
                }
            }
                // only username
            else
                userName = first;

            reader.Consume(); // eat delimiter.
            domain = reader.ReadToEnd(":;");
            if (reader.Current == '\r' || userName == null)
                return null; // domain was not specified.

            // We got a port.
            if (reader.Current == ':')
            {
                reader.Consume();
                string portStr = reader.ReadToEnd(';');
                if (portStr != null)
                {
                    if (!int.TryParse(portStr, out port))
                        return null;
                }
            }

            // parse parameters
            var values = new KeyValueCollection();
            if (reader.Current == ';')
                ParseParameters(values, reader);

            return new SipUri(scheme, userName, password, domain, port, values);
        }