Exemplo n.º 1
0
    protected override void doExecute() {
      base.doExecute();
      EBioException ebioex = null;
      if (this.FBioDesc == null)
        throw new EBioException(String.Format("Описание объекта {0} не найдено на сервере.", this.bioCode));

      var vDS = this.FBioDesc.DocumentElement;
      if (vDS == null) 
        throw new EBioException(String.Format("В описании объекта {0} не найден раздел <store>.", this.bioCode));

      var v_hashCodeOfFile = Params.FindParamValue(this.QParams, CS_HASH_CODE_WEB_PARAM) as String;
      if (String.IsNullOrEmpty(v_hashCodeOfFile)) 
        throw new EBioException(String.Format("В параметрах запроса должен присутствовать параметр {0}.", CS_HASH_CODE_WEB_PARAM));

        var rqst = this.BioRequest<BioRequest>();
        var vConn = this.BioSession.Cfg.dbSession.GetConnection();
        try {
          try {
            var cursor = new CJSCursor(vConn, vDS, this.bioCode);
            var ajaxRequestTimeOut = Utl.Convert2Type<int>(Params.FindParamValue(this.QParams, "ajaxrqtimeout"));
            var vMon = SQLGarbageMonitor.GetSQLGarbageMonitor(this.Context);
            vMon.RegisterSQLCmd(cursor, (SQLCmd vSQLCmd, ref Boolean killQuery, ref Boolean killSession, Boolean vAjaxTimeoutExceeded) => {
              if (Equals(cursor, vSQLCmd)) {
                killQuery = !this.Context.Response.IsClientConnected || vAjaxTimeoutExceeded;
                killSession = killQuery;
              }
            }, ajaxRequestTimeOut);
            try {
              var prms = new Params();
              prms.Add("p_hash_code", v_hashCodeOfFile);
              prms.Add(new Param(CS_FILE_NAME_PARAM, null, typeof(String), ParamDirection.Output));
              prms.Add(new Param(CS_FILE_PARAM, null, typeof(Byte[]), ParamDirection.Output));
              cursor.DoExecuteSQL(prms, 120);
              this._sendFileToClient(prms);
            } catch (Exception ex) {
              throw EBioException.CreateIfNotEBio(ex);
            } finally {
              vMon.RemoveItem(cursor);
            }
          } catch (Exception ex) {
            vConn.Close();
            vConn.Dispose();
            throw EBioException.CreateIfNotEBio(ex);
          }
        } catch (Exception ex) {
          ebioex = new EBioException("Ошибка выполнения на сервере. Сообщение: " + ex.Message, ex);
        } 
      if (ebioex != null) {
        this.Context.Response.Write(new BioResponse() { Success = false, BioParams = this.bioParams, Ex = ebioex }.Encode());
      }
    }
Exemplo n.º 2
0
    private Params extractPKItem(String pBioSelItem, CJSCursor pCur) {
      Params vRslt = new Params();
      String vBioSelItem = pBioSelItem;
      this.killTrailerChars(ref vBioSelItem, '(', ')');
      String[] vBioSelItemVals = Utl.SplitString(vBioSelItem, ")-(");
      for(int i = 0; i < vBioSelItemVals.Length; i++) {
        String vKey = "" + (i + 1);
        if(pCur.PKFields.ContainsKey(vKey)) {
          Field vPKFld = (Field)pCur.PKFields[vKey];
          vRslt.Add(vPKFld.FieldName, vBioSelItemVals[i], vPKFld);
        }
      }
      return vRslt;

    }
Exemplo n.º 3
0
 public void regConnect(String user,
                        String sessionID,
                        String sessionRemoteIP,
                        String sessionRemoteHost,
                        String sessionRemoteClient,
                        TRemoteConnectionStatus status) {
   var v_prms = new Params();
   v_prms.Add("pUser", user);
   v_prms.Add("pSessionID", sessionID);
   v_prms.Add("pSessionRemoteIP", sessionRemoteIP);
   v_prms.Add("pSessionRemoteHost", sessionRemoteHost);
   v_prms.Add("pSessionRemoteClient", sessionRemoteClient);
   v_prms.Add("pStatus", this.decConStat(status));
   var v_sql = String.Format("begin {0}.reg_connection(:pUser, :pSessionID," +
                           ":pSessionRemoteIP, :pSessionRemoteHost, :pSessionRemoteClient, :pStatus); end;", BIO_LOGIN_PKG);
   SQLCmd.ExecuteScript(this.dbSession, v_sql, v_prms, DEFAULT_SQL_TIMEOUT);
 }
Exemplo n.º 4
0
 private Params extractPKS(String pBioSelection, CJSCursor pCur) {
   Params vRslt = new Params();
   String vRsltStr = null;
   Regex vr = new Regex("\"pks\" *: *.+}", RegexOptions.IgnoreCase);
   Match m = vr.Match(pBioSelection);
   if(m.Success) {
     String[] vPrts = Utl.SplitString(m.Value, ':');
     if(vPrts.Length == 2)
       vRsltStr = vPrts[1].Trim().Substring(0, vPrts[1].Length - 1);
   }
   if(vRsltStr != null) {
     killTrailerChars(ref vRsltStr, '[', ']');
     String[] vRows = Utl.SplitString(vRsltStr, ',');
     for(int i = 0; i < vRows.Length; i++ ) {
       String vStrItem = vRows[i];
       vStrItem = vStrItem.Trim();
       this.killTrailerChars(ref vStrItem, '"', '"');
       Params vPKRow = this.extractPKItem(vStrItem, pCur);
       vRslt.Add("ROW_ID", vStrItem, vPKRow);
     }
   }
   return vRslt;
 }
Exemplo n.º 5
0
 public SbcCallDl(byte relAddr, byte size)
 {
     Params.Add(relAddr);
     Params.Add(size);
 }
Exemplo n.º 6
0
 public SbcShape(byte shpId)
 {
     Params.Add(shpId);
 }
Exemplo n.º 7
0
 public SbcMat(byte option, byte matId)
 {
     Option = option;
     Params.Add(matId);
 }
Exemplo n.º 8
0
 public SbcNode(EndianBinaryReader er)
 {
     Params.Add(er.ReadByte());
     Params.Add(er.ReadByte());
 }
Exemplo n.º 9
0
 /// <summary>
 /// Добавляем состояние к отчету
 /// </summary>
 /// <param name="rptUID"></param>
 /// <param name="cmd"></param>
 protected override void doOnMarkRQCmdState(String rptUID, QueueCmd cmd) {
   //throw new NotImplementedException();
   const string sql = "begin xlr.mark_cmd_done(:p_rpt_uid, :p_cmd); end;";
   var v_prms = new Params();
   v_prms.Add("p_rpt_uid", rptUID);
   v_prms.Add("p_cmd", (int)cmd);
   SQLCmd.ExecuteScript(this.cfg.dbSession, sql, v_prms, 120);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Добавляем состояние к отчету
 /// </summary>
 /// <param name="rptUID"></param>
 /// <param name="newState"></param>
 /// <param name="newStateDesc"></param>
 /// <param name="userUID"></param>
 /// <param name="remoteIP"></param>
 protected override void doOnAddQueueState(String rptUID, RemoteProcState newState, String newStateDesc, String userUID, String remoteIP) {
   const string sql = "begin xlr.set_rpt_state(:p_rpt_uid, :p_rpt_state, :p_state_desc, :p_usr_uid, :p_remote_ip); end;";
   var v_prms = new Params();
   v_prms.Add("p_rpt_uid", rptUID);
   v_prms.Add("p_rpt_state", (int)newState);
   v_prms.Add("p_state_desc", newStateDesc);
   v_prms.Add("p_usr_uid", userUID);
   v_prms.Add("p_remote_ip", remoteIP);
   SQLCmd.ExecuteScript(this.cfg.dbSession, sql, v_prms, 120);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Тут вытаскиваем из очереди файл готового отчета
 /// </summary>
 /// <param name="rptUID"></param>
 /// <param name="userUID"></param>
 /// <param name="remoteIP"></param>
 /// <param name="fileName"></param>
 /// <param name="buff"></param>
 protected override void doOnGetReportResult(String rptUID, String userUID, String remoteIP, ref String fileName, ref Byte[] buff) {
   const string sql = "SELECT a.rpt_result_fn, a.rpt_result_len, a.rpt_result" +
                      " FROM rpt$queue_rslts a"+
                      " WHERE a.rpt_uid = :rpt_uid";
   var v_prms = new Params();
   v_prms.Add("rpt_uid", rptUID);
   var v_cur = new SQLCmd(this.cfg.dbSession);
   v_cur.Init(sql, v_prms);
   v_cur.Open(120);
   try {
     if (v_cur.Next()) {
       fileName = (String)v_cur.DataReader.GetValue(0);
       var v_szAct = v_cur.DataReader.GetDecimal(1);
       var v_szActInt = (int)v_szAct;
       buff = new byte[v_szActInt];
       v_cur.DataReader.GetBytes(2, 0, buff, 0, v_szActInt);
     }
   } finally {
     v_cur.Close();
   }
 }
Exemplo n.º 12
0
 public XRpcMethodResponse Add <T>(T value)
 {
     Params.Add(XRpcData.For(value));
     return(this);
 }
Exemplo n.º 13
0
 public SbcPrjMap(byte matId, byte flag = 0)
 {
     Option = 0;
     Params.Add(matId);
     Params.Add(flag);
 }
Exemplo n.º 14
0
		public Params GetSingleRow(Int32 timeout){
			Params vResult = null;
      CXLRDataFactory v_dataFactory = this.Owner.Owner.DataFactory;//CXLRDataFactory.createDataFactory(this.Owner.Cfg, this.Owner.DataFactoryTypeName);
      try {

        v_dataFactory.Open(this.Owner.Owner.currentDbConnection, this.Owner.Cfg, timeout);
        if (v_dataFactory.Next()) {
          vResult = new Params();
          for (int i = 0; i < v_dataFactory.ColCount; i++) {
            vResult.Add(v_dataFactory.ColName(i), v_dataFactory.Values[i].ToString());
          }
        }

      }finally{
      }
      return vResult;
		}
Exemplo n.º 15
0
    static void testReport2() {
      DataTable tbl = new DataTable();
      tbl.Columns.Add(new DataColumn { ColumnName = "ID", DataType = typeof(Int32) });
      tbl.Columns.Add(new DataColumn { ColumnName = "ORGNAME", DataType = typeof(String) });
      tbl.Rows.Add(1, "org 1");
      //tbl.Rows.Add(1, "org 2");

      CXLReportDSConfigs v_dss = new CXLReportDSConfigs();
      v_dss.Add(new CXLReportDSConfig {
        alias = "cdsRpt",
        rangeName = "rngRpt",
        outerDataTable = tbl
      });
      Params prms = new Params();
      prms.Add("org_type", "p");

      String vrsltFileName = CXLReport.BuildReportSync(new CXLReportConfig {
        title = "Заголовок отчета",
        subject = "Описание отчета",
        templateAdv = @"report100(rpt).xls",
        inPrms = prms,
        filenameFmt = "{$code}_{$now}",
        dss = v_dss,
        debug = true
      });
    }
Exemplo n.º 16
0
    static void testReport1() {
      CXLReportDSConfigs v_dss = new CXLReportDSConfigs();
      v_dss.Add(new CXLReportDSConfig { 
        alias = "cdsRpt", 
        rangeName = "rngRpt",
        sql = "dbo.ant_get_org", 
        commandType = CommandType.StoredProcedure 
      });
      Params prms = new Params();
      prms.Add("@p0", 38);

      String vrsltFileName = CXLReport.BuildReportSync(new CXLReportConfig{
        title = "Заголовок отчета",
        subject = "Описание отчета",
        templateAdv =  @"d:\data\prjs\bioSys-8\Bio.Helpers\Bio.XLFRpt2\Bio.XLFRpt2.Test\bin\Debug\report100(rpt).xls",
        inPrms = prms,
        dataFactoryTypeName = "Bio.Helpers.XLFRpt2.DataFactory.MSSQL.CDataFactory, Bio.Helpers.XLFRpt2.MSSQLDataFactory",
        filenameFmt = "{$code}_{$now}",
        dss = v_dss,
        dbSession = null,
        //dbSession = new CRptDBSession(@"Data Source= EKP51\SQLEXPRESS; Initial Catalog=GIVCORG; Integrated Security=True; User ID=ayrat; Password=rtabh"),
        connStr = @"Data Source= EKP51\SQLEXPRESS; Initial Catalog=GIVCORG; Integrated Security=True; User ID=ayrat; Password=rtabh",
        debug = false
      });
    }
Exemplo n.º 17
0
 public override void BuildSQLCondition(ref String sql, Params prms) {
   if (prms == null)
     throw new ArgumentNullException("prms");
   var v_val_param_name = this.FieldName + "$afilter";
   var v_ftype = this._detectFTypeGranted();
   sql = String.Format(this.detectSQLFormat(this.Not, this.CmpOperator, v_ftype), this.FieldName, v_val_param_name);
   var v_ptype = ftypeHelper.ConvertFTypeToType(v_ftype);
   Object v_pval;
   if (v_ftype == JSFieldType.Boolean) {
     v_ptype = typeof(Int64);
     var v_bool = (Boolean)this.FieldValue;
     v_pval = (v_bool) ? 1 : 0;
   }else
     v_pval = this.FieldValue;
   prms.Add(new Param { 
     Name = v_val_param_name,
     ParamType = v_ptype,
     Value = v_pval
   });
 }
Exemplo n.º 18
0
        /// <summary>
        /// Seeds the default data.
        /// </summary>
        private void Seed()
        {
            SaveChanges();

            //
            // Params
            //
            var param = Params.FirstOrDefault(p => p.Key == Config.ARCHIVE_PAGE_SIZE);

            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.ARCHIVE_PAGE_SIZE,
                    Value        = 5.ToString(),
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            param = Params.FirstOrDefault(p => p.Key == Config.CACHE_EXPIRES_PAGES);
            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.CACHE_EXPIRES_PAGES,
                    Value        = 0.ToString(),
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            param = Params.FirstOrDefault(p => p.Key == Config.CACHE_EXPIRES_POSTS);
            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.CACHE_EXPIRES_POSTS,
                    Value        = 0.ToString(),
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            param = Params.FirstOrDefault(p => p.Key == Config.PAGES_HIERARCHICAL_SLUGS);
            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.PAGES_HIERARCHICAL_SLUGS,
                    Value        = true.ToString(),
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            param = Params.FirstOrDefault(p => p.Key == Config.MANAGER_EXPANDED_SITEMAP_LEVELS);
            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.MANAGER_EXPANDED_SITEMAP_LEVELS,
                    Value        = 1.ToString(),
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            param = Params.FirstOrDefault(p => p.Key == Config.MEDIA_CDN_URL);
            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.MEDIA_CDN_URL,
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            //
            // Default language
            //
            var langId = Guid.NewGuid();

            if (Languages.Count() == 0)
            {
                Languages.Add(new Data.Language
                {
                    Id        = langId,
                    Title     = "Default",
                    Culture   = "en-US",
                    IsDefault = true
                });
            }
            else
            {
                langId = Languages.FirstOrDefault(l => l.IsDefault).Id;
            }

            //
            // Default site
            //
            if (Sites.Count() == 0)
            {
                Sites.Add(new Data.Site
                {
                    Id           = Guid.NewGuid(),
                    LanguageId   = langId,
                    InternalId   = "Default",
                    IsDefault    = true,
                    Title        = "Default Site",
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }
            else
            {
                // When upgrading, make sure we assign the default language id
                // to already created sites.
                foreach (var site in Sites.Where(s => s.LanguageId == Guid.Empty))
                {
                    site.LanguageId = langId;
                }
            }

            //
            // Make sure we don't have NULL values in Piranha_MediaVersions.FileExtension
            //
            var versions = MediaVersions
                           .Where(m => m.FileExtension == null)
                           .ToList();

            foreach (var version in versions)
            {
                version.FileExtension = ".jpg";
            }

            var pageBlocks = PageBlocks
                             .Where(b => b.ParentId.HasValue)
                             .ToList();
            var pageBlocksId = pageBlocks.Select(b => b.BlockId).ToList();
            var blocks       = Blocks
                               .Where(b => pageBlocksId.Contains(b.Id))
                               .ToList();

            foreach (var block in blocks)
            {
                var pageBlock = pageBlocks.Single(b => b.BlockId == block.Id);
                block.ParentId     = pageBlock.ParentId;
                pageBlock.ParentId = null;
            }
            var postBlocks = PostBlocks
                             .Where(b => b.ParentId.HasValue)
                             .ToList();
            var postBlocksId = postBlocks.Select(b => b.BlockId).ToList();

            blocks = Blocks
                     .Where(b => postBlocksId.Contains(b.Id))
                     .ToList();
            foreach (var block in blocks)
            {
                var postBlock = postBlocks.Single(b => b.BlockId == block.Id);
                block.ParentId     = postBlock.ParentId;
                postBlock.ParentId = null;
            }

            SaveChanges();
        }
Exemplo n.º 19
0
 public GreaterThanEqualTo(TProperty greaterThanEqualTo)
 {
     Params.Add(new RuleParameter("greaterThanEqualTo", greaterThanEqualTo));
 }
Exemplo n.º 20
0
 public CountGreaterThanEqualTo(int countGreaterThanEqualTo)
 {
     Params.Add(new RuleParameter("countGreaterThanEqualTo", countGreaterThanEqualTo));
 }
Exemplo n.º 21
0
 public CountGreaterThanEqualTo(Expression <Func <T, int> > expression)
 {
     Params.Add(new RuleParameter("countGreaterThanEqualTo", expression));
 }
Exemplo n.º 22
0
 /// <summary>
 /// Перезапуск отчета
 /// </summary>
 /// <param name="rptUID"></param>
 /// <param name="userUID"></param>
 /// <param name="remoteIP"></param>
 protected override void doOnRestartReportInst(String rptUID, String userUID, String remoteIP) {
   const string sql = "begin xlr.restart_rpt(:p_rpt_uid, :p_usr_uid, :p_remote_ip); end;";
   var v_prms = new Params();
   v_prms.Add("p_rpt_uid", rptUID);
   v_prms.Add("p_usr_uid", userUID);
   v_prms.Add("p_remote_ip", remoteIP);
   SQLCmd.ExecuteScript(this.cfg.dbSession, sql, v_prms, 120);
 }
Exemplo n.º 23
0
 public IsInSet(IEnumerable <TProperty> set)
 {
     Params.Add(new RuleParameter("set", set));
 }
Exemplo n.º 24
0
 /// <summary>
 /// Возвращаем список ролей пользователя - строка перечень через ";"
 /// </summary>
 /// <param name="userUID"></param>
 /// <returns></returns>
 protected override String doOnGetUsrRoles(String userUID) {
   const string sql = "begin :rslt := xlr.usr_roles(:p_usr_uid); end;";
   var v_prms = new Params();
   v_prms.Add("p_usr_uid", userUID);
   v_prms.Add(new Param("rslt", null, typeof(String), 1000, ParamDirection.InputOutput));
   SQLCmd.ExecuteScript(this.cfg.dbSession, sql, v_prms, 120);
   return v_prms.ValueAsStringByName("rslt", true);
 }
Exemplo n.º 25
0
 public IsInSet(Func <T, IEnumerable <TProperty> > expression)
 {
     Params.Add(new RuleParameter("set", expression));
 }
Exemplo n.º 26
0
    /*
    /// <summary>
    /// Удаляет запись по признаку первичного ключа.
    /// </summary>
    /// <exception cref="EBioException">Возбуждается, когда операция завершилась с ошибкой.</exception>
    public void DoDelete(Params @params) {
      this.doExecute(@params, "delete");
    }

    /// <summary>
    /// Добавляет/Изменяет запись по признаку первичного ключа.
    /// </summary>
    /// <exception cref="EBioException">Возбуждается, когда операция завершилась с ошибкой.</exception>
    public void DoInsertUpdate(Params @params) {
      this.doExecute(@params, "insertupdate");
    }
    */

    private Params _buildPostParams(JsonStoreMetadata metadata, JsonStoreRow row, Params bioParams) {
      Params v_rslt = new Params();
      for (int i = 0; i < metadata.Fields.Count; i++)
        v_rslt.Add(metadata.Fields[i].Name.ToLower(), row.Values[i]);
      v_rslt = v_rslt.Merge(bioParams, false);
      return v_rslt;

    }
        /// <summary>
        /// Generates up to n solutions of the given variability model.
        /// Note that this method could also generate less than n solutions if the variability model does not contain sufficient solutions.
        /// Moreover, in the case that <code>n &lt; 0</code>, all solutions are generated.
        /// </summary>
        /// <param name="vm">The <see cref="VariabilityModel"/> to obtain solutions for.</param>
        /// <param name="n">The number of solutions to obtain.</param>
        /// <returns>A list of configurations, in which a configuration is a list of SELECTED binary options.</returns>
        public List <List <BinaryOption> > GenerateUpToNFast(VariabilityModel vm, int n)
        {
            // Use the random seed to produce new random seeds
            Random random = new Random(Convert.ToInt32(z3RandomSeed));

            List <BoolExpr> variables;
            Dictionary <BoolExpr, BinaryOption> termToOption;
            Dictionary <BinaryOption, BoolExpr> optionToTerm;
            Tuple <Context, BoolExpr>           z3Tuple = Z3Solver.GetInitializedBooleanSolverSystem(out variables, out optionToTerm, out termToOption, vm, this.henard, random.Next());
            Context         z3Context              = z3Tuple.Item1;
            BoolExpr        z3Constraints          = z3Tuple.Item2;
            List <BoolExpr> excludedConfigurations = new List <BoolExpr>();
            List <BoolExpr> constraints            = Z3Solver.lastConstraints;

            List <List <BinaryOption> > configurations = new List <List <BinaryOption> >();

            Microsoft.Z3.Solver s = z3Context.MkSolver();

            // TODO: The following line works for z3Solver version >= 4.6.0
            //solver.Set (RANDOM_SEED, z3RandomSeed);
            Params solverParameter = z3Context.MkParams();

            if (henard)
            {
                solverParameter.Add(RANDOM_SEED, NextUInt(random));
            }
            else
            {
                solverParameter.Add(RANDOM_SEED, z3RandomSeed);
            }
            s.Parameters = solverParameter;

            s.Assert(z3Constraints);
            s.Push();

            Model model = null;

            while (s.Check() == Status.SATISFIABLE && (configurations.Count < n || n < 0))
            {
                model = s.Model;

                List <BinaryOption> config = RetrieveConfiguration(variables, model, termToOption);

                configurations.Add(config);

                if (henard)
                {
                    BoolExpr newConstraint = Z3Solver.NegateExpr(z3Context, Z3Solver.ConvertConfiguration(z3Context, config, optionToTerm, vm));

                    excludedConfigurations.Add(newConstraint);

                    Dictionary <BoolExpr, BinaryOption> oldTermToOption = termToOption;

                    // Now, initialize a new one for the next configuration
                    z3Tuple       = Z3Solver.GetInitializedBooleanSolverSystem(out variables, out optionToTerm, out termToOption, vm, this.henard, random.Next());
                    z3Context     = z3Tuple.Item1;
                    z3Constraints = z3Tuple.Item2;

                    s = z3Context.MkSolver();

                    //s.Set (RANDOM_SEED, NextUInt (random));
                    solverParameter = z3Context.MkParams();

                    solverParameter.Add(RANDOM_SEED, NextUInt(random));
                    s.Parameters = solverParameter;

                    constraints = Z3Solver.lastConstraints;

                    excludedConfigurations = Z3Solver.ConvertConstraintsToNewContext(oldTermToOption, optionToTerm, excludedConfigurations, z3Context);

                    constraints.AddRange(excludedConfigurations);

                    s.Assert(z3Context.MkAnd(Z3Solver.Shuffle(constraints, new Random(random.Next()))));

                    s.Push();
                }
                else
                {
                    s.Add(Z3Solver.NegateExpr(z3Context, Z3Solver.ConvertConfiguration(z3Context, config, optionToTerm, vm)));
                }
            }

            return(configurations);
        }
Exemplo n.º 28
0
 public SbcMtx(byte index)
 {
     Params.Add(index);
 }
        /// <summary>
        /// This method searches for a corresponding methods in the dynamically loaded assemblies and calls it if found. It prefers due to performance reasons the Microsoft Solver Foundation implementation.
        /// </summary>
        /// <param name="config">The (partial) configuration which needs to be expaned to be valid.</param>
        /// <param name="vm">Variability model containing all options and their constraints.</param>
        /// <param name="minimize">If true, we search for the smallest (in terms of selected options) valid configuration. If false, we search for the largest one.</param>
        /// <param name="unWantedOptions">Binary options that we do not want to become part of the configuration. Might be part if there is no other valid configuration without them.</param>
        /// <returns>The valid configuration (or null if there is none) that satisfies the VM and the goal.</returns>
        public List <BinaryOption> MinimizeConfig(List <BinaryOption> config, VariabilityModel vm, bool minimize, List <BinaryOption> unWantedOptions)
        {
            List <BoolExpr> variables;
            Dictionary <BoolExpr, BinaryOption> termToOption;
            Dictionary <BinaryOption, BoolExpr> optionToTerm;
            Tuple <Context, BoolExpr>           z3Tuple = Z3Solver.GetInitializedBooleanSolverSystem(out variables, out optionToTerm, out termToOption, vm, this.henard);
            Context  z3Context     = z3Tuple.Item1;
            BoolExpr z3Constraints = z3Tuple.Item2;

            List <BoolExpr> constraints = new List <BoolExpr>();

            constraints.Add(z3Constraints);

            //Feature Selection
            foreach (BinaryOption binOpt in config)
            {
                BoolExpr term = optionToTerm[binOpt];
                constraints.Add(term);
            }

            Model model = null;

            if (minimize == true)
            {
                //Defining Goals
                ArithExpr[] optimizationGoals = new ArithExpr[variables.Count];

                for (int r = 0; r < variables.Count; r++)
                {
                    BinaryOption currOption      = termToOption[variables[r]];
                    ArithExpr    numericVariable = z3Context.MkIntConst(currOption.Name);

                    int weight = 1;
                    if (unWantedOptions != null && (unWantedOptions.Contains(termToOption[variables[r]]) && !config.Contains(termToOption[variables[r]])))
                    {
                        weight = 1000;
                    }

                    constraints.Add(z3Context.MkEq(numericVariable, z3Context.MkITE(variables[r], z3Context.MkInt(weight), z3Context.MkInt(0))));

                    optimizationGoals[r] = numericVariable;
                }
                // For minimization, we need the class 'Optimize'
                Optimize optimizer = z3Context.MkOptimize();
                optimizer.Assert(constraints.ToArray());
                optimizer.MkMinimize(z3Context.MkAdd(optimizationGoals));

                if (optimizer.Check() != Status.SATISFIABLE)
                {
                    return(new List <BinaryOption>());
                }
                else
                {
                    model = optimizer.Model;
                }
            }
            else
            {
                // Return the first configuration returned by the solver
                Microsoft.Z3.Solver solver = z3Context.MkSolver();

                // TODO: The following line works for z3Solver version >= 4.6.0
                //solver.Set (RANDOM_SEED, z3RandomSeed);
                Params solverParameter = z3Context.MkParams();
                solverParameter.Add(RANDOM_SEED, z3RandomSeed);
                solver.Parameters = solverParameter;

                solver.Assert(constraints.ToArray());

                if (solver.Check() != Status.SATISFIABLE)
                {
                    return(new List <BinaryOption>());
                }
                else
                {
                    model = solver.Model;
                }
            }


            List <BinaryOption> result = RetrieveConfiguration(variables, model, termToOption);

            return(result);
        }
Exemplo n.º 30
0
 public SbcMat(byte option, EndianBinaryReaderEx er)
 {
     Option = option;
     Params.Add(er.ReadByte());
 }
        public List <BinaryOption> GenerateConfigurationFromBucket(VariabilityModel vm, int numberSelectedFeatures, Dictionary <List <BinaryOption>, int> featureWeight, Configuration lastSampledConfiguration)
        {
            if (_z3Cache == null)
            {
                _z3Cache = new Dictionary <int, Z3Cache>();
            }

            List <KeyValuePair <List <BinaryOption>, int> > featureRanking;

            if (featureWeight != null)
            {
                featureRanking = featureWeight.ToList();
                featureRanking.Sort((first, second) => first.Value.CompareTo(second.Value));
            }
            else
            {
                featureRanking = new List <KeyValuePair <List <BinaryOption>, int> >();
            }

            List <BoolExpr> variables = null;
            Dictionary <BoolExpr, BinaryOption> termToOption = null;
            Dictionary <BinaryOption, BoolExpr> optionToTerm = null;
            Tuple <Context, BoolExpr>           z3Tuple;
            Context z3Context;

            Microsoft.Z3.Solver solver;

            // Reuse the solver if it is already in the cache
            if (this._z3Cache.Keys.Contains(numberSelectedFeatures))
            {
                Z3Cache cache = this._z3Cache[numberSelectedFeatures];
                z3Context    = cache.GetContext();
                solver       = cache.GetSolver();
                variables    = cache.GetVariables();
                termToOption = cache.GetTermToOptionMapping();
                optionToTerm = cache.GetOptionToTermMapping();

                if (lastSampledConfiguration != null)
                {
                    // Add the previous configurations as constraints
                    solver.Assert(Z3Solver.NegateExpr(z3Context, Z3Solver.ConvertConfiguration(z3Context, lastSampledConfiguration.getBinaryOptions(BinaryOption.BinaryValue.Selected), optionToTerm, vm)));

                    // Create a new backtracking point for the next run
                    solver.Push();
                }
            }
            else
            {
                z3Tuple   = Z3Solver.GetInitializedBooleanSolverSystem(out variables, out optionToTerm, out termToOption, vm, this.henard);
                z3Context = z3Tuple.Item1;
                BoolExpr z3Constraints = z3Tuple.Item2;
                solver = z3Context.MkSolver();

                // TODO: The following line works for z3Solver version >= 4.6.0
                //solver.Set (RANDOM_SEED, z3RandomSeed);
                Params solverParameter = z3Context.MkParams();
                solverParameter.Add(RANDOM_SEED, z3RandomSeed);
                solver.Parameters = solverParameter;

                solver.Assert(z3Constraints);

                if (lastSampledConfiguration != null)
                {
                    // Add the previous configurations as constraints
                    solver.Assert(Z3Solver.NegateExpr(z3Context, Z3Solver.ConvertConfiguration(z3Context, lastSampledConfiguration.getBinaryOptions(BinaryOption.BinaryValue.Selected), optionToTerm, vm)));
                }

                // The goal of this method is, to have an exact number of features selected

                // Therefore, initialize an integer array with the value '1' for the pseudo-boolean equal function
                int[] neutralWeights = new int[variables.Count];
                for (int i = 0; i < variables.Count; i++)
                {
                    neutralWeights[i] = 1;
                }
                solver.Assert(z3Context.MkPBEq(neutralWeights, variables.ToArray(), numberSelectedFeatures));

                // Create a backtracking point before adding the optimization goal
                solver.Push();

                this._z3Cache[numberSelectedFeatures] = new Z3Cache(z3Context, solver, variables, optionToTerm, termToOption);
            }

            // Check if there is still a solution available by finding the first satisfiable configuration
            if (solver.Check() == Status.SATISFIABLE)
            {
                Model model = solver.Model;
                List <BinaryOption> possibleSolution = RetrieveConfiguration(variables, model, termToOption);

                // Disable finding a configuration where the least frequent feature/feature combinations are selected
                // if no featureWeight is given.
                List <BinaryOption> approximateOptimal = null;
                if (featureRanking.Count != 0)
                {
                    approximateOptimal = WeightMinimizer
                                         .getSmallWeightConfig(featureRanking, this._z3Cache[numberSelectedFeatures], vm);
                }

                if (approximateOptimal == null)
                {
                    return(possibleSolution);
                }
                else
                {
                    return(approximateOptimal);
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 32
0
 public SbcShape(EndianBinaryReaderEx er)
 {
     Params.Add(er.ReadByte());
 }
Exemplo n.º 33
0
 /// <summary>
 /// 将列更新为指定值
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="col"></param>
 /// <param name="val"></param>
 /// <returns></returns>
 public Sql Set <T>(string col, T val)
 {
     _SetColumns.Add(DB.GetCondition(col));
     Params.Add(DB.GetParam(col, val));
     return(this);
 }
Exemplo n.º 34
0
 public SbcCallDl(EndianBinaryReaderEx er)
 {
     Params.Add(er.ReadByte()); //Rel Addr
     Params.Add(er.ReadByte()); //Size
 }
Exemplo n.º 35
0
        /// <summary>
        /// Seeds the default data.
        /// </summary>
        private void Seed()
        {
            SaveChanges();

            //
            // Params
            //
            var param = Params.FirstOrDefault(p => p.Key == Config.ARCHIVE_PAGE_SIZE);

            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.ARCHIVE_PAGE_SIZE,
                    Value        = 5.ToString(),
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            param = Params.FirstOrDefault(p => p.Key == Config.CACHE_EXPIRES_PAGES);
            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.CACHE_EXPIRES_PAGES,
                    Value        = 0.ToString(),
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            param = Params.FirstOrDefault(p => p.Key == Config.CACHE_EXPIRES_POSTS);
            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.CACHE_EXPIRES_POSTS,
                    Value        = 0.ToString(),
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            param = Params.FirstOrDefault(p => p.Key == Config.PAGES_HIERARCHICAL_SLUGS);
            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.PAGES_HIERARCHICAL_SLUGS,
                    Value        = true.ToString(),
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            param = Params.FirstOrDefault(p => p.Key == Config.MANAGER_EXPANDED_SITEMAP_LEVELS);
            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.MANAGER_EXPANDED_SITEMAP_LEVELS,
                    Value        = 1.ToString(),
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            param = Params.FirstOrDefault(p => p.Key == Config.MEDIA_CDN_URL);
            if (param == null)
            {
                Params.Add(new Data.Param
                {
                    Id           = Guid.NewGuid(),
                    Key          = Config.MEDIA_CDN_URL,
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            //
            // Default site
            //
            if (Sites.Count() == 0)
            {
                Sites.Add(new Data.Site
                {
                    Id           = Guid.NewGuid(),
                    InternalId   = "Default",
                    IsDefault    = true,
                    Title        = "Default Site",
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                });
            }

            //
            // Make sure we don't have NULL values in Piranha_MediaVersions.FileExtension
            //
            var versions = MediaVersions
                           .Where(m => m.FileExtension == null)
                           .ToList();

            foreach (var version in versions)
            {
                version.FileExtension = ".jpg";
            }

            SaveChanges();
        }
Exemplo n.º 36
0
 public SbcPrjMap(EndianBinaryReaderEx er)
 {
     Option = 0;
     Params.Add(er.ReadByte());
     Params.Add(er.ReadByte());
 }
Exemplo n.º 37
0
 /// <summary>
 /// Преобразует строку со значениями первичного ключа в параметры.
 /// </summary>
 /// <param name="row">Строка со значениями первичного ключа.</param>
 /// <returns></returns>
 public Params GetPK(CRTObject row) {
   var @params = new Params();
   var pkDef = this.GetPKFields();
   foreach (var t in pkDef) {
     var vType = t.GetDotNetType();
     var vValue = row.GetValue(t.Name, vType);
     @params.Add(new Param(t.Name, vValue, vType, ParamDirection.Input));
   }
   return @params;
 }
Exemplo n.º 38
0
        void DefineTools()
        {
            Define("hold-process", new Func <dynamic>(() => {
                var processName = Process.GetCurrentProcess().ProcessName;
                var defColor    = Console.ForegroundColor;

                Console.ForegroundColor = ConsoleColor.Green;

                Console.WriteLine("The {0} is ready", processName);
                Console.WriteLine("Press <Enter> to terminate {0}", processName);

                Console.ForegroundColor = defColor;

                Console.ReadLine();
                return(null);
            }));

            Define("exit", new Func <dynamic>(() => {
                Environment.Exit(0);
                return(null);
            }));

            Define("begin-invoke", new Func <MulticastDelegate, Params, dynamic>((mcd, param) => {
                Task.Factory.StartNew(() => {
                    var parameters = mcd.Method.GetParameters();
                    var cArg       = new List <object>();
                    for (var i = 0; i < parameters.Length; i++)
                    {
                        var pi = parameters[i];
                        if (typeof(Params) == pi.ParameterType)
                        {
                            var par = new Params();
                            while (i < param.Count)
                            {
                                par.Add(param[i++]);
                            }
                            cArg.Add(par);
                        }
                        else
                        {
                            if (i < param.Count)
                            {
                                cArg.Add(param[i]);
                            }
                        }
                    }


                    if (parameters.Length == cArg.Count)
                    {
                        return(mcd.DynamicInvoke(cArg.ToArray()));
                    }
                    else
                    {
                        throw new Exception($"Arity mismatch {mcd}, expected {parameters.Length}, given {cArg.Count} arguments");
                    }
                });

                return(true);
            }));
        }
Exemplo n.º 39
0
 /// <summary>
 /// Преобразует строку со значениями первичного ключа в параметры.
 /// </summary>
 /// <param name="data"></param>
 /// <param name="row"></param>
 /// <returns></returns>
 public Params getPK(JsonStoreData data, JsonStoreRow row) {
   Params vParams = new Params();
   var v_pkDef = this.GetPKFields();
   for (int i = 0; i < v_pkDef.Length; i++) {
     var vType = v_pkDef[i].GetDotNetType();
     var vValue = data.GetValue(row, v_pkDef[i].Name);
     vParams.Add(new Param(v_pkDef[i].Name, vValue, vType, ParamDirection.Input));
   }
   return vParams;
 }
Exemplo n.º 40
0
 public LessThanEvent(long addr, EventParam a, EventParam b, EventParam c) : base(addr)
 {
     Params.Add(a);
     Params.Add(b);
     Params.Add(c);
 }
Exemplo n.º 41
0
 public override IStoredProcedureBuilder AddParam(object Value)
 {
     Params.Add(Value);
     return(this);
 }
Exemplo n.º 42
0
    public override void Login(String login) {
      this.CurUser = null;

      var v_sql = String.Format("begin {0}.check_login(:login, :usr_uid); end;", BIO_LOGIN_PKG);

      var v_prms = new Params();
      v_prms.Add("login", login);
      v_prms.Add(new Param("usr_uid", (String)null, typeof(String), ParamDirection.Output));
      SQLCmd.ExecuteScript(this.dbSession, v_sql, v_prms, DEFAULT_SQL_TIMEOUT);
      var v_usrUID = Params.FindParamValue(v_prms, "usr_uid") as String;

      v_sql = String.Format("select * from table({0}.get_usr(:usr_uid))", BIO_LOGIN_PKG);
      var v_cur = SQLCursor.CreateAndOpenCursor(this.dbSession, v_sql, new Params(new Param("usr_uid", v_usrUID)), DEFAULT_SQL_TIMEOUT);
      try {
        if (v_cur.IsActive && v_cur.Next()) {
          this.CurUser = new BioUser();

          enumHelper.ForEachPropertyInfo(this.CurUser.GetType(), p => {
            var fld = enumHelper.GetAttributeByInfo<DbFieldAttribute>(p);
            if (fld != null) {
              var val = v_cur.GetOraValue(fld.Name);
              try {
                p.SetValue(this.CurUser, val, null);
              } catch (Exception ex) {
                throw new Exception(String.Format("Ошибка при восстановлении значения поля [{0}] из [{1}]({2}). Сообщение: {3}", p.Name, val, fld.Name, ex.Message), ex);
              }
            }
          });

        } else {
          throw new EBioException { ErrorCode = 20401 };
        }
      } finally {
        v_cur.Close();
      }
    }
Exemplo n.º 43
0
 public IHttpRequest AddParams(string key, string value)
 {
     Params.Add(key, value);
     return(this);
 }
Exemplo n.º 44
0
 /// <summary>
 /// Тут засовываем в очередь файл готового отчета
 /// </summary>
 /// <param name="rptUID"></param>
 /// <param name="fileName"></param>
 protected override void doOnAddReportResult2DB(String rptUID, String fileName) {
   const string sql = "begin xlr.save_rpt_file(:p_rpt_uid, :p_file_name, :p_file); end;";
   var v_prms = new Params();
   v_prms.Add("p_rpt_uid", rptUID);
   v_prms.Add("p_file_name", Path.GetFileName(fileName));
   byte[] v_buffer = null;
   Utl.ReadBinFileInBuffer(fileName, ref v_buffer);
   v_prms.Add("p_file", v_buffer);
   SQLCmd.ExecuteScript(this.cfg.dbSession, sql, v_prms, 120);
 }
Exemplo n.º 45
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Error" /> class
        ///     from a given <see cref="Exception" /> instance and
        ///     <see cref="HttpContext" /> instance representing the HTTP
        ///     context during the exception.
        /// </summary>
        public Error(Exception e, HttpContext context = null, string body = null)
        {
            var baseException = e?.GetBaseException();

            _message  = baseException?.Message;
            _typeName = baseException?.GetType().FullName;

            //
            // If this is an HTTP exception, then get the status code
            // and detailed HTML message provided by the host.
            //
            if (baseException is HttpException httpExc)
            {
                StatusCode    = httpExc.StatusCode;
                baseException = baseException.InnerException;
                if (baseException == null)
                {
                    _typeName = "HTTP";
                }
            }
            else
            {
                if (context?.Connection?.LocalIpAddress != null && StatusCode == 0)
                {
                    StatusCode = 500;
                }
            }

            Exception = baseException;

            //
            // Load the basic information.
            //

            try
            {
                _hostName = Environment.MachineName;
            }
            catch (SecurityException)
            {
                // A SecurityException may occur in certain, possibly
                // user-modified, Medium trust environments.
                _hostName = string.Empty;
            }

            _source = baseException?.Source;
            _detail = e?.ToString();
            _user   = context?.User?.Identity?.Name ?? string.Empty;
            Time    = DateTime.Now;

            //
            // If the HTTP context is available, then capture the
            // collections that represent the state request as well as
            // the user.
            //

            if (context != null)
            {
                var webUser = context.User;
                if (webUser != null &&
                    (webUser.Identity.Name ?? string.Empty).Length > 0)
                {
                    _user = webUser.Identity.Name;
                }

                var request = context.Request;

                //Load Server Variables
                _serverVariables = GetServerVariables(context);
                _serverVariables.Add("HttpStatusCode", StatusCode.ToString());
                _queryString = CopyCollection(QueryHelpers.ParseQuery(request.QueryString.Value));
                _form        = CopyCollection(request.HasFormContentType ? request.Form : null);
                if (!string.IsNullOrEmpty(body))
                {
                    _form ??= new NameValueCollection();
                    _form.Add("$request-body", body);
                }

                _cookies   = CopyCollection(request.Cookies);
                MessageLog = context.Features.Get <ElmahLogFeature>()?.Log ?? new List <ElmahLogMessageEntry>();
                SqlLog     = context.Features.Get <ElmahLogFeature>()?.LogSql ?? new List <ElmahLogSqlEntry>();
                var paramList = context.Features.Get <ElmahLogFeature>()?.Params;
                if (paramList != null)
                {
                    foreach (var param in paramList)
                    {
                        if (param.Params.Any())
                        {
                            Params.Add(new ElmahLogParamEntry(
                                           param.TimeStamp,
                                           GetStringParams(param.Params),
                                           param.TypeName,
                                           param.MemberName,
                                           param.File,
                                           param.Line));
                        }
                    }
                }
            }

            var callerInfo = e?.TryGetCallerInfo() ?? CallerInfo.Empty;

            if (!callerInfo.IsEmpty)
            {
                _detail = "# caller: " + callerInfo
                          + Environment.NewLine
                          + _detail;
            }
        }
Exemplo n.º 46
0
 /// <summary>
 /// Формируем список отчетов в очереди
 /// </summary>
 /// <param name="userUID"></param>
 /// <param name="remoteIP"></param>
 /// <returns></returns>
 protected override XmlDocument doOnGetQueue(String userUID, String remoteIP) {
   var v_rslt = dom4cs.NewDocument("queue").XmlDoc;
   if (v_rslt.DocumentElement != null) {
     v_rslt.DocumentElement.SetAttribute("usr", userUID);
     v_rslt.DocumentElement.SetAttribute("remote_ip", remoteIP);
     v_rslt.DocumentElement.SetAttribute("count", "0");
   }
   const string sql = "select * from table(xlr.rqueue_xml(null,:p_usr_uid))";
   var v_prms = new Params();
   v_prms.Add("p_usr_uid", userUID);
   var v_cur = new SQLCmd(this.cfg.dbSession);
   v_cur.Init(sql, v_prms);
   v_cur.Open(120);
   var v_sb = new StringBuilder();
   try{
     var v_cnt = 0;
     while (v_cur.Next()) {
       v_sb.AppendLine(v_cur.DataReader.GetString(0));
       v_cnt++;
     }
     if (v_sb.Length > 0) {
       if (v_rslt.DocumentElement != null) {
         v_rslt.DocumentElement.InnerXml = v_sb.ToString();
         v_rslt.DocumentElement.SetAttribute("count", "" + v_cnt);
       }
     }
   } finally {
     v_cur.Close();
   }
   return v_rslt;
 }
Exemplo n.º 47
0
 public LessThanEqualTo(TProperty lessThanEqualTo)
 {
     Params.Add(new RuleParameter("lessThanEqualTo", lessThanEqualTo));
 }
Exemplo n.º 48
0
    private Params _getRptParams(String uid) {
      var v_rslt = new Params();
      var v_cur = new SQLCmd(this.cfg.dbSession);
      var v_prms = new Params(new Param("rpt_uid", uid));
      v_cur.Init("select prm_name, prm_type, prm_val from rpt$rparams where rpt_uid = :rpt_uid", v_prms);
      v_cur.Open(120);
      try {
        while (v_cur.Next()) {
          var v_prmName = v_cur.DataReader.GetValue(0) as String;
          var v_prmType = v_cur.DataReader.GetValue(1) as String;
          var v_prmVal = v_cur.DataReader.GetValue(2) as String;
          var v_prm = new Param();
          v_prm.Name = v_prmName;
          v_prm.Value = _paramDecode(v_prmType, v_prmVal);
          v_rslt.Add(v_prm);
        }
      } finally {
        v_cur.Close();
      }

      return v_rslt;
    }
Exemplo n.º 49
0
 public LessThanEqualTo(Expression <Func <T, TProperty> > expression)
 {
     Params.Add(new RuleParameter("lessThanEqualTo", expression));
 }
Exemplo n.º 50
0
 /// <summary>
 /// Проверка логина
 /// </summary>
 /// <param name="usr"></param>
 /// <param name="pwd"></param>
 /// <returns></returns>
 protected override String doOnCheckUsrLogin(String usr, String pwd) {
   const string sql = "begin :rslt := xlr.check_usr_login(:p_usr, :p_pwd); end;";
   var v_prms = new Params();
   v_prms.Add("p_usr", usr);
   v_prms.Add("p_pwd", pwd);
   v_prms.Add(new Param("rslt", null, typeof(String), 1000, ParamDirection.InputOutput));
   SQLCmd.ExecuteScript(this.cfg.dbSession, sql, v_prms, 120);
   return v_prms.ValueAsStringByName("rslt", true);
 }
Exemplo n.º 51
0
 public SbcNode(byte nodeId, bool isVisible)
 {
     Params.Add(nodeId);
     Params.Add((byte)(isVisible ? 1 : 0));
 }
Exemplo n.º 52
0
 /// <summary>
 /// Тут добавляем отчет в "очередь", которая обрабатывается построителем отчетов
 /// </summary>
 /// <param name="rptCode"></param>
 /// <param name="sessionID"></param>
 /// <param name="userUID"></param>
 /// <param name="remoteIP"></param>
 /// <param name="prms"></param>
 /// <param name="pPriority"></param>
 /// <returns></returns>
 protected override String doOnAdd(String rptCode, String sessionID, String userUID, String remoteIP, Params prms, ThreadPriority pPriority) {
   String v_rptUID;
   var v_conn = this.cfg.dbSession.GetConnection();
   try {
     const string sql = "begin xlr.add_rpt(:p_rpt_uid, :p_rpt_code, :p_rpt_prms, :p_rpt_desc, :p_usr_uid, :p_remote_ip); end;";
     var v_prms = new Params();
     v_prms.Add(new Param("p_rpt_uid", null, typeof(String), ParamDirection.InputOutput));
     v_prms.Add("p_rpt_code", rptCode);
     v_prms.Add("p_rpt_desc", null);
     v_prms.Add("p_usr_uid", userUID);
     v_prms.Add("p_remote_ip", remoteIP);
     SQLCmd.ExecuteScript(v_conn, sql, v_prms, 120);
     v_rptUID = v_prms.ValueAsStringByName("p_rpt_uid", true);
     _addRptParams(v_conn, v_rptUID, prms, userUID, remoteIP);
   } finally {
     v_conn.Close();
   }
   return v_rptUID;
 }
Exemplo n.º 53
0
    /// <summary>
    /// Устанавливает у параметров типы, прописанные в описании ИОбъекта.
    /// </summary>
    /// <param name="sqlElement">XML-описание запроса.</param>
    /// <param name="prms">Набор параметров, в которые пропишутся типы.</param>
    /// <exception cref="ArgumentNullException"></exception>
    private static void _applyParamsTypes(XmlElement sqlElement, Params prms) {
      if (sqlElement == null)
        throw new ArgumentNullException("sqlElement");
      if (prms != null) {
        foreach (XmlElement SQLParam in sqlElement.SelectNodes("param")) {
          var vParamName = SQLParam.GetAttribute("name");
          var vParamTypeName = SQLParam.GetAttribute("type");
          var vParamType = ftypeHelper.ConvertStrToType(vParamTypeName);

          var vDir = SQLUtils.EncodeParamDirection(_detectDir(SQLParam));
          var param = SQLUtils.FindParam(prms, vParamName);
          if (vDir == ParamDirection.Input) {
            if (param != null) {
              param.ParamType = vParamType;
              param.ParamDir = ParamDirection.Input;
            } else {
              param = new Param(vParamName, null, vParamType, ParamDirection.Input);
              prms.Add(param);
            }
          } else if ((vDir == ParamDirection.Output) || (vDir == ParamDirection.InputOutput)) {
            if (param == null) {
              param = new Param(vParamName, null);
              prms.Add(param);
            }
            param.ParamType = vParamType;
            param.InnerObject = vParamTypeName; // Сохраняем имя типа параметра. Его придется использовать при инициализации оракловых параметров

            param.ParamDir = vDir;
            if (param.ParamType == typeof(String))
              param.ParamSize = 32000;
          }
        }
      }
    }