public SettingPair[] GetExtensionsInstalled(ServerManager srvman)
        {
            var settings = new List<SettingPair>();
			var config = srvman.GetApplicationHostConfiguration();

            var handlersSection = (HandlersSection) config.GetSection(Constants.HandlersSection, typeof (HandlersSection));

            var executalbesToLookFor = new[]
            {
                // Perl
                new KeyValuePair<string, string>(Constants.PerlPathSetting, "\\perl.exe"),
                // Php
                new KeyValuePair<string, string>(Constants.Php4PathSetting, "\\php.exe"),
                new KeyValuePair<string, string>(Constants.PhpPathSetting, "\\php-cgi.exe"),
                // Classic ASP
                new KeyValuePair<string, string>(Constants.AspPathSetting, @"\inetsrv\asp.dll"),
                // ASP.NET
                new KeyValuePair<string, string>(Constants.AspNet11PathSetting, @"\Framework\v1.1.4322\aspnet_isapi.dll"),
                new KeyValuePair<string, string>(Constants.AspNet20PathSetting, @"\Framework\v2.0.50727\aspnet_isapi.dll"),
                new KeyValuePair<string, string>(Constants.AspNet40PathSetting, @"\Framework\v4.0.30319\aspnet_isapi.dll"),
                // ASP.NET x64
                new KeyValuePair<string, string>(Constants.AspNet20x64PathSetting, @"\Framework64\v2.0.50727\aspnet_isapi.dll"),
                new KeyValuePair<string, string>(Constants.AspNet40x64PathSetting, @"\Framework64\v4.0.30319\aspnet_isapi.dll"),
            };

            foreach (var handler in handlersSection.Handlers)
            {
                foreach (var valuePair in executalbesToLookFor)
                {
                    var key = valuePair.Key;
                    if (handler.ScriptProcessor.EndsWith(valuePair.Value) && !settings.Exists(s => s.Name == key))
                    {
						settings.Add(new SettingPair{Name = valuePair.Key, Value = handler.ScriptProcessor});
                    }
                }
            }

            return settings.ToArray();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 是否重複的字碼主檔數據
 /// </summary>
 /// <param name="listAll">字碼主檔數據列表</param>
 /// <param name="recCheck">檢查數據</param>
 /// <returns></returns>
 private bool IsRepetitiveCodeMasterRecord(List<CodeMaster_cmt_Info> listAll, CodeMaster_cmt_Info recCheck)
 {
     if (listAll != null && recCheck != null)
     {
         bool res = listAll.Exists(x => x.cmt_cRemark == recCheck.cmt_cRemark);
         return res;
     }
     return true;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 是否重複的區域主檔數據
 /// </summary>
 /// <param name="listAll">區域主檔數據列表</param>
 /// <param name="recCheck">檢查數據</param>
 /// <returns></returns>
 private bool IsRepetitiveAreaMasterRecord(List<AreaMaster_amr_Info> listAll, AreaMaster_amr_Info recCheck)
 {
     if (listAll != null && recCheck != null)
     {
         bool res = listAll.Exists(x => x.amr_cAreaName == recCheck.amr_cAreaName);
         return res;
     }
     return true;
 }
        /// <summary>
        /// 导入Excel文件
        /// </summary>
        /// <param name="strFilePath"></param>
        void ImportExcelData(string strFilePath)
        {
            try
            {
                DataSet ds = General.GetExcelDs(strFilePath, "转账充值表");
                if (ds != null && ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        List<TempBatchRechargeInfo> listTemp = new List<TempBatchRechargeInfo>();

                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            #region  逐行验证充值数据的有效性

                            TempBatchRechargeInfo tmpRechargeInfo = new TempBatchRechargeInfo();

                            try
                            {
                                string strTmpNum = ds.Tables[0].Rows[i][0].ToString();
                                tmpRechargeInfo.UserNum = strTmpNum;
                                string strTmpName = ds.Tables[0].Rows[i][1].ToString();
                                tmpRechargeInfo.UserName = strTmpName;
                                if (string.IsNullOrEmpty(strTmpNum) && string.IsNullOrEmpty(strTmpName))
                                {
                                    break;
                                }
                                decimal dTmpRecharge = Convert.ToDecimal(ds.Tables[0].Rows[i][2].ToString());
                                tmpRechargeInfo.Recharge = dTmpRecharge;

                                if (dTmpRecharge <= 0)
                                {
                                    tmpRechargeInfo.ValidInfo = "第" + (i + 1).ToString() + "行充值金额异常,需要为大于零的金额。";
                                    tmpRechargeInfo.Valid = false;
                                    listTemp.Add(tmpRechargeInfo);
                                    continue;
                                }
                                else if (dTmpRecharge > Common.DefineConstantValue.MaxRechargeVal)
                                {
                                    tmpRechargeInfo.ValidInfo = "第" + (i + 1).ToString() + "行充值金额异常,不能大于" + Common.DefineConstantValue.MaxRechargeVal + "。";
                                    tmpRechargeInfo.Valid = false;
                                    listTemp.Add(tmpRechargeInfo);
                                    continue;
                                }

                                //使用导入的Excel表资料中的用户编号查找用户
                                CardUserMaster_cus_Info searchUserInfo = new CardUserMaster_cus_Info();
                                searchUserInfo.cus_cStudentID = strTmpNum;
                                List<CardUserMaster_cus_Info> listTmpUser = this._ICardUserMasterBL.SearchRecords(searchUserInfo);
                                if (listTmpUser != null && listTmpUser.Count > 0)
                                {
                                    //有对应用户时,对比是否拥有对应excel数据里的名字的用户
                                    CardUserMaster_cus_Info cusUser = listTmpUser.Find(x => x.cus_cChaName.Trim() == strTmpName.Trim() && x.cus_lValid);
                                    if (cusUser != null)
                                    {
                                        tmpRechargeInfo.UserID = cusUser.cus_cRecordID;

                                        if (cusUser.PairInfo != null)
                                        {
                                            tmpRechargeInfo.CardID = cusUser.PairInfo.ucp_cCardID;

                                            if (cusUser.ClassInfo != null)
                                            {
                                                tmpRechargeInfo.Dept = cusUser.ClassInfo.csm_cClassName;
                                            }
                                            else if (cusUser.DeptInfo != null)
                                            {
                                                tmpRechargeInfo.Dept = cusUser.DeptInfo.dpm_cName;
                                            }

                                            tmpRechargeInfo.Valid = true;
                                            tmpRechargeInfo.ValidInfo = "验证通过";
                                        }
                                        //else
                                        //{
                                        //    tmpRechargeInfo.ValidInfo = "用户卡信息异常";
                                        //    tmpRechargeInfo.Valid = false;
                                        //}
                                        tmpRechargeInfo.Valid = true;
                                        tmpRechargeInfo.ValidInfo = "验证通过";
                                    }
                                    else
                                    {
                                        tmpRechargeInfo.ValidInfo = "用户编号与用户名称不符合";
                                        tmpRechargeInfo.Valid = false;
                                    }
                                }
                                else
                                {
                                    tmpRechargeInfo.ValidInfo = "不存在该编号的用户";
                                    tmpRechargeInfo.Valid = false;
                                }
                            }
                            catch (Exception ex)
                            {
                                tmpRechargeInfo.ValidInfo = "第" + (i + 1).ToString() + "行数据异常,异常信息:" + ex.Message;
                                tmpRechargeInfo.Valid = false;
                            }

                            listTemp.Add(tmpRechargeInfo);

                            #endregion
                        }

                        if (listTemp.Count < 1)
                        {
                            ShowWarningMessage("没有可用的批量充值数据,请检查导入文件内容后重试。");
                            return;
                        }
                        if (listTemp.Count > Common.DefineConstantValue.MaxRechargeCount)
                        {
                            ShowWarningMessage("导入的充值记录数量超出限制【" + Common.DefineConstantValue.MaxRechargeCount.ToString() + "】条,请修改后重试。");
                            return;
                        }

                        lvBatchRechargeList.SetDataSource<TempBatchRechargeInfo>(listTemp, true);
                        if (lvBatchRechargeList.Items.Count > 0)
                        {
                            foreach (ListViewItem item in lvBatchRechargeList.Items)
                            {
                                if (Convert.ToBoolean(item.SubItems[2].Text))
                                {
                                    item.BackColor = Color.Green;
                                }
                                else
                                {
                                    item.BackColor = Color.Red;
                                }
                                item.ForeColor = Color.White;
                            }
                        }

                        bool isValid = listTemp.Exists(x => !x.Valid);
                        if (!isValid)
                        {
                            btnConfirmRecharge.Enabled = true;
                        }
                        else
                        {
                            btnConfirmRecharge.Enabled = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                base.ShowErrorMessage(ex);
            }
        }
Ejemplo n.º 5
0
        private void findSP(List<int> allResultIds, PartOfSpeech PartOfSpeech, ObjectType type, List<int> excludeIds)
        {
            // из всех текущих id выбираем такие, которые являются заданным типом СЧР
            List<int> idsToAnalyze = new List<int>();
            foreach (var resultId in allResultIds)
            {
                if (_sentence.WordList.Exists(x => x.Id == resultId && x.PartOfSpeech.Value == PartOfSpeech.Value))
                    idsToAnalyze.Add(resultId);
            }

            foreach (var wordId in idsToAnalyze)
            {
                //ищем дочернее слово для СЧР
                List<SentenceWord> childWords = _sentence.WordList.FindAll(x => x.DOM == wordId && !excludeIds.Contains(x.Id));

                foreach (var childWord in childWords)
                {
                    // найдем в текущих результатах такой элемент, id которого либо равен исследуемому, либо в его ServiceParts присутствует исследуемый id - чтобы знать куда добавлять инфу
                    var resultItem = Result.Items.Find(x => x.Id == wordId);
                    if (resultItem == null)
                    {
                        foreach (var i in Result.Items)
                        {
                            if (i.ServiceParts.Concat(i.AddedWordsCase1).Concat(i.AddedWordsCase2).ToList().Exists(x => x.Id == wordId))
                                resultItem = i;
                        }
                    }

                    if (resultItem != null)
                    {
                        // если дочернего слова нет в списке предварительных элеметнов, то добавляем его вместо текущего элемента, присоединяя к нему СЧР с заданным типом СЧР
                        if (!allResultIds.Exists(x => x == childWord.Id))
                        {
                            Stage3ResultElement itemToAdd = new Stage3ResultElement();
                            itemToAdd.IsRestoredFromServicePart = true;
                            itemToAdd.CopyFromSourceWord(childWord);
                            itemToAdd.ObjectType = type;
                            List<SentenceWord> itemAddWords = itemToAdd.ServiceParts.Concat(itemToAdd.AddedWordsCase1).Concat(itemToAdd.AddedWordsCase2).ToList();
                            if (itemAddWords.Find(x => x.Id == wordId) == null)
                                itemToAdd.AddedWordsCase2.Add(_sentence.WordList.Find(x => x.Id == wordId));

                            itemAddWords = itemToAdd.ServiceParts.Concat(itemToAdd.AddedWordsCase1).Concat(itemToAdd.AddedWordsCase2).ToList();
                            if (itemAddWords.Find(x => x.Id == wordId) == null)
                                itemToAdd.AddedWordsCase2.Add(_sentence.WordList.Find(x => x.Id == resultItem.Id));

                            Result.Items.Remove(resultItem);

                            Result.Items.Add(itemToAdd);
                        }
                        // а если такое слово есть, то берем его и объединяем с СЧР, с заданным типом
                        else
                        {
                            List<SentenceWord> resultAddWords = resultItem.ServiceParts.Concat(resultItem.AddedWordsCase1).Concat(resultItem.AddedWordsCase2).ToList();

                            if (resultAddWords.Find(x => x.Id == wordId) == null && resultItem.Id != wordId)
                                resultItem.AddedWordsCase2.Add(_sentence.WordList.Find(x => x.Id == wordId));
                            Result.Items.RemoveAll(x => x.Id == wordId);
                        }
                    }
                    else
                        Debug.WriteLine("IPPI MainParts 583: resultItem == null, sentence " + allResultIds.ToString());

                    allResultIds = getAllMainPartsIds(type);
                }
            }
        }
Ejemplo n.º 6
0
        public DecisionMakerType2(string stretchedParametersXml, FuzzyVariable outputVariable, RulesList ruleDefinitions, List<FuzzyVariable> includedVariables)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Type2ParamsList));
            XmlReaderSettings settings = new XmlReaderSettings();
            using (StringReader textReader = new StringReader(stretchedParametersXml))
            {
                using (XmlReader xmlReader = XmlReader.Create(textReader, settings))
                {
                    Type2ParamsList deserializedT2Params = (Type2ParamsList)serializer.Deserialize(xmlReader);

                    inputVariables = new List<Type2FuzzyVariable>();
                    foreach (var variable in deserializedT2Params.Items)
                    {
                        if (includedVariables.Exists(v => v.Name == variable.ParamName))
                        {
                            Type2FuzzyVariable newVariable = new Type2FuzzyVariable(
                                variable.ParamName,
                                variable.Min,
                                variable.Max,
                                variable.Unit);
                            foreach (var term in variable.Terms)
                            {
                                Type2FuzzyTerm newTerm = new Type2FuzzyTerm(
                                    term.name,
                                    new NormalMembershipFunction(term.b.Upper, term.c.Upper),
                                    new NormalMembershipFunction(term.b.Lower, term.c.Lower));
                                newVariable.Terms.Add(newTerm);
                            }

                            inputVariables.Add(newVariable);
                        }
                    }

                    // output variable
                    this.outputVariable = new Type2FuzzyVariable(
                            outputVariable.Name,
                            outputVariable.Min,
                            outputVariable.Max,
                            outputVariable.Unit);
                    foreach (var term in outputVariable.Terms)
                    {
                        Type2FuzzyTerm newTerm = new Type2FuzzyTerm(
                            term.Name,
                            new NormalMembershipFunction(
                                (term.MembershipFunction as NormalMembershipFunction).B,
                                (term.MembershipFunction as NormalMembershipFunction).Sigma),
                            new NormalMembershipFunction(
                                (term.MembershipFunction as NormalMembershipFunction).B,
                                (term.MembershipFunction as NormalMembershipFunction).Sigma));
                        this.outputVariable.Terms.Add(newTerm);
                    }

                    // rules
                    rules = new List<Type2MamdaniFuzzyRule>();
                    var updatedDefinitions = new List<RuleDef>();
                    foreach (var rule in ruleDefinitions.Items)
                    {
                        string[] splitDef = rule.Definition.Split(
                            new[] {"if", "and", "(", ")"},
                            StringSplitOptions.RemoveEmptyEntries);

                        string updatedDef = string.Empty;
                        foreach (var condition in splitDef)
                        {
                            if (condition == string.Empty)
                            {
                                continue;
                            }

                            var trimmedCondition = condition.Trim();
                            if (trimmedCondition.StartsWith("then"))
                            {
                                updatedDef += trimmedCondition;
                            }
                            else
                            {
                                string variable = trimmedCondition.Split(' ')[0];
                                if (includedVariables.Exists(v => v.Name == variable))
                                {
                                    string keyword = updatedDef == string.Empty ? "if" : "and";
                                    updatedDef += string.Format("{0} ({1}) ", keyword, trimmedCondition);
                                }
                            }
                        }

                        if (!updatedDefinitions.Exists(r => r.Definition.Equals(updatedDef)))
                        {
                            updatedDefinitions.Add(new RuleDef { Definition = updatedDef, Weight = rule.Weight });
                            Type2MamdaniFuzzyRule newRule = ParseRule(updatedDef);
                            newRule.Weight = rule.Weight;
                            rules.Add(newRule);
                        }
                    }

                    isInitialized = true;
                }
            }
        }