Exemplo n.º 1
0
 public ObjectBuilder()
 {
     API.onClientEventTrigger += API_onClientEventTrigger;
     if (!System.IO.Directory.Exists("MapEditorSettings"))
     {
         System.IO.Directory.CreateDirectory("MapEditorSettings");
     }
     if (System.IO.File.Exists("MapEditorSettings/ModelList.xml"))
     {
         System.Xml.Serialization.XmlSerializer reader =
             new System.Xml.Serialization.XmlSerializer(typeof(ModelList));
         System.IO.StreamReader file = new System.IO.StreamReader("MapEditorSettings/ModelList.xml");
         ObjectModels = (ModelList)reader.Deserialize(file);
         file.Close();
         if (ObjectModels == null)
         {
             API.consoleOutput(LogCat.Error, "Parsing of ModelList.xml failed..");
             ObjectModels = new ModelList();
         }
         else
         {
             API.consoleOutput(LogCat.Info, "Parsing of ModelList.xml succeed..");
         }
     }
     else
     {
         API.consoleOutput(LogCat.Info, "MapEditorSettings/ModelList.xml does not exist.. Skip..");
         ObjectModels = new ModelList();
     }
 }
Exemplo n.º 2
0
        public void AddModels(ModelFromFile fromFile, bool isNew)//(string fileName,byte[] data)
        {
            if (!availableModel)
            {
                availableGCode = false;
                gCode          = "";
                GCodeChange(gCode);
                InitSlicerView();
            }
            availableModel = true;
            IsChanged      = true;
            PrintModel model = new PrintModel(control, fromFile);

            model.Load(fromFile.Name, fromFile.Data);
            model.update();
            if (isNew)
            {
                model.Center(SettingsProvider.Instance.Printer_Settings.PrintAreaWidth / 2, SettingsProvider.Instance.Printer_Settings.PrintAreaDepth / 2);
                model.Land();
            }
            ModelList.Add(model);
            if (model.ActiveModel.triangles.Count > 0)
            {
                PreView.models.AddLast(model);

                if (isNew)
                {
                    Allocate(model);
                    model.addAnimation(new DropAnimation("drop"));
                }

                updateSTLState(model);
            }
        }
Exemplo n.º 3
0
 private void ProductEditor_Load(object sender, EventArgs e)
 {
     brandsBindingSource.DataSource       = BrandList.GetBrandList();
     productTypesBindingSource.DataSource = ProductTypeList.GetProductTypeList();
     BindProductType();
     modelsBindingSource.DataSource = ModelList.GetModelList();
 }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Ajax.RegMethod(GetSiteByCityID);

            citys = CityDAO.Instance.GetCityList();
            //DataTable category = CategoryDAO.Instance.GetDataList();
        }
Exemplo n.º 5
0
 /// <summary>
 /// モデルを追加する
 /// </summary>
 /// <param name="model"></param>
 private void AddModel(LiplisModel model)
 {
     //TODO CtrlModelController AddModel 登録キーチェックすべきか?
     TableModel.Add(model.ModelName, model);
     TableModelId.Add(model.AllocationId, model);
     ModelList.Add(model);
 }
Exemplo n.º 6
0
        public Tiles(string dbUrl) : base(dbUrl)
        {
            // API only available to authenticated users
            BeforeAsync = async(p, c) => await c.EnsureIsAuthenticatedAsync();

            GetAsync["/"] = async(p, c) =>
            {
                var res      = new ModelList <Tile>();
                var authUser = await c.GetAuthenticatedUserAsync();

                var filterAuth = (new Tile()).FilterAuthUser(authUser);
                using (DB db = await DB.CreateAsync(dbUrl))
                {
                    var result = await Model.SearchAsync <Tile>(db, c, filterAuth);

                    foreach (var tile in result.Data)
                    {
                        if (await tile.GetRightsAsync(c) != TileRightType.None)
                        {
                            res.Add(tile);
                        }
                    }
                }
                c.Response.StatusCode = 200;
                c.Response.Content    = res.ToJson();
            };
        }
        public void TestObserveCollectionChanged()
        {
            // 被観測者, 観測者を生成します
            var modelList = new ModelList <int>()
            {
                1, 2, 3
            };
            var observer = new Observer <NotifyCollectionChangedEventArgs>();

            // イベントを購読します
            var subscription =
                modelList
                .ObserveCollectionChanged()
                .Subscribe(observer.OnObservedEvent);

            observer.Subscriptions.Add(subscription);

            // イベントを送受信することで, 以上の動作を確認します
            modelList.Add(8);
            Assert.That(observer.LastEventArgs.Action, Is.EqualTo(NotifyCollectionChangedAction.Add));

            // イベント購読を解除します
            observer.Subscriptions.Dispose();

            // イベントを受信できないことで, 以上の動作を確認します
            observer.LastEventArgs = null;
            modelList.Add(16);
            Assert.That(observer.LastEventArgs, Is.Null);
        }
 /// <summary>
 /// Adds a blank phrase to Phrases.
 /// </summary>
 public void Add()
 {
     ModelList.AddedNew += ModelList_AddedNew;
     ModelList.AddNew();
     ModelList.AddedNew -= ModelList_AddedNew;
     //NotifyOfPropertyChange(() => CanSave);
 }
