void CreateItem() { UIAppendSuitItemInDesigner ui = new UIAppendSuitItemInDesigner(); ui.BulidInItems = _buildIn; string[] exists = new string[0]; foreach (SuitSchemePrinter.SchemeItem item in axSuitSchemeView1.SchemeItemParent.Items) { Array.Resize <string>(ref exists, exists.Length + 1); exists[exists.Length - 1] = item.Name; } ui.ExistsItems = exists; if (ui.ShowDialog(this) == DialogResult.OK) { string result = ui.ResultItems; Core.XmlExplorer xml = new XmlExplorer(); xml.XmlDoc.LoadXml(result); System.Xml.XmlNodeList nodes = xml.XmlDoc.GetElementsByTagName("item"); foreach (System.Xml.XmlNode node in nodes) { SchemeItem newItem = new SchemeItem(); newItem.Name = axSuitSchemeView1.GetUniqueName(node.Attributes["name"].Value); if (node.InnerText.Length > 0) { newItem.Expression = (char)34 + node.InnerText + (char )34; } axSuitSchemeView1.Add(newItem); axSuitSchemeView1.AxSchemeItemBringToFront(newItem.Name, true); } } }
public void Delete(SchemeItem model) { var target = Find(model.ID); db.Remove <SchemeItem>(target); db.Commit(); }
public ActionResult EditSchemeMedia(EditSchemeViewModel model) { ServiceResult result = new ServiceResult(); try { var startTime = Convert.ToDateTime(model.startTime); var entity = new SchemeItem() { ID = model.id, PeriodCode = model.periodCode, PeriodCount = model.periodCount, StartTime = startTime, Price = Convert.ToDecimal(model.price), EndTime = startTime.AddDays(model.periodCode * model.periodCount) }; SchemeItemService.Update(entity); } catch (Exception ex) { result.Message = "加入方案失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog(CookieHelper.MemberID + model.id + "加入方案失败", ex); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult ContainerItem(int idSchemeItem = 0, int idSchemeItemType = ModuleCore.CategoryType) { var schemeItem = new SchemeItem(idSchemeItem, idSchemeItemType); using (var db = this.CreateUnitOfWork()) { var fields = db.CustomFieldsFields.Where(x => x.IdModule == Module.ID && x.Block == 0).ToDictionary(x => x.IdField, x => x); var schemes = db.CustomFieldsSchemes. Where(x => x.IdModule == Module.ID && x.IdScheme > 0). OrderBy(x => x.NameScheme). ToDictionary(x => (uint)x.IdScheme, x => new Model.SchemeContainerItem.Scheme() { Name = x.NameScheme, Fields = new Dictionary <int, Field.IField>() }); schemes[0] = new Model.SchemeContainerItem.Scheme() { Name = "По-умолчанию", Fields = new Dictionary <int, Field.IField>() }; var sql = (from datas in db.CustomFieldsSchemeDatas where datas.IdModule == Module.ID && datas.IdItemType == schemeItem.IdItemType && datas.IdSchemeItem == schemeItem.IdItem group new { datas.IdField, datas.Order } by datas.IdScheme into gr select new { IdScheme = gr.Key, Fields = gr.OrderBy(x => x.Order).Select(x => x.IdField).ToList() }); var fieldsWithSchemes = sql. ToList(). ToDictionary(x => (uint)x.IdScheme, x => x.Fields.GroupBy(IdField => IdField). Select(group => fields.GetValueOrDefault(group.Key)). Where(field => field != null). ToDictionary(field => field.IdField, field => field as Field.IField) ); var model = new Model.SchemeContainerItem() { SchemeItem = schemeItem }; if (fieldsWithSchemes.ContainsKey(0)) { schemes[0].Fields = fieldsWithSchemes[0]; } foreach (var p in schemes) { model.Schemes[p.Key] = p.Value; if (fieldsWithSchemes.ContainsKey(p.Key)) { p.Value.Fields = fieldsWithSchemes[p.Key]; } int i = 0; p.Value.Fields = p.Value.Fields.Where(x => schemes[0].Fields.ContainsKey(x.Key)).ToDictionary(x => i++, x => x.Value); } return(Controller.display("ModuleExtensions/CustomFields/Design/Item.cshtml", model)); } }
public void SyncItemsToBase() { base.Items.Clear(); for (int i = 0; i < suitItems.Length; i++) { SchemeItemSerialization src = suitItems[i]; SchemeItem item = new SchemeItem(); src.Clone(item); base.Items.Add(item.Name, item); } }
public void Update(SchemeItem model) { var target = Find(model.ID); db.Attach <SchemeItem>(target); target.PeriodCode = model.PeriodCode; target.StartTime = model.StartTime; target.EndTime = model.EndTime; target.PeriodCount = model.PeriodCount; target.Price = model.Price; db.Commit(); }
void axSuitSchemeView1_SchemeItemMouseClick(object sender, MouseEventArgs e) { if (toolStripButton6.Tag is SchemeItem) { SchemeItem item = sender as SchemeItem; SchemeItem src = toolStripButton6.Tag as SchemeItem; item.ItemType = src.ItemType; src.Style.Clone(item.Style); axSuitSchemeView1.RedrawItems(new string[1] { item.Name }, false); } }
public override void OnClick() { ///读取配置方案到对象 /// m_pProject = new SchemeProjectClass(); //创建实例 m_pProject.Load(Application.StartupPath + "\\..\\Template\\DBSchema.mdb", e_FileType.GO_SCHEMEFILETYPE_MDB); //加载schema文件 ///创建数据库连接 OleDbConnection _con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + TopologyCheckClass.GeoDataCheckParaPath); //OleDbConnection _con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\..\\Res\\checker\\GeoCheckPara.mdb"); _con.Open(); if (m_pProject != null) { MyMap pmap = null; m_pProject.FindAttrValueFromTable("CODE", ref pmap); SchemeItem psi = null; int ItemCount = pmap.get_MapCount(); string CodeValue; string FCName; string CodeName; string geoType; string pDelSql = "delete from GeoCheckCode";//GeoCheckerDataClassify OleDbCommand DelSqlCommand = new OleDbCommand(pDelSql, _con); DelSqlCommand.ExecuteNonQuery(); for (int i = 0; i < ItemCount; i++) { psi = pmap.get_ItemByIndex(i) as SchemeItem; CodeName = psi.Name; FCName = psi.ExtAttributeList.get_AttributeByName("ATTRTABLENAME").Value as string; CodeValue = psi.ExtAttributeList.get_AttributeByName("CODE").Value as string; geoType = psi.ExtAttributeList.get_AttributeByName("GEOTYPE").Value as string; string pSql = "insert into GeoCheckCode(分类代码,类型,要素说明,图层) values('" + CodeValue + "','" + geoType + "','" + CodeName + "','" + FCName + "'" + ")"; OleDbCommand SqlCommand = new OleDbCommand(pSql, _con); SqlCommand.ExecuteNonQuery(); } } if (_con.State == System.Data.ConnectionState.Open) { _con.Close(); } }
public ActionResult AddScheme(AddSchemeViewModel model) { ServiceResult result = new ServiceResult(); try { SchemeItem entity = new SchemeItem(); entity.MediaID = model.id; entity.StartTime = Convert.ToDateTime(model.startTime); entity.EndTime = Convert.ToDateTime(model.endTime); entity.Price = Convert.ToDecimal(model.price); entity.PeriodCode = model.periodCode; entity.PeriodCount = model.periodCount; if (string.IsNullOrEmpty(model.Name) && model.schemeId != 0) { entity.SchemeID = model.schemeId; if (SchemeItemService.GetALL().Any(x => x.MediaID == model.id && x.SchemeID == model.schemeId)) { result.AddServiceError("该方案已经包含了此媒体"); result.Message = "该方案已经包含了此媒体!"; } } else { Scheme scheme = new Scheme() { AddTime = DateTime.Now, Name = model.Name, Description = model.Description, LastTime = DateTime.Now, MemberID = CookieHelper.MemberID }; SchemeService.Create(scheme); entity.SchemeID = scheme.ID; } if (result.Success) { SchemeItemService.Create(entity); result.Message = "加入方案成功!"; } } catch (Exception ex) { result.Message = "加入方案失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "加入方案失败!", ex); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public static bool Copy(SuitScheme dst, SuitScheme src) { if (src == null || dst == null) { return(false); } dst.BackgroundImage = src.BackgroundImage; dst.Size = src.Size; dst.Items.Clear(); foreach (SchemeItem item in src.Items) { SchemeItem dstItem = new SchemeItem(); item.Clone(dstItem); dst.Items.Add(dstItem.Name, dstItem); } return(true); }
public ActionResult ContainerItem(int?idModule = null, int idSchemeItem = 0, int idSchemeItemType = 0) { if (!idModule.HasValue) { throw new Exception("Не указан идентификатор модуля."); } var module = AppCore.GetModulesManager().GetModule(idModule.Value) as IModuleCore; if (module == null) { throw new Exception("Модуль не найден."); } var schemeItem = new SchemeItem(idSchemeItem, idSchemeItemType); using (var db = this.CreateUnitOfWork()) { var fields = db.CustomFieldsFields.Where(x => x.IdModule == idModule.Value && x.Block == 0).ToDictionary(x => x.IdField, x => x); var schemes = db.CustomFieldsSchemes. Where(x => x.IdModule == idModule.Value && x.IdScheme > 0). OrderBy(x => x.NameScheme). ToDictionary(x => (uint)x.IdScheme, x => new SchemeContainerItem.Scheme() { Name = x.NameScheme, Fields = new Dictionary <int, IField>() }); schemes[0] = new SchemeContainerItem.Scheme() { Name = "По-умолчанию", Fields = new Dictionary <int, IField>() }; var sql = (from datas in db.CustomFieldsSchemeDatas where datas.IdModule == idModule.Value && datas.IdItemType == schemeItem.IdItemType && datas.IdSchemeItem == schemeItem.IdItem group new { datas.IdField, datas.Order } by datas.IdScheme into gr select new { IdScheme = gr.Key, Fields = gr.OrderBy(x => x.Order).Select(x => x.IdField).ToList() }); var fieldsWithSchemes = sql. ToList(). ToDictionary(x => (uint)x.IdScheme, x => x.Fields.GroupBy(IdField => IdField). Select(group => fields.GetValueOrDefault(group.Key)). Where(field => field != null). ToDictionary(field => field.IdField, field => field as IField) ); var model = new SchemeContainerItem() { IdModule = idModule.Value, SchemeItem = schemeItem }; if (fieldsWithSchemes.ContainsKey(0)) { schemes[0].Fields = fieldsWithSchemes[0]; } foreach (var p in schemes) { model.Schemes[p.Key] = p.Value; if (fieldsWithSchemes.ContainsKey(p.Key)) { p.Value.Fields = fieldsWithSchemes[p.Key]; } int i = 0; p.Value.Fields = p.Value.Fields.Where(x => schemes[0].Fields.ContainsKey(x.Key)).ToDictionary(x => i++, x => x.Value); } return(View("Item.cshtml", model)); } }
public JsonResult ContainerItemSave(int?idModule = null, int idSchemeItem = 0, int idSchemeItemType = 0, Dictionary <string, int[]> model = null) { var result = JsonAnswer(); try { if (!idModule.HasValue) { throw new Exception("Не указан идентификатор модуля."); } var module = AppCore.GetModulesManager().GetModule(idModule.Value) as IModuleCore; if (module == null) { throw new Exception("Модуль не найден."); } var schemeItem = new SchemeItem(idSchemeItem, idSchemeItemType); using (var db = Module.CreateUnitOfWork()) using (var scope = db.CreateScope()) { db.CustomFieldsSchemeDatas.Where(x => x.IdModule == idModule.Value && x.IdSchemeItem == schemeItem.IdItem && x.IdItemType == schemeItem.IdItemType).Delete(); int k = 0; var modelPrepared = model != null?model.Where(x => int.TryParse(x.Key, out k)).ToDictionary(x => uint.Parse(x.Key), x => new List <int>(x.Value)) : null; if (modelPrepared != null) { if (!modelPrepared.ContainsKey(0)) { modelPrepared[0] = new List <int>(); } foreach (var key in modelPrepared.Keys.ToList()) { if (key == 0) { continue; } var list = modelPrepared[key].Where(x => modelPrepared[0].Contains(x)).ToList(); modelPrepared[key] = list; } foreach (var pair in modelPrepared) { int i = 0; foreach (var field in pair.Value) { db.CustomFieldsSchemeDatas.Add(new CustomFieldsSchemeData() { IdModule = idModule.Value, IdScheme = (int)pair.Key, IdField = field, IdSchemeItem = schemeItem.IdItem, IdItemType = schemeItem.IdItemType, Order = i++ }); } } db.SaveChanges(); } scope.Commit(); result.Message = "Сохранение расположения полей прошло успешно."; result.Success = true; } AppCore.Get <ModuleItemsCustomize <WebApplication> >().UpdateCache(); } catch (Exception ex) { result.Message = ex.Message; } return(ReturnJson(result)); }
void button_Click(object sender, EventArgs e) { switch (((ToolStripItem)sender).Text) { case "关闭": this.Close(); break; case "打开": //OpenExist(); break; case "保存": Core.ToolTip tip = new UnvaryingSagacity.Core.ToolTip(); tip.ShowPrompt(this, "正在保存票证设计......"); this.Cursor = Cursors.WaitCursor; BeforeSave(); Core.XmlSerializer <SchemeSerialization> .ToXmlSerializer(CurrentEnvironment.AccountCoverFilename, CurrentScheme); tip.Hide(); this.Cursor = Cursors.Default; break; case "更换底图": //Image image = _environment.ShowImageCollectionDialog(this, this._environment.MainUIClientBounds); //if (image != null) //{ // CurrentScheme.BackgroundImage = image; // axSuitSchemeView1.SchemeItemParent.BackgroundImage = image; // axSuitSchemeView1.RedrawSchemeBackgroundImage(); //} break; case "新增": CreateItem(); break; case "手绘模式": if (((ToolStripButton)sender).Checked) { axSuitSchemeView1.HandleDrawMode = true; axSuitSchemeView1.Cursor = Cursors.Cross; toolStrip2.Enabled = false; } else { axSuitSchemeView1.HandleDrawMode = false; axSuitSchemeView1.Cursor = Cursors.Default; toolStrip2.Enabled = true; } break; case "复制": SuitSchemeItemCollection items = new SuitSchemeItemCollection(); axSuitSchemeView1.SelectedItems(items); if (items.Count > 1) { SchemeSerialization scheme = new SchemeSerialization(); foreach (SchemeItem item in items) { SchemeItemSerialization dst = new SchemeItemSerialization(); item.Clone(dst); scheme.Items.Add(dst); } scheme.SyncItemsFromBase(); System.IO.MemoryStream m = new System.IO.MemoryStream(); Core.XmlSerializer <SchemeSerialization> .ToXmlSerializer(m, scheme); Core.XmlSerializer <SchemeSerialization> .ToXmlSerializer(@"C:\aaa.txt", scheme); byte[] readByte = m.ToArray(); string readString = Encoding.UTF8.GetString(readByte, 0, readByte.Length); Clipboard.SetText("SchemeItems:" + readString, TextDataFormat.UnicodeText); } else { if (axSuitSchemeView1.ActivedSchemeItem != null) { SchemeItemSerialization dst = new SchemeItemSerialization(); axSuitSchemeView1.ActivedSchemeItem.Clone(dst); System.IO.MemoryStream m = new System.IO.MemoryStream(); Core.XmlSerializer <SchemeItemSerialization> .ToXmlSerializer(m, dst); //Core.XmlSerializer<SchemeItemSerialization>.ToXmlSerializer(@"C:\aaa.txt", dst); byte[] readByte = m.ToArray(); string readString = Encoding.UTF8.GetString(readByte, 0, readByte.Length); Clipboard.SetText("SchemeItem:" + readString, TextDataFormat.UnicodeText); } } break; case "粘贴": string s = Clipboard.GetText(TextDataFormat.UnicodeText); if (s.IndexOf("SchemeItem:") == 0) { s = s.Substring("SchemeItem:".Length); byte[] b = Encoding.Unicode.GetBytes(s); System.IO.MemoryStream m = new System.IO.MemoryStream(b, 0, b.Length); SchemeItemSerialization o = new SchemeItemSerialization(); if (Core.XmlSerializer <SchemeItemSerialization> .FromXmlSerializer(m, out o)) { SchemeItem item = new SchemeItem(); o.Copy(item); item.Name = axSuitSchemeView1.GetUniqueName(o.Name); axSuitSchemeView1.Add(item); axSuitSchemeView1.AxSchemeItemBringToFront(item.Name, true); } } else if (s.IndexOf("SchemeItems:") == 0) { s = s.Substring("SchemeItems:".Length); byte[] b = Encoding.Unicode.GetBytes(s); System.IO.MemoryStream m = new System.IO.MemoryStream(b, 0, b.Length); SchemeSerialization dstItems = new SchemeSerialization(); if (Core.XmlSerializer <SchemeSerialization> .FromXmlSerializer(m, out dstItems)) { dstItems.SyncItemsToBase(); foreach (SchemeItem o in dstItems.Items) { SchemeItem item = new SchemeItem(); o.Copy(item); item.Name = axSuitSchemeView1.GetUniqueName(o.Name); axSuitSchemeView1.Add(item); axSuitSchemeView1.AxSchemeItemBringToFront(item.Name, true); } } } break; case "删除": if (MessageBox.Show(this, "您确定要删除选中的打印项吗?", "删除打印项", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Delete(); } break; case "锁定": Locked(); break; case "解锁": UnLocked(); break; case "打印": break; case "打印设置": BeforeSave(); CurrentEnvironment.ShowPrintSettingsDialog(this, CurrentScheme); break; case "有票样图的预览": break; case "预览": BeforeSave(); SetVisualValue(CurrentScheme); CurrentEnvironment.PrintScheme(this, CurrentScheme, true, false, false); break; case "移动...": break; case "格式刷": axSuitSchemeView1.Cursor = Cursors.Default; if (this.toolStripButton6.Checked) { this.toolStripButton6.Tag = null; this.toolStripButton6.Checked = false; } else { if (axSuitSchemeView1.ActivedSchemeItem != null) { SchemeItem formatItem = new SchemeItem(); axSuitSchemeView1.ActivedSchemeItem.Clone(formatItem); this.toolStripButton6.Tag = formatItem; this.toolStripButton6.Checked = true; axSuitSchemeView1.Cursor = Cursors.Hand; } } break; case "使大小相同": SameSize(0); break; case "使高度相同": SameSize(2); break; case "使宽度相同": SameSize(1); break; case "底对齐": SameLocation(5); break; case "垂直中间对齐": SameLocation(6); break; case "顶对齐": SameLocation(4); break; case "右对齐": SameLocation(2); break; case "水平中间对齐": SameLocation(3); break; case "左对齐": SameLocation(1); break; case "全选": axSuitSchemeView1.SelectAll(); break; case "使用底图尺寸": if (CurrentScheme.BackgroundImage != null) { float w = (CurrentScheme.BackgroundImage.Width / (AxSuitSchemeView.MMTOINCH * CurrentScheme.DpiX)); float h = (CurrentScheme.BackgroundImage.Height / (AxSuitSchemeView.MMTOINCH * CurrentScheme.DpiY)); Size imageSize = new Size((int)Math.Round(w, 0), (int)(Math.Round(h, 0))); CurrentScheme.Size = imageSize; axSuitSchemeView1.SchemeItemParent.Size = CurrentScheme.Size; axSuitSchemeView1.RedrawSchemeBackgroundImage(); } break; case "封面尺寸": Core.InputBox input = new InputBox("输入封面尺寸", "请准确输入封面的宽和高并用逗号(或非数字字符)分隔\n注意单位是毫米", 7, CurrentScheme.Size.Width + "," + CurrentScheme.Size.Height); if (input.ShowDialog(this) == DialogResult.OK) { string sz = input.Result.ToString(); if (sz.Length < 0) { return; } if (sz == CurrentScheme.Size.Width + "," + CurrentScheme.Size.Height) { return; } int w = 0; int h = 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i < sz.Length; i++) { string c = sz.Substring(i, 1); if (Core.General.IsNumberic(c, false, false)) { sb.Append(c); } else { if (sb.Length > 0 && w == 0) { w = int.Parse(sb.ToString()); sb.Remove(0, sb.Length); } } } if (sb.Length > 0 && h == 0) { h = int.Parse(sb.ToString()); } if (w > 0 && h > 0) { if (MessageBox.Show(this, "您确定新的票证尺寸为: " + w + "," + h + " 毫米吗?", "票证尺寸", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { CurrentScheme.Size = new Size(w, h); axSuitSchemeView1.SchemeItemParent.Size = new Size(w, h); axSuitSchemeView1.RedrawSchemeBackgroundImage(); } } } break; case "清除水平间距": ChangSpaceH(0); break; case "增加水平间距": ChangSpaceH(1); break; case "减少水平间距": ChangSpaceH(-1); break; case "清除垂直间距": ChangSpaceV(0); break; case "增加垂直间距": ChangSpaceV(1); break; case "减少垂直间距": ChangSpaceV(-1); break; default: break; } }
public static string GetEqualityKey(SchemeItem schemeItem) { return(schemeItem == null ? null : schemeItem.IdItemType.ToString() + "_" + schemeItem.IdItem.ToString()); }
public void Create(SchemeItem model) { db.Add <SchemeItem>(model); db.Commit(); }
public JsonResult ContainerItemSave(int idSchemeItem = 0, int idSchemeItemType = 0, Dictionary <string, int[]> model = null) { var result = Controller.JsonAnswer(); try { var schemeItem = new SchemeItem(idSchemeItem, idSchemeItemType); using (var db = this.CreateUnitOfWork()) using (var scope = db.CreateScope()) { db.CustomFieldsSchemeDatas.Where(x => x.IdModule == this.Module.ID && x.IdSchemeItem == schemeItem.IdItem && x.IdItemType == schemeItem.IdItemType).Delete(); int k = 0; var modelPrepared = model != null?model.Where(x => int.TryParse(x.Key, out k)).ToDictionary(x => uint.Parse(x.Key), x => new List <int>(x.Value)) : null; if (modelPrepared != null) { if (!modelPrepared.ContainsKey(0)) { modelPrepared[0] = new List <int>(); } foreach (var key in modelPrepared.Keys.ToList()) { if (key == 0) { continue; } var list = modelPrepared[key].Where(x => modelPrepared[0].Contains(x)).ToList(); modelPrepared[key] = list; } foreach (var pair in modelPrepared) { int i = 0; foreach (var field in pair.Value) { db.CustomFieldsSchemeDatas.Add(new CustomFieldsSchemeData() { IdModule = this.Module.ID, IdScheme = (int)pair.Key, IdField = field, IdSchemeItem = schemeItem.IdItem, IdItemType = schemeItem.IdItemType, Order = i++ }); } } db.SaveChanges(); } scope.Commit(); result.Message = "Сохранение расположения полей прошло успешно."; result.Success = true; } UpdateCache(); } catch (Exception ex) { result.Message = ex.Message; } return(Controller.ReturnJson(result)); }
public DefaultScheme this[SchemeItem schemeItem] { get => this[SchemeItem.GetEqualityKey(schemeItem)]; }