protected void Page_Load(object sender, EventArgs e) { MembershipUser currentUser = Membership.GetUser(); AccountClass objAccountClass; objAccountClass = new AccountClass(objSqlConnClass.sqlConnection); BackofficeClass objBackOfficeClass; objBackOfficeClass = new BackofficeClass(objSqlConnClass.OpenConnection()); DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(currentUser.UserName); if (DS != null) { if (DS.Tables[0].Rows.Count > 0) { if (DS.Tables[0].Rows[0]["ROLENAME"].ToString().Equals("User")) { string strTemp = DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString(); if (DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString().Equals(string.Empty) || DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString() != "6") Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep1.aspx?id=" + AppLib.Encrypt(currentUser.UserName), true); } } } DS = null; objTemplateClass = new TemplateClass(objSqlConnClass.OpenConnection()); }
//MultiLayerLineSymbol private void button8_Click(object sender, EventArgs e) { IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass(); ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot; simpleLineSymbol.Width = 10; IRgbColor rgbColor = getRGB(255, 0, 0); simpleLineSymbol.Color = rgbColor; ISymbol symbol = simpleLineSymbol as ISymbol; symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt; cartographicLineSymbol.Join = esriLineJoinStyle.esriLJSBevel; cartographicLineSymbol.Width = 10; cartographicLineSymbol.MiterLimit = 4; ILineProperties lineProperties; lineProperties = cartographicLineSymbol as ILineProperties; lineProperties.Offset = 0; double[] dob = new double[6]; dob[0] = 0; dob[1] = 1; dob[2] = 2; dob[3] = 3; dob[4] = 4; dob[5] = 5; ITemplate template = new TemplateClass(); template.Interval = 1; for (int i = 0; i < dob.Length; i += 2) { template.AddPatternElement(dob[i], dob[i + 1]); } lineProperties.Template = template; IPolyline polyline = new PolylineClass(); IPoint point = new PointClass(); point.PutCoords(1, 1); polyline.FromPoint = point; point.PutCoords(10, 10); polyline.ToPoint = point; rgbColor = getRGB(0, 255, 0); cartographicLineSymbol.Color = rgbColor; multiLayerLineSymbol.AddLayer(simpleLineSymbol); multiLayerLineSymbol.AddLayer(cartographicLineSymbol); IActiveView activeView = this.axMapControl1.ActiveView; activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); activeView.ScreenDisplay.SetSymbol(multiLayerLineSymbol as ISymbol); activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry); activeView.ScreenDisplay.FinishDrawing(); activeView.ScreenDisplay.FinishDrawing(); }
public void Run() { var templateClass = new TemplateClass(); templateClass.Dispose(); templateClass.Dispose(); }
public ActionResult TemplateClass() { TemplateClass model = new TemplateClass(); model.Property = ""; return(View(model)); }
/// <summary> /// Executed when there is progress reported from BackgroundWorker Logic. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void Generate_ProgressChanged(object sender, ProgressChangedEventArgs e) { var worker = (BackgroundWorker)sender; //if (worker.CancellationPending) { } else if (e.UserState is Exception) { var ex = (Exception)e.UserState; // Delete Template Class File TemplateClass.Delete(); // Log Error LogManager.LogError(ex); // Raise OnException event GeneratorManager.RaiseEvent <GeneratorOnExceptionEventArgs>(new GeneratorOnExceptionEventArgs(ex)); } else if (e.UserState is GeneratorOnProgressEventArgs) { var eventArgs = (GeneratorOnProgressEventArgs)e.UserState; // Raise OnProgress event GeneratorManager.RaiseEvent <GeneratorOnProgressEventArgs>(eventArgs); } else if (e.UserState is GeneratorOnCompleteEventArgs) { var eventArgs = (GeneratorOnCompleteEventArgs)e.UserState; // Raise OnComplete event GeneratorManager.RaiseEvent <GeneratorOnCompleteEventArgs>(eventArgs); } }
public ActionResult ReceivesPost(string property) { TemplateClass model = new TemplateClass(); model.Property = property; return(View(model)); }
private ISymbol CreateBikeRouteSymbol() { IColor color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 90, 250)); ICharacterMarkerSymbol charMarkerSymbol = new CharacterMarkerSymbolClass(); charMarkerSymbol.Color = color; charMarkerSymbol.Font = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToStdFont(new Font("ESRI Default Marker", 17.0f, FontStyle.Bold)); charMarkerSymbol.CharacterIndex = 189; charMarkerSymbol.Size = 17; IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbolClass(); markerLineSymbol.Color = color; markerLineSymbol.Width = 17.0; markerLineSymbol.MarkerSymbol = (IMarkerSymbol)charMarkerSymbol; // Makes a new Cartographic Line symbol and sets its properties ICartographicLineSymbol cartographicLineSymbol = markerLineSymbol as ICartographicLineSymbol; // In order to set additional properties like offsets and dash patterns we must create an ILineProperties object ILineProperties lineProperties = cartographicLineSymbol as ILineProperties; lineProperties.Offset = 0; // Here's how to do a template for the pattern of marks and gaps double[] hpe = new double[4]; hpe[0] = 0; hpe[1] = 39; hpe[2] = 1; hpe[3] = 0; ITemplate template = new TemplateClass(); template.Interval = 1; for (int i = 0; i < hpe.Length; i = i + 2) { template.AddPatternElement(hpe[i], hpe[i + 1]); } lineProperties.Template = template; // Set the basic and cartographic line properties cartographicLineSymbol.Color = color; color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 220, 100)); // create a simple line ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = color; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 1.2; IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass(); multiLayerLineSymbol.AddLayer((ILineSymbol)cartographicLineSymbol); multiLayerLineSymbol.AddLayer((ILineSymbol)simpleLineSymbol); return(multiLayerLineSymbol as ISymbol); }
/// <summary> /// serialize a templace class in a file /// </summary> /// <param name="filename">the path of the file</param> /// <param name="tc">the template class to serialize</param> public static void SerializeTemplateClass(string filename, TemplateClass tc) { Stream stream = File.Open(filename, FileMode.Create); BinaryFormatter bFormatter = new BinaryFormatter(); bFormatter.Serialize(stream, tc); stream.Close(); }
protected void btnSave_Click(object sender, EventArgs e) { TemplateClass.GetTemplate = txtTemplate.Text.Trim(); TemplateClass.GetLeaveTypeID = Convert.ToInt32(ddLeaveType.SelectedValue); TemplateClass.InsertTemplate(); FillTemplate(); ClearAll(); btnSave.Visible = true; btnUpdate.Visible = false; }
protected void Delete_Click(object sender, ImageClickEventArgs e) { ImageButton delete = (ImageButton)sender; TemplateClass.GetTemplateID = Convert.ToInt32(delete.CommandArgument); TemplateClass.DeleteTemplate(); FillTemplate(); ClearAll(); btnSave.Visible = true; btnUpdate.Visible = false; }
static void Main(string[] args) { // This is allowed (where T : ClassB) var templateClassInstance = new TemplateClass <ClassB>(); // This is also allowed (ClassC is successor of ClassB) var templateClassInstance2 = new TemplateClass <ClassC>(); // This is invalid: // var templateClassInstance3 = new TemplateClass<ClassA>(); // 'ClassA' cannot be used as type parameter 'T' // There is no implicit reference conversion from 'ClassA' to 'ClassB'. // These are allowed (where T : IClassable) var templateClassConstrainedByInterface = new TemplateClassConstrainedByInterface <ClassA>(new ClassA()); var templateClassConstrainedByInterface2 = new TemplateClassConstrainedByInterface <ClassB>(new ClassB()); var templateClassConstrainedByInterface3 = new TemplateClassConstrainedByInterface <StructureA>(new StructureA()); // This is allowed (where T : class) var templateClassConstrainedByReference = new TemplateClassConstrainedByReference <ClassA, ClassB>(); // This is allowed (where T : class) var templateClassConstrainedByReference2 = new TemplateClassConstrainedByReference <ClassA, ClassA>(); // This is invalid //// var templateClassConstrainedByReference2 = //// new TemplateClassConstrainedByReference<ClassB, ClassA>(); // 'ClassA' cannot be used as type parameter 'T2' in the generic type or method 'TemplateClassConstrainedByReference<T,T2>'. // There is no implicit reference conversion from 'ClassA' to 'ClassB'. // This is also invalid //// var templateClassConstrainedByReference3 = //// new TemplateClassConstrainedByReference<StructureA, StructureA>(); // 'StructureA' must be a reference type in order to use it as parameter 'T' // in the generic type or method 'TemplateClassConstrainedByReference<T,T2>' // This is allowed (where T : new()) var templateClassConstrainedByEmptyConstructor = new TemplateClassConstrainedByEmptyConstructor <ClassA>(); // This is invalid //// var templateClassConstrainedByEmptyConstructor2 = //// new TemplateClassConstrainedByEmptyConstructor<ClassC>(); // 'ClassC' must be a non-abstract type with a public parameterless constructor // in order to use it as parameter 'T' in the generic type or method 'TemplateClassConstrainedByEmptyConstructor<T>' }
/// <summary> /// Checks if there is a worker cancellation pending. /// </summary> /// <returns></returns> public static bool CheckCancellationPending() { if (_worker != null && _worker.CancellationPending) { // Wait for worker signal _resetEvent.Set(); // Delete Template Class File TemplateClass.Delete(); return(true); } return(false); }
public static void Main() { // This is allowed (where T : ClassB) var templateClassInstance = new TemplateClass<ClassB>(); // This is also allowed (ClassC is successor of ClassB) var templateClassInstance2 = new TemplateClass<ClassC>(); // This is invalid: //// var templateClassInstance3 = new TemplateClass<ClassA>(); // 'ClassA' cannot be used as type parameter 'T' // There is no implicit reference conversion from 'ClassA' to 'ClassB'. // These are allowed (where T : IClassable) var templateClassConstrainedByInterface = new TemplateClassConstrainedByInterface<ClassA>(); var templateClassConstrainedByInterface2 = new TemplateClassConstrainedByInterface<ClassB>(); var templateClassConstrainedByInterface3 = new TemplateClassConstrainedByInterface<StructureA>(); // This is allowed (where T : class) var templateClassConstrainedByReference = new TemplateClassConstrainedByReference<ClassA, ClassB>(); // This is invalid //// var templateClassConstrainedByReference2 = //// new TemplateClassConstrainedByReference<ClassB, ClassA>(); // 'ClassA' cannot be used as type parameter 'T2' in the generic type or method 'TemplateClassConstrainedByReference<T,T2>'. // There is no implicit reference conversion from 'ClassA' to 'ClassB'. // This is also invalid //// var templateClassConstrainedByReference3 = //// new TemplateClassConstrainedByReference<StructureA, StructureA>(); // 'StructureA' must be a reference type in order to use it as parameter 'T' // in the generic type or method 'TemplateClassConstrainedByReference<T,T2>' // This is allowed (where T : new()) var templateClassConstrainedByEmptyConstructor = new TemplateClassConstrainedByEmptyConstructor<ClassA>(); // This is invalid //// var templateClassConstrainedByEmptyConstructor2 = //// new TemplateClassConstrainedByEmptyConstructor<ClassC>(); // 'ClassC' must be a non-abstract type with a public parameterless constructor // in order to use it as parameter 'T' in the generic type or method 'TemplateClassConstrainedByEmptyConstructor<T>' }
public TemplateProductionTypeForm(bool isDialog) { this.InitializeComponent(); this.Is_Dialog = isDialog; this.DocClass = new TemplateClass(this.ds, TemplateType.ProductionType, false); this.LoadFromBase(); this.FormClosing += new FormClosing(this.TemplateForm_FormClosing); this.Shown += new Shown(this.TemplateForm_Shown); this.gridViewTemplate.DoubleClick += new EventHandler(this.gridViewTemplate_DoubleClick); this.gridViewTemplateParam.FocusedRowChanged += new FocusedRowChangedEventHandler(this.gridViewTemplateParam_FocusedRowChanged); this.gridViewTemplateParam.GotFocus += new EventHandler(this.gridViewTemplateParam_GotFocus); this.treeListTemplateGroup.FocusedNodeChanged += new FocusedNodeChangedEventHandler(this.treeListTemplateGroup_FocusedNodeChanged); this.MenuGroupSetMain.Click += new EventHandler(this.MenuGroupSetMain_Click); this.MenuGroupMoveToGroup.Click += new EventHandler(this.MenuGroupMoveToGroup_Click); this.atButtonsPanel1.Print = new atButtonsPanel.PrintDelegate(this.RefreshParameters); this.ApplyGrants(); }
private void ReadTemplate(EventArgs e) { this.TemplatelistView.ForeColor = SystemColors.WindowText; ITemplate template = new TemplateClass { Interval = this.m_LineProperties.Template.Interval }; double mark = 0.0; double gap = 0.0; try { double num3 = 0.0; for (int i = 0; i < this.TemplatelistView.Items.Count; i += 2) { mark = Convert.ToDouble(this.TemplatelistView.Items[i].SubItems[1].Text); gap = Convert.ToDouble(this.TemplatelistView.Items[i + 1].SubItems[1].Text); if ((mark < 0.0) || (gap < 0.0)) { MessageBox.Show("实步长或虚步长不能为负数!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); this.TemplatelistView.ForeColor = Color.Red; return; } mark /= this.m_unit; gap /= this.m_unit; num3 = (num3 + mark) + gap; template.AddPatternElement(mark, gap); } if (num3 == 0.0) { MessageBox.Show("模板总长不能为0!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); this.TemplatelistView.ForeColor = Color.Red; } else { this.m_LineProperties.Template = template; this.refresh(e); } } catch (Exception) { MessageBox.Show("数据类型错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); this.TemplatelistView.ForeColor = Color.Red; } }
public ReturnValue locateTemplate(string url, int u_webFAid) { ReturnValue info = new ReturnValue(); Uri _url = new Uri(url); //Regex r = new Regex(@"(?<=/)((.[^/]*)_((\d){1,5}))(." + BaseConfig.extension + ")", RegexOptions.IgnoreCase); //string newUrl = r.Replace(url.AbsolutePath.ToLower(), new MatchEvaluator(_replaceUrl)); bool isMobilePage = false; string virtualWebDir = ""; string newUrl = WebService.urlZhuanyi(new Uri(url), ref isMobilePage, ref virtualWebDir); TemplateInfo v = TemplateClass.get(newUrl, isMobilePage); //ColumnInfo column = null; double moduleId = 0, classId = 0; if (v == null) { info.errNo = -1; info.errMsg = "定位失败"; } else { if (v.classId > 0) { object value = Sql.ExecuteScalar("select id from module where id=@id", new MySqlParameter[] { new MySqlParameter("id", v.classId) }); if (value == null) { IDataReader rs = Sql.ExecuteReader("select id,moduleId from class where id=@id", new MySqlParameter[] { new MySqlParameter("id", v.classId) }); if (rs.Read()) { classId = v.classId; moduleId = rs.GetDouble(1); } rs.Close(); } else { moduleId = (double)value; classId = 1; } } object[] obj = new object[] { moduleId, classId, v.u_type, v.id, isMobilePage ? 1 : 0 }; info.userData = obj; } return(info); }
//HashLineSymbol private void button9_Click(object sender, EventArgs e) { IHashLineSymbol hashLineSymbol = new HashLineSymbolClass(); ILineProperties lineProperties = hashLineSymbol as ILineProperties; lineProperties.Offset = 0; double[] dob = new double[6]; dob[0] = 0; dob[1] = 1; dob[2] = 2; dob[3] = 3; dob[4] = 4; dob[5] = 5; ITemplate template = new TemplateClass(); template.Interval = 1; for (int i = 0; i < dob.Length; i += 2) { template.AddPatternElement(dob[i], dob[i + 1]); } lineProperties.Template = template; hashLineSymbol.Width = 2; hashLineSymbol.Angle = 45; IRgbColor hashColor = new RgbColor(); hashColor = getRGB(0, 0, 255); hashLineSymbol.Color = hashColor; IPolyline polyline = new PolylineClass(); IPoint point = new PointClass(); point.PutCoords(1, 1); polyline.FromPoint = point; point.PutCoords(10, 10); polyline.ToPoint = point; IActiveView activeView = this.axMapControl1.ActiveView; activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); activeView.ScreenDisplay.SetSymbol(hashLineSymbol as ISymbol); activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry); activeView.ScreenDisplay.FinishDrawing(); activeView.ScreenDisplay.FinishDrawing(); }
public async Task OutputRedisHelperAsync(string filename) { var engine = new RazorLightEngineBuilder() .DisableEncoding() .UseFileSystemProject(Directory.GetCurrentDirectory()) .UseMemoryCachingProvider() .Build(); var model = new TemplateClass(methods.Select(_method => _method.ToMethod()).ToList()); #region Build Interface var result = await engine.CompileRenderAsync("Template/Helper.cshtml", model); using (var writeStream = File.OpenWrite(filename)) { using (var streamWrite = new StreamWriter(writeStream, Encoding.UTF8)) await streamWrite.WriteLineAsync(result); } #endregion }
protected void Page_Load(object sender, EventArgs e) { objPALClass = new PALClass(objSqlConnClass.OpenConnection()); gsUserID = Membership.GetUser().ProviderUserKey.ToString(); MembershipUser currentUser = Membership.GetUser(); if (!AppLib.IsLoggedinSessionExists() || currentUser == null) Response.Redirect(AppConfig.GetBaseSiteUrl() + "Welcome/main_frame.aspx", true); AccountClass objAccountClass; objAccountClass = new AccountClass(objSqlConnClass.sqlConnection); BackofficeClass objBackOfficeClass; objBackOfficeClass = new BackofficeClass(objSqlConnClass.OpenConnection()); #region Insert visited log details AppLib.InsertVisitedSectionDetails("Dashboard Page"); #endregion DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(currentUser.UserName); if (DS != null) { if (DS.Tables[0].Rows.Count > 0) { if (DS.Tables[0].Rows[0]["ROLENAME"].ToString().Equals("User")) { if (DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString().Equals(string.Empty) || DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString() != "6") { DS = null; Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep1.aspx?id=" + AppLib.Encrypt(currentUser.UserName), true); } } } } BindNutritionalJournal(); DS = null; objTemplateClass = new TemplateClass(objSqlConnClass.OpenConnection()); }
private ISymbol CreateBikeRouteSymbol() { IColor color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 90, 250)); ICharacterMarkerSymbol charMarkerSymbol = new CharacterMarkerSymbolClass(); charMarkerSymbol.Color = color; charMarkerSymbol.Font = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToStdFont(new Font("ESRI Default Marker", 17.0f, FontStyle.Bold)); charMarkerSymbol.CharacterIndex = 189; charMarkerSymbol.Size = 17; IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbolClass(); markerLineSymbol.Color = color; markerLineSymbol.Width = 17.0; markerLineSymbol.MarkerSymbol = (IMarkerSymbol)charMarkerSymbol; // Makes a new Cartographic Line symbol and sets its properties ICartographicLineSymbol cartographicLineSymbol = markerLineSymbol as ICartographicLineSymbol; // In order to set additional properties like offsets and dash patterns we must create an ILineProperties object ILineProperties lineProperties = cartographicLineSymbol as ILineProperties; lineProperties.Offset = 0; // Here's how to do a template for the pattern of marks and gaps double[] hpe = new double[4]; hpe[0] = 0; hpe[1] = 39; hpe[2] = 1; hpe[3] = 0; ITemplate template = new TemplateClass(); template.Interval = 1; for (int i = 0; i < hpe.Length; i = i + 2) { template.AddPatternElement(hpe[i], hpe[i + 1]); } lineProperties.Template = template; // Set the basic and cartographic line properties cartographicLineSymbol.Color = color; color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 220, 100)); // create a simple line ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = color; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 1.2; IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass(); multiLayerLineSymbol.AddLayer((ILineSymbol)cartographicLineSymbol); multiLayerLineSymbol.AddLayer((ILineSymbol)simpleLineSymbol); return multiLayerLineSymbol as ISymbol; }
///////////////////////////////////// public NewObjectSettingsScene() { // default select first template. Template = GetTemplates().FirstOrDefault(); }
/// <summary> /// compare a template and all the templates in a templateClass /// </summary> /// <param name="tc">the template class</param> /// <param name="sample">the template to test</param> /// <returns>a template description of the template found</returns> internal static FoundTemplateDesc CompareTemplates(TemplateClass tc, Template sample) { //int maxInterCorrelationShift = (int)(templateSize * maxRotateAngle / Math.PI); //maxInterCorrelationShift = Math.Min(templateSize, maxInterCorrelationShift+13); double rate = 0; double angle = 0; Complex interCorr = default(Complex); Template foundTemplate = null; foreach (var template in tc.templates) { // if (Math.Abs(sample.autoCorrDescriptor1 - template.autoCorrDescriptor1) > maxACFDescriptorDeviation) { continue; } if (Math.Abs(sample.autoCorrDescriptor2 - template.autoCorrDescriptor2) > maxACFDescriptorDeviation) { continue; } if (Math.Abs(sample.autoCorrDescriptor3 - template.autoCorrDescriptor3) > maxACFDescriptorDeviation) { continue; } if (Math.Abs(sample.autoCorrDescriptor4 - template.autoCorrDescriptor4) > maxACFDescriptorDeviation) { continue; } // double r = 0; if (checkACF) { r = template.autoCorr.NormDot(sample.autoCorr).Norm; if (r < minACF) { continue; } } if (checkICF) { interCorr = template.contour.InterCorrelation(sample.contour).FindMaxNorm(); r = interCorr.Norm / (template.contourNorma * sample.contourNorma); if (r < minICF) { continue; } if (Math.Abs(interCorr.Angle) > maxRotateAngle) { continue; } } if (template.preferredAngleNoMore90 && Math.Abs(interCorr.Angle) >= Math.PI / 2) { continue;//unsuitable angle } //find max rate if (r >= rate) { rate = r; foundTemplate = template; angle = interCorr.Angle; } } //ignore antipatterns if (foundTemplate != null && foundTemplate.name == antiPatternName) { foundTemplate = null; } // if (foundTemplate != null) { return new FoundTemplateDesc() { template = foundTemplate, rate = rate, sample = sample, angle = angle, name = tc.name } } ; else { return(null); } }
/// <summary> /// Generates the DTOs of the EDMX Document provided using the parameters received. /// </summary> /// <param name="parameters">Parameters for the generation of DTOs.</param> /// <param name="worker">BackgroundWorker reference.</param> public static List <DTOEntity> GenerateDTOs(GenerateDTOsParams parameters, BackgroundWorker worker) { LogManager.LogMethodStart(); if (parameters.DTOsServiceReady) { VisualStudioHelper.AddReferenceToProject(parameters.TargetProject, Resources.AssemblySystemRuntimeSerialization, Resources.AssemblySystemRuntimeSerialization); } if (GeneratorManager.CheckCancellationPending()) { return(null); } EditPoint objEditPoint; // EditPoint to reuse CodeParameter objCodeParameter; // CodeParameter to reuse CodeNamespace objNamespace = null; // Namespace item to add Classes ProjectItem sourceFileItem = null; // Source File Item to save int dtosGenerated = 0; List <EnumType> enums = DTOGenerator.GetEnumTypes(parameters); PropertyHelper.SetEnumTypes(enums); List <DTOEntity> entitiesDTOs = DTOGenerator.GetEntityDTOs(parameters); if (GeneratorManager.CheckCancellationPending()) { return(null); } worker.ReportProgress(0, new GeneratorOnProgressEventArgs(0, string.Format(Resources.Text_DTOsGenerated, dtosGenerated, entitiesDTOs.Count))); TemplateClass.CreateFile(); // Imports to add to the Source File var importList = new List <SourceCodeImport>(); // EnumTypes defined in the EDMX ? if (enums.Exists(e => e.IsExternal == false)) { importList.Add(new SourceCodeImport(parameters.EntitiesNamespace)); VisualStudioHelper.AddReferenceToProject(parameters.TargetProject, parameters.EDMXProject); } // Include imports of external enums. foreach (string externalEnumNamespace in enums.Where(e => e.IsExternal).Select(e => e.Namespace).Distinct()) { importList.Add(new SourceCodeImport(externalEnumNamespace)); } // Generate Source File if type is One Source File if (parameters.SourceFileGenerationType == SourceFileGenerationType.OneSourceFile) { sourceFileItem = null; // Generate Source and Get the Namespace item objNamespace = VisualStudioHelper.GenerateSourceAndGetNamespace( parameters.TargetProject, parameters.TargetProjectFolder, parameters.SourceFileName, parameters.SourceFileHeaderComment, parameters.SourceNamespace, parameters.DTOsServiceReady, out sourceFileItem); // Add Imports to Source File VisualStudioHelper.AddImportsToSourceCode(ref sourceFileItem, importList); } // Check Cancellation Pending if (GeneratorManager.CheckCancellationPending()) { return(null); } // Loop through Entities DTOs foreach (DTOEntity entityDTO in entitiesDTOs) { // Generate Source File if type is Source File per Class if (parameters.SourceFileGenerationType == SourceFileGenerationType.SourceFilePerClass) { sourceFileItem = null; // Generate Source and Get the Namespace item objNamespace = VisualStudioHelper.GenerateSourceAndGetNamespace( parameters.TargetProject, parameters.TargetProjectFolder, entityDTO.NameDTO, parameters.SourceFileHeaderComment, parameters.SourceNamespace, parameters.DTOsServiceReady, out sourceFileItem); // Add Imports to Source File VisualStudioHelper.AddImportsToSourceCode(ref sourceFileItem, importList); } // Add Class CodeClass objCodeClass = objNamespace.AddClassWithPartialSupport(entityDTO.NameDTO, entityDTO.NameBaseDTO, entityDTO.DTOClassAccess, entityDTO.DTOClassKind); // Set IsAbstract objCodeClass.IsAbstract = entityDTO.IsAbstract; // Set Class Attributes foreach (DTOAttribute classAttr in entityDTO.Attributes) { objCodeClass.AddAttribute(classAttr.Name, classAttr.Parameters, AppConstants.PLACE_AT_THE_END); } // Set Class Properties foreach (DTOClassProperty entityProperty in entityDTO.Properties) { // Add Property CodeProperty objCodeProperty = objCodeClass.AddProperty(entityProperty.PropertyName, entityProperty.PropertyName, entityProperty.PropertyType, AppConstants.PLACE_AT_THE_END, entityProperty.PropertyAccess, null); // Get end of accessors auto-generated code objEditPoint = objCodeProperty.Setter.EndPoint.CreateEditPoint(); objEditPoint.LineDown(); objEditPoint.EndOfLine(); var getSetEndPoint = objEditPoint.CreateEditPoint(); // Move to the start of accessors auto-generated code objEditPoint = objCodeProperty.Getter.StartPoint.CreateEditPoint(); objEditPoint.LineUp(); objEditPoint.LineUp(); objEditPoint.EndOfLine(); // Replace accessors auto-generated code with a more cleaner one objEditPoint.ReplaceText(getSetEndPoint, Resources.CSharpCodeGetSetWithBrackets, Convert.ToInt32(vsEPReplaceTextOptions.vsEPReplaceTextAutoformat)); // Set Property Attributes foreach (DTOAttribute propAttr in entityProperty.PropertyAttributes) { objCodeProperty.AddAttribute(propAttr.Name, propAttr.Parameters, AppConstants.PLACE_AT_THE_END); } objEditPoint = objCodeProperty.StartPoint.CreateEditPoint(); objEditPoint.SmartFormat(objEditPoint); } if (parameters.GenerateDTOConstructors) { // Add empty Constructor CodeFunction emptyConstructor = objCodeClass.AddFunction(objCodeClass.Name, vsCMFunction.vsCMFunctionConstructor, null, AppConstants.PLACE_AT_THE_END, vsCMAccess.vsCMAccessPublic, null); // Does this DTO have a Base Class ? if (entityDTO.BaseDTO != null) { // Add call to empty Base Constructor objEditPoint = emptyConstructor.StartPoint.CreateEditPoint(); objEditPoint.EndOfLine(); objEditPoint.Insert(Resources.Space + Resources.CSharpCodeBaseConstructor); } // Does this DTO have properties ? if (entityDTO.Properties.Count > 0) { // Add Constructor with all properties as parameters CodeFunction constructorWithParams = objCodeClass.AddFunction(objCodeClass.Name, vsCMFunction.vsCMFunctionConstructor, null, AppConstants.PLACE_AT_THE_END, vsCMAccess.vsCMAccessPublic, null); foreach (DTOClassProperty entityProperty in entityDTO.Properties) { // Add Constructor parameter objCodeParameter = constructorWithParams.AddParameter( Utils.SetFirstLetterLowercase(entityProperty.PropertyName), entityProperty.PropertyType, AppConstants.PLACE_AT_THE_END); // Add assignment objEditPoint = constructorWithParams.EndPoint.CreateEditPoint(); objEditPoint.LineUp(); objEditPoint.EndOfLine(); objEditPoint.Insert(Environment.NewLine + AppConstants.TAB + AppConstants.TAB + AppConstants.TAB); objEditPoint.Insert(string.Format(Resources.CSharpCodeAssignmentThis, entityProperty.PropertyName, objCodeParameter.Name)); } // Does this DTO have a Base Class ? if (entityDTO.BaseDTO != null) { // Get the Base Class properties (includes the properties of the base recursively) List <DTOClassProperty> baseProperties = DTOGenerator.GetPropertiesForConstructor(entityDTO.BaseDTO); // Base Constructor parameters var sbBaseParameters = new StringBuilder(); foreach (DTOClassProperty entityProperty in baseProperties) { // Add Constructor parameter objCodeParameter = constructorWithParams.AddParameter( Utils.SetFirstLetterLowercase(entityProperty.PropertyName), entityProperty.PropertyType, AppConstants.PLACE_AT_THE_END); // Add parameter separation if other parameters exists if (sbBaseParameters.Length > 0) { sbBaseParameters.Append(Resources.CommaSpace); } // Add to Base Constructor parameters sbBaseParameters.Append(objCodeParameter.Name); } // Add call to Base Constructor with parameters objEditPoint = constructorWithParams.StartPoint.CreateEditPoint(); objEditPoint.EndOfLine(); objEditPoint.Insert( Environment.NewLine + AppConstants.TAB + AppConstants.TAB + AppConstants.TAB); objEditPoint.Insert( string.Format(Resources.CSharpCodeBaseConstructorWithParams, sbBaseParameters.ToString())); } // END if DTO has a Base Class } // END if DTO has properties } // END if Generate DTO Constructor methods // Save changes to Source File Item sourceFileItem.Save(); // Count DTO generated dtosGenerated++; // Report Progress int progress = ((dtosGenerated * 100) / entitiesDTOs.Count); if (progress < 100) { worker.ReportProgress(progress, new GeneratorOnProgressEventArgs(progress, string.Format(Resources.Text_DTOsGenerated, dtosGenerated, entitiesDTOs.Count))); } // Check Cancellation Pending if (GeneratorManager.CheckCancellationPending()) { return(null); } } // END Loop through Entities DTOs // Save Target Project parameters.TargetProject.Save(); // Delete Template Class File TemplateClass.Delete(); // Report Progress worker.ReportProgress(100, new GeneratorOnProgressEventArgs(100, string.Format(Resources.Text_DTOsGenerated, dtosGenerated, entitiesDTOs.Count))); LogManager.LogMethodEnd(); // Return the DTOs generated return(entitiesDTOs); }
/// <summary> /// 根据全名和路径构造对象 /// </summary> /// <param name="PluginPath">插件链接库文件路径</param> /// <param name="DynamicLoad">在内存中动态热加载</param> /// <returns></returns> public static IEnumerable <TemplateClass> CreatePluginInstance(string PluginPath, bool DynamicLoad = true) { Debug.Print("开始创建实例 {0}...", DynamicLoad ? "(动态模式) " : string.Empty); //List<TemplateClass> PluginInstanceList = new List<TemplateClass>(); Assembly AssemblyObject = null; try { if (!DynamicLoad) { // 从链接库文件路径加载 AssemblyObject = Assembly.LoadFrom(PluginPath); } else { // 把链接库文件读入内存后从内存加载,允许程序在运行时更新链接库 using (FileStream PluginStream = new FileStream(PluginPath, FileMode.Open, FileAccess.Read)) { using (BinaryReader PluginReader = new BinaryReader(PluginStream)) { byte[] PluginBuffer = PluginReader.ReadBytes((int)PluginStream.Length); AssemblyObject = Assembly.Load(PluginBuffer); PluginReader.Close(); } PluginStream.Close(); } } } catch (Exception ex) { Debug.Print("创建程序集遇到异常:{0}", ex.Message); throw ex; } if (AssemblyObject == null) { throw new Exception("无法加载链接库文件 : " + PluginPath); } foreach (Type PluginType in AssemblyObject.GetTypes()) { Debug.Print("发现类型 : {0}", PluginType.FullName); // 仅加载TemplateClass类型派生的子类 if (!PluginType.IsSubclassOf(typeof(TemplateClass))) { continue; } Debug.Print(">>> 可加载的插件类型 : {0}", PluginType.FullName); //创建并添加可加载类型的实例 TemplateClass PluginInstance = null; try { PluginInstance = AssemblyObject.CreateInstance(PluginType.FullName) as TemplateClass; //PluginInstanceList.Add(PluginInstance); } catch (Exception ex) { Debug.Print("创建 {0} 类型实例遇到异常 : {1}", PluginType.FullName, ex.Message); continue; } yield return(PluginInstance); } //return PluginInstanceList; }
private void btnChangeY_Click(object sender, EventArgs e) { maploaded = true; System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; if ((cboBotYear.Text != "") && (cboTopYear.Text != "")) { label3.Text = cboTopYear.Text; label4.Text = cboBotYear.Text; if (!(topPublicMosaicLayer == null)) { //Delete old top layer, ??check still the same top to save time? m_MapControl.ActiveView.FocusMap.DeleteLayer((ILayer)topPublicMosaicLayer); m_MapControltop.ActiveView.FocusMap.DeleteLayer((ILayer)topPublicMosaicLayer); } if (!(botPublicMosaicLayer == null)) { //Delete old bot layer, ??check still the same bot to save time? m_MapControl.ActiveView.FocusMap.DeleteLayer((ILayer)botPublicMosaicLayer); m_MapControlbase.ActiveView.FocusMap.DeleteLayer((ILayer)botPublicMosaicLayer); } //This version, we will use mosaicdataset======================== IMosaicWorkspaceExtensionHelper MosaicWsHelper = new MosaicWorkspaceExtensionHelperClass(); IWorkspaceFactory2 workspaceFactory = new FileGDBWorkspaceFactoryClass(); string mosaicdatabase = ConfigurationManager.AppSettings["MosaicDatabase"]; IWorkspace ws = workspaceFactory.OpenFromFile(mosaicdatabase, 0); IMosaicWorkspaceExtension mosaicWsExtension = MosaicWsHelper.FindExtension(ws); //BOT strBaseYr = "AmherstOrthoMosaic" + cboBotYear.Text; IMosaicDataset pMosaicDatasetBot = mosaicWsExtension.OpenMosaicDataset(strBaseYr); botPublicMosaicLayer = new MosaicLayerClass(); botPublicMosaicLayer.CreateFromMosaicDataset(pMosaicDatasetBot); if (!(botPublicMosaicLayer == null)) { IFeatureLayer footprint = (IFeatureLayer)botPublicMosaicLayer.FootprintLayer; ((ILayer)footprint).Visible = false; ILayer botLayer = (ILayer)botPublicMosaicLayer; botLayer.MinimumScale = 6000; m_MapControl.ActiveView.FocusMap.AddLayer(botLayer); m_MapControlbase.ActiveView.FocusMap.AddLayer(botLayer); } //TOP strTopYr = "AmherstOrthoMosaic" + cboTopYear.Text; IMosaicDataset pMosaicDatasetTop = mosaicWsExtension.OpenMosaicDataset(strTopYr); topPublicMosaicLayer = new MosaicLayerClass(); topPublicMosaicLayer.CreateFromMosaicDataset(pMosaicDatasetTop); if (!(topPublicMosaicLayer == null)) { IFeatureLayer footprint = (IFeatureLayer)topPublicMosaicLayer.FootprintLayer; ((ILayer)footprint).Visible = false; ILayer topLayer = (ILayer)topPublicMosaicLayer; topLayer.MinimumScale = 6000; m_MapControl.ActiveView.FocusMap.AddLayer(topLayer); m_MapControltop.ActiveView.FocusMap.AddLayer(topLayer); ILayerEffectProperties lepSwip = m_CommandsEnvironment as ILayerEffectProperties; lepSwip.SwipeLayer = topLayer; //===possible problem toplayer is not public variable any more } IFeatureLayer featurelayerParcel = new FeatureLayerClass(); featurelayerParcel.FeatureClass = featureClassParcels; featurelayerParcel.Name = "parcels"; featurelayerParcel.MinimumScale = 6000; featurelayerParcel.Visible = false; IRgbColor pLColor = new RgbColorClass(); pLColor.Red = 255; pLColor.Green = 255; pLColor.Blue = 255; ISimpleFillSymbol pSFS = new SimpleFillSymbolClass(); ICartographicLineSymbol pCLineS = new CartographicLineSymbolClass(); pCLineS.Color = pLColor; ILineProperties lineProperties = pCLineS as ILineProperties; lineProperties.Offset = 0; System.Double[] hpe = new System.Double[4]; hpe[0] = 7; hpe[1] = 2; hpe[2] = 1; hpe[3] = 2; ITemplate template = new TemplateClass(); template.Interval = 3; for (int i = 0; i < hpe.Length; i = i + 2) { template.AddPatternElement(hpe[i], hpe[i + 1]); } lineProperties.Template = template; pCLineS.Width = 1; pCLineS.Cap = esriLineCapStyle.esriLCSButt; pCLineS.Join = esriLineJoinStyle.esriLJSBevel; pCLineS.Color = pLColor; pSFS.Outline = pCLineS; pSFS.Style = esriSimpleFillStyle.esriSFSHollow; IGeoFeatureLayer pGFL = (IGeoFeatureLayer)featurelayerParcel; ISimpleRenderer pRend = pGFL.Renderer as ISimpleRenderer; pRend.Symbol = pSFS as ISymbol; if ((Helper.FindMyFeatureLayer(m_MapControl.ActiveView.FocusMap, "parcels") == null)) { if (!(featurelayerParcel == null)) { m_MapControl.ActiveView.FocusMap.AddLayer(featurelayerParcel); m_MapControltop.ActiveView.FocusMap.AddLayer(featurelayerParcel); m_MapControlbase.ActiveView.FocusMap.AddLayer(featurelayerParcel); } } else { //is this temp necessary??????? IFeatureLayer parcellayertemp = Helper.FindMyFeatureLayer(m_MapControl.ActiveView.FocusMap, "parcels"); m_MapControl.ActiveView.FocusMap.MoveLayer(parcellayertemp, 0); m_MapControltop.ActiveView.FocusMap.MoveLayer(parcellayertemp, 0); m_MapControlbase.ActiveView.FocusMap.MoveLayer(parcellayertemp, 0); } //MessageBox.Show("Top aerophoto is taken on: " + cboTopYear.Text + ".\r\nBottom areophoto is taken on: " + cboBotYear.Text + "."); } else { MessageBox.Show("Please select two years to compare"); } GeneratePageLayout(); System.Windows.Forms.Cursor.Current = Cursors.Default; }
protected void Page_Load(object sender, EventArgs e) { objPALClass = new PALClass(objSqlConnClass.OpenConnection()); gsUserID = Membership.GetUser().ProviderUserKey.ToString(); MembershipUser currentUser = Membership.GetUser(); if (!AppLib.IsLoggedinSessionExists() || currentUser == null) Response.Redirect(AppConfig.GetBaseSiteUrl() + "Welcome/main_frame.aspx", true); AccountClass objAccountClass; objAccountClass = new AccountClass(objSqlConnClass.sqlConnection); BackofficeClass objBackOfficeClass; objBackOfficeClass = new BackofficeClass(objSqlConnClass.OpenConnection()); #region Insert visited log details AppLib.InsertVisitedSectionDetails("Dashboard Page"); #endregion DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(currentUser.UserName); if (DS != null) { if (DS.Tables[0].Rows.Count > 0) { if (DS.Tables[0].Rows[0]["ROLENAME"].ToString().Equals("User")) { if (DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString().Equals(string.Empty) || DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString() != "6") { DS = null; Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep1.aspx?id=" + AppLib.Encrypt(currentUser.UserName), true); } } } } BindNutritionalJournal(); DS = null; objTemplateClass = new TemplateClass(objSqlConnClass.OpenConnection()); int ileftMargin = 0; string sTriangleImg = "triangle1.jpg"; int iMET = 0; string sLastWorkout = ""; DataSet entries = objPALClass.PAL_GET_PalEntries_BY_UserId(gsUserID, "", ""); foreach (DataRow DR in entries.Tables[0].Rows) { iMET += Convert.ToInt32(DR["MET_EQUIVALENT"]); sLastWorkout = DR["PAL_ENTRY_DATE"].ToString(); } labelLastWorkout.Text = sLastWorkout; iMET = 100; // 0 if (iMET <= 0) { ileftMargin = 7; sTriangleImg = "triangle1.jpg"; } // 1 else if (iMET <= 100) { ileftMargin = 32; sTriangleImg = "triangle1.jpg"; } // 2 else if (iMET <= 200) { ileftMargin = 52; sTriangleImg = "triangle2.jpg"; } // 3 else if (iMET <= 300) { ileftMargin = 72; sTriangleImg = "triangle3.jpg"; } // 4 else if (iMET <= 400) { ileftMargin = 92; sTriangleImg = "triangle4.jpg"; } // 5 else if (iMET <= 500) { ileftMargin = 112; sTriangleImg = "triangle5.jpg"; } // 6 else if (iMET <= 600) { ileftMargin = 132; sTriangleImg = "triangle6.jpg"; } // 7 else if (iMET <= 700) { ileftMargin = 152; sTriangleImg = "triangle7.jpg"; } // 8 else if (iMET <= 800) { ileftMargin = 172; sTriangleImg = "triangle8.jpg"; } // 9 else if (iMET <= 900) { ileftMargin = 192; sTriangleImg = "triangle9.jpg"; } // 10 else if (iMET > 900) { ileftMargin = 212; sTriangleImg = "triangle10.jpg"; } literalTriangle.Text = "<img style='margin-left:20px;' src='" + AppConfig.GetBaseSiteUrl() + "Images/dashboard/" + sTriangleImg + "' />"; literalMetsMarker.Text = "<div style='width:30px;margin-left:" + ileftMargin.ToString() + "px;margin-top:-7px;font-weight:bold;font-size:larger;font-color:Black;text-align:center;line-height:80%'>▲<br />" + iMET.ToString() + "</div>"; getActivitiesData(); }
/// <summary> /// Generates Assemblers for DTOs generated using the parameters received. /// </summary> /// <param name="parameters">Parameters for the generation of Assemblers.</param> /// <param name="worker">BackgroundWorker reference.</param> public static void GenerateAssemblers(GenerateAssemblersParams parameters, BackgroundWorker worker) { LogManager.LogMethodStart(); // Variables EditPoint objEditPoint; // EditPoint to reuse CodeNamespace objNamespace = null; // Namespace item to add Classes ProjectItem sourceFileItem = null; // Source File Item to save int assemblersGenerated = 0; // Report Progress worker.ReportProgress(0, new GeneratorOnProgressEventArgs(0, string.Format(Resources.Text_AssemblersGenerated, assemblersGenerated, parameters.EntitiesDTOs.Count))); // Add Reference to System.Core VisualStudioHelper.AddReferenceToProject(parameters.TargetProject, Resources.AssemblySystemCore, Resources.AssemblySystemCore); // Add Reference to System.Data.Entity VisualStudioHelper.AddReferenceToProject(parameters.TargetProject, Resources.AssemblySystemDataEntity, Resources.AssemblySystemDataEntity); if (parameters.IsServiceReady) { // Add Reference to System.Runtime.Serialization VisualStudioHelper.AddReferenceToProject(parameters.TargetProject, Resources.AssemblySystemRuntimeSerialization, Resources.AssemblySystemRuntimeSerialization); } if (parameters.TargetProject.UniqueName != parameters.EDMXProject.UniqueName) { // Add Reference to EDMX Project VisualStudioHelper.AddReferenceToProject(parameters.TargetProject, parameters.EDMXProject); } if (parameters.TargetProject.UniqueName != parameters.DTOsTargetProject.UniqueName) { // Add Reference to DTOs Project VisualStudioHelper.AddReferenceToProject(parameters.TargetProject, parameters.DTOsTargetProject); } // Check Cancellation Pending if (GeneratorManager.CheckCancellationPending()) { return; } // Create Template Class File TemplateClass.CreateFile(); // Imports to add to the Source File var importList = new List <SourceCodeImport>(); importList.Add(new SourceCodeImport(Resources.AssemblySystemLinq)); if (parameters.SourceNamespace != parameters.DTOsNamespace) { // Add import of DTOs namespace importList.Add(new SourceCodeImport(parameters.DTOsNamespace)); } if (parameters.SourceNamespace != parameters.EntitiesNamespace) { // Add import of Entities namespace importList.Add(new SourceCodeImport(parameters.EntitiesNamespace)); } // Generate Source File if type is One Source File if (parameters.SourceFileGenerationType == SourceFileGenerationType.OneSourceFile) { sourceFileItem = null; // Generate Source and Get the Namespace item objNamespace = VisualStudioHelper.GenerateSourceAndGetNamespace( parameters.TargetProject, parameters.TargetProjectFolder, parameters.SourceFileName, parameters.SourceFileHeaderComment, parameters.SourceNamespace, parameters.IsServiceReady, out sourceFileItem); // Add import of System.Data.Objects.DataClasses (necessary for AssemblerBase) importList.Add(new SourceCodeImport(Resources.AssemblySystemDataObjectsDataClasses)); // Add Imports to Source File VisualStudioHelper.AddImportsToSourceCode(ref sourceFileItem, importList); } // Check Cancellation Pending if (GeneratorManager.CheckCancellationPending()) { return; } // Set Assembler for all DTOs foreach (DTOEntity dto in parameters.EntitiesDTOs) { dto.SetAssembler(parameters); } // Check Cancellation Pending if (GeneratorManager.CheckCancellationPending()) { return; } // Loop through Entities DTOs foreach (DTOEntity dto in parameters.EntitiesDTOs) { if (dto.IsAbstract == true && (dto.DTOChilds == null || dto.DTOChilds.Count == 0)) { // DTO is abstract and does not have childs // Get the source file name if it is one source file generation type string sourceFileName = null; if (parameters.SourceFileGenerationType == SourceFileGenerationType.OneSourceFile) { sourceFileName = sourceFileItem.Name; } // Add warning VisualStudioHelper.AddToErrorList(TaskErrorCategory.Warning, string.Format(Resources.Warning_AbstractWithoutChildsAssembler, dto.Name), parameters.TargetProject, sourceFileName, null, null); } else { // Generate Source File if type is Source File per Class if (parameters.SourceFileGenerationType == SourceFileGenerationType.SourceFilePerClass) { sourceFileItem = null; // Generate Source and Get the Namespace item objNamespace = VisualStudioHelper.GenerateSourceAndGetNamespace( parameters.TargetProject, parameters.TargetProjectFolder, dto.Assembler.Name, parameters.SourceFileHeaderComment, parameters.SourceNamespace, parameters.IsServiceReady, out sourceFileItem); // Add Imports to Source File VisualStudioHelper.AddImportsToSourceCode(ref sourceFileItem, importList); } // Instance creation code variables var toDTOInstanceCode = string.Empty; var toEntityInstanceCode = string.Empty; #region Generate instance creation code if (dto.DTOChilds != null && dto.DTOChilds.Count > 0) { bool firstIfStatement = true; // Add null assignment for DTO instance code toDTOInstanceCode += string.Format(Resources.AssemblerToDTOInstanceNull, dto.NameDTO); toDTOInstanceCode += Environment.NewLine + Environment.NewLine; // Add null assignment for Entity instance code toEntityInstanceCode += string.Format(Resources.AssemblerToEntityInstanceNull, dto.Name); toEntityInstanceCode += Environment.NewLine + Environment.NewLine; // Loop DTO Child classes foreach (DTOEntity dtoChild in dto.DTOChilds) { // Set if statement checking if the entity is of this type, if it is then invoke DTO Assembler ToDTO method if (firstIfStatement) { firstIfStatement = false; toDTOInstanceCode += string.Format(Resources.AssemblerToDTOInstanceIfChild, dtoChild.Name); toEntityInstanceCode += string.Format(Resources.AssemblerToEntityInstanceIfChild, dtoChild.NameDTO); } else { toDTOInstanceCode += Environment.NewLine; toDTOInstanceCode += string.Format(Resources.AssemblerToDTOInstanceElseIfChild, dtoChild.Name); toEntityInstanceCode += Environment.NewLine; toEntityInstanceCode += string.Format(Resources.AssemblerToEntityInstanceElseIfChild, dtoChild.NameDTO); } toDTOInstanceCode += Environment.NewLine; toDTOInstanceCode += string.Format(Resources.AssemblerToDTOInstanceChild, dtoChild.Name); toEntityInstanceCode += Environment.NewLine; toEntityInstanceCode += string.Format(Resources.AssemblerToEntityInstanceChild, dtoChild.NameDTO); } if (dto.IsAbstract == false) { toDTOInstanceCode += Environment.NewLine + Resources.AssemblerToDTOInstanceElse + Environment.NewLine; toDTOInstanceCode += string.Format(Resources.AssemblerToDTOInstanceNew, dto.NameDTO); toEntityInstanceCode += Environment.NewLine + Resources.AssemblerToEntityInstanceElse + Environment.NewLine; toEntityInstanceCode += string.Format(Resources.AssemblerToEntityInstanceNew, dto.Name); } } else if (dto.IsAbstract == false) { // No childs, simple DTO instance toDTOInstanceCode = Resources.CSharpCodeVar + Resources.Space; toDTOInstanceCode += string.Format(Resources.AssemblerToDTOInstanceNew, dto.NameDTO); toEntityInstanceCode = Resources.CSharpCodeVar + Resources.Space; toEntityInstanceCode += string.Format(Resources.AssemblerToEntityInstanceNew, dto.Name); } #endregion Generate instance creation code // Property assignments code variables var toDTOAssignmentsCode = string.Empty; var toEntityAssignmentsCode = string.Empty; #region Generate property assignments code if ((dto.DTOChilds != null && dto.DTOChilds.Count > 0) || dto.IsAbstract == false) { foreach (var property in dto.Properties) { bool includeAssignments = true; string toDTOAssignment = null; string toEntityAssignment = null; if (property.IsNavigation == true) { // Do not map navigation properties. // The developer has to map navigations manually on partial methods if needed. includeAssignments = false; } else if (property.IsComplex == true) { toDTOAssignment = string.Format(Resources.AssemblerToDTOAssignmentEntityComplexProp, property.PropertyNameEDMX); toEntityAssignment = string.Format(Resources.AssemblerToEntityAssignmentDTOComplexProp, property.PropertyName); } else { toDTOAssignment = string.Format(Resources.AssemblerToDTOAssignmentEntityProp, property.PropertyNameEDMX); toEntityAssignment = string.Format(Resources.AssemblerToEntityAssignmentDTOProp, property.PropertyName); } if (includeAssignments) { // ToDTO assignment => dto.prop = ... toDTOAssignmentsCode += Environment.NewLine + string.Format(Resources.AssemblerToDTOAssignment, property.PropertyName, toDTOAssignment); // ToEntity assignment => entity.prop = ... toEntityAssignmentsCode += Environment.NewLine + string.Format(Resources.AssemblerToEntityAssignment, property.PropertyNameEDMX, toEntityAssignment); } } } #endregion Generate property assignments code // Get the start point where to insert the Assembler code objEditPoint = objNamespace.EndPoint.CreateEditPoint(); objEditPoint.LineUp(); objEditPoint.EndOfLine(); objEditPoint.Insert(Environment.NewLine); // Get the Assembler's code string assemblerCode = dto.Assembler.GetAssemblerCode(toDTOInstanceCode, toEntityInstanceCode, toDTOAssignmentsCode, toEntityAssignmentsCode); // Insert Assembler's code objEditPoint.Insert(assemblerCode); // Format code objEditPoint.StartOfDocument(); EditPoint endOfDocument = objNamespace.EndPoint.CreateEditPoint(); endOfDocument.EndOfDocument(); objEditPoint.SmartFormat(endOfDocument); // Save changes to Source File Item sourceFileItem.Save(); } // END (else) if dto is abstract and does not have childs // Count Assemblers generated assemblersGenerated++; // Report Progress int progress = ((assemblersGenerated * 100) / parameters.EntitiesDTOs.Count); if (progress < 100) { worker.ReportProgress(progress, new GeneratorOnProgressEventArgs(progress, string.Format(Resources.Text_AssemblersGenerated, assemblersGenerated, parameters.EntitiesDTOs.Count))); } // Check Cancellation Pending if (GeneratorManager.CheckCancellationPending()) { return; } } // END Loop through Entities DTOs // Save Target Project parameters.TargetProject.Save(); // Delete Template Class File TemplateClass.Delete(); // Report Progress worker.ReportProgress(100, new GeneratorOnProgressEventArgs(100, string.Format(Resources.Text_AssemblersGenerated, assemblersGenerated, parameters.EntitiesDTOs.Count))); LogManager.LogMethodEnd(); }
private void CreateFile() { TemplateClass tc = new TemplateClass(); try { bookmarkjs = ""; foreach (Bookmark bm in nightTab.Bookmarks) { string tempBookmarks = ""; List <string> valueList = new List <string>(); valueList.Add(bm.Display); //0 valueList.Add(bm.Letter); //1 valueList.Add(bm.Icon.Name); //2 valueList.Add(bm.Icon.Prefix); //3 valueList.Add(bm.Icon.Label); //4 valueList.Add(bm.Name); //5 valueList.Add(bm.Url); //6 valueList.Add(bm.Accent.OverRide); //7 valueList.Add(bm.Accent.Color.R); //8 valueList.Add(bm.Accent.Color.G); //9 valueList.Add(bm.Accent.Color.B); //10 valueList.Add(bm.Timestamp); //11 tempBookmarks += "[\ndisplay: \"{0}\", \n" + "letter: \"{1}\", \n" + "icon: [\n name: \"{2}\",\n prefix: \"{3}\",\n label: \"{4}\"\n],\n " + "name: \"{5}\",\n " + "url: \"{6}\",\n" + "accent: [\n" + "override: {7},\n" + "color: [ \n" + "r: {8}, \n" + "g: {9}, \n" + "b: {10}\n" + "]\n" + "], \n " + "timeStamp: {11}\n]"; if (bm != nightTab.Bookmarks.Last()) { tempBookmarks += ","; } bookmarkjs += string.Format(tempBookmarks, valueList.ToArray()).Replace("[", "{").Replace("]", "}"); } bookmarksFile = tc.olbookmarksjs.Replace("{0}", bookmarkjs); } catch (Exception ee) { error = true; MessageBox.Show($"error writing new bookmarks.js file.\n\nError message: {ee.Message}"); } try { statejs = ""; List <string> valueList = new List <string>(); #region Building Value List valueList.Add(nightTab.State.Header.Area.Width.ToString().ToLower()); //Header.Area valueList.Add(nightTab.State.Header.Area.Alignment.ToString().ToLower()); //Header.Area valueList.Add(nightTab.State.Header.Item.Alignment.ToString().ToLower()); //Header.Item valueList.Add(nightTab.State.Header.Clock.Hours.Show.ToString().ToLower()); //Header.Clock valueList.Add(nightTab.State.Header.Clock.Hours.Display.ToString().ToLower()); //Header.Clock valueList.Add(nightTab.State.Header.Clock.Minutes.Show.ToString().ToLower()); //Header.Clock valueList.Add(nightTab.State.Header.Clock.Minutes.Display.ToString().ToLower()); //Header.Clock valueList.Add(nightTab.State.Header.Clock.Seconds.Show.ToString().ToLower()); //Header.Clock valueList.Add(nightTab.State.Header.Clock.Seconds.Display.ToString().ToLower()); //Header.Clock valueList.Add(nightTab.State.Header.Clock.Separator.Show.ToString().ToLower()); //Header.Clock valueList.Add(nightTab.State.Header.Clock.Meridiem.Show.ToString().ToLower()); //Header.Clock valueList.Add(nightTab.State.Header.Clock.Hour24.Show.ToString().ToLower()); //Header.Clock valueList.Add(nightTab.State.Header.Clock.Size.ToString().ToLower()); //Header.Clock valueList.Add(nightTab.State.Header.Date.Day.Show.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Day.Display.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Day.WeekStart.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Day.Length.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Date.Show.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Date.Display.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Date.Ordinal.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Month.Show.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Month.Display.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Month.Length.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Month.Ordinal.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Year.Show.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Year.Display.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Separator.Show.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Format.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Date.Size.ToString().ToLower()); //Header.Date valueList.Add(nightTab.State.Header.Search.Show.ToString().ToLower()); //Header.Search valueList.Add(nightTab.State.Header.Search.Style.ToString().ToLower()); //Header.Search valueList.Add(nightTab.State.Header.Search.Width.ToString().ToLower()); //Header.Search valueList.Add(nightTab.State.Header.Search.Focus.ToString().ToLower()); //Header.Search valueList.Add(nightTab.State.Header.Search.Engine.Selected.ToString().ToLower()); //Header.Search -33 valueList.Add(nightTab.State.Header.Search.Engine.Custom.Url.ToString().ToLower()); //Header.Search valueList.Add(nightTab.State.Header.Search.Engine.Custom.Name.ToString().ToLower()); //Header.Search valueList.Add(nightTab.State.Header.Search.Text.Alignment.ToString().ToLower()); //Header.Search valueList.Add(nightTab.State.Header.Search.Size.ToString().ToLower()); //Header.Search valueList.Add(nightTab.State.Header.Button.EditAdd.Show.ToString().ToLower()); //Header.Button valueList.Add(nightTab.State.Header.Button.Accent.Show.ToString().ToLower()); //Header.Button valueList.Add(nightTab.State.Header.Button.Style.ToString().ToLower()); //Header.Button valueList.Add(nightTab.State.Header.Button.Size.ToString().ToLower()); //Header.Button -41 valueList.Add(nightTab.State.Header.Shade.Show.ToString().ToLower()); //Header.Shade valueList.Add(nightTab.State.Header.Shade.Style.ToString().ToLower()); //Header.Shade valueList.Add(nightTab.State.Header.Shade.Opacity.ToString().ToLower()); //Header.Shade - 44 valueList.Add(nightTab.State.Header.Border.Top.ToString().ToLower()); //Header.Border valueList.Add(nightTab.State.Header.Border.Bottom.ToString().ToLower()); //Header.Border valueList.Add(nightTab.State.Header.Greeting.Show.ToString().ToLower()); //Header.Greeting valueList.Add(nightTab.State.Header.Greeting.Type.ToString().ToLower()); //Header.Greeting valueList.Add(nightTab.State.Header.Greeting.Name.ToString()); //Header.Greeting valueList.Add(nightTab.State.Header.Greeting.Size.ToString().ToLower()); //Header.Greeting valueList.Add(nightTab.State.Header.Transitional.Show.ToString().ToLower()); //Header.Transitional valueList.Add(nightTab.State.Header.Transitional.Type.ToString().ToLower()); //Header.Transitional valueList.Add(nightTab.State.Header.Transitional.Size.ToString().ToLower()); //Header.Transitional valueList.Add(nightTab.State.Header.Radius.ToString().ToLower()); //Header.Transitional - 54 valueList.Add(nightTab.State.Link.Area.Width.ToString().ToLower()); //Link.Area valueList.Add(nightTab.State.Link.Area.Alignment.ToString().ToLower()); //Link.Area valueList.Add(nightTab.State.Link.Item.Display.Show.ToString().ToLower()); //Link.Item valueList.Add(nightTab.State.Link.Item.Display.Size.ToString().ToLower()); //Link.Item valueList.Add(nightTab.State.Link.Item.Display.Alignment.ToString().ToLower()); //Link.Item valueList.Add(nightTab.State.Link.Item.Display.Letter.Size.ToString().ToLower()); //Link.Item valueList.Add(nightTab.State.Link.Item.Display.Icon.Size.ToString().ToLower()); //Link.Item valueList.Add(nightTab.State.Link.Item.Name.Show.ToString().ToLower()); //Link.Item valueList.Add(nightTab.State.Link.Item.Name.Size.ToString().ToLower()); //Link.Item - 63 valueList.Add(nightTab.State.Link.Item.Url.Show.ToString().ToLower()); //Link.Item valueList.Add(nightTab.State.Link.Item.Line.Show.ToString().ToLower()); //Link.Item valueList.Add(nightTab.State.Link.Item.HoverScale.Show.ToString().ToLower()); //Link.Item valueList.Add(nightTab.State.Link.Item.Order.ToString().ToLower()); //Link.Item valueList.Add(nightTab.State.Link.Item.Size.ToString().ToLower()); //Link.Item valueList.Add(nightTab.State.Link.Item.NewTab.ToString().ToLower()); //Link.Item -69 valueList.Add(nightTab.State.Link.Show.ToString().ToLower()); //Link.Show valueList.Add(nightTab.State.Link.Edit.ToString().ToLower()); //Link.Edit valueList.Add(nightTab.State.Link.Style.ToString().ToLower()); //Link.Style valueList.Add(nightTab.State.Link.NewTab.ToString().ToLower()); //Link.NewTab valueList.Add(nightTab.State.Layout.Alignment.ToString().ToLower()); //Layout.Alignment valueList.Add(nightTab.State.Layout.Order.ToString().ToLower()); //Layout.Order valueList.Add(nightTab.State.Layout.Padding.ToString().ToLower()); //Layout.Padding valueList.Add(nightTab.State.Layout.Gutter.ToString().ToLower()); //Layout.Gutter valueList.Add(nightTab.State.Layout.Width.ToString().ToLower()); //Layout.Width valueList.Add(nightTab.State.Layout.ScrollPastEnd.ToString().ToLower()); //Layout.ScrollPastEnd valueList.Add(nightTab.State.Layout.Title.ToString()); //Layout.Title - 80 valueList.Add(nightTab.State.Theme.Accent.Current.R.ToString().ToLower()); //Theme.Accent valueList.Add(nightTab.State.Theme.Accent.Current.G.ToString().ToLower()); //Theme.Accent valueList.Add(nightTab.State.Theme.Accent.Current.B.ToString().ToLower()); //Theme.Accent valueList.Add(nightTab.State.Theme.Accent.Random.Active.ToString().ToLower()); //Theme.Accent valueList.Add(nightTab.State.Theme.Accent.Random.Style.ToString().ToLower()); //Theme.Accent valueList.Add(nightTab.State.Theme.Style.ToString().ToLower()); //Theme.Style valueList.Add(nightTab.State.Theme.Radius.ToString().ToLower()); //Theme.Radius -87 valueList.Add(nightTab.State.Background.Image.Show.ToString().ToLower()); //Background.Image valueList.Add(nightTab.State.Background.Image.Url.ToString().ToLower()); //Background.Image valueList.Add(nightTab.State.Background.Image.Blur.ToString().ToLower()); //Background.Image valueList.Add(nightTab.State.Background.Image.Scale.ToString().ToLower()); //Background.Image valueList.Add(nightTab.State.Background.Image.Opacity.ToString().ToLower()); //Background.Image valueList.Add(nightTab.State.Background.Image.Grayscale.ToString().ToLower()); //Background.Image valueList.Add(nightTab.State.Background.Image.Accent.ToString().ToLower()); //Background.Image valueList.Add(nightTab.State.Edge.ToString().ToLower()); //Edge valueList.Add(nightTab.State.Search.ToString().ToLower()); //Search valueList.Add(nightTab.State.Menu.ToString().ToLower()); //Menu valueList.Add(nightTab.State.Modal.ToString().ToLower()); //Modal valueList.Add(nightTab.State.AutoSuggest.ToString().ToLower()); //AutoSuggest - 99 #endregion stateFile = String.Format(tc.oldStatejs, valueList.ToArray()); stateFile = stateFile.Replace('¿', '{').Replace('╡', '}'); } catch (Exception ee) { error = true; MessageBox.Show($"error writing new state.js file.\n\nError message: {ee.Message}"); } }
public void Run() { var templateClass = new TemplateClass(); templateClass.Dispose(); templateClass.Dispose(); }