Ejemplo n.º 1
0
 public int Insert(Model.WebContentType1 model)
 {
     model.Replace4MySQL();
     StringBuilder sb = new StringBuilder();
     try
     {
             if (model.content_status == 1)//啟用
             {
                 WebContentTypeSetupDao _setDao = new WebContentTypeSetupDao(_connStr);
                 WebContentTypeSetup smodel = new WebContentTypeSetup();
                 smodel.site_id = model.site_id;
                 smodel.page_id = model.page_id;
                 smodel.area_id = model.area_id;
                 smodel.web_content_type = "web_content_type1";
                 _setDao.UpdateLimitStatus(smodel);////當前已啟用的個數超過5筆時,使最舊的不啟用,
             }
           
             sb.AppendFormat(@"insert into web_content_type1(site_id,page_id,area_id,type_id,content_title,content_image,content_default,content_status,link_url,link_page,link_mode,update_on,created_on) 
         values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}')", model.site_id, model.page_id, model.area_id, model.type_id, model.content_title, model.content_image, model.content_default, model.content_status, model.link_url, model.link_page, model.link_mode, CommonFunction.DateTimeToString(model.update_on), CommonFunction.DateTimeToString(model.created_on));
             return _access.execCommand(sb.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("WebContentType1Dao.Insert-->" + ex.Message + sb.ToString(), ex);
     }
    
 }
Ejemplo n.º 2
0
        public int Update(Model.WebContentType1 model)
        {
            model.Replace4MySQL(); 
            StringBuilder sb = new StringBuilder();
            try
            {
                         WebContentType1 oldModel = GetModel(model);
                        if (model.content_status == 1 && oldModel.content_status != 1)//啟用
                        {
                            WebContentTypeSetupDao _setDao = new WebContentTypeSetupDao(_connStr);
                            WebContentTypeSetup smodel = new WebContentTypeSetup();
                            smodel.site_id = model.site_id;
                            smodel.page_id = model.page_id;
                            smodel.area_id = model.area_id;
                            smodel.web_content_type = "web_content_type1";
                            _setDao.UpdateLimitStatus(smodel);////當前已啟用的個數超過5筆時,使最舊的不啟用,
                        }
                       
                        sb.AppendFormat(@"update web_content_type1  set site_id='{0}',page_id='{1}',area_id='{2}',type_id='{3}',content_title='{4}',content_image='{5}',`content_default`='{6}',content_status='{7}',link_url='{8}',link_page='{9}',link_mode='{10}',update_on='{11}' where content_id={12}",
                            model.site_id, model.page_id, model.area_id, model.type_id, model.content_title, model.content_image, model.content_default, model.content_status, model.link_url, model.link_page, model.link_mode, CommonFunction.DateTimeToString(model.update_on), model.content_id);
                        return _access.execCommand(sb.ToString());
            }
            catch (Exception ex)
            {

                throw new Exception("WebContentType1Dao.Update-->" + ex.Message + sb.ToString(), ex);
            }
          
        }
Ejemplo n.º 3
0
        public int Add(Model.Manager model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into Manager(");
            strSql.Append("username,isAdmin,repair,phonenum,works,states )");
            strSql.Append(" values(");
            strSql.Append("@username,@isAdmin,@repair,@phonenum,@works,@states )");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters ={
                new SqlParameter("@username",SqlDbType.NVarChar,50),
                new SqlParameter("@isAdmin",SqlDbType.Int,4),
                new SqlParameter("@repair",SqlDbType.NVarChar,50),
                new SqlParameter("@phonenum",SqlDbType.NChar,20),
                new SqlParameter("@works",SqlDbType.Int,4),
                new SqlParameter("@states",SqlDbType.Int,4)};
            parameters[0].Value = model.UserName;
            parameters[1].Value = model.isAdmin;
            parameters[2].Value = model.repair;
            parameters[3].Value = model.phonenum;
            parameters[4].Value = 0;
            parameters[5].Value = 1;


            object obj = DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Model.city model)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("insert into td_city(");
            strSql.Append("CityID,CityName,ZipCode,ProvinceID,DateCreated,DateUpdated");
            strSql.Append(") values (");
            strSql.Append("@CityID,@CityName,@ZipCode,@ProvinceID,@DateCreated,@DateUpdated");
            strSql.Append(") ");

            SqlParameter[] parameters = {
                        new SqlParameter("@CityID", SqlDbType.BigInt,8) ,
                        new SqlParameter("@CityName", SqlDbType.VarChar,50) ,
                        new SqlParameter("@ZipCode", SqlDbType.VarChar,50) ,
                        new SqlParameter("@ProvinceID", SqlDbType.BigInt,8) ,
                        new SqlParameter("@DateCreated", SqlDbType.DateTime) ,
                        new SqlParameter("@DateUpdated", SqlDbType.DateTime)

            };

            parameters[0].Value = model.CityID;
            parameters[1].Value = model.CityName;
            parameters[2].Value = model.ZipCode;
            parameters[3].Value = model.ProvinceID;
            parameters[4].Value = model.DateCreated;
            parameters[5].Value = model.DateUpdated;
                        DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
        }
Ejemplo n.º 5
0
 public static string AddMaintenance(Model.MyLog.DL_Maintenance DL_MainItem)
 {
     DataBase db = new DataBase();
     DataBaseVisitor visitor = new WSV.DAL.MyLog.OperData();
     bool bSuc = false;
     int nEffectRows = 0;
     SqlParameter[] prams ={
         db.MakeInParam("@ID", SqlDbType.Float,50, DL_MainItem.ID),
         db.MakeInParam("@TableNum", SqlDbType.VarChar,50,DL_MainItem.TableNum),
         db.MakeInParam("@SaverCode", SqlDbType.VarChar,50, DL_MainItem.SaverCode),
         db.MakeInParam("@WorkCode", SqlDbType.VarChar,50, DL_MainItem.WorkCode),
         db.MakeInParam("@OperCode", SqlDbType.VarChar,50, DL_MainItem.OperCode),
     };
     try
     {
         bSuc = db.TransactSql(visitor, "AddMaintenance", prams, out nEffectRows);
     }
     catch (Exception ex) { throw new Exception(ex.Message); }
     finally
     {
         db.Dispose();
     }
     if (bSuc && nEffectRows > 0)
         return "0101";
     else
         return "0";
 }
Ejemplo n.º 6
0
        public Vehicle(Model model, ObjectStats.VehicleStats vehicleStats)
            : base(model, vehicleStats)
        {
            rearWheelsCount = vehicleStats.RearWheelCount;
            frontWheelsCount = vehicleStats.FrontWheelCount;
            doorCount = vehicleStats.DoorCount;
            hasTurret = vehicleStats.HasTurret;
            waterSourceCount = vehicleStats.WaterSourceCount;

            leftDoorAngle = 0;
            rightDoorAngle = 0;
            leftDoorState = DoorState.Closed;
            rightDoorState = DoorState.Closed;

            wheelAngle = 0;
            wheelState = WheelState.Straight;

            NextStep = new Vector2(Position.X,Position.Z);

            //TEMP
            //leftDoorState = DoorState.Opening;
            //rightDoorState = DoorState.Opening;
            //wheelState = WheelState.StraightLeft;
            //gi = new GameInfo();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.express model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into " + databaseprefix + "express(");
            strSql.Append("title,express_code,express_fee,website,remark,sort_id,is_lock)");
            strSql.Append(" values (");
            strSql.Append("@title,@express_code,@express_fee,@website,@remark,@sort_id,@is_lock)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@title", SqlDbType.NVarChar,100),
                    new SqlParameter("@express_code", SqlDbType.NVarChar,100),
                    new SqlParameter("@express_fee", SqlDbType.Decimal,5),
                    new SqlParameter("@website", SqlDbType.NVarChar,255),
                    new SqlParameter("@remark", SqlDbType.NText),
                    new SqlParameter("@sort_id", SqlDbType.Int,4),
                    new SqlParameter("@is_lock", SqlDbType.TinyInt,1)};
            parameters[0].Value = model.title;
            parameters[1].Value = model.express_code;
            parameters[2].Value = model.express_fee;
            parameters[3].Value = model.website;
            parameters[4].Value = model.remark;
            parameters[5].Value = model.sort_id;
            parameters[6].Value = model.is_lock;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
Ejemplo n.º 8
0
 public int Add(Model.TaskLog obj)
 {
     string cmd = @"insert into tb_log(Content,LogType,CreateTime,Task_Id,Node_Id)
                    values(@Content,@LogType,@CreateTime,@Task_Id,@Node_Id)";
     IDataParameter[] param = {
         new SqlParameter("@Content", SqlDbType.NVarChar, 8000),
         new SqlParameter("@LogType", SqlDbType.Int, 4),
         new SqlParameter("@CreateTime", SqlDbType.DateTime),
         new SqlParameter("@Task_Id", SqlDbType.Int, 4),
         new SqlParameter("@Node_Id",SqlDbType.Int,4)
     };
     param[0].Value = obj.Content;
     param[1].Value = obj.LogType;
     param[2].Value = obj.CreateTime;
     param[3].Value = obj.Task_Id;
     param[4].Value = obj.Node_Id;
     try
     {
         return dbHelper.ExecuteSql(cmd, param);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 9
0
 public override RuleBase Build(Model.CoverageRulesContainer request)
 {
     NoneAreCarried.Build(request);
     TOWIsCarried.Build(request);
     ERSIsCarried.Build(request);
     return this;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(Model.Category model)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("insert into Category(");
            strSql.Append("CategoryName,ParentCategoryID,Orders,LastModifyTime,IsValid,Memo)");
            strSql.Append(" values (");
            strSql.Append("@CategoryName,@ParentCategoryID,@Orders,@LastModifyTime,@IsValid,@Memo)");
            strSql.Append(";select @@IDENTITY");
            MySqlParameter[] parameters = {
                    new MySqlParameter("@CategoryName", MySqlDbType.VarChar,50),
                    new MySqlParameter("@ParentCategoryID", MySqlDbType.Int64),
                    new MySqlParameter("@Orders", MySqlDbType.Int32),
                    new MySqlParameter("@LastModifyTime", MySqlDbType.DateTime),
                    new MySqlParameter("@IsValid", MySqlDbType.Bit,1),
                    new MySqlParameter("@Memo", MySqlDbType.VarChar,50)};
            parameters[0].Value = model.CategoryName;
            parameters[1].Value = model.ParentCategoryID;
            parameters[2].Value = model.Orders;
            parameters[3].Value = model.LastModifyTime;
            parameters[4].Value = model.IsValid;
            parameters[5].Value = model.Memo;

            object obj = DbHelperMySQL.GetSingle(strSql.ToString(),parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt64(obj);
            }
        }
Ejemplo n.º 11
0
        public override List<EpisodeParseResult> PerformSearch(Repository.Series series, dynamic options, Model.Notification.ProgressNotification notification)
        {
            if (options.Episode == null)
                throw new ArgumentException("Episode is invalid");

            notification.CurrentMessage = "Looking for " + options.Episode;

            var reports = new List<EpisodeParseResult>();
            var title = GetSearchTitle(series);

            var seasonNumber = options.Episode.SeasonNumber;
            var episodeNumber = options.Episode.EpisodeNumber;

            Parallel.ForEach(_indexerProvider.GetEnabledIndexers(), indexer =>
            {
                try
                {
                    reports.AddRange(indexer.FetchEpisode(title, seasonNumber, episodeNumber));
                }

                catch (Exception e)
                {
                    logger.ErrorException(String.Format("An error has occurred while searching for {0}-S{1:00}E{2:00} from: {3}",
                                                         series.Title, options.SeasonNumber, options.EpisodeNumber, indexer.Name), e);
                }
            });

            return reports;
        }
Ejemplo n.º 12
0
 public Controller_MainForm(int sizeField,int amountTanks,int amountApples,int speedGame)
 {
     InitializeComponent();
     model = new Model(sizeField,amountTanks,amountApples,speedGame);
     view = new View(model);
     this.Controls.Add(view);
 }
Ejemplo n.º 13
0
        public PesFisica(Model.pessoas.Pessoa pes,
            string apelido,
            DateTime dtNascimento,
            string rg,
            string cpf,
            string cnh,
            string cnhLetra,
            DateTime cnhValidade,
            DateTime cnhEmissao)
        {
            // carrega dados disponivel da classe pai
            this.Id = pes.Id;
            this.Nome = pes.Nome; //razão social!!!
            this.Tipo = pes.Tipo;
            this.Status = pes.Status;
            this.DtCad = pes.DtCad;

            _apelido = apelido.Trim().ToUpper();
            _dtNascimento = dtNascimento;
            _rg = rg.Trim();
            _cpf = cpf.Trim();
            _cnh = cnh.Trim();
            _cnhLetra = cnhLetra.Trim().ToUpper();
            _cnhValidade = cnhValidade;
            _cnhEmissao = cnhEmissao;
        }
Ejemplo n.º 14
0
        public List<Model.Query.WebContentType1Query> QueryAll(Model.Query.WebContentType1Query query, out int totalCount)
        {
            query.Replace4MySQL();
            StringBuilder str = new StringBuilder();
            StringBuilder strcondition = new StringBuilder();
            try
            {
                    str.Append(@"select w1.* , t_site.parameterName as site_name,t_page.parameterName as page_name,t_area.parameterName as area_name from web_content_type1 w1 ");
                    str.AppendFormat(" left join t_parametersrc t_site on t_site.parameterType='site_id' and t_site.parameterCode=w1.site_id");
                    str.AppendFormat(" left join t_parametersrc t_page on t_page.parameterType='page_id' and t_page.parameterCode=w1.page_id and t_page.topValue=t_site.rowid");
                    str.AppendFormat(" left join t_parametersrc t_area on t_area.parameterType='area_id' and t_area.parameterCode=w1.area_id and t_area.topValue=t_page.rowid");
                    strcondition.AppendFormat(" where 1=1 order by content_id desc ");
                    totalCount = 0;

                    if (query.IsPage)
                    {
                        DataTable dt = _access.getDataTable(@"SELECT count(*) as totalcount from web_content_type1 ");
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            totalCount = Convert.ToInt32(dt.Rows[0]["totalcount"]);

                        }
                        strcondition.AppendFormat(" limit {0},{1}", query.Start, query.Limit);
                    }
                    string strs = str.ToString() + strcondition.ToString();
                    return _access.getDataTableForObj<WebContentType1Query>(strs.ToString());

            }
            catch (Exception ex)
            {
                throw new Exception("WebContentType1Dao.QueryAll-->" + ex.Message + str.ToString(), ex);
            }
            
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.app_oauth model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into dt_app_oauth(");
            strSql.Append("title,img_url,app_id,app_key,remark,sort_id,is_lock,api_path)");
            strSql.Append(" values (");
            strSql.Append("@title,@img_url,@app_id,@app_key,@remark,@sort_id,@is_lock,@api_path)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar, 100),
            new SqlParameter("@img_url", SqlDbType.NVarChar, 255),
            new SqlParameter("@app_id", SqlDbType.NVarChar, 100),
            new SqlParameter("@app_key", SqlDbType.NVarChar, 100),
            new SqlParameter("@remark", SqlDbType.NVarChar, 500),
            new SqlParameter("@sort_id", SqlDbType.Int, 4),
            new SqlParameter("@is_lock", SqlDbType.TinyInt, 1),
            new SqlParameter("@api_path", SqlDbType.NVarChar, 100) };
            parameters[0].Value = model.title;
            parameters[1].Value = model.img_url;
            parameters[2].Value = model.app_id;
            parameters[3].Value = model.app_key;
            parameters[4].Value = model.remark;
            parameters[5].Value = model.sort_id;
            parameters[6].Value = model.is_lock;
            parameters[7].Value = model.api_path;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        internal Option(string displayName, int? addressId, AddressType? addressType, string postcode, OptionType optionType, Model.Link[] links)
        {
            if (string.IsNullOrWhiteSpace(displayName)) throw new ArgumentNullException("displayName");
            if (links == null) throw new ArgumentNullException("links");

            DisplayName = displayName;
            AddressId = addressId;
            AddressType = addressType;
            Postcode = postcode;
            OptionType = optionType;

            var newLinks = new List<Model.Link>();

            foreach (Model.Link link in links)
            {
                Model.Link newLink;

                switch (link.Rel)
                {
                    case "next":
                        newLink = new Link(link.Rel, link.Href);
                        break;
                    default:
                        newLink = link;
                        break;
                }

                newLinks.Add(newLink);
            }

            Links = newLinks.ToArray();
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Model.NewsRegionalRelation model)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("insert into NewsRegionalRelation(");
            strSql.Append("AutoID,NewsID,RegionalID)");
            strSql.Append(" values (");
            strSql.Append("@AutoID,@NewsID,@RegionalID)");
            MySqlParameter[] parameters = {
                    new MySqlParameter("@AutoID", MySqlDbType.Int64),
                    new MySqlParameter("@NewsID", MySqlDbType.Int64),
                    new MySqlParameter("@RegionalID", MySqlDbType.VarChar,50)};
            parameters[0].Value = model.AutoID;
            parameters[1].Value = model.NewsID;
            parameters[2].Value = model.RegionalID;

            int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// ����һ������
        /// </summary>
        public int Add(Model.contents.article_attribute_field model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into " + databaseprefix + "article_attribute_field(");
            strSql.Append("name,title,control_type,data_type,data_length,data_place,item_option,default_value,is_required,is_password,is_html,editor_type,valid_tip_msg,valid_error_msg,valid_pattern,sort_id,is_sys)");
            strSql.Append(" values (");
            strSql.Append("@name,@title,@control_type,@data_type,@data_length,@data_place,@item_option,@default_value,@is_required,@is_password,@is_html,@editor_type,@valid_tip_msg,@valid_error_msg,@valid_pattern,@sort_id,@is_sys)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@name", SqlDbType.NVarChar,100),
                    new SqlParameter("@title", SqlDbType.NVarChar,100),
                    new SqlParameter("@control_type", SqlDbType.NVarChar,50),
                    new SqlParameter("@data_type", SqlDbType.NVarChar,50),
                    new SqlParameter("@data_length", SqlDbType.Int,4),
                    new SqlParameter("@data_place", SqlDbType.TinyInt,1),
                    new SqlParameter("@item_option", SqlDbType.NText),
                    new SqlParameter("@default_value", SqlDbType.NText),
                    new SqlParameter("@is_required", SqlDbType.TinyInt,1),
                    new SqlParameter("@is_password", SqlDbType.TinyInt,1),
                    new SqlParameter("@is_html", SqlDbType.TinyInt,1),
                    new SqlParameter("@editor_type", SqlDbType.TinyInt,1),
                    new SqlParameter("@valid_tip_msg", SqlDbType.NVarChar,255),
                    new SqlParameter("@valid_error_msg", SqlDbType.NVarChar,255),
                    new SqlParameter("@valid_pattern", SqlDbType.NVarChar,500),
                    new SqlParameter("@sort_id", SqlDbType.Int,4),
                    new SqlParameter("@is_sys", SqlDbType.TinyInt,1),
                    new SqlParameter("@ReturnValue",SqlDbType.Int)};
            parameters[0].Value = model.name;
            parameters[1].Value = model.title;
            parameters[2].Value = model.control_type;
            parameters[3].Value = model.data_type;
            parameters[4].Value = model.data_length;
            parameters[5].Value = model.data_place;
            parameters[6].Value = model.item_option;
            parameters[7].Value = model.default_value;
            parameters[8].Value = model.is_required;
            parameters[9].Value = model.is_password;
            parameters[10].Value = model.is_html;
            parameters[11].Value = model.editor_type;
            parameters[12].Value = model.valid_tip_msg;
            parameters[13].Value = model.valid_error_msg;
            parameters[14].Value = model.valid_pattern;
            parameters[15].Value = model.sort_id;
            parameters[16].Value = model.is_sys;
            parameters[17].Direction = ParameterDirection.Output;

            List<CommandInfo> sqllist = new List<CommandInfo>();
            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            //������չ�ֶα���һ��
            StringBuilder strSql2 = new StringBuilder();
            strSql2.Append("alter table " + databaseprefix + "article_attribute_value add " + model.name + " " + model.data_type);
            SqlParameter[] parameters2 = { };
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return (int)parameters[17].Value;
        }
Ejemplo n.º 19
0
        public void AlterarCidades(Model.CidadeModel cidadesModel)
        {
            conn = new SqlConnection(Strconexao);
            try
            {
                SqlCommand cmd = new SqlCommand("update cidades set cidade=@cidade, uf=@uf, bloqueado=@bloqueado where codigo=@codigo", conn);
                cmd.Parameters.AddWithValue("@codigo", cidadesModel.Codigo);
                cmd.Parameters.AddWithValue("@cidade", cidadesModel.Cidade);
                cmd.Parameters.AddWithValue("@uf", cidadesModel.UF);
                cmd.Parameters.AddWithValue("@bloqueado", cidadesModel.Bloqueado);

                conn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao alterar cidade" + ex.Message);
            }

            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }
 /// <summary>
 /// Constructor of test, supplied with all neccessary values
 /// </summary>
 /// <param name="n">The length of the bit string</param>
 /// <param name="model">Model containing the the binary string</param>
 /// <exception cref="ArgumentException"/>
 public RandomExcursions(int n, ref Model model)
     : base(ref model) {
         if (n > model.epsilon.Count || n <= 0) {
             throw new ArgumentException("The value of n must be smaller than the size of the input data, and be greater than 0", "Frequency n");
         }
         this.n = n;
 }
Ejemplo n.º 21
0
        public static void Main(string[] argv)
        {
          int N = 5;
          var A = new double[][]
              { new double[] { 0.0,  0.5,  -0.1,  -0.2,   0.5},
                new double[] { 0.5,  1.25, -0.05, -0.1,   0.25},
                new double[] {-0.1, -0.05,  0.51,  0.02, -0.05},
                new double[] {-0.2, -0.1,   0.02,  0.54, -0.1},
                new double[] { 0.5,  0.25, -0.05, -0.1,   1.25} };

          // Create a model with the name 'NearestCorrelation
          using (var M = new Model("NearestCorrelation"))
          {
            // Setting up the variables
            var X = M.Variable("X", Domain.InPSDCone(N));
            var t = M.Variable("t", 1, Domain.Unbounded());

            // (t, vec (A-X)) \in Q
            M.Constraint( Expr.Vstack(t, Vec(Expr.Sub(new DenseMatrix(A),X))), Domain.InQCone() );

            // diag(X) = e
            M.Constraint(X.Diag(), Domain.EqualsTo(1.0));

            // Objective: Minimize t
            M.Objective(ObjectiveSense.Minimize, t);
                              
            // Solve the problem
            M.Solve();

            // Get the solution values
            Console.WriteLine("X = {0}",arrtostr(X.Level()));
            
            Console.WriteLine("t = {0}", arrtostr(t.Level()));
          } 
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Model.Regional model)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("insert into regional(");
            strSql.Append("RegionalID,RegionalName,RegionalCode,SubRegionalID,RegionalLevel,Orders,LastModifyTime,IsValid,Memo)");
            strSql.Append(" values (");
            strSql.Append("@RegionalID,@RegionalName,@RegionalCode,@SubRegionalID,@RegionalLevel,@Orders,@LastModifyTime,@IsValid,@Memo)");
            MySqlParameter[] parameters = {
                    new MySqlParameter("@RegionalID", MySqlDbType.VarChar,50),
                    new MySqlParameter("@RegionalName", MySqlDbType.VarChar,50),
                    new MySqlParameter("@RegionalCode", MySqlDbType.VarChar,50),
                    new MySqlParameter("@SubRegionalID", MySqlDbType.VarChar,50),
                    new MySqlParameter("@RegionalLevel", MySqlDbType.VarChar,50),
                    new MySqlParameter("@LastModifyTime", MySqlDbType.DateTime),
                    new MySqlParameter("@IsValid", MySqlDbType.Bit),
                    new MySqlParameter("@Memo", MySqlDbType.VarChar,50),
                    new MySqlParameter("@Orders", MySqlDbType.Int32)};
            parameters[0].Value = model.RegionalID;
            parameters[1].Value = model.RegionalName;
            parameters[2].Value = model.RegionalCode;
            parameters[3].Value = model.SubRegionalID;
            parameters[4].Value = model.RegionalLevel;
            parameters[5].Value = model.LastModifyTime;
            parameters[6].Value = model.IsValid;
            parameters[7].Value = model.Memo;
            parameters[8].Value = model.Orders;

            StringBuilder strSql1 = new StringBuilder();
            strSql1.Append("insert into T_SYSCODEDETIAL(");
            strSql1.Append("SYSCodeID,SYSCodeDetialID,SYSCodeDetialContext,LastModifyTime,IsValid,Memo)");
            strSql1.Append(" values (");
            strSql1.Append("@SYSCodeID,@SYSCodeDetialID,@SYSCodeDetialContext,@LastModifyTime,@IsValid,@Memo)");
            MySqlParameter[] parameters1 = {
                    new MySqlParameter("@SYSCodeID", MySqlDbType.VarChar,50),
                    new MySqlParameter("@SYSCodeDetialID", MySqlDbType.VarChar,50),
                    new MySqlParameter("@SYSCodeDetialContext", MySqlDbType.VarChar,50),
                    new MySqlParameter("@LastModifyTime", MySqlDbType.DateTime),
                    new MySqlParameter("@IsValid", MySqlDbType.Bit,1),
                    new MySqlParameter("@Memo", MySqlDbType.VarChar,50)};
            parameters1[0].Value = "Region";
            parameters1[1].Value = model.RegionalID;
            parameters1[2].Value = model.RegionalName;
            parameters1[3].Value = DateTime.Now;
            parameters1[4].Value = model.IsValid;
            parameters1[5].Value = model.Memo;

            System.Collections.Hashtable sqlStringList = new System.Collections.Hashtable();
            sqlStringList.Add(strSql, parameters);
            sqlStringList.Add(strSql1, parameters1);

            try
            {
                DbHelperMySQL.ExecuteSqlTran(sqlStringList);
                return true;
            }
            catch
            {
                return false;
            }
        }
Ejemplo n.º 23
0
        public IModel Select(FbConnection conn, FbTransaction trans, string code)
        {
            string query = "SELECT * FROM models WHERE modelcode = UPPER(@modelcode)";

            IModel ret = null;

            try
            {
                using (FbCommand cmd = new FbCommand(query, conn, trans))
                {
                    cmd.Parameters.AddWithValue("modelcode", code.ToUpper());
                    using (FbDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            ret = new Model
                            {
                                Id = reader.GetInt32(0),
                                Code = reader.GetString(1),
                                ObjectIdRoot = reader.GetInt32(2)
                            };
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("Ошибка SQL запроса. {0}", ex.Message));
            }

            return ret;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// ����һ������
        /// </summary>
        public int Add(Model.distribution model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into dt_distribution(");
            strSql.Append("title,remark,type,amount,sort_id,is_lock)");
            strSql.Append(" values (");
            strSql.Append("@title,@remark,@type,@amount,@sort_id,@is_lock)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@title", SqlDbType.NVarChar,100),
                    new SqlParameter("@remark", SqlDbType.NText),
                    new SqlParameter("@type", SqlDbType.TinyInt,1),
                    new SqlParameter("@amount", SqlDbType.Decimal,5),
                    new SqlParameter("@sort_id", SqlDbType.Int,4),
                    new SqlParameter("@is_lock", SqlDbType.TinyInt,1)};
            parameters[0].Value = model.title;
            parameters[1].Value = model.remark;
            parameters[2].Value = model.type;
            parameters[3].Value = model.amount;
            parameters[4].Value = model.sort_id;
            parameters[5].Value = model.is_lock;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
Ejemplo n.º 25
0
        protected internal override TestResult RunImpl(ITestCommand rootTestCommand, Model.Tree.TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
        {
            using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount))
            {
                // Note: We do not check options.SkipTestExecution here because we want to build up
                // the tree of data-driven test steps.  So we actually check it later on in the
                // PatternTestExecutor.  This is different from framework adapters
                // at this time (because they do not generally support dynamically generated data-driven tests).
                Sandbox sandbox = new Sandbox();
                EventHandler canceledHandler = delegate { sandbox.Abort(TestOutcome.Canceled, "The user canceled the test run."); };
                try
                {
                    progressMonitor.Canceled += canceledHandler;

                    TestAssemblyExecutionParameters.Reset();

                    PatternTestExecutor executor = new PatternTestExecutor(options, progressMonitor, formatter, converter, environmentManager);

                    // Inlined to minimize stack depth.
                    var action = executor.CreateActionToRunTest(rootTestCommand, parentTestStep, sandbox, null);
                    action.Run();
                    return action.Result;
                }
                finally
                {
                    progressMonitor.Canceled -= canceledHandler;
                    sandbox.Dispose();
                }
            }
        }
 public Model.Fixture AddFixture(Model.Fixture fixture)
 {
     return this.restServiceAsync.AddFixtureAsync(fixture)
         .ConfigureAwait(false)
         .GetAwaiter()
         .GetResult();
 }
        public void throw_when_no_httpcontext_is_available()
        {
            HttpContext.Current = null;

            var model = new Model();
            var assertAttribute = new AssertThatAttribute("true");
            var requirAttribute = new RequiredIfAttribute("true");

            var metadata = GetModelMetadata(model, m => m.Value);
            var controllerContext = GetControllerContext();

            var e = Assert.Throws<ValidationException>(() => new AssertThatValidator(metadata, controllerContext, assertAttribute).GetClientValidationRules().Single());
            Assert.Equal(
                "AssertThatValidator: collecting of client validation rules for Value field failed.",
                e.Message);
            Assert.IsType<ApplicationException>(e.InnerException);
            Assert.Equal(
                "HttpContext not available.",
                e.InnerException.Message);

            e = Assert.Throws<ValidationException>(() => new RequiredIfValidator(metadata, controllerContext, requirAttribute).GetClientValidationRules().Single());
            Assert.Equal(
                "RequiredIfValidator: collecting of client validation rules for Value field failed.",
                e.Message);
            Assert.IsType<ApplicationException>(e.InnerException);
            Assert.Equal(
                "HttpContext not available.",
                e.InnerException.Message);
        }
Ejemplo n.º 28
0
        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            Logging.Setup();
            Logging.AddToAuthorun();
            ShowInTaskbar = false;
            RegisterHotkey();
            
            _Model = new Model();
            this.DataContext = _Model;
            foreach (string s in Environment.GetCommandLineArgs())
            {
                if (File.Exists(s) && System.IO.Path.GetExtension(s) != ".exe")
                {
                    _Model.Open(s);
                }
            }
            if (!_Model._Loaded) _Model.Load();
            KeyDown += new KeyEventHandler(Window1_KeyDown);
            Closed += new EventHandler(Window1_Closed);
            
            Closing += new System.ComponentModel.CancelEventHandler(Window1_Closing);
            App.Current.Deactivated += new EventHandler(Current_Deactivated);
            _RitchTextBox.Focus();
            _RitchTextBox.TextChanged += new TextChangedEventHandler(RitchTextBox_TextChanged);

            new DispatcherTimer().StartRepeatMethod(60 * 10, Update);
            this.Show(); 
           
            
        }
        public PresentationModel(Model model)
        {
            _model = model;
            List<Tuple<string, string>> imageList = new List<Tuple<string, string>>
            {
                new Tuple<string, string>("fingersSpread", "Image/fingersSpread.png"),
                new Tuple<string, string>("waveOut", "Image/waveOut.png"),
                new Tuple<string, string>("waveIn", "Image/waveIn.png"),
                new Tuple<string, string>("fist", "Image/fist.png"),
                new Tuple<string, string>("rightArrow", "Image/rightArrow.png"),
                new Tuple<string, string>("downArrow", "Image/downArrow.png"),
                new Tuple<string, string>("keyboard", "Image/keyboard.png"),
            };

            foreach (Tuple<string, string> item in imageList)
            {
                AddImage(item.Item1, Image.FromFile(item.Item2));
            }

            Bitmap source = new Bitmap("Image/arm-device.png");
            List<Tuple<string, Rectangle>> sectionList = new List<Tuple<string, Rectangle>>
            {
                new Tuple<string, Rectangle>("rollUp", new Rectangle(0, 0, 230, 230)),
                new Tuple<string, Rectangle>("rollDown", new Rectangle(182, 0, 230, 230)),
                new Tuple<string, Rectangle>("pitchUp", new Rectangle(0, 182, 230, 230)),
                new Tuple<string, Rectangle>("pitchDown", new Rectangle(180, 180, 230, 230)),
                new Tuple<string, Rectangle>("yawUp", new Rectangle(0, 360, 230, 230)),
                new Tuple<string, Rectangle>("yawDown", new Rectangle(182, 360, 230, 230)),
            };

            foreach (Tuple<string, Rectangle> item in sectionList)
            {
                CutImage(item.Item1, source, item.Item2);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.manager_log model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into " + databaseprefix + "manager_log(");
            strSql.Append("user_id,user_name,action_type,remark,user_ip)");
            strSql.Append(" values (");
            strSql.Append("@user_id,@user_name,@action_type,@remark,@user_ip)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@user_id", SqlDbType.Int,4),
					new SqlParameter("@user_name", SqlDbType.NVarChar,100),
					new SqlParameter("@action_type", SqlDbType.NVarChar,100),
					new SqlParameter("@remark", SqlDbType.NVarChar,255),
					new SqlParameter("@user_ip", SqlDbType.NVarChar,30)
					};
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.user_name;
            parameters[2].Value = model.action_type;
            parameters[3].Value = model.remark;
            parameters[4].Value = model.user_ip;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
Ejemplo n.º 31
0
 /// <inheritdoc />
 /// <summary>
 /// Выполнить
 /// </summary>
 public void Do()
 {
     Model.AddFigure(Index, Figure);
 }
Ejemplo n.º 32
0
 /// <inheritdoc />
 /// <summary>
 /// Отменить
 /// </summary>
 public void Undo()
 {
     Model.DeleteFigureAt(Index, Figure);
 }