Exemplo n.º 9
0
        /// <summary>
        /// 执行指定SQL的命令,返回数据字典集合
        /// </summary>
        /// <param name="transaction">一个有效的连接事务</param>
        /// <param name="cmdType">命令类型 (存储过程,命令文本或其它)</param>
        /// <param name="cmdText">存储过程名称或SQL语句</param>
        /// <param name="parms">分配给命令的SqlParamter参数数组</param>
        /// <returns>返回指定列数据字典集合</returns>
        public static ModelList ExecuteList(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] parms)
        {
            QueryCount++;

            SqlCommand cmd = new SqlCommand();

            using (SqlConnection conn = new SqlConnection(CONNECTIONSTRING))
            {
                PrepareCommand(cmd, conn, trans, cmdType, cmdText, parms);
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.HasRows)
                    {
                        ModelList list = new ModelList();
                        do
                        {
                            while (rdr.Read())
                            {
                                Model model = new Model();
                                for (int i = 0; i < rdr.FieldCount; i++)
                                {
                                    model.Add(rdr.GetName(i), rdr[i].ToString());
                                }
                                list.Add(model);
                            }
                        } while (rdr.NextResult());
                        return(list);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
Exemplo n.º 10
0
        public bool Remove(TaskOrder model, bool RemoveListOnly = false)
        {
            if (RemoveListOnly)
            {
                if (ModelList.Remove(model))
                {
                    return(true);
                }
            }
            else
            {
                if (_taskOrderService.IsAny(x => x.id == model.id))
                {
                    if (_taskOrderService.Delete(x => x.id == model.id))
                    {
                        _taskOrderDetailService.Delete(x => x.order_id == model.id);//删除明细
                        if (ModelList.Remove(model))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Ajax.RegMethod(AddSite);

            cityList = CityDAO.Instance.GetCityList();
            siteID   = Utils.GetQueryInt("ID");
            if (siteID > 0)
            {
                TuanSite tuanSite = TuanSiteDAO.Instance.GetModel(siteID);
                if (tuanSite != null)
                {
                    txt_SiteName.Value = tuanSite.SiteName;
                    txt_SiteUrl.Value  = tuanSite.SiteUrl;
                    txt_LogoUrl.Value  = tuanSite.LogoUrl;
                    txt_ApiUrl.Value   = tuanSite.ApiUrl;
                    txt_QQ.Value       = tuanSite.QQ;
                    cityID             = tuanSite.CityID;
                    apiTypeID          = tuanSite.ApiTypeID;
                    if (tuanSite.SiteType == 0)
                    {
                        rdo_SiteType_1.Checked = true;
                    }
                    else
                    {
                        rdo_SiteType_2.Checked = true;
                    }
                }
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Adds the elements of another ModelContainer to the end of this ModelContainer.
 /// </summary>
 /// <param name="items">
 /// The ModelContainer whose elements are to be added to the end of this ModelContainer.
 /// </param>
 public virtual void AddRange(ModelList items)
 {
     foreach (IModel item in items)
     {
         Add(item);
     }
 }
Exemplo n.º 13
0
        private void saveToJson(string fileUrn, string tags, string filename)
        {
            var filePath = string.Format("c:\\models.json");

            var reader     = new StreamReader(filePath);
            var jsonReader = new JsonTextReader(reader);
            var serializer = new JsonSerializer();
            var modelList  = serializer.Deserialize <ModelList>(jsonReader);

            jsonReader.Close();

            if (modelList == null)
            {
                modelList = new ModelList {
                    Models = new List <Model>()
                };
            }

            if (modelList.Models.All(x => x.FileUrn != fileUrn))
            {
                var model = new Model {
                    FileUrn = fileUrn, Tags = tags, FileName = filename
                };
                modelList.Models.Add(model);
            }

            var writer     = new StreamWriter(filePath);
            var jsonWriter = new JsonTextWriter(writer);
            var ser        = new JsonSerializer();

            ser.Serialize(jsonWriter, modelList);
            jsonWriter.Flush();
        }
Exemplo n.º 14
0
        internal void Dispose()
        {
            LoggedIn = false;

            socket.Dispose();
            socket = null;

            guid      = Guid.Empty;
            name      = null;
            orgname   = null;
            version   = null;
            region    = null;
            message   = null;
            avatar    = null;
            orgavatar = null;
            localip   = null;
            nodeip    = null;

            counters.Clear();
            counters = null;

            ignored.Clear();
            ignored = null;

            extended_props.Clear();
            extended_props = null;
        }
Exemplo n.º 15
0
        private void RuleChecker(string line)
        {
            int    modelNameEnd = line.IndexOf("(");
            string TypeOfModel  = line.Substring(0, modelNameEnd);

            //browsking apriopriate model
            // Trzeba się zastanowic nad leszym sposobem na identyfikację mało uniwersalny
            if (TypeOfModel == _config._elementsNamesLanguageConfig.SimpleModel)
            {
                ModelList.Add(SimpleModel(line));
            }
            else if (TypeOfModel == _config._elementsNamesLanguageConfig.ExtendedModel)
            {
                ModelList.Add(ExtendedModel(line));
            }
            else if (TypeOfModel == _config._elementsNamesLanguageConfig.LinearModel)
            {
                ModelList.Add(LinearModel(line));
            }
            else if (TypeOfModel == _config._elementsNamesLanguageConfig.PolyModel)
            {
                ModelList.Add(PolyModel(line));
            }
            else if (TypeOfModel == _config._elementsNamesLanguageConfig.Argument)
            {
                ArgumentList.Add(ReturnArgument(line));
            }
            else if (TypeOfModel == _config._elementsNamesLanguageConfig.ModelFact)
            {
                _modelFactsList.Add(ModelFact(line));
            }
        }
Exemplo n.º 16
0
        public ActionResult GetCategoryProductList(int id, string type = "g", int cpgn = 1)
        {
            ModelList    model       = new ModelList();
            List <MMM00> productList = null;

            if (type == "g")
            {
                ViewBag.MMG00_CODE = id;
                productList        = productManagement.GetProducts(id);
            }
            else if (type == "c")
            {
                ViewBag.MMH00_CODE = id;
                productList        = productManagement.GetProducts(0, id);
            }


            int cnt = productList == null ? 0 : productList.Count;

            model.d1            = productList.Skip((cpgn - 1) * rpp).Take(rpp).ToList();
            ViewBag.MaxPage     = Math.Ceiling((decimal)cnt / rpp);
            ViewBag.CurrentPage = cpgn;

            return(View("AllProducts", model));
        }
Exemplo n.º 17
0
        /// <summary>
        /// 获取网站基本统计信息
        /// </summary>
        public override ModelList GetBaseStats()
        {
            string procName = "[Proc_GetBaseStats]";

            ModelList model = SqlHelper.ExecuteList(CommandType.StoredProcedure, procName, null);

            return(model);
        }
Exemplo n.º 18
0
        public ActionResult ProductDetail(int id)
        {
            ModelList model = new ModelList();

            model.d1 = productManagement.GetProduct(id);

            return(View(model));
        }
Exemplo n.º 19
0
 public AddArticle()
 {
     InitializeComponent();
     ArticlesController  = new ArticlesController();
     ModelListController = new ModelListController();
     ModelList           = new ModelList();
     ModelList           = ModelListController.GetAllModelList();
 }
Exemplo n.º 20
0
        private void SaveOrderNo_OnClick(object sender, RoutedEventArgs e)
        {
            SaveModel();
            var orders = ((OrderRepo)Repo).LoadOrders(JobCardId);

            ModelList.Clear();
            ModelList.AddAll(orders);
        }
Exemplo n.º 21
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (lbModel.SelectedItem != null)
     {
         ModelList         = lbModel.SelectedItem as ModelList;
         this.DialogResult = DialogResult.OK;
     }
 }
Exemplo n.º 22
0
 public static List <string> GetNameByID(ModelList lstmodel, int id)
 {
     if (lstmodel != null && lstmodel.Models.Count >= id)
     {
         return(lstmodel.Models[id - 1]);
     }
     return(null);
 }
Exemplo n.º 23
0
        public override ModelList GetCityList()
        {
            string strSql = "SELECT CityID,City FROM TN_City WHERE IsDisplay=1 ORDER BY OrderID";

            ModelList list = SqlHelper.ExecuteList(CommandType.Text, strSql);

            return(list);
        }
Exemplo n.º 24
0
 public AresUserHistory()
 {
     this.admins    = new Admin();
     this.bans      = new Banned();
     this.rBans     = new RangeBanned();
     this.records   = new ModelList <Record>();
     this.LastSaved = DateTime.Now;
 }
Exemplo n.º 25
0
        /// <summary>
        /// ランダムにキャラクターを取得する
        /// </summary>
        /// <returns></returns>
        public LiplisModel GetCharacterRandam()
        {
            //シャッフルする
            ModelList.Shuffle();

            //先頭1つを返す
            return(ModelList[0]);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Write all the data to a csv file.
        /// </summary>
        /// <param name="FilePath"></param>
        /// <param name="FormExport"></param>
        public static void WriteFile(string FilePath, FormExport FormExport)
        {
            try
            {
                ModelList ModelList = new ModelList();
                string    HeaderCsv = null;

                if (FilePath == "")
                {
                    if (MessageBox.Show("Please choose a file!", "ERROR") == DialogResult.OK)
                    {
                        using (OpenFileDialog openFileDialog = new OpenFileDialog())
                        {
                            openFileDialog.Filter           = "csv files (*.csv)|*.csv";
                            openFileDialog.RestoreDirectory = true;

                            if (openFileDialog.ShowDialog() == DialogResult.OK)
                            {
                                FilePath = openFileDialog.FileName;
                                FormExport.label_FichierExporte.Text = "FileName: " + System.IO.Path.GetFileName(FilePath);
                            }
                        }
                    }
                }

                using (var StreamReader = new StreamReader(FilePath, Encoding.Default))
                {
                    HeaderCsv = StreamReader.ReadLine();
                    StreamReader.Close();
                }

                using (var FileStream = new FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                {
                    FileStream.SetLength(0);
                    using (var StreamWriter = new StreamWriter(FileStream, Encoding.Default))
                    {
                        FormExport.progressBar.Maximum = ModelList.Articles.Count + 1;
                        FormExport.progressBar.Value   = 1;

                        StreamWriter.WriteLine(HeaderCsv);
                        foreach (var Article in ModelList.Articles)
                        {
                            StreamWriter.WriteLine(Article.Description + ";" + Article.RefArticle + ";" + Article.Marque.MarqueName
                                                   + ";" + FamilleController.FindFamillesByRefFamille(Article.SousFamille.RefFamille).FamilleName + ";" + Article.SousFamille.SousFamilleName + ";" + Article.PrixHT);
                            FormExport.progressBar.Value++;
                        }
                    }
                }

                string Message = ModelList.Articles.Count + " articles have been added!";

                MessageBox.Show(" Export success!\n" + Message, System.IO.Path.GetFileName(FilePath));
            }
            catch
            {
                MessageBox.Show("Please close the selected file!");
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// 获取指定城市推荐团购
        /// </summary>
        public override ModelList GetRecommend(int cityID)
        {
            string strSql = string.Format(@"SELECT TuanID,TG.SiteID,TS.SiteName,TS.SiteUrl,Title,TuanUrl,ImageUrl,ImageThumbUrl,MarketPrice,TuanPrice,Rebate,BuyCount,TG.Description,TG.CommentCount,PointCount,BeginTime,EndTime FROM
                (SELECT TOP 3 TuanID,SiteID,Title,TuanUrl,ImageUrl,ImageThumbUrl,CONVERT(DECIMAL(18,2),MarketPrice) MarketPrice,CONVERT(DECIMAL(18,2),TuanPrice) TuanPrice,CONVERT(DECIMAL(18,2),Rebate) Rebate,BuyCount,CommentCount,PointCount,BeginTime,EndTime,Description FROM TN_TuanGou WHERE CityID={0} ORDER BY Rank DESC) TG LEFT JOIN TN_TuanSite TS ON TG.SiteID=TS.SiteID", cityID);

            ModelList tuanList = SqlHelper.ExecuteList(CommandType.Text, strSql.ToString());

            return(tuanList);
        }
        /// <summary>
        /// Constructor which takes the parent list for a new item
        /// </summary>
        /// <param name="list">Parent list for an item</param>
        public ModifyItemChildWindow(ModelList list)
        {
            InitializeComponent();

            item    = ContextModel.Instance.GetNewItem(list);
            NewItem = true;

            this.Loaded += new RoutedEventHandler(ItemModifyChildWindow_Loaded);
        }
        public ModifyListChildWindow(DefaultScope.List scopeList)
        {
            InitializeComponent();

            list    = ContextModel.Instance.GetList(scopeList);
            NewList = true;

            this.Loaded += new RoutedEventHandler(NewListChildWindow_Loaded);
        }
Exemplo n.º 30
0
        public static Type GetModelType(string editorType)
        {
            var type = ModelList.Find(o => o.EditorType == editorType);

            if (type != null)
            {
                return(type.GetType());
            }
            return(null);
        }
Exemplo n.º 31
0
		/// <summary>
		/// Gets the templatize models.
		/// </summary>
		/// <returns>
		/// The templatize models.
		/// </returns>
		public ModelList<Model> getTemplatizeModels() {
			Assembly[] assemblies = this.getAssemblies();
			ModelList<Model> models = new ModelList<Model>();
			Model auxModel = new Model();
			Type[] modelType = new Type[1];
			modelType[0] = typeof(Model);
			
			for(int i = 0; i < assemblies.Length; i++) {
				Type[] types = assemblies[i].GetTypes();
				for(int j = 0; j < types.Length; j++) {
					//types[j].ba
					if(types[j].IsGenericType == false && this.isChildOf(types[j], typeof(Orm.Model))) {
					//if(types[j].GetNestedType("AltairStudios.Core.Orm.Model") != null) {
					//if(types[j].Namespace != null && (types[j].Namespace == "AltairStudios.Core.Orm.Models" || types[j].Namespace.EndsWith(".Model"))) {
						models.Add(auxModel.cast<Model>(Activator.CreateInstance(types[j])));
					}
				}
			}
			
			return models;
		}
 /// <summary>
 /// inicializacni metoda
 /// </summary>
 public override void Initialize()
 {
     models = ModelList.GetInstance();
     LoadContent();
     base.Initialize();
 }
Exemplo n.º 33
0
 public PlusPlayProcessor()
 {
     _modelList = new ModelList();
     workingDirectory = new DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings.Get("DirectoryPath"));
 }
Exemplo n.º 34
0
		/// <summary>
		/// Initializes a new instance of the <see cref="AltairStudios.Core.Orm.Models.Admin.Menu"/> class.
		/// </summary>
		public Menu() {
			this.submenus = new ModelList<Menu>();
		}
		/// <summary>
		/// Users the authentify.
		/// </summary>
		/// <returns>
		/// The authentify.
		/// </returns>
		/// <param name='user'>
		/// User.
		/// </param>
		protected virtual User userAuthentify(User user) {
			ModelList<User> users = new ModelList<User>();
			users = user.getBy<User>();
			
			if(users.Count > 0) {
				return users[0];
			} else {
				return null;
			}
		}
Exemplo n.º 36
0
 public void resetByModelList(ModelList ml, Panel parent)
 {
     isInit = true;
     resetUpDownBtn(parent);
     allItems.SelectedIndex = ml.AllItem;
     switch(ml.AllItem)
     {
         case 0:
             //文本
             if(ml.Items.Count != 1)
                 break;
             textSelected.Text = ml.Items[0];
             break;
         case 1:
             //扩展名
             if(ml.Items.Count != 2)
                 break;
             extension1Selected.Text = ml.Items[0];
             extension2Selected.IsChecked = (ml.Items[1] == "1");
             break;
         case 2:
             //当前文件名
             if(ml.Items.Count != 2)
                 break;
             nowName1Selected.SelectedIndex = Convert.ToInt32(ml.Items[0]);
             nowName2Selected.SelectedIndex = Convert.ToInt32(ml.Items[1]);
             break;
         case 3:
             //序列数字
             if(ml.Items.Count != 2)
                 break;
             orderNum1Selected.Text = ml.Items[0];
             orderNum2Selected.SelectedIndex = Convert.ToInt32(ml.Items[1]);
             break;
         case 4:
             //序列字母
             if(ml.Items.Count != 1)
                 break;
             orderLetterSelected.SelectedIndex = Convert.ToInt32(ml.Items[0]);
             break;
         case 5:
             //时间日期
             if(ml.Items.Count != 2)
                 break;
             time1Selected.SelectedIndex = Convert.ToInt32(ml.Items[0]);
             time2Selected.SelectedIndex = Convert.ToInt32(ml.Items[1]);
             break;
         case 6:
             //文件夹名称
             if(ml.Items.Count != 1)
                 break;
             folderNameSelected.SelectedIndex = Convert.ToInt32(ml.Items[0]);
             break;
         case 7:
             //字符串替换
             if(ml.Items.Count != 7)
                 break;
             replaceStr3Selected.IsChecked = (ml.Items[0] == "1");
             replaceStr4Selected.IsChecked = (ml.Items[1] == "1");
             searchString.Text = ml.Items[2];
             replaceString.Text = ml.Items[3];
             isIgnoreCase.IsChecked = (ml.Items[4] == "1");
             if(ml.Items[5] == "1")
                 renameBefore.IsChecked = true;
             else
                 renameAfter.IsChecked = true;
             useRegular.IsChecked = (ml.Items[6] == "1");
             break;
         default:
             return;
     }
     isInit = false;
     refreshRequestMethod(this);
 }
Exemplo n.º 37
0
		/// <summary>
		/// Sqls the create foreign basic table.
		/// </summary>
		/// <returns>
		/// The create foreign basic table.
		/// </returns>
		/// <param name='type1'>
		/// Type1.
		/// </param>
		/// <param name='type2'>
		/// Type2.
		/// </param>
		public string sqlCreateForeignBasicTable(Type type1, string basicName, Type type2) {
			StringBuilder sql = new StringBuilder();
			PropertyInfo[] properties1 = type1.GetProperties();
			ModelList<string> fields = new ModelList<string>();
			ModelList<string> keys = new ModelList<string>();
			
			for(int i = 0; i < properties1.Length; i++) {
				PrimaryKeyAttribute[] primaryKeys = (PrimaryKeyAttribute[])properties1[i].GetCustomAttributes(typeof(PrimaryKeyAttribute), true);
				
				if(primaryKeys.Length > 0) {
					string sqlType = this.convertTypeToSql(properties1[i].PropertyType);
					string name = this.sqlEscapeField(type1.Name + "_" + properties1[i].Name);
					
					fields.Add(name + " " + sqlType + " NOT NULL");
					keys.Add(name);
				}
			}
			
			string sqlBasicType = this.convertTypeToSql(type2);
			//basicName = this.sqlEscapeField(basicName);
					
			fields.Add(this.sqlEscapeField(basicName) + " " + sqlBasicType + " NOT NULL");
			
			
			if(keys.Count > 0) {
				fields.Add("KEY (" + string.Join(",", keys.ToArray()) + ")");
			}
			
			sql.Append("CREATE TABLE IF NOT EXISTS " + this.sqlEscapeTable(type1.Name + "_" + basicName) + " (");
			sql.Append(string.Join(",", fields.ToArray()));
			
			sql.Append(") ENGINE=InnoDB DEFAULT CHARSET=utf8");
			
			return sql.ToString();
		}
Exemplo n.º 38
0
		/// <summary>
		/// Sqls the create table.
		/// </summary>
		/// <returns>
		/// The create table.
		/// </returns>
		/// <param name='type'>
		/// Type.
		/// </param>
		public string sqlCreateTable(Type type) {
			StringBuilder sql = new StringBuilder();
			PropertyInfo[] properties = type.GetProperties();
			ModelList<string> sqlFields = new ModelList<string>();
			ModelList<string> primaryFields = new ModelList<string>();
			ModelList<string> indexFields = new ModelList<string>();
			ModelList<string> uniqueFields = new ModelList<string>();
			ModelList<string> foreignFields = new ModelList<string>();
			//ModelList<string> keys = new ModelList<string>();
			ModelList<string> createdModelsName = new ModelList<string>();
			
			sql.Append("CREATE TABLE IF NOT EXISTS " + this.sqlEscapeTable(type.Name) + " (");
			
			for(int i = 0; i < properties.Length; i++) {
				TemplatizeAttribute[] attributes = (TemplatizeAttribute[])properties[i].GetCustomAttributes(typeof(TemplatizeAttribute), true);
				PrimaryKeyAttribute[] primaryKeys = (PrimaryKeyAttribute[])properties[i].GetCustomAttributes(typeof(PrimaryKeyAttribute), true);
				IndexAttribute[] indexes = (IndexAttribute[])properties[i].GetCustomAttributes(typeof(IndexAttribute), true);
				//ForeignKeyAttribute[] foreigns = (ForeignKeyAttribute[])properties[i].GetCustomAttributes(typeof(ForeignKeyAttribute), true);
				
				if(primaryKeys.Length > 0) {
					primaryFields.Add(this.sqlEscapeField(properties[i].Name));
				} else if(indexes.Length > 0 && indexes[0].Unique) {
					uniqueFields.Add(this.sqlEscapeField(properties[i].Name));
				} else if(indexes.Length > 0) {
					indexFields.Add(this.sqlEscapeField(properties[i].Name));
				}
				
				if(attributes.Length > 0) {
					string sqlType = this.convertTypeToSql(properties[i].PropertyType);
					
					if(primaryKeys.Length > 0 && primaryKeys[0].AutoIncrement) {
						sqlFields.Add(this.sqlEscapeField(properties[i].Name) + " " + sqlType + " NOT NULL AUTO_INCREMENT");
					} else {
						if(properties[i].PropertyType.GetInterface("IModelizable") != null && !createdModelsName.Contains(properties[i].PropertyType.ToString())) {
							if(properties[i].PropertyType.GetInterface("IList") != null) {
								if(properties[i].PropertyType.GetGenericArguments()[0].GetInterface("IModelizable") != null) {
									foreignFields.Add(this.sqlCreateTable(properties[i].PropertyType.GetGenericArguments()[0]));
									foreignFields.Add(this.sqlCreateForeignTable(type, properties[i].PropertyType.GetGenericArguments()[0]));
								} else {
									foreignFields.Add(this.sqlCreateForeignBasicTable(type, properties[i].Name, properties[i].PropertyType.GetGenericArguments()[0]));
								}
							} else {
								foreignFields.Add(this.sqlCreateTable(properties[i].PropertyType));
								foreignFields.Add(this.sqlCreateForeignTable(type, properties[i].PropertyType));
							}
							
							createdModelsName.Add(properties[i].PropertyType.ToString());
						} else {
							sqlFields.Add(this.sqlEscapeField(properties[i].Name) + " " + sqlType + " NOT NULL");
						}
					}
				}
			}
			
			if(primaryFields.Count > 0) {
				sqlFields.Add("PRIMARY KEY (" + string.Join(",", primaryFields.ToArray()) + ")");
			}
			
			if(uniqueFields.Count > 0) {
				sqlFields.Add("UNIQUE KEY (" + string.Join(",", uniqueFields.ToArray()) + ")");
			}
			
			if(indexFields.Count > 0) {
				sqlFields.Add("KEY (" + string.Join(",", indexFields.ToArray()) + ")");
			}
			
			sql.Append(string.Join(",", sqlFields.ToArray()));
			
			sql.Append(") ENGINE=InnoDB DEFAULT CHARSET=utf8");
			
			if(foreignFields.Count > 0) {
				sql.Append(";" + string.Join(";", foreignFields.ToArray()));
			}
			
			return sql.ToString();
		}
Exemplo n.º 39
0
		/// <summary>
		/// Sqls the string.
		/// </summary>
		/// <returns>
		/// The string.
		/// </returns>
		/// <param name='model'>
		/// Model.
		/// </param>
		/// <param name='type'>
		/// Type.
		/// </param>
		/// <param name='fields'>
		/// Fields.
		/// </param>
		/// <param name='properties'>
		/// Properties.
		/// </param>
		public string sqlString(Model model, Type type, List<string> fields, PropertyInfo[] properties) {
			StringBuilder sql = new StringBuilder();
			ModelList<PropertyInfo> parameters = new ModelList<PropertyInfo>();
			
			for(int i = 0; i < fields.Count; i++) {
				fields[i] = this.sqlEscapeField(fields[i]);
			}
			
			sql.Append("SELECT " + string.Join(",", fields.ToArray()) + " FROM " + this.sqlEscapeTable(type.Name) + " WHERE ");
			
			for(int i = 0; i < properties.Length; i++) {
				if(properties[i].GetValue(model, null) != null) {					
					TemplatizeAttribute[] attributes = (TemplatizeAttribute[])properties[i].GetCustomAttributes(typeof(TemplatizeAttribute), true);
					if(attributes.Length > 0 && properties[i].PropertyType.GetInterface("IModelizable") == null) {
						sql.Append(this.sqlEscapeField(properties[i].Name) + " = @" + properties[i].Name + " AND " );
						parameters.Add(properties[i]);
					}
				}
			}
			
			sql.Append("1 = 1");
			
			return sql.ToString();
		}
Exemplo n.º 40
0
        public bool Initialize(SystemConfiguration configuration, IntPtr windowHandle)
        {
            try
            {
                // Create the Direct3D object.
                D3D = new DX11();
                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowHandle))
                {
                    MessageBox.Show("Could not initialize Direct3D", "Error", MessageBoxButtons.OK);
                    return false;
                }

                // Create the camera object
                Camera = new Camera();

                // Initialize a base view matrix the camera for 2D user interface rendering.
                Camera.SetPosition(0, 0, -1);
                Camera.Render();
                var baseViewMatrix = Camera.ViewMatrix;

                // Create the text object.
                Text = new Text();
                if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, baseViewMatrix))
                {
                    MessageBox.Show("Could not initialize the text object", "Error", MessageBoxButtons.OK);
                    return false;
                }

                // Create the model class.
                Model = new Model();

                // Initialize the model object.
                if (!Model.Initialize(D3D.Device, "sphere.txt", new[] { "stone01.dds", "light01.dds" }))
                {
                    MessageBox.Show("Could not initialize the model object", "Error", MessageBoxButtons.OK);
                    return false;
                }

                // Create the light shader object.
                LightMapShader = new LightMapShader();

                // Initialize the light shader object.
                if (!LightMapShader.Initialize(D3D.Device, windowHandle))
                {
                    MessageBox.Show("Could not initialize the light shader", "Error", MessageBoxButtons.OK);
                    return false;
                }

                // Create the light object.
                Light = new Light();

                // Initialize the light object.
                Light.SetAmbientColor(0.15f, 0.15f, 0.15f, 1.0f);
                Light.SetDiffuseColor(1, 0, 0, 1f);
                Light.SetDirection(1, 0, 1);
                Light.SetSpecularColor(0, 1, 1, 1);
                Light.SetSpecularPower(32);

                // Create the model list object.
                ModelList = new ModelList();

                // Initialize the model list object.
                if (!ModelList.Initialize(25))
                {
                    MessageBox.Show("Could not initialize the model list object", "Error", MessageBoxButtons.OK);
                    return false;
                }

                // Create the frustum object.
                Frustum = new Frustum();

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return false;
            }
        }
Exemplo n.º 41
0
		public string sqlInsert(Type type, ModelList<PropertyInfo> parameters) {
			StringBuilder sql = new StringBuilder();
			ModelList<string> sqlFields = new ModelList<string>();
			ModelList<string> sqlNames = new ModelList<string>();
			
			sql.Append("INSERT INTO " + this.sqlEscapeTable(type.Name));
			
			for(int i = 0; i < parameters.Count; i++) {
				TemplatizeAttribute[] attributes = (TemplatizeAttribute[])parameters[i].GetCustomAttributes(typeof(TemplatizeAttribute), true);
				PrimaryKeyAttribute[] primaryKeys = (PrimaryKeyAttribute[])parameters[i].GetCustomAttributes(typeof(PrimaryKeyAttribute), true);
				
				if((primaryKeys.Length > 0 && primaryKeys[0].AutoIncrement == false) || (primaryKeys.Length == 0 && attributes.Length > 0)) {
					if(parameters[i].PropertyType.GetInterface("IModelizable") == null) {
						sqlNames.Add(this.sqlEscapeField(parameters[i].Name));
						sqlFields.Add("@" + parameters[i].Name);
					}
				}
			}
			
			sql.Append("(" + string.Join(",", sqlNames.ToArray()) + ")");
			sql.Append(" VALUES ");
			sql.Append("(" + string.Join(",", sqlFields.ToArray()) + ")");
			
			sql.Append(";");
			
			sql.Append(this.getInsertedId());
			
			return sql.ToString();
		}
Exemplo n.º 42
0
		/// <summary>
		/// Gets the core plugins.
		/// </summary>
		/// <returns>
		/// The core plugins.
		/// </returns>
		public ModelList<PluginBase> getCorePlugins() {
			Assembly[] assemblies = this.getAssemblies();
			ModelList<PluginBase> plugins = new ModelList<PluginBase>();
			Model auxModel = new Model();
			
			for(int i = 0; i < assemblies.Length; i++) {
				Type[] types = assemblies[i].GetTypes();
				for(int j = 0; j < types.Length; j++) {
					if(types[j].Namespace != null && types[j].Namespace.Contains("Plugin.") && types[j].GetInterface("iPlugin") != null) {
						plugins.Add(auxModel.cast<PluginBase>(Activator.CreateInstance(types[j])));
					}
				}
			}
			
			return plugins;
		}
Exemplo n.º 43
0
		/// <summary>
		/// Sqls the update.
		/// </summary>
		/// <returns>
		/// The update.
		/// </returns>
		/// <param name='type'>
		/// Type.
		/// </param>
		public string sqlUpdate(Type type) {
			StringBuilder sql = new StringBuilder();
			PropertyInfo[] properties = type.GetProperties();
			ModelList<string> sqlFields = new ModelList<string>();
			ModelList<string> sqlNames = new ModelList<string>();
			ModelList<string> whereFields = new ModelList<string>();
			
			sql.Append("UPDATE " + this.sqlEscapeTable(type.Name));
			
			for(int i = 0; i < properties.Length; i++) {
				TemplatizeAttribute[] attributes = (TemplatizeAttribute[])properties[i].GetCustomAttributes(typeof(TemplatizeAttribute), true);
				PrimaryKeyAttribute[] primaryKeys = (PrimaryKeyAttribute[])properties[i].GetCustomAttributes(typeof(PrimaryKeyAttribute), true);
				
				if(attributes.Length > 0 && attributes[0].Templatize && primaryKeys.Length == 0 && properties[i].PropertyType.GetInterface("IModelizable") == null) {
					sqlNames.Add(properties[i].Name);
					sqlFields.Add(this.sqlEscapeField(properties[i].Name) + " = @" + properties[i].Name);
				} else if(primaryKeys.Length > 0 && properties[i].PropertyType.GetInterface("IModelizable") == null) {
					whereFields.Add(this.sqlEscapeField(properties[i].Name) + " = @" + properties[i].Name);
				}
			}
			
			sql.Append(" SET " + string.Join(",", sqlFields.ToArray()) + "");
			sql.Append(" WHERE ");
			sql.Append("(" + string.Join(",", whereFields.ToArray()) + ")");
			
			return sql.ToString();
		}
Exemplo n.º 44
0
 private void Validate_Claims(Binding binding, ModelList<ClaimsetType> claims, SoaModel model)
 {
     foreach (Endpoint endpoint in model.Instances.OfType<Endpoint>().Where(ep => ep.Binding == binding))
     {
         Authorization authorization = endpoint.Authorization;
         if (authorization != null)
         {
             foreach (OperationAuthorization operation in authorization.OperationAuthorizations)
             {
                 foreach (Reference reference in operation.References.Where(rf => rf.Object is ClaimsetType))
                 {
                     ClaimsetType claimset = (ClaimsetType)reference.Object;
                     if (!claims.Contains(claimset))
                     {
                         claims.Add(claimset);
                     }
                 }
                 foreach (Reference reference in operation.References.Where(rf => rf.Object is ClaimField))
                 {
                     ClaimsetType claimset = ((ClaimField)reference.Object).Claimset;
                     if (!claims.Contains(claimset))
                     {
                         claims.Add(claimset);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 45
0
        /// <summary>
        /// 将当前重命名项转化为xmlElement, 并添加到参数xml文档中
        /// </summary>
        /// <param name="root"></param>
        private void readCurrentML()
        {
            if(IsLoaded)
            {
                currentML = new ModelList();
                currentML.AllItem = allItems.SelectedIndex;

                switch(currentML.AllItem)
                {
                    case 0:
                        //文本
                        currentML.Items.Add(textSelected.Text);
                        break;
                    case 1:
                        //扩展名
                        currentML.Items.Add(extension1Selected.Text);
                        currentML.Items.Add(extension2Selected.IsChecked == true ? "1" : "0");
                        break;
                    case 2:
                        //当前文件名
                        currentML.Items.Add(nowName1Selected.SelectedIndex.ToString());
                        currentML.Items.Add(nowName2Selected.SelectedIndex.ToString());
                        break;
                    case 3:
                        //序列数字
                        currentML.Items.Add(orderNum1Selected.Text);
                        currentML.Items.Add(orderNum2Selected.SelectedIndex.ToString());
                        break;
                    case 4:
                        //序列字母
                        currentML.Items.Add(orderLetterSelected.SelectedIndex.ToString());
                        break;
                    case 5:
                        //时间日期
                        currentML.Items.Add(time1Selected.SelectedIndex.ToString());
                        currentML.Items.Add(time2Selected.SelectedIndex.ToString());
                        break;
                    case 6:
                        //文件夹名称
                        currentML.Items.Add(folderNameSelected.SelectedIndex.ToString());
                        break;
                    case 7:
                        //字符串替换
                        currentML.Items.Add(replaceStr3Selected.IsChecked == true ? "1" : "0");
                        currentML.Items.Add(replaceStr4Selected.IsChecked == true ? "1" : "0");
                        currentML.Items.Add(searchString.Text);
                        currentML.Items.Add(replaceString.Text);
                        currentML.Items.Add(isIgnoreCase.IsChecked == true ? "1" : "0");
                        currentML.Items.Add(renameBefore.IsChecked == true ? "1" : "0");
                        currentML.Items.Add(useRegular.IsChecked == true ? "1" : "0");
                        break;
                    default:
                        return;
                }
            }
            else
                currentML = null;
        }
Exemplo n.º 46
0
		/// <summary>
		/// Sqls the delete.
		/// </summary>
		/// <returns>
		/// The delete.
		/// </returns>
		/// <param name='type'>
		/// Type.
		/// </param>
		public string sqlDelete(Type type) {
			StringBuilder sql = new StringBuilder();
			PropertyInfo[] properties = type.GetProperties();
			ModelList<string> whereFields = new ModelList<string>();
			
			sql.Append("DELETE FROM " + this.sqlEscapeTable(type.Name));
			
			for(int i = 0; i < properties.Length; i++) {
				PrimaryKeyAttribute[] primaryKeys = (PrimaryKeyAttribute[])properties[i].GetCustomAttributes(typeof(PrimaryKeyAttribute), true);
				
				if(primaryKeys.Length > 0 && properties[i].PropertyType.GetInterface("IModelizable") == null) {
					whereFields.Add(this.sqlEscapeField(properties[i].Name) + " = @" + properties[i].Name);
				}
			}
			
			sql.Append(" WHERE ");
			sql.Append("(" + string.Join(",", whereFields.ToArray()) + ")");
			
			return sql.ToString();
		}
Exemplo n.º 47
0
		public string sqlInsertBasicForeign(Type type1, string basicName, Type type2) {
			StringBuilder sql = new StringBuilder();
			PropertyInfo[] properties1 = type1.GetProperties();
			PropertyInfo[] properties2 = type2.GetProperties();
			ModelList<string> fields = new ModelList<string>();
			ModelList<string> parameters = new ModelList<string>();
			string name = type1.Name + "_" + type2.Name;
			
			for(int i = 0; i < properties1.Length; i++) {
				PrimaryKeyAttribute[] primaryKeys = (PrimaryKeyAttribute[])properties1[i].GetCustomAttributes(typeof(PrimaryKeyAttribute), true);
				
				if(primaryKeys.Length > 0) {
					fields.Add(this.sqlEscapeField(type1.Name + "_" + properties1[i].Name));
					parameters.Add("@" + type1.Name + "_" + properties1[i].Name);
				}
			}
			
			fields.Add(this.sqlEscapeField(basicName));
			parameters.Add("@" + basicName);
			
			sql.Append("INSERT INTO " + this.sqlEscapeTable(name));
			sql.Append("(" + string.Join(",", fields.ToArray()) + ") VALUES (" + string.Join(",", parameters.ToArray()) + ")");
			
			return sql.ToString();
		}