//private static bool GetLoggerMethodsFromClass(ClassDef methodLogger, out Method startLogMethod, out Method endLogMethod) //{ // startLogMethod = endLogMethod = null; // Method tempStartLogMethod = methodLogger.GetMethodDesc(startLogMethodName); // Method tempEndLogMethod = methodLogger.GetMethodDesc(endLogMethodName); // if (tempStartLogMethod != null && tempEndLogMethod != null) // { // if (CheckLogMethodParameters(tempStartLogMethod.GetParTypes()) && CheckLogMethodParameters(tempEndLogMethod.GetParTypes())) // { // startLogMethod = tempStartLogMethod; // endLogMethod = tempEndLogMethod; // return true; // } // } // return false; //} public static bool LocateLoggerMethods(out Method startLogMethod, out Method endLogMethod) { string str1 = null; startLogMethod = endLogMethod = null; if (!System.IO.File.Exists("MethodExecLoggerLib.dll")) { return(false); } str1 = "MethodExecLoggerLib.dll"; // Console.WriteLine(str1); PEFile file = PEFile.ReadPEFile(str1); string Assemblyname = System.IO.Path.GetFileNameWithoutExtension(str1);; AssemblyRef newAssemblyRef = file.MakeExternAssembly(Assemblyname); ClassRef newMethodLoggerRef = TryGetMethodLoggerFromAssembly(file, newAssemblyRef, "MethodExecLogger"); if (newMethodLoggerRef != null) { if (GetLoggerMethodsFromClass(newMethodLoggerRef, out startLogMethod, out endLogMethod)) { return(true); } } return(false); }
public XElement GenerateAddRq(decimal?TotalValue = null, DateTime?InventoryDate = null) { XElement Add = new XElement(typeof(ItemInventory).Name + "Add"); Add.Add(Name?.ToQBXML(nameof(Name))); Add.Add(BarCode?.ToQBXML(nameof(BarCode))); Add.Add(IsActive.ToQBXML(nameof(IsActive))); Add.Add(ClassRef?.ToQBXML(nameof(ClassRef))); Add.Add(ParentRef?.ToQBXML(nameof(ParentRef))); Add.Add(ManufacturerPartNumber?.ToQBXML(nameof(ManufacturerPartNumber))); Add.Add(UnitOfMeasureSetRef?.ToQBXML(nameof(UnitOfMeasureSetRef))); Add.Add(SalesTaxCodeRef?.ToQBXML(nameof(SalesTaxCodeRef))); Add.Add(SalesDesc?.ToQBXML(nameof(SalesDesc))); Add.Add(SalesPrice?.ToQBXML(nameof(SalesPrice))); Add.Add(IncomeAccountRef?.ToQBXML(nameof(IncomeAccountRef))); Add.Add(PurchaseDesc?.ToQBXML(nameof(PurchaseDesc))); Add.Add(PurchaseCost?.ToQBXML(nameof(PurchaseCost))); Add.Add(COGSAccountRef?.ToQBXML(nameof(COGSAccountRef))); Add.Add(PrefVendorRef?.ToQBXML(nameof(PrefVendorRef))); Add.Add(AssetAccountRef?.ToQBXML(nameof(AssetAccountRef))); Add.Add(ReorderPoint?.ToQBXML(nameof(ReorderPoint))); Add.Add(Max?.ToQBXML(nameof(Max))); Add.Add(QuantityOnHand?.ToQBXML(nameof(QuantityOnHand))); Add.Add(TotalValue?.ToQBXML(nameof(TotalValue))); Add.Add(InventoryDate?.ToQBXML(nameof(InventoryDate))); Add.Add(ExternalGUID?.ToQBXML(nameof(ExternalGUID))); XElement AddRq = new XElement(typeof(ItemInventory).Name + "AddRq", Add); foreach (var value in IncludeRetElement) { AddRq.Add(value.ToQBXML(nameof(IncludeRetElement))); } return(AddRq); }
public static IMarkdownCustomModule Create(string name, ClassRef classRef) { Contract.Requires(!String.IsNullOrEmpty(name)); Contract.Requires(classRef != null); Contract.Ensures(Contract.Result <IMarkdownCustomModule>() != null); return(Create(name, null, _ => classRef)); }
public override XElement GenerateAddRq() { XElement Add = new XElement("CustomerAdd"); Add.Add(Name?.ToQBXML(nameof(Name))); Add.Add(IsActive.ToQBXML(nameof(IsActive))); Add.Add(ClassRef?.ToQBXML(nameof(ClassRef))); Add.Add(ParentRef?.ToQBXML(nameof(ParentRef))); Add.Add(CompanyName?.ToQBXML(nameof(CompanyName))); Add.Add(Salutation?.ToQBXML(nameof(Salutation))); Add.Add(FirstName?.ToQBXML(nameof(FirstName))); Add.Add(MiddleName?.ToQBXML(nameof(MiddleName))); Add.Add(LastName?.ToQBXML(nameof(LastName))); Add.Add(JobTitle?.ToQBXML(nameof(JobTitle))); Add.Add(BillAddress?.ToQBXML(nameof(BillAddress))); Add.Add(ShipAddress?.ToQBXML(nameof(ShipAddress))); Add.Add(ShipToAddress?.ToQBXML(nameof(ShipToAddress))); Add.Add(Phone?.ToQBXML(nameof(Phone))); Add.Add(AltPhone?.ToQBXML(nameof(AltPhone))); Add.Add(Fax?.ToQBXML(nameof(Fax))); Add.Add(Email?.ToQBXML(nameof(Email))); Add.Add(Cc?.ToQBXML(nameof(Cc))); Add.Add(Contact?.ToQBXML(nameof(Contact))); Add.Add(AltContact?.ToQBXML(nameof(AltContact))); Add.Add(AdditionalContactRef?.ToQBXML(nameof(AdditionalContactRef))); Add.Add(Contacts?.ToQBXML <Contacts>(nameof(Contacts))); Add.Add(CustomerTypeRef?.ToQBXML(nameof(CustomerTypeRef))); Add.Add(TermsRef?.ToQBXML(nameof(TermsRef))); Add.Add(SalesRepRef?.ToQBXML(nameof(SalesRepRef))); Add.Add(OpenBalance?.ToQBXML(nameof(OpenBalance))); Add.Add(OpenBalanceDate?.ToQBXML(nameof(OpenBalanceDate))); Add.Add(SalesTaxCodeRef?.ToQBXML(nameof(SalesTaxCodeRef))); Add.Add(ItemSalesTaxRef?.ToQBXML(nameof(ItemSalesTaxRef))); Add.Add(ResaleNumber?.ToQBXML(nameof(ResaleNumber))); Add.Add(AccountNumber?.ToQBXML(nameof(AccountNumber))); Add.Add(CreditLimit?.ToQBXML(nameof(CreditLimit))); Add.Add(PreferredPaymentMethodRef?.ToQBXML(nameof(PreferredPaymentMethodRef))); Add.Add(CreditCardInfo?.ToQBXML(nameof(CreditCardInfo))); Add.Add(JobStatus.ToQBXML(nameof(JobStatus))); Add.Add(JobStartDate?.ToQBXML(nameof(JobStartDate))); Add.Add(JobProjectedEndDate?.ToQBXML(nameof(JobProjectedEndDate))); Add.Add(JobEndDate?.ToQBXML(nameof(JobEndDate))); Add.Add(JobDesc?.ToQBXML(nameof(JobDesc))); Add.Add(JobTypeRef?.ToQBXML(nameof(JobTypeRef))); Add.Add(Notes?.ToQBXML(nameof(Notes))); Add.Add(AdditionalNotes?.ToQBXML(nameof(AdditionalNotes))); Add.Add(PreferredDeliveryMethod.ToQBXML(nameof(PreferredDeliveryMethod))); Add.Add(PriceLevelRef?.ToQBXML(nameof(PriceLevelRef))); Add.Add(ExternalGUID?.ToQBXML(nameof(ExternalGUID))); Add.Add(CurrencyRef?.ToQBXML(nameof(CurrencyRef))); XElement AddRq = new XElement("CustomerAddRq"); AddRq.Add(Add); AddRq.Add(IncludeRetElement?.ToQBXML(nameof(IncludeRetElement))); return(AddRq); }
/// <summary> /// Find the Method for this method on the given type. /// </summary> internal Method findMethod(string qname, string methodName, string[] paramTypes, string returnType) { string key = getMethodKey(qname, methodName, paramTypes); Method method = (Method)methods[key]; if (method == null) { // this stuff should be the same for both cases PERWAPI.Type rtype = findType(returnType); PERWAPI.Type[] pars = new PERWAPI.Type[paramTypes.Length]; for (int i = 0; i < paramTypes.Length; i++) { pars[i] = findType(paramTypes[i]); } // check for stubs object obj = findType(qname); if (obj is ClassDef) { // class is an internal stub, so we need to stub this // method out too, which should get flushed out later ClassDef cdef = obj as ClassDef; // TODO - need to fix attrs Param[] mpars = new Param[pars.Length]; for (int i = 0; i < mpars.Length; i++) { mpars[i] = new Param(ParamAttr.Default, "v" + i, pars[i]); } // TODO - fix param names // Use Public here for stub - real MethAttr will be set // when method is flushed out method = cdef.AddMethod(MethAttr.Public, ImplAttr.IL, methodName, rtype, mpars); } else if (obj is ClassRef) { // class is external, just get or add ref ClassRef cref = obj as ClassRef; method = cref.GetMethod(methodName, pars, new PERWAPI.Type[0]); if (method == null) { method = cref.AddMethod(methodName, rtype, pars); } } else { throw new System.Exception("Don't know how to handle: " + obj.GetType()); } // make sure we add method to hashtable methods[key] = method; } return(method); }
public static AlphaRef ColorAlpha(ClassRef <Color> color) { Func <float> get = () => color.get().a; Action <float> set = (a) => { var col = color.get(); col.a = a; color.set(col); }; return(new AlphaRef(set, get)); }
internal static ClassRef AddClass(AssemblyRef assembly, string ns, string name) { ClassRef klass = assembly.GetClass(ns, name); if (klass != null) { return(klass); } else { return(assembly.AddClass(ns, name)); } }
public XElement GenerateAddRq() { XElement Add = new XElement(nameof(ExpenseLine) + "Add"); Add.Add(AccountRef.ToQBXML(nameof(AccountRef))); Add.Add(Amount.ToQBXML(nameof(Amount))); Add.Add(Memo.ToQBXML(nameof(Memo))); Add.Add(CustomerRef.ToQBXML(nameof(CustomerRef))); Add.Add(ClassRef.ToQBXML(nameof(ClassRef))); Add.Add(BillableStatus.ToQBXML(nameof(BillableStatus))); Add.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef))); Add.Add(DataExt.ToQBXML(nameof(DataExt))); return(Add); }
public string toXmlAdd() { string xml = "<InvoiceLineAdd>"; if (ItemRef != null) { xml += ItemRef.toXmlRef(); } if (Desc != "") { xml += "<Desc>" + Desc + "</Desc>"; } if (Quantity != null) { xml += "<Quantity>" + Functions.FloatToString((float)Quantity) + "</Quantity>"; } if (UnitOfMeasure != "") { xml += "<UnitOfMeasure>" + UnitOfMeasure + "</UnitOfMeasure>"; } if (Rate != null) { xml += "<Rate>" + Functions.FloatToString((float)Rate) + "</Rate>"; } else if (RatePercent != null) { xml += "<RatePercent>" + Functions.FloatToString((float)RatePercent) + "</RatePercent>"; } else if (PriceLevelRef != null) { xml += PriceLevelRef.toXmlRef(); } if (ClassRef != null) { xml += ClassRef.toXmlRef(); } if (Amount != null) { xml += "<Amount>" + Functions.FloatToString((float)Amount) + "</Amount>"; } if (InventorySiteRef != null) { xml += InventorySiteRef.toXmlRef(); } //OptionForPriceRuleConflict xml += "</InvoiceLineAdd>"; return(xml); }
//internal static ClassRef GetClass(string strClassName) //{ // if (string.IsNullOrEmpty(strClassName)) // strClassName = "Myexce"; // string str1 = Process.GetCurrentProcess().MainModule.FileName; // //Console.WriteLine(str1); // PEFile file = PEFile.ReadPEFile(str1); // string Assemblyname = System.IO.Path.GetFileNameWithoutExtension(str1); ; // AssemblyRef newAssemblyRef = file.MakeExternAssembly(Assemblyname); // ClassRef newMethodLoggerRef = TryGetMethodLoggerFromAssembly(newAssemblyRef, "MethodExecLogger"); // return newMethodLoggerRef; //} internal static bool GEtMethodsFromClass(ClassRef methodClass, string strMethodName, out Method TagetMethod) { TagetMethod = null; MethodRef tmpTagetMethod = methodClass.GetMethod(strMethodName); if (tmpTagetMethod != null) { TagetMethod = tmpTagetMethod; return(true); } return(false); }
private static IEnumerator process(TransforPointIndex originBorn, AnimationCurve pop, float popTime) { ColorScreen.Main.SetColor(Color.black, 0); var getFinished = SceneTransforer.Main.TransforToPoint(originBorn, 1); yield return(new WaitUntil(getFinished)); PlayerProperty.Main.born = originBorn; yield return(new WaitForSeconds(1)); Func <bool> xoCtrlConnected = () => { var names = Input.GetJoystickNames(); return(names.Length != 0 && names[0] != ""); }; var path = xoCtrlConnected() ? gamepadPath : keyboardPath; CameraSprite ctrlSprite = new CameraSprite("CtrlPadUI", path, Vector2.right); var originScale = ctrlSprite.transform.localScale; Func <float> getScale = () => ctrlSprite.transform.localScale.x / originScale.x; Action <float> setScale = (f) => ctrlSprite.transform.localScale = originScale * f; ClassRef <float> scaleRef = new ClassRef <float>(setScale, getScale); Time.timeScale = 0; scaleRef.set(0); float timeCount = 0; while (timeCount < 1) { yield return(null); timeCount += Time.unscaledDeltaTime / popTime; timeCount = Mathf.Clamp01(timeCount); scaleRef.set(pop.Evaluate(timeCount)); } yield return(new WaitUntil(() => Input.anyKey)); var s = getScale(); timeCount = 0; while (timeCount < 1) { yield return(null); timeCount += Time.unscaledDeltaTime / 0.3f; timeCount = Mathf.Clamp01(timeCount); scaleRef.set(Mathf.Lerp(s, 0, timeCount)); } ctrlSprite.Destroy(); Time.timeScale = 1; }
public XElement GenerateModRq() { XElement Mod = new XElement(nameof(ExpenseLine) + "Mod"); Mod.Add(TxnLineID.ToQBXML(nameof(TxnLineID))); Mod.Add(AccountRef.ToQBXML(nameof(AccountRef))); Mod.Add(Amount.ToQBXML(nameof(Amount))); Mod.Add(Memo.ToQBXML(nameof(Memo))); Mod.Add(CustomerRef.ToQBXML(nameof(CustomerRef))); Mod.Add(ClassRef.ToQBXML(nameof(ClassRef))); Mod.Add(BillableStatus.ToQBXML(nameof(BillableStatus))); Mod.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef))); return(Mod); }
internal static bool GetMethodsFromClass(string strClassName, string strMethodName, out Method TagetMethod) { if (string.IsNullOrEmpty(strClassName)) { strClassName = "MethodExecLogger"; } string str1 = "MethodExecLoggerLib.dll"; //Console.WriteLine(str1); PEFile file = PEFile.ReadPEFile(str1); string Assemblyname = System.IO.Path.GetFileNameWithoutExtension(str1);; AssemblyRef newAssemblyRef = file.MakeExternAssembly(Assemblyname); ClassRef newMethodLoggerRef = TryGetMethodLoggerFromAssembly(file, newAssemblyRef, "MethodExecLogger"); return(GEtMethodsFromClass(newMethodLoggerRef, strMethodName, out TagetMethod)); }
//private static bool GEtMethodsFromClass(ClassDef methodClass, string strMethodName, out Method TagetMethod) //{ // TagetMethod = null; // Method tmpTagetMethod = methodClass.GetMethodDesc(strMethodName); // if (tmpTagetMethod != null) // { // TagetMethod = tmpTagetMethod; // return true; // } // return false; //} private static bool GetLoggerMethodsFromClass(ClassRef methodLogger, out Method startLogMethod, out Method endLogMethod) { startLogMethod = endLogMethod = null; MethodRef tempStartLogMethod = methodLogger.GetMethod(startLogMethodName); MethodRef tempEndLogMethod = methodLogger.GetMethod(endLogMethodName); if (tempStartLogMethod != null && tempEndLogMethod != null) { if (CheckLogMethodParameters(tempStartLogMethod.GetParTypes()) && CheckLogMethodParameters(tempEndLogMethod.GetParTypes())) { startLogMethod = tempStartLogMethod; endLogMethod = tempEndLogMethod; return(true); } } return(false); }
/// <summary> /// Find the Field for this field on the given type. /// </summary> internal Field findField(string qname, string fieldName, string fieldType) { string key = qname + "/F" + fieldName; Field field = (Field)fields[key]; if (field == null) { // should be same for both cases PERWAPI.Type ftype = findType(fieldType); // check for stubs object obj = findType(qname); if (obj is ClassDef) { // class is an internal stub, so we need to stub this field // out too, which is actually complete and not a stub ClassDef cdef = obj as ClassDef; // TODO - fix attr field = cdef.AddField(FieldAttr.Public, fieldName, ftype); } else if (obj is ClassRef) { // class is external, just get or add ref ClassRef cref = obj as ClassRef; field = cref.GetField(fieldName); if (field == null) { field = cref.AddField(fieldName, ftype); } } else { throw new System.Exception("Don't know how to handle: " + obj.GetType()); } // remember to add field to lookup table fields[key] = field; } return(field); }
public string toXmlAdd() { if (Amount > 0) { string xml = Environment.NewLine + "<ExpenseLineAdd>"; if (AccountRef != null) { xml += Environment.NewLine + AccountRef.toXmlRef(); } System.Globalization.CultureInfo myInfo = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB"); xml += Environment.NewLine + "<Amount>" + Amount.ToString("0.00", myInfo) + "</Amount>"; if (Memo != string.Empty) { xml += Environment.NewLine + "<Memo>" + Memo + "</Memo>"; } if (CustomerRef != null) { xml += CustomerRef.toXmlRef(); } if (ClassRef != null) { xml += ClassRef.toXmlRef(); } if (BillableStatus != null && BillableStatus != string.Empty) { xml += Environment.NewLine + "<BillableStatus>" + BillableStatus + "</BillableStatus> "; } xml += Environment.NewLine + "</ExpenseLineAdd>"; return(xml); } else { return(string.Empty); } }
public XElement ToQBXML(string name, BaseRef OverrideItemAccountRef = null) { XElement xElement = new XElement(name); xElement.Add(TxnLineID.ToQBXML(nameof(TxnLineID))); xElement.Add(ItemRef.ToQBXML(nameof(ItemRef))); xElement.Add(InventorySiteRef.ToQBXML(nameof(InventorySiteRef))); xElement.Add(InventorySiteLocationRef.ToQBXML(nameof(InventorySiteLocationRef))); xElement.Add(SerialNumber.ToQBXML(nameof(SerialNumber))); xElement.Add(LotNumber.ToQBXML(nameof(LotNumber))); xElement.Add(Desc.ToQBXML(nameof(Desc))); xElement.Add(UnitOfMeasure.ToQBXML(nameof(UnitOfMeasure))); xElement.Add(OverrideUOMSetRef.ToQBXML(nameof(OverrideUOMSetRef))); xElement.Add(Cost.ToQBXML(nameof(Cost))); xElement.Add(Amount.ToQBXML(nameof(Amount))); xElement.Add(CustomerRef.ToQBXML(nameof(CustomerRef))); xElement.Add(ClassRef.ToQBXML(nameof(ClassRef))); xElement.Add(BillableStatus.ToQBXML(nameof(BillableStatus))); xElement.Add(OverrideItemAccountRef.ToQBXML(nameof(OverrideItemAccountRef))); xElement.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef))); return(xElement); }
//public static bool LocateLoggerMethods(PEFile file, string assemblyName, string className, out Method startLogMethod, out Method endLogMethod) //{ // startLogMethod = endLogMethod = null; // // Check if it is in this assembly itself // if (file.GetThisAssembly().Name() == assemblyName) // { // ClassDef methodLogger = file.GetClass(className); // if (methodLogger != null) // { // return GetLoggerMethodsFromClass(methodLogger, out startLogMethod, out endLogMethod); // } // } // // Check referenced assemblies // foreach (AssemblyRef assemblyRef in file.GetImportedAssemblies()) // { // if (assemblyRef.Name() == assemblyName) // { // ClassRef methodLoggerRef = TryGetMethodLoggerFromAssembly(assemblyRef, className); // if (methodLoggerRef != null) // { // if (GetLoggerMethodsFromClass(methodLoggerRef, out startLogMethod, out endLogMethod)) // return true; // } // } // } // // Not found in this assembly or referenced assemblies. Try loading given assembly and adding it as reference // AssemblyRef newAssemblyRef = file.MakeExternAssembly(assemblyName); // ClassRef newMethodLoggerRef = TryGetMethodLoggerFromAssembly(newAssemblyRef, className); // if (newMethodLoggerRef != null) // { // if (GetLoggerMethodsFromClass(newMethodLoggerRef, out startLogMethod, out endLogMethod)) // return true; // } // return false; //} private static ClassRef TryGetMethodLoggerFromAssembly(PEFile pef, AssemblyRef assemblyRef, string className) { //string fileName = ""; //if (assemblyRef.Name().ToLower().EndsWith(".dll")|| assemblyRef.Name().ToLower().EndsWith(".exe")) // fileName = assemblyRef.Name(); //else // fileName = assemblyRef.Name() + ".exe"; ////Console.WriteLine("TryGetMethodLoggerFromAssembly ->" + fileName); //if (!System.IO.File.Exists(fileName)) //{ // Console.WriteLine(fileName + " not present in current directory. Skipping it in search"); // return null; //} PEFile refFile = pef;//PEFile.ReadPEFile(fileName); ClassDef methodLogger = refFile.GetClass(className); if (methodLogger != null) { ClassRef methodLoggerRef = methodLogger.MakeRefOf(); if (assemblyRef.GetClass(className) == null) { assemblyRef.AddClass(methodLoggerRef); } System.Array.ForEach(methodLogger.GetMethods(), delegate(MethodDef methodDef) { if (methodLoggerRef.GetMethod(methodDef.Name()) == null) { methodLoggerRef.AddMethod(methodDef.Name(), methodDef.GetRetType(), methodDef.GetParTypes()); } }); return(methodLoggerRef); } return(null); }
public virtual XElement GenerateModRq(BaseRef OverrideItemAccountRef = null) { XElement xElement = new XElement(nameof(ItemLine) + "Mod"); xElement.Add(TxnLineID.ToQBXML(nameof(TxnLineID))); xElement.Add(ItemRef.ToQBXML(nameof(ItemRef))); xElement.Add(InventorySiteRef.ToQBXML(nameof(InventorySiteRef))); xElement.Add(InventorySiteLocationRef.ToQBXML(nameof(InventorySiteLocationRef))); xElement.Add(SerialNumber.ToQBXML(nameof(SerialNumber))); xElement.Add(LotNumber.ToQBXML(nameof(LotNumber))); xElement.Add(Desc.ToQBXML(nameof(Desc))); xElement.Add(Quantity.ToQBXML(nameof(Quantity))); xElement.Add(UnitOfMeasure.ToQBXML(nameof(UnitOfMeasure))); xElement.Add(OverrideUOMSetRef.ToQBXML(nameof(OverrideUOMSetRef))); xElement.Add(Cost.ToQBXML(nameof(Cost))); xElement.Add(Amount.ToQBXML(nameof(Amount))); xElement.Add(CustomerRef.ToQBXML(nameof(CustomerRef))); xElement.Add(ClassRef.ToQBXML(nameof(ClassRef))); xElement.Add(BillableStatus.ToQBXML(nameof(BillableStatus))); xElement.Add(OverrideItemAccountRef.ToQBXML(nameof(OverrideItemAccountRef))); xElement.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef))); return(xElement); }
public XElement GenerateModRq(bool?ForceUOMChange = null, bool?ApplyIncomeAccountRefToExistingTxns = null, bool?ApplyCOGSAccountRefToExistingTxns = null) { XElement Mod = new XElement(typeof(ItemInventory).Name + "Mod"); Mod.Add(ListID?.ToQBXML(nameof(ListID))); Mod.Add(EditSequence?.ToQBXML(nameof(EditSequence))); Mod.Add(Name?.ToQBXML(nameof(Name))); Mod.Add(BarCode?.ToQBXML(nameof(BarCode))); Mod.Add(IsActive.ToQBXML(nameof(IsActive))); Mod.Add(ClassRef?.ToQBXML(nameof(ClassRef))); Mod.Add(ParentRef?.ToQBXML(nameof(ParentRef))); Mod.Add(ManufacturerPartNumber?.ToQBXML(nameof(ManufacturerPartNumber))); Mod.Add(UnitOfMeasureSetRef?.ToQBXML(nameof(UnitOfMeasureSetRef))); Mod.Add(ForceUOMChange?.ToQBXML(nameof(ForceUOMChange))); Mod.Add(SalesTaxCodeRef?.ToQBXML(nameof(SalesTaxCodeRef))); Mod.Add(SalesDesc?.ToQBXML(nameof(SalesDesc))); Mod.Add(SalesPrice?.ToQBXML(nameof(SalesPrice))); Mod.Add(IncomeAccountRef?.ToQBXML(nameof(IncomeAccountRef))); Mod.Add(ApplyIncomeAccountRefToExistingTxns?.ToQBXML(nameof(ApplyIncomeAccountRefToExistingTxns))); Mod.Add(PurchaseDesc?.ToQBXML(nameof(PurchaseDesc))); Mod.Add(PurchaseCost?.ToQBXML(nameof(PurchaseCost))); Mod.Add(COGSAccountRef?.ToQBXML(nameof(COGSAccountRef))); Mod.Add(ApplyCOGSAccountRefToExistingTxns?.ToQBXML(nameof(ApplyCOGSAccountRefToExistingTxns))); Mod.Add(PrefVendorRef?.ToQBXML(nameof(PrefVendorRef))); Mod.Add(AssetAccountRef?.ToQBXML(nameof(AssetAccountRef))); Mod.Add(ReorderPoint?.ToQBXML(nameof(ReorderPoint))); Mod.Add(Max?.ToQBXML(nameof(Max))); XElement ModRq = new XElement(typeof(ItemInventory).Name + "ModRq", Mod); foreach (var value in IncludeRetElement) { ModRq.Add(value.ToQBXML(nameof(IncludeRetElement))); } return(ModRq); }
private void ProcessInvoice(VendIvc invoice, ApexDataDataContext apexData) { PO po = apexData.POs.Where(s => s.Po1 == invoice.PO).SingleOrDefault(); //get the corresponding P/O if (po == null) { _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = "The invoice points to an invalid P/O!?" }); return; } if (po.Vendor == null) { _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = "There is no vendor on this P/O" }); return; } Job job = apexData.Jobs.Where(s => s.Job1 == po.Job).SingleOrDefault(); //get the job if (job == null) { _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = "There is no job on this P/O" }); return; } QBJob qbjob = apexData.QBJobs.Where(s => s.ApexCompany == _ApexTargetCompany && s.ApexJobID == po.Job).SingleOrDefault(); if (qbjob == null) { _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = "This P/O has an invalid QuickBooks job reference" }); return; } QBVendor qbvendor = apexData.QBVendors.Where(s => s.ApexCompany == _ApexTargetCompany && s.ApexVendorID == po.Vendor).SingleOrDefault(); if (qbvendor == null) { _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = "This P/O has an invalid QuickBooks vendor reference" }); return; } var qbxml = new QBXML(); qbxml.ItemsElementName = new ItemsChoiceType99[1] { ItemsChoiceType99.QBXMLMsgsRq }; var qbMsgsRq = new QBXMLMsgsRq(); qbMsgsRq.onError = QBXMLMsgsRqOnError.continueOnError; var billaddrq = new BillAddRqType(); billaddrq.requestID = "1"; TermsRef termsref = new TermsRef { FullName = po.VendorTerms }; string ApexGLRef = apexData.Costcodes .Where(s => s.Schedule == "STD" && s.CostCode1 == po.POLines.Select(l => l.CostCode).FirstOrDefault()) .Select(s => s.GL).FirstOrDefault(); if (String.IsNullOrEmpty(ApexGLRef)) { ApexGLRef = "M"; } string QBGLAcctFullName = GLAcctUtility.GLAcctList .Where(s => s.ApexCompany == _ApexTargetCompany && s.ApexGLRef == ApexGLRef) .Select(s => s.QBGLAcctFullName).SingleOrDefault(); AccountRef accountref = new AccountRef { FullName = QBGLAcctFullName }; AccountRef creditaccountref = new AccountRef { FullName = "Cash Discount on Payables" }; //Classes in QuickBooks equate to Divisions in Apex for this client ClassRef classref = new ClassRef { FullName = apexData.Divisions.Where(s => s.Company == po.Company && s.Division1 == po.Division).Select(s => s.Name).SingleOrDefault() }; CustomerRef customerref = new CustomerRef { ListID = qbjob.QBListID }; ExpenseLineAdd expenseline = new ExpenseLineAdd { AccountRef = accountref, Amount = invoice.IvcAmt?.ToString("F2"), CustomerRef = customerref, Memo = job.Job1 + " " + qbjob.QBJobName.Substring(0, qbjob.QBJobName.IndexOf(':')) }; if (classref.FullName != null) { expenseline.ClassRef = classref; } ExpenseLineAdd[] expenseLines; if ((invoice.Discount ?? 0) != 0) //Add an expense line for the discount amount if the discount is not zero { ExpenseLineAdd creditexpenseline = new ExpenseLineAdd { AccountRef = creditaccountref, Amount = (0 - invoice.Discount ?? 0).ToString("F2"), ClassRef = classref, Memo = job.Job1 + " " + qbjob.QBJobName.Substring(0, qbjob.QBJobName.IndexOf(':')) }; expenseLines = new ExpenseLineAdd[2]; expenseLines[0] = expenseline; expenseLines[1] = creditexpenseline; } else { expenseLines = new ExpenseLineAdd[1]; expenseLines[0] = expenseline; } VendorRef vendorref = new VendorRef { ListID = qbvendor.QBListID }; var billadd = new BillAdd { DueDate = invoice.PayDate?.ToString("yyyy-MM-dd"), Memo = "From Apex", RefNumber = invoice.Invoice, TermsRef = termsref, TxnDate = invoice.IvcDate?.ToString("yyyy-MM-dd"), ExpenseLineAdd = expenseLines, VendorRef = vendorref }; qbMsgsRq.Items = new object[1] { billaddrq }; qbxml.Items = new object[1] { qbMsgsRq }; billaddrq.BillAdd = billadd; XmlSerializer serializer = new XmlSerializer(typeof(QBXML)); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); //Don't use a namespace in the XML for QuickBooks MemoryStream ms = new MemoryStream(); serializer.Serialize(ms, qbxml, ns); ms.Seek(0, SeekOrigin.Begin); var sr = new StreamReader(ms); string xmlRequest = sr.ReadToEnd(); xmlRequest = xmlRequest.Replace("<?xml version=\"1.0\"?>", "<?xml version=\"1.0\"?><?qbxml version=\"4.0\"?>"); if (DEBUGMODE) { File.WriteAllText("c:\\QB\\BillAddQBXML.xml", xmlRequest); } _Response = _Rp.ProcessRequest(_Ticket, xmlRequest); if (DEBUGMODE) { File.WriteAllText("c:\\QB\\BillAddResponse.xml", _Response); } QBXML rsXML = GetQbxml(serializer); string message = ((BillAddRsType)((QBXMLMsgsRs)rsXML?.Items?[0])?.Items?[0]).statusMessage; string statuscode = ((BillAddRsType)((QBXMLMsgsRs)rsXML?.Items?[0])?.Items?[0]).statusCode; _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = message, StatusCode = statuscode }); if (statuscode == "0") //Apex's part is done now that the invoice has been successfully sent to QuickBooks to be paid { QBInvoice qbIvc = new QBInvoice { Invoice = invoice.Invoice, PO = invoice.PO, SentDate = DateTime.Now }; apexData.QBInvoices.InsertOnSubmit(qbIvc); invoice.IvcStatus = "P"; apexData.SubmitChanges(); } }
public static ClassRef <Color> SRGBToLiner(ClassRef <Color> srgb) { return(new ClassRef <Color>((c) => srgb.set(VectorUtils.Do(c, f => Mathf.Pow(f, 1 / 2.2f))), () => VectorUtils.Do(srgb.get(), f => Mathf.Pow(f, 2.2f)))); }