/// <summary> /// Returns true if OutputMultiCollection instances are equal /// </summary> /// <param name="other">Instance of OutputMultiCollection to be compared</param> /// <returns>Boolean</returns> public bool Equals(OutputMultiCollection other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Result1 == other.Result1 || Result1 != null && other.Result1 != null && Result1.SequenceEqual(other.Result1) ) && ( Result2 == other.Result2 || Result2 != null && other.Result2 != null && Result2.SequenceEqual(other.Result2) )); }
private bool GetResult1(ref Result1 result) { if (null == myJobManager1) { return false; } ICogRecord tmpRecord; ICogRecord topRecord; try { topRecord = myJobManager1.UserResult(); if (null == topRecord) { return false; } if (null != cogRecordDisplay1) { tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"]; tmpRecord = tmpRecord.SubRecords["LastRun"]; tmpRecord = tmpRecord.SubRecords["CogFixtureTool1.OutputImage"]; if (null != tmpRecord.Content) { cogRecordDisplay1.Record = tmpRecord; } cogRecordDisplay1.AutoFit = true; } return true; } catch { return false; } }
public void DataContractJsonSerializerSerializesAllProperties() { var targetRequest = new Request1(); targetRequest.Id = "42"; var targetResult = new Result1(targetRequest); targetResult.Id = "42"; targetResult.Succeed = true; targetResult.Errors.AddDetail(Error1.Error42, "The detail.", "The error to all failed algorithms."); var serializer = new DataContractJsonSerializer(typeof(Result1)); var stream = new MemoryStream(); serializer.WriteObject(stream, targetResult); stream.Seek(0L, SeekOrigin.Begin); var unserialized = (Result1)serializer.ReadObject(stream); Assert.AreEqual(targetResult.Succeed, unserialized.Succeed); Assert.AreEqual(targetResult.Id, unserialized.Id); Assert.AreEqual(targetResult.Request.Id, unserialized.Request.Id); Assert.AreEqual(targetResult.Errors.Count, unserialized.Errors.Count); Assert.AreEqual(targetResult.Errors[0].Code, unserialized.Errors[0].Code); Assert.AreEqual(targetResult.Errors[0].DisplayMessage, unserialized.Errors[0].DisplayMessage); Assert.AreEqual(targetResult.Errors[0].Detail, unserialized.Errors[0].Detail); }
/* * Determina cual es la maxima cantidad de eventos en un lapso de K dias y * cual es ese intervalo. En caso de empates, puedes devolver cualquiera * de los intervalos de K dias que tienen la misma maxima cantidad de * homicidios. */ static Result1 MaxNumberOfEventsInAnyKDayInterval(Event[] events, int K) { // TODO: implementar algoritmo que resuelva este problema e indique cual // es su complejidad average case. Asume que el arreglo de eventos // 'events' ya esta ordenada por dia. // HINT: Usa un Doubly Ended Queue para grabar los eventos de los // ultimos K dias. // Complejidad esperada: mejor que O((N-K)*K) // Valor: 3 puntos // Documentacion de LinkedList: https://docs.microsoft.com/es-es/dotnet/api/system.collections.generic.linkedlist-1?view=netframework-4.7.2 // Operaciones utilizadas: RemoveFirst, AddLast, Count, son O(1) int MaxDay = 0; // O(1) LinkedList <Event> Dlink = new LinkedList <Event>(); // O(1) int tmp = 0; // O(1) for (int i = 0; i < events.Length; i++) // O(N) { if (events[i].day < 0) { throw new NegativenumberException(); } if (Dlink.Count == 0) { Dlink.AddLast(events[i]); // O(1) } else if (events[i].day >= Dlink.First.Value.day && events[i].day < Dlink.First.Value.day + K) { Dlink.AddLast(events[i]); // O(1) } else { Dlink.RemoveFirst(); // O(1) i--; // O(1) } if (Dlink.Count >= MaxDay) { tmp = Dlink.Last.Value.day; // O(1) MaxDay = Dlink.Count; // O(1) } } int number = tmp + 1 - K; // O(1) if (number < 0) { number = 0; // O(1) } Result1 var = new Result1(number, tmp, MaxDay); // O(1) return(var); // Mi complejidad en avg case es O(N) mejor que O(N-k)*K }
private void OnItemClick(Result1 clickedItem) { if (clickedItem != null) { NavigationService.Frame.SetListDataItemForNextConnectedAnimation(clickedItem); NavigationService.Navigate(typeof(TV_ShowsDetailViewModel).FullName, clickedItem.id); } }
public int Run1(int time, string _pathin, ref Result1 result) { Stop1(); if(GetImage1(_pathin)) { try { myJobManager1.Run())} System.Threading.Thread.Sleep(time); }
public void Overload1() { var result = new Result1(new Request1()); var code = Error1.Hello; var message = "bad error"; result.Errors.Add(code, message); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual(code, result.Errors[0].Code); Assert.AreEqual(message, result.Errors[0].DisplayMessage); Assert.IsNull(result.Errors[0].Detail); }
/* * Determina cual es la maxima cantidad de eventos en un lapso de K dias y * cual es ese intervalo. En caso de empates, puedes devolver cualquiera * de los intervalos de K dias que tienen la misma maxima cantidad de * homicidios. */ static Result1 MaxNumberOfEventsInAnyKDayInterval(Event[] events, int K) { // TODO: implementar algoritmo que resuelva este problema e indique cual // es su complejidad average case. Asume que el arreglo de eventos // 'events' ya esta ordenada por dia. // NOTES: // * A diferencia del metodo MostFrequentLocationInAnyKDayInterval, // no debes asumir que D esta limitado a 10000. // * El rango de fecha que devuelvas debe tener exactamente K dias. // HINT: Usa un Doubly Ended Queue para grabar los eventos de los // ultimos K dias. // Complejidad esperada: mejor que O((N-K)*K) // Valor: 3 puntos LinkedList <Event> CurrentLapse = new LinkedList <Event>(); // LinkedList donde se guardan los elementos del intervalo actual int TempEnd = 0, end = 0, counter = 0; for (int i = 0; i < events.Length; i++) { if (CurrentLapse.Count == 0) { CurrentLapse.AddLast(events[i]); } else if (events[i].day < CurrentLapse.First.Value.day + K) { CurrentLapse.AddLast(events[i]); TempEnd = events[i].day; if (CurrentLapse.Count == events.Length) // Caso SUPER especial donde todos los eventos estan en un solo intervalo. { end = TempEnd; counter = CurrentLapse.Count; } } else { if (CurrentLapse.Count >= counter) { counter = CurrentLapse.Count; end = TempEnd; CurrentLapse.RemoveFirst(); i--; } else { CurrentLapse.RemoveFirst(); i--; } } } Result1 result = new Result1(end - K + 1 >= 0 ? end - K + 1 : 1, end < K ? K : end, counter); return(result); }
public void Overload2() { var result = new Result1(new Request1()); var code = Error1.Hello; var message = "Error1 Hello"; result.Errors.Add(code, Strings.ResourceManager); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual(code, result.Errors[0].Code); Assert.AreEqual(message, result.Errors[0].DisplayMessage); Assert.IsNull(result.Errors[0].Detail); }
/* * Determina cual es la maxima cantidad de eventos en un lapso de K dias y * cual es ese intervalo. En caso de empates, puedes devolver cualquiera * de los intervalos de K dias que tienen la misma maxima cantidad de * homicidios. */ static Result1 MaxNumberOfEventsInAnyKDayInterval(Event[] events, int K) { // TODO: implementar algoritmo que resuelva este problema e indique cual // es su complejidad average case. Asume que el arreglo de eventos // 'events' ya esta ordenada por dia. // HINT: Usa un Doubly Ended Queue para grabar los eventos de los // ultimos K dias. // Complejidad esperada: mejor que O((N-K)*K) // Valor: 3 puntos int contador2 = 0; int contador1 = 0; Stack <Result1> stack = new Stack <Result1>(); // Crearlo es constante for (int i = 0; i < events.Length - K; i++) { Result1 var = new Result1(events[i].day, events[i].day + K, contador2); contador1 = 0; int y = i; while (y + K < events.Length) { if (events[y].day >= events[i].day && events[y].day < events[i].day + K) { contador1++; } else { break; } y++; } if (contador2 <= contador1) { contador2 = contador1; var.count = contador2; if (stack.Count != 0) { stack.Pop(); } stack.Push(var); } } return(stack.Pop()); }
public void Overload2_Format() { var result = new Result1(new Request1()); var code = Error1.World; var format = "Mlivej"; var message = @"WorldCode """ + format + @""""; result.Errors.Add(code, Strings.ResourceManager, format); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual(code, result.Errors[0].Code); Assert.AreEqual(message, result.Errors[0].DisplayMessage); Assert.IsNull(result.Errors[0].Detail); }
public void Overload1_Format() { var result = new Result1(new Request1()); var code = Error1.World; var format = "Mlivej"; var message = @"WorldCode """ + format + @""""; var detail = "Glarg"; result.Errors.AddDetail(code, detail, @"WorldCode ""{0}""", format); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual(code, result.Errors[0].Code); Assert.AreEqual(message, result.Errors[0].DisplayMessage); Assert.AreEqual(detail, result.Errors[0].Detail); }
private bool GetResult1(ref Result1 result) { if (null == myJobManager1) { return false; } ICogRecord tmpRecord; ICogRecord topRecord; try { topRecord = myJobManager1.UserResult(); if (null == topRecord) { return false; } tmpRecord = topRecord.SubRecords[@"Angle"]; if (null != tmpRecord.Content) { result.ResultAngle = (double)tmpRecord.Content; } tmpRecord = topRecord.SubRecords[@"Tilt"]; if (null != tmpRecord.Content) { result.ResultTilt = (double)tmpRecord.Content; } tmpRecord = topRecord.SubRecords[@"Distance"]; if (null != tmpRecord.Content) { result.ResultDistance = (double)tmpRecord.Content; } if (null != cogRecordDisplay1) { tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"]; tmpRecord = tmpRecord.SubRecords["LastRun"]; tmpRecord = tmpRecord.SubRecords["CogFixtureTool1.OutputImage"]; if (null != tmpRecord.Content) { cogRecordDisplay1.Record = tmpRecord; } cogRecordDisplay1.Fit(true); } return true; } catch { return false; } }
/// <summary> /// Compares two results for equality. /// </summary> /// <param name="Result1">A result.</param> /// <param name="Result2">Another result.</param> /// <returns>True if both match; False otherwise.</returns> public static Boolean operator ==(Result Result1, Result Result2) { // If both are null, or both are same instance, return true. if (ReferenceEquals(Result1, Result2)) { return(true); } // If one is null, but not both, return false. if (((Object)Result1 == null) || ((Object)Result2 == null)) { return(false); } return(Result1.Equals(Result2)); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Result1 != null) { hashCode = hashCode * 59 + Result1.GetHashCode(); } if (Result2 != null) { hashCode = hashCode * 59 + Result2.GetHashCode(); } return(hashCode); } }
private void btnCalculate_Click(object sender, EventArgs e) { decimal Result1; decimal Number1 = Decimal.Parse(txtNumber1.Text, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowTrailingSign | NumberStyles.AllowThousands); decimal Number2 = Decimal.Parse(txtNumber2.Text, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowTrailingSign | NumberStyles.AllowThousands); Result1 = Number1 * Number2; txtNumber1.Text = Number1.ToString(); txtNumber2.Text = Number2.ToString(); txtResult1.Text = Result1.ToString(); }
protected void pageSave(Object sender, ToolbarService.iUCToolbarClient e) { try { CustomProfile profile = CustomProfile.GetProfile(); iCustomerClient ServiceAccountMaster = new iCustomerClient(); mVendor Objvendor = new mVendor(); tCustomerHead objCutomerHead = new tCustomerHead(); tOpeningBalance objOpeningBal = new tOpeningBalance(); int result; long Result1; if (checkDuplicate() == "") { if (HdnAccountId.Value != "" && HdnAccountId.Value != "0") { //objCutomerHead = ServiceAccountMaster.GetCustomerHeadDetailByCustomerID(Convert.ToInt64(HdnAccountId.Value), profile.DBConnection._constr); Objvendor = ServiceAccountMaster.GetVendorDetailByVendorID(Convert.ToInt64(HdnAccountId.Value), profile.DBConnection._constr); objOpeningBal = ServiceAccountMaster.GetTOpeningBalanceDtls(Convert.ToInt64(HdnAccountId.Value), "Vendor", profile.DBConnection._constr); objCutomerHead.LastModifiedBy = profile.Personal.UserID.ToString(); objCutomerHead.LastModifiedDate = DateTime.Now; } else { objCutomerHead.CreatedBy = profile.Personal.UserID.ToString(); objCutomerHead.CreationDate = DateTime.Now; } Objvendor.Name = txt_custname.Text; Objvendor.CompanyID = long.Parse(ddlcompany.SelectedItem.Value); Objvendor.Code = txt_custcode.Text; Objvendor.Sector = Convert.ToInt64(Ddl_Sector.SelectedItem.Value); Objvendor.VCType = Convert.ToInt64(ddlvendortype.SelectedItem.Value); Objvendor.Creditdays = Convert.ToInt64(txt_CreditDays.Text); Objvendor.TurnOver = decimal.Parse(txt_turnOver.Text); Objvendor.CompType = Convert.ToInt64(Ddl_CompanyType.SelectedItem.Value); if (rbtnYes.Checked == true) { Objvendor.Active = "Y"; } if (rbtnNo.Checked == true) { Objvendor.Active = "N"; } Objvendor.CustomerID = long.Parse(hdncustomerid.Value); Objvendor.Website = TxtWebsite.Text; Objvendor.AccountType = "Vendor"; /* if (Ddl_CompanyType.SelectedIndex > 0) objCutomerHead.CustomerTypeID = Convert.ToInt64(Ddl_CompanyType.SelectedItem.Value); * * objCutomerHead.CustomerCode = null; * if (txt_custcode.Text.ToString().Trim() != "") objCutomerHead.CustomerCode = (txt_custcode.Text).ToString(); * * if (Ddl_Sector.SelectedIndex > 0) objCutomerHead.SectorID = Convert.ToInt64(Ddl_Sector.SelectedItem.Value); * * objCutomerHead.Name = null; * if (txt_custname.Text.ToString().Trim() != "") objCutomerHead.Name = (txt_custname.Text).ToString(); * * objCutomerHead.WebSite = null; * if (TxtWebsite.Text.ToString().Trim() != "") objCutomerHead.WebSite = (TxtWebsite.Text).ToString(); * * objCutomerHead.TurnOver = null; * if (txt_turnOver.Text.ToString().Trim() != "") objCutomerHead.TurnOver = (txt_turnOver.Text).ToString(); * * * objCutomerHead.CreditDays = null; * if (txt_CreditDays.Text.ToString().Trim() != "") objCutomerHead.CreditDays = Convert.ToInt32(txt_CreditDays.Text); * * if (rbtnYes.Checked == true) objCutomerHead.Active = "Y"; * if (rbtnNo.Checked == true) objCutomerHead.Active = "N"; * * objCutomerHead.BillingAddressID = Convert.ToInt64(UCAddress1.BillingSeq); * objCutomerHead.ShippingAddressID = Convert.ToInt64(UCAddress1.ShippingSeq); * * objCutomerHead.ConperID = UCContactPerson1.ContactPersonIDs;*/ objOpeningBal.FinancialYear = null; if (ddl_FinancialYr.SelectedIndex > 0) { objOpeningBal.FinancialYear = ddl_FinancialYr.SelectedValue; } objOpeningBal.ObjectName = "Vendor"; objOpeningBal.OpeningBalance = null; if (txt_OpeningBalance.Text.ToString().Trim() != "") { objOpeningBal.OpeningBalance = Convert.ToDecimal((txt_OpeningBalance.Text).ToString()); } objOpeningBal.DrCr = null; if (ddl_DrCr.SelectedIndex > 0) { objOpeningBal.DrCr = ddl_DrCr.SelectedValue; } //objOpeningBal.ID = Convert.ToInt64(HdnOpeningBalId.Value.ToString()); if (HdnAccountId.Value == string.Empty) { //objCutomerHead.CreatedBy = profile.Personal.UserID.ToString(); //objCutomerHead.CreationDate = DateTime.Now; //objCutomerHead.CompanyID = profile.Personal.CompanyID; Objvendor.CreatedBy = profile.Personal.UserID.ToString(); Objvendor.CreationDate = DateTime.Now; // result = ServiceAccountMaster.SaveCustomerDetails(objCutomerHead, "AddNew", profile.DBConnection._constr); result = ServiceAccountMaster.SaveVendorDetails(Objvendor, "AddNew", profile.DBConnection._constr); } else { //objCutomerHead.LastModifiedBy = profile.Personal.UserID.ToString(); //objCutomerHead.LastModifiedDate = DateTime.Now; Objvendor.LastModifiedBy = profile.Personal.UserID.ToString(); Objvendor.LastModifiedDate = DateTime.Now; //result = ServiceAccountMaster.SaveCustomerDetails(objCutomerHead, "Edit", profile.DBConnection._constr); result = ServiceAccountMaster.SaveVendorDetails(Objvendor, "Edit", profile.DBConnection._constr); } objOpeningBal.ReferenceID = result; HdnAccountId.Value = result.ToString(); if (HdnOpeningBalId.Value == "0" || HdnOpeningBalId.Value == "") { objOpeningBal.CreatedBy = profile.Personal.UserID.ToString(); objOpeningBal.CreatedDate = DateTime.Now; // Result1 = ServiceAccountMaster.SaveOpeningBalance(objOpeningBal, "AddNew", profile.DBConnection._constr); Result1 = ServiceAccountMaster.SaveAccountOpeningBal(objOpeningBal, profile.DBConnection._constr); } else { objOpeningBal.LastModifiedBy = profile.Personal.UserID.ToString(); objOpeningBal.LastModifiedDate = DateTime.Now; // Result1 = ServiceAccountMaster.SaveOpeningBalance(objOpeningBal, "Edit", profile.DBConnection._constr); Result1 = ServiceAccountMaster.SaveAccountOpeningBal(objOpeningBal, profile.DBConnection._constr); } HdnOpeningBalId.Value = Result1.ToString(); UCAddress1.FinalSaveAddress(Address.ReferenceObjectName.Vendor, result); UCContactPerson1.FinalSaveContactPerson("Vendor", result); UC_AttachDocument1.FinalSaveDocument(result); /* UC_StatutoryDetails1.FinalSaveToStatutoryDetails(Convert.ToInt64(result), "Customer", profile.Personal.CompanyID);*/ if (result != 0) { WebMsgBox.MsgBox.Show("Record saved successfully"); } clr(); MainCustomerGridBind(); // FillUserControl(result); ActiveTab("Load"); } } catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, this, "Account Master", "pageSave"); } finally { } }
//----< define how to process each message command >------------- void initializeMessageDispatcher() { // load remoteFiles listbox with files from root messageDispatcher["getTopFiles"] = (CommMessage msg) => { remoteFiles.Items.Clear(); foreach (string file in msg.arguments) { remoteFiles.Items.Add(file); } }; // load remoteDirs listbox with dirs from root messageDispatcher["getTopDirs"] = (CommMessage msg) => { remoteDirs.Items.Clear(); foreach (string dir in msg.arguments) { remoteDirs.Items.Add(dir); } }; // load remoteFiles listbox with files from folder messageDispatcher["moveIntoFolderFiles"] = (CommMessage msg) => { remoteFiles.Items.Clear(); foreach (string file in msg.arguments) { remoteFiles.Items.Add(file); } }; // load remoteDirs listbox with dirs from folder messageDispatcher["moveIntoFolderDirs"] = (CommMessage msg) => { remoteDirs.Items.Clear(); foreach (string dir in msg.arguments) { remoteDirs.Items.Add(dir); } }; messageDispatcher["moveUpDirs"] = (CommMessage msg) => { remoteDirs.Items.Clear(); foreach (string dir in msg.arguments) { remoteDirs.Items.Add(dir); } }; messageDispatcher["moveUpDirsFile"] = (CommMessage msg) => { remoteFiles.Items.Clear(); foreach (string files in msg.arguments) { remoteFiles.Items.Add(files); } }; messageDispatcher["moveSelectedFiles"] = (CommMessage msg) => { File_sets.Items.Clear(); foreach (var item in msg.arguments) { File_sets.Items.Add(item); } }; messageDispatcher["Add_all"] = (CommMessage msg) => { File_sets.Items.Clear(); foreach (var item in msg.arguments) { File_sets.Items.Add(item); } }; messageDispatcher["importone"] = (CommMessage msg) => { File_sets.Items.Clear(); foreach (var item in msg.arguments) { File_sets.Items.Add(item); } }; messageDispatcher["importall"] = (CommMessage msg) => { File_sets.Items.Clear(); foreach (var item in msg.arguments) { File_sets.Items.Add(item); } }; messageDispatcher["removeSelectedFiles"] = (CommMessage msg) => { File_sets.Items.Clear(); foreach (var item in msg.arguments) { File_sets.Items.Add(item); } }; messageDispatcher["clearSelectedFiles"] = (CommMessage msg) => { File_sets.Items.Clear(); }; messageDispatcher["Generate_TT"] = (CommMessage msg) => { //Result1.Items.Clear(); Result1.Clear(); foreach (var item in msg.arguments) { Result1.AppendText(item); //Result1.Items.Add(item); } }; messageDispatcher["Generate_DT"] = (CommMessage msg) => { //Result1.Items.Clear(); Result1.Clear(); foreach (var item in msg.arguments) { Result1.AppendText(item); //Result1.Items.Add(item); } }; messageDispatcher["Generate_SC"] = (CommMessage msg) => { //Result1.Items.Clear(); Result1.Clear(); foreach (var item in msg.arguments) { Result1.AppendText(item); //Result1.Items.Add(item); } }; }
public void Run(Result1 res1, Result2 res2, Result3 res3) => Interlocked.Add(ref _result, res1.Data + res2.Data + res3.Data);
public int Run1(int time, string _pathin, ref Result1 result) { Stop1(); if(GetImage1(_pathin)) { try { myJobManager1.Run())} System.Threading.Thread.Sleep(time); } catch { return 2; } if(GetResult1(ref result)) { Stop1(); return 0; } else { return 3; } }
private void Button18_Click(object sender, EventArgs e) { Result1.Clear(); }