public static void DeleteUserDefined(long id) { UserDefined userDefined = userDefinedRepository.GetById(id); if (userDefined != null) { userDefinedRepository.Delete(userDefined); } }
public ActionResult UserDefinedAdd(string description) { if (!string.IsNullOrEmpty(description)) { UserDefined userDefined = UserDefinedFactory.Create(description, CurrentManager.Id, CurrentManager.ParentId != 0 ? CurrentManager.ParentId : CurrentManager.Id); BaseService.SaveUserDefined(userDefined); } return(RedirectToAction("UserDefinedList")); }
private void setCookies(UserDefined data) { //if (data.Cookies.Count > 0) //{ var container = new CookieContainer(); container.Add(data.Cookies); request.CookieContainer = container; //} }
public void RefreshData(RWSystem rwSystem) { RapidData rPipeGrooveModel = rwSystem.Controller.Rapid.GetRapidData(strTaskName, strDataModuleName, strDataName); RapidDataType rPipeGrooveModelType = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType); UserDefined rPipeGrooveModelUserDefine = new UserDefined(rPipeGrooveModelType); rPipeGrooveModelUserDefine.FillFromString(rPipeGrooveModel.Value.ToString()); int i = 0; this.numIndex = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numPipeGrooveType = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numSeamCenterX = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numSeamNormalAngle = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numHeaderDiameter = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numHeaderThickness = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numHeaderMaterial = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numBranchDiameter = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numBranchThickness = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numBranchMaterial = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numMultiPassTotal = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numCooperativeRobots = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numPathSource = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numReviseScanBranchType = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numReviseScanHeaderType = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numWeldLegWidth = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numGrooveGap = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numBranchGrooveRoot = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numBranchGrooveAngle = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numBranchGrooveAngle90 = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numTopHeight90 = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numBottomHeight90 = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numProfCosine = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numLayerHeight = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numLayerPassTotalRoundType = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.numAlgorithmType = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.boolContinuous = bool.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.boolUseAlignedSTNbyFixedValue = bool.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString()); this.strID = rPipeGrooveModelUserDefine.Components[i++].ToString(); this.strRemark = rPipeGrooveModelUserDefine.Components[i++].ToString(); rPipeGrooveModelUserDefine.Dispose(); rPipeGrooveModelType.Dispose(); rPipeGrooveModel.Dispose(); }
public void Write_ABB_DataRecord(string Data_Record_Name, string Module_Name, string Task_Name, Controller aController, List <string> Variables, int ArrayIndex) { string L_Module_Name = Module_Name; string L_Task_Name = Task_Name; string L_Data_Record_Name = Data_Record_Name; List <string> _Variables = Variables; Controller L_aController = aController; int _ArrayIndex = ArrayIndex; string _info; try { //Get the array with the records rd_array = aController.Rapid.GetRapidData(Task_Name, Module_Name, "RawIndividuals"); ad = (ArrayData)rd_array.Value; int aRank = ad.Rank; //Read the record rd = L_aController.Rapid.GetRapidData(Task_Name, Module_Name, L_Data_Record_Name); rdt = L_aController.Rapid.GetRapidDataType(L_Task_Name, L_Module_Name, L_Data_Record_Name); UserDefined processdata = new UserDefined(rdt); //Prepare the parameters for (int i = 0; i < 5; i++) { processdata.Components[i].FillFromString(_Variables[i]); } //Add the parameters to the array rd_array.Value = ad; ad[ArrayIndex] = processdata; } catch (ABB.Robotics.Controllers.RapidDomain.RapidModuleNotFoundException ee) { _info = "Error: " + ee.Message; } catch (ABB.Robotics.Controllers.RapidDomain.RapidSymbolNotFoundException ee) { _info = "Error: " + ee.Message; } catch (ABB.Robotics.GenericControllerException ee) { _info = "Error: " + ee.Message; } catch (System.Exception ee) { _info = "Error: " + ee.Message; } finally { // Release resources } }
public ActionResult UserDefinedEdit(long id, string description) { if (id != 0 && !string.IsNullOrEmpty(description)) { UserDefined userDefined = BaseService.GetUserDefinedById(id); userDefined.Description = description; BaseService.SaveUserDefined(userDefined); return(Json(InfoTools.GetMsgInfo(ResponseCode.Ok))); } return(Json(InfoTools.GetMsgInfo(ResponseCode.DataError), JsonRequestBehavior.AllowGet)); }
public void RefreshData(RWSystem rwSystem, int intGroupIndex, int intIndex) { this.intGroupIndex = intGroupIndex; this.intIndex = intIndex; RapidData rWeldProcedureArray = rwSystem.Controller.Rapid.GetRapidData(strTaskName, strDataModuleName, strDataName + this.intGroupIndex); //RapidDataType rWeldProcedureType = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType); UserDefined rWeldProcedure = (UserDefined)rWeldProcedureArray.ReadItem(this.intIndex); int i = 0; this.strWeldProcedureID = rWeldProcedure.Components[i++].ToString(); this.strWeldProcedureID = this.strWeldProcedureID.Substring(1, this.strWeldProcedureID.Length - 2); this.numWeldSpeed = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numPreFlow = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numSche = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numTrackCurrent = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numPostFlow = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numWeaveShape = int.Parse(rWeldProcedure.Components[i++].ToString()); this.numWeaveType = int.Parse(rWeldProcedure.Components[i++].ToString()); this.numWeaveLength = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numWeaveWidth = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numWeaveHeigth = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numDwellLeft = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numDwellCenter = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numDwellRight = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numWeaveDir = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numWeaveTilt = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numWeaveOri = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numWeaveBias = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numTrackType = int.Parse(rWeldProcedure.Components[i++].ToString()); this.numGainY = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numGainZ = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numPenetration = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numTrackBias = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.numWeaveWidth90 = decimal.Parse(rWeldProcedure.Components[i++].ToString()); this.strRemark = rWeldProcedure.Components[i++].ToString(); this.strRemark = this.strRemark.Substring(1, this.strRemark.Length - 2); //rWeldProcedureType.Dispose(); rWeldProcedure.Dispose(); rWeldProcedureArray.Dispose(); }
/// <summary>Connects this Rule to it's property.</summary> /// <param name="vs">The parent <see cref="RuleSet" />.</param> /// Element created at 07/11/2014,6:19 AM by Charles internal void Connect(RuleSet vs) { Host = vs; UserDefined = UserDefined ?? string.Empty; _predicates = AvailablePredicates.Where(x => x.IsA(Validators)) .Union( _userValidatorPredicates.Where( x => UserDefined.ToLower().Contains(x.UserName.ToLower()))) .OrderBy(y => y.Priority) .Select(z => z.Predicate).ToList(); Element.PropertyChanged += ElementPropertyChanged; }
public void ApplyData(RWSystem rwSystem) { RapidData rPipeGrooveModel = rwSystem.Controller.Rapid.GetRapidData(strTaskName, strDataModuleName, strDataName); RapidDataType rPipeGrooveModelType = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType); UserDefined rPipeGrooveModelUserDefine = new UserDefined(rPipeGrooveModelType); rPipeGrooveModelUserDefine.FillFromString(this.ToString()); ErrorHandler.AddErrorMessage("MichaelLog", this.ToString()); rPipeGrooveModel.Value = rPipeGrooveModelUserDefine; rPipeGrooveModelUserDefine.Dispose(); rPipeGrooveModelType.Dispose(); rPipeGrooveModel.Dispose(); }
//Functions public string Read_ABB_DataRecord(string Data_Record_Name, string Module_Name, string Task_Name, Controller aController, int ArrayIndex) { string Data_Records_Time = " "; string L_Module_Name = Module_Name; string L_Task_Name = Task_Name; string L_Data_Record_Name = Data_Record_Name; Controller L_aController = aController; string _info; try { //Get the array with the records rd_array = aController.Rapid.GetRapidData(Task_Name, Module_Name, "RawIndividuals"); ad = (ArrayData)rd_array.Value; int aRank = ad.Rank; //Read the record rd = L_aController.Rapid.GetRapidData(Task_Name, Module_Name, L_Data_Record_Name); rdt = L_aController.Rapid.GetRapidDataType(L_Task_Name, L_Module_Name, L_Data_Record_Name); UserDefined processdata = new UserDefined(rdt); processdata = (UserDefined)ad[ArrayIndex]; //Get the time elapsed using the individual's parameters Data_Records_Time = processdata.Components[5].ToString(); return(Data_Records_Time); } catch (ABB.Robotics.Controllers.RapidDomain.RapidModuleNotFoundException ee) { return(_info = "Error: " + ee.Message); } catch (ABB.Robotics.Controllers.RapidDomain.RapidSymbolNotFoundException ee) { return(_info = "Error: " + ee.Message); } catch (ABB.Robotics.GenericControllerException ee) { return(_info = "Error: " + ee.Message); } catch (System.Exception ee) { return(_info = "Error: " + ee.Message); } finally { // } }
public void ApplyData(RWSystem rwSystem) { RapidData rLayerParameter = rwSystem.Controller.Rapid.GetRapidData(strTaskName, strDataModuleName, string.Format("{0}{1:00}", strDataName, this.intLayerNo)); RapidDataType rLayerParameterType = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType); UserDefined rLayerParameterUserDefine = new UserDefined(rLayerParameterType); rLayerParameterUserDefine.FillFromString(this.ToString()); ErrorHandler.AddErrorMessage("MichaelLog", this.ToString()); rLayerParameter.Value = rLayerParameterUserDefine; rLayerParameterUserDefine.Dispose(); rLayerParameterType.Dispose(); rLayerParameter.Dispose(); }
public void ApplyData(RWSystem rwSystem) { RapidData rWeldProcedureArray = rwSystem.Controller.Rapid.GetRapidData(strTaskName, strDataModuleName, strDataName + this.intGroupIndex); //RapidDataType rWeldProcedureType = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType); UserDefined rWeldProcedure = (UserDefined)rWeldProcedureArray.ReadItem(this.intIndex); rWeldProcedure.FillFromString(this.ToString()); ErrorHandler.AddErrorMessage("MichaelLog", this.ToString()); rWeldProcedureArray.WriteItem(rWeldProcedure, this.intIndex); //rWeldProcedureType.Dispose(); rWeldProcedure.Dispose(); rWeldProcedureArray.Dispose(); }
private Curl_HttpReq setRequestMethod(UserDefined data) { Curl_HttpReq httpreq = data.Httpreq; if ( // (conn->handler->protocol&(CURLPROTO_HTTP|CURLPROTO_FTP)) && //(MB) I'm handeling http request, so I don't need to check this data.Upload) { httpreq = Curl_HttpReq.PUT; } // Now set the request.Method to the proper request string if (data.Str[(int)DupString.CUSTOMREQUEST] != null) { request.Method = PhpVariable.AsString(data.Str[(int)DupString.CUSTOMREQUEST]); } else { if (data.OptNoBody) { request.Method = "HEAD"; } else { switch (httpreq) { case Curl_HttpReq.POST: case Curl_HttpReq.POST_FORM: request.Method = "POST"; break; case Curl_HttpReq.PUT: request.Method = "PUT"; break; default: /* this should never happen */ case Curl_HttpReq.GET: request.Method = "GET"; break; case Curl_HttpReq.HEAD: request.Method = "HEAD"; break; } } } return(httpreq); }
private void setCredentials(UserDefined data) { if (data.Str[(int)DupString.USERNAME] != null) { //This is obvious way, but unfortunatelly it doesn't work //httpauth set to CURLAUTH_ANY is .NET default because it will use right authentication protocol //request.Credentials = new NetworkCredential( // PhpVariable.AsString(data.Str[(int)DupString.USERNAME]), // data.Str[(int)DupString.PASSWORD] != null ? PhpVariable.AsString(data.Str[(int)DupString.PASSWORD]) : String.Empty); //We only support BASIC HttpUtils.SetBasicAuthHeader(request, PhpVariable.AsString(data.Str[(int)DupString.USERNAME]), data.Str[(int)DupString.PASSWORD] != null ? PhpVariable.AsString(data.Str[(int)DupString.PASSWORD]) : String.Empty); } }
public static void MoveEnquiryToUseDefine(long enquiryId, long useDefineId) { Enquiry enquiry = enquiryRepository.GetById(enquiryId); if (enquiry != null) { enquiry.UserDefinedId = 0; enquiry.UserDefinedName = string.Empty; UserDefined userDefined = userDefinedRepository.GetById(useDefineId); if (userDefined != null) { enquiry.UserDefinedId = userDefined.Id; enquiry.UserDefinedName = userDefined.Description; } enquiryRepository.Save(enquiry); } }
private void setHttpVersion(UserDefined data) { switch (data.HttpVersion) { //case CurlHttpVersion.CURL_HTTP_VERSION_NONE: //case CurlHttpVersion.CURL_HTTP_VERSION_LAST: // do nothing, default will be used // break; case CurlHttpVersion.CURL_HTTP_VERSION_1_0: request.ProtocolVersion = HttpVersion.Version10; break; case CurlHttpVersion.CURL_HTTP_VERSION_1_1: request.ProtocolVersion = HttpVersion.Version11; break; } }
public void RefreshData(RWSystem rwSystem, string strCircle) { RapidDataType rCircleType = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType); UserDefined rCircleUserDefine = new UserDefined(rCircleType); rCircleUserDefine.FillFromString(strCircle); int i = 0; this.numDegree0 = decimal.Parse(rCircleUserDefine.Components[i++].ToString()); //ErrorHandler.AddErrorMessage("MichaelLog", rCircleUserDefine.Components[i].ToString()); this.numDegree90 = decimal.Parse(rCircleUserDefine.Components[i++].ToString()); this.numDegree180 = decimal.Parse(rCircleUserDefine.Components[i++].ToString()); this.numDegree270 = decimal.Parse(rCircleUserDefine.Components[i++].ToString()); this.numCurveType = int.Parse(rCircleUserDefine.Components[i++].ToString()); rCircleUserDefine.Dispose(); rCircleType.Dispose(); }
private void setTimeOut(UserDefined data) { // Curl default is 300000 milliseconds == five minutes // .NET default is 100000 milliseconds, we'll leave it there as a default int timeout_set = 0; if (data.Timeout > 0) { timeout_set |= 1; } if (data.ConnectTimeout > 0) { timeout_set |= 2; } switch (timeout_set) { case 1: request.Timeout = data.Timeout; break; case 2: request.Timeout = data.ConnectTimeout; break; case 3: if (data.Timeout < data.ConnectTimeout) { request.Timeout = data.Timeout; } else { request.Timeout = data.ConnectTimeout; } break; } }
private void setProxy(UserDefined data) { string proxyAddress; WebProxy myProxy; if (data.Str[(int)DupString.PROXY] == null) { return; } if (data.ProxyType != CURLproxyType.CURLPROXY_HTTP) { return; } myProxy = new WebProxy(); proxyAddress = PhpVariable.AsString(data.Str[(int)DupString.PROXY]); // Create a new Uri object. Uri uri = Utils.CompleteUri(proxyAddress, Scheme, data.ProxyPort); // Associate the newUri object to 'myProxy' object so that new myProxy settings can be set. myProxy.Address = uri; // Create a NetworkCredential object and associate it with the // Proxy property of request object. if (data.Str[(int)DupString.PROXYUSERNAME] != null) { //data.proxyauth set to CURLAUTH_ANY is .NET default because it will use right authentication protocol myProxy.Credentials = new NetworkCredential( PhpVariable.AsString(data.Str[(int)DupString.PROXYUSERNAME]), data.Str[(int)DupString.PROXYPASSWORD] != null ? PhpVariable.AsString(data.Str[(int)DupString.PROXYPASSWORD]) : String.Empty); } request.Proxy = myProxy; }
//ORIGINAL void Curl_flush_cookies(struct SessionHandle *data, int cleanup) public static void FlushCookies(UserDefined data /*, int cleanup*/) { string cookieJar = data.Str[(int)DupString.COOKIEJAR] as string; if (!String.IsNullOrEmpty(cookieJar)) { var cookies = data.Cookies; string fullPath = Path.Combine(ScriptContext.CurrentContext.WorkingDirectory, cookieJar); //TODO: check the file lock Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); try { CookieOutput(cookies, cookieJar); } catch (Exception ex) { // do nothing PhpException.Throw(PhpError.Warning, String.Format("WARNING: failed to save cookies in {0}; {1}\n", cookieJar, ex.Message)); } // } // else { // if(cleanup && data->change.cookielist) // /* since nothing is written, we can just free the list of cookie file // names */ // curl_slist_free_all(data->change.cookielist); /* clean up list */ // Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); // } // if(cleanup && (!data->share || (data->cookies != data->share->cookies))) { // Curl_cookie_cleanup(data->cookies); // } // Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); } }
static Conversion FindConversation_Match(List <UserDefined> collection, Type sx, Type tx, ITypeMapper typeMapper) { if (sx == null || tx == null) { return(new Ambiguous(typeMapper)); } Conversion match = null; for (int i = 0; i < collection.Count; i++) { UserDefined udc = collection[i]; if (udc._fromType == sx && udc._toType == tx) { if (match != null) { return(new Ambiguous(typeMapper)); // ambiguous match } match = udc; } } return(match ?? new Ambiguous(typeMapper)); }
public void RefreshData(RWSystem rwSystem, int intLayerNo) { this.intLayerNo = intLayerNo; RapidData rLayerParameter = rwSystem.Controller.Rapid.GetRapidData(strTaskName, strDataModuleName, string.Format("{0}{1:00}", strDataName, this.intLayerNo)); RapidDataType rLayerParameterType = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType); UserDefined rLayerParameterUserDefine = new UserDefined(rLayerParameterType); rLayerParameterUserDefine.FillFromString(rLayerParameter.Value.ToString()); int i = 0; this.numWorkAngleDeclination = int.Parse(rLayerParameterUserDefine.Components[i++].ToString()); //ErrorHandler.AddErrorMessage("MichaelLog", rLayerParameterUserDefine.Components[i].ToString()); this.rCircleOffsetX.RefreshData(rwSystem, rLayerParameterUserDefine.Components[i++].ToString()); this.rCircleOffsetZ.RefreshData(rwSystem, rLayerParameterUserDefine.Components[i++].ToString()); this.rCircleRotationX.RefreshData(rwSystem, rLayerParameterUserDefine.Components[i++].ToString()); this.rCircleRotationY.RefreshData(rwSystem, rLayerParameterUserDefine.Components[i++].ToString()); this.rCircleRotationZ.RefreshData(rwSystem, rLayerParameterUserDefine.Components[i++].ToString()); this.strLayerParameterID = rLayerParameterUserDefine.Components[i++].ToString(); this.strLayerParameterID = this.strLayerParameterID.Substring(1, this.strLayerParameterID.Length - 2); rLayerParameterUserDefine.Dispose(); rLayerParameterType.Dispose(); rLayerParameter.Dispose(); //DataRow row = this.CircleTable.Rows.Find("OffsetX"); //row[1] = this.circleOffsetX.numDegree0; //row[2] = this.circleOffsetX.numDegree90; //row[3] = this.circleOffsetX.numDegree180; //row[4] = this.circleOffsetX.numDegree270; //row[5] = this.circleOffsetX.numCurveType; //row = this.CircleTable.Rows.Find("OffsetZ"); //row[1] = this.circleOffsetZ.numDegree0; //row[2] = this.circleOffsetZ.numDegree90; //row[3] = this.circleOffsetZ.numDegree180; //row[4] = this.circleOffsetZ.numDegree270; //row[5] = this.circleOffsetZ.numCurveType; //row = this.CircleTable.Rows.Find("RotationX"); //row[1] = this.circleRotationX.numDegree0; //row[2] = this.circleRotationX.numDegree90; //row[3] = this.circleRotationX.numDegree180; //row[4] = this.circleRotationX.numDegree270; //row[5] = this.circleRotationX.numCurveType; //row = this.CircleTable.Rows.Find("RotationY"); //row[1] = this.circleRotationY.numDegree0; //row[2] = this.circleRotationY.numDegree90; //row[3] = this.circleRotationY.numDegree180; //row[4] = this.circleRotationY.numDegree270; //row[5] = this.circleRotationY.numCurveType; //row = this.CircleTable.Rows.Find("RotationZ"); //row[1] = this.circleRotationZ.numDegree0; //row[2] = this.circleRotationZ.numDegree90; //row[3] = this.circleRotationZ.numDegree180; //row[4] = this.circleRotationZ.numDegree270; //row[5] = this.circleRotationZ.numCurveType; }
public static Conversion GetExplicit(Operand op, Type to, bool onlyStandard, ITypeMapper typeMapper) { // try implicit Conversion conv = GetImplicit(op, to, onlyStandard, typeMapper); if (conv.IsValid) { return(conv); } Type from = Operand.GetType(op, typeMapper); Type fromUnderlying = Helpers.GetNullableUnderlyingType(@from); if (fromUnderlying == to) { return(new UnwrapNullable(typeMapper)); } Type toUnderlying = Helpers.GetNullableUnderlyingType(to); if (toUnderlying != null && fromUnderlying != null) { var c = GetExplicit(new FakeTypedOperand(fromUnderlying), toUnderlying, onlyStandard, typeMapper); if (c.IsValid) { return(new ConvertNullable(typeMapper, c)); } } // section 6.3.2 - Standard explicit conversions if (onlyStandard) { if (from == null || !GetImplicit(to, @from, true, typeMapper).IsValid) { return(new Invalid(typeMapper)); } } TypeCode tcFrom = Type.GetTypeCode(from); TypeCode tcTo = Type.GetTypeCode(to); byte ct = _convTable[(int)tcFrom][(int)tcTo]; // section 6.2.1 - Explicit numeric conversions, 6.2.2 - Explicit enumeration conversions if ((from.IsPrimitive || from.IsEnum || Helpers.AreTypesEqual(from, typeof(decimal), typeMapper)) && (to.IsPrimitive || to.IsEnum || Helpers.AreTypesEqual(to, typeof(decimal), typeMapper))) { if (ct == D) { return(new Direct(typeMapper)); // this can happen for conversions involving enum-s } if (ct <= E) { if (Helpers.AreTypesEqual(from, typeof(decimal), typeMapper) || Helpers.AreTypesEqual(to, typeof(decimal), typeMapper)) { // decimal is handled as user-defined conversion, but as it is a standard one, always enable UDC processing onlyStandard = false; } else { return(new Primitive(typeMapper)); } } } // section 6.2.5 - User-defined explicit conversions (details in section 6.4.4) if (!(onlyStandard || Helpers.AreTypesEqual(from, typeof(object), typeMapper) || Helpers.AreTypesEqual(to, typeof(object), typeMapper) || from.IsInterface || to.IsInterface || to.IsSubclassOf(from) || from.IsSubclassOf(to))) { List <UserDefined> candidates = null; FindCandidates(ref candidates, FindExplicitMethods(from, to, typeMapper), op, to, GetExplicit, typeMapper); if (candidates != null) { if (candidates.Count == 1) { return(candidates[0]); } return(UserDefined.FindExplicit(candidates, @from, to, typeMapper)); } } // section 6.2.3 - Explicit reference conversions, 6.2.4 - Unboxing conversions // TODO: not really according to spec, but mostly works if (!from.IsValueType && from.IsAssignableFrom(to)) { if (to.IsValueType) { return(new Unboxing(typeMapper)); } else { return(new Cast(typeMapper)); } } return(new Invalid(typeMapper)); }
// the sections mentioned in comments of this method are from C# specification v1.2 public static Conversion GetImplicit(Operand op, Type to, bool onlyStandard, ITypeMapper typeMapper) { Type from = Operand.GetType(op, typeMapper); Type toUnderlying = Helpers.GetNullableUnderlyingType(to); if (to.Equals(from)) { return(new Direct(typeMapper)); } Type fromUnderlying = Helpers.GetNullableUnderlyingType(@from); if (toUnderlying != null) { if (fromUnderlying != null) { Conversion c = GetImplicit(new FakeTypedOperand(fromUnderlying), toUnderlying, onlyStandard, typeMapper); if (c.IsValid) { return(new ConvertNullable(typeMapper, c)); } } else { Conversion c = GetImplicit(op, toUnderlying, onlyStandard, typeMapper); if (c.IsValid) { return(new WrapNullable(typeMapper, c)); } } } // required for arrays created from TypeBuilder-s if (from != null && to.IsArray && from.IsArray) { if (to.GetArrayRank() == from.GetArrayRank()) { if (to.GetElementType().Equals(from.GetElementType())) { return(new Direct(typeMapper)); } } } TypeCode tcFrom = Type.GetTypeCode(from); TypeCode tcTo = Type.GetTypeCode(to); byte ct = _convTable[(int)tcFrom][(int)tcTo]; // section 6.1.2 - Implicit numeric conversions if (from != null && (from.IsPrimitive || Helpers.AreTypesEqual(from, typeof(decimal), typeMapper)) && (to.IsPrimitive || Helpers.AreTypesEqual(to, typeof(decimal), typeMapper))) { if (ct <= I) { if (Helpers.AreTypesEqual(from, typeof(decimal), typeMapper) || Helpers.AreTypesEqual(to, typeof(decimal), typeMapper)) { // decimal is handled as user-defined conversion, but as it is a standard one, always enable UDC processing onlyStandard = false; } else { return(new Primitive(typeMapper)); } } } IntLiteral intLit = op as IntLiteral; // section 6.1.3 - Implicit enumeration conversions if (!onlyStandard && to.IsEnum && (object)intLit != null && intLit.Value == 0) { return(new Primitive(typeMapper)); } // section 6.1.4 - Implicit reference conversions if ((from == null || !from.IsValueType) && !to.IsValueType) { if (from == null) // from the null type to any reference type { return(new Direct(typeMapper)); } if (to.IsAssignableFrom(from)) // the rest { return(new Direct(typeMapper)); } } if (from == null) // no other conversion from null type is possible { return(new Invalid(typeMapper)); } // section 6.1.5 - Boxing conversions if (from.IsValueType) { if (to.IsAssignableFrom(from)) { return(new Boxing(typeMapper)); } } // section 6.1.6 - Implicit constant expression conversions if ((object)intLit != null && Helpers.AreTypesEqual(from, typeof(int), typeMapper) && to.IsPrimitive) { int val = intLit.Value; switch (tcTo) { case TypeCode.SByte: if (val >= sbyte.MinValue && val <= sbyte.MaxValue) { return(new Direct(typeMapper)); } break; case TypeCode.Byte: if (val >= byte.MinValue && val <= byte.MaxValue) { return(new Direct(typeMapper)); } break; case TypeCode.Int16: if (val >= short.MinValue && val <= short.MaxValue) { return(new Direct(typeMapper)); } break; case TypeCode.UInt16: if (val >= ushort.MinValue && val <= ushort.MaxValue) { return(new Direct(typeMapper)); } break; case TypeCode.UInt32: if (val >= 0) { return(new Direct(typeMapper)); } break; case TypeCode.UInt64: if (val >= 0) { return(new Direct(typeMapper)); } break; } } // section 6.1.7 - User-defined implicit conversions (details in section 6.4.3) if (onlyStandard || Helpers.AreTypesEqual(from, typeof(object), typeMapper) || Helpers.AreTypesEqual(to, typeof(object), typeMapper) || from.IsInterface || to.IsInterface || to.IsSubclassOf(from) || from.IsSubclassOf(to)) { return(new Invalid(typeMapper)); // skip not-permitted conversion attempts (section 6.4.1) } List <UserDefined> candidates = null; FindCandidates(ref candidates, FindImplicitMethods(from, to, typeMapper), op, to, GetImplicit, typeMapper); if (candidates == null) { return(new Invalid(typeMapper)); } if (candidates.Count == 1) { return(candidates[0]); } return(UserDefined.FindImplicit(candidates, @from, to, typeMapper)); }
public static Conversion FindExplicit(List <UserDefined> collection, Type @from, Type to, ITypeMapper typeMapper) { Type sx = null, tx = null; bool sxSubset = false, txSubset = false; bool any = false; for (int i = 0; i < collection.Count; i++) { UserDefined udc = collection[i]; any = true; if (sx == null && udc._fromType == from) { sx = from; } if (tx == null && udc._toType == to) { tx = to; } if (udc._sxSubset = GetImplicit(@from, udc._fromType, true, typeMapper) != null) { sxSubset = true; } if (udc._txSubset = GetImplicit(udc._toType, to, true, typeMapper) != null) { txSubset = true; } } if (!any) { return(new Invalid(typeMapper)); } if (sx == null || tx == null) { for (int i = 0; i < collection.Count; i++) { UserDefined udc = collection[i]; bool sxMatch = sx == null && !sxSubset || udc._sxSubset; bool txMatch = tx == null && !txSubset || udc._txSubset; if (!(sxMatch || txMatch)) { continue; } for (int j = 0; j < collection.Count; j++) { UserDefined udc2 = collection[j]; if (udc2 == udc) { continue; } if (sxMatch) { if (sxSubset) { if (udc._sxSubset && GetImplicit(udc._fromType, udc2._fromType, true, typeMapper) == null) { sxMatch = false; } } else { if (GetImplicit(udc2._fromType, udc._fromType, true, typeMapper) == null) { sxMatch = false; } } } if (txMatch) { if (txSubset) { if (udc._txSubset && GetImplicit(udc2._toType, udc._toType, true, typeMapper) == null) { txMatch = false; } } else { if (GetImplicit(udc._toType, udc2._toType, true, typeMapper) == null) { txMatch = false; } } } if (!(sxMatch || txMatch)) { break; } } if (sxMatch) { sx = udc._fromType; } if (txMatch) { tx = udc._toType; } if (sx != null && tx != null) { break; } } } return(FindConversation_Match(collection, sx, tx, typeMapper)); }
public SpeedData(RapidDataType rdt) { this.data = new UserDefined(rdt); this.data.FillFromString2("[0,0,0,0]"); }
public SpeedData(RapidDataType rdt, DataNode root) { this.data = new UserDefined(rdt); this.data.Fill2(root); }
public SpeedData(RapidDataType rdt, string newValue) { this.data = new UserDefined(rdt); this.data.FillFromString2(newValue); }
/// <summary> /// Execute is modified Curl_http() which in Curl gets called from the generic Curl_do() function when a HTTP /// request is to be performed. This creates and sends a properly constructed /// HTTP request. /// </summary> /// <param name="curl"></param> /// <param name="result"></param> /// <returns></returns> internal override object Execute(PhpCurlResource curl, ref CURLcode result) { UserDefined data = curl.Data; HttpBitsUploader uploader; bool terminatedCorrectly = false; int redirectAttempts = 0; bool keepVerb = false; result = CURLcode.CURLE_OK; if (data.Str[(int)DupString.SET_URL] == null) { result = CURLcode.CURLE_COULDNT_CONNECT; return(false); } Uri uri = Utils.CompleteUri(PhpVariable.AsString(data.Str[(int)DupString.SET_URL]), Scheme, data.UsePort); for (; ;) { request = (HttpWebRequest)HttpWebRequest.Create(uri); Curl_HttpReq httpreq = (redirectAttempts == 0) || keepVerb?setRequestMethod(data) : Curl_HttpReq.GET; setTimeOut(data); setHttpVersion(data); request.AllowAutoRedirect = data.FollowLocation; request.MaximumAutomaticRedirections = data.MaxRedirects; if (data.Str[(int)DupString.USERAGENT] != null) { request.UserAgent = PhpVariable.AsString(data.Str[(int)DupString.USERAGENT]); } if (data.Str[(int)DupString.SET_REFERER] != null) { request.Referer = PhpVariable.AsString(data.Str[(int)DupString.SET_REFERER]); } if (data.Headers != null) { request.SetHttpHeaders(data.Headers); } setProxy(data); setCredentials(data); setCookies(data); //ssl.VerifyPeer && ssl.VerifyHost == 2 is supported by default .NET // other values are currently unsupported if (data.Str[(int)DupString.CERT] != null) { X509Certificate cert; string certPath; try { certPath = Path.Combine(ScriptContext.CurrentContext.WorkingDirectory, PhpVariable.AsString(data.Str[(int)DupString.SSL_CAFILE])); if (data.Str[(int)DupString.KEY_PASSWD] == null) { cert = new X509Certificate(certPath); } else { cert = new X509Certificate(certPath, PhpVariable.AsString(data.Str[(int)DupString.KEY_PASSWD])); } request.ClientCertificates.Add(cert); } catch (CryptographicException) { //TODO: here are more caises to differentiate result = CURLcode.CURLE_SSL_CACERT_BADFILE; return(false); } } switch (httpreq) { case Curl_HttpReq.POST_FORM: //same as POST but we can send multiple items asform-data if (data.HttpPostForm != null) { try { HttpFormDataUploader formUploader = new HttpFormDataUploader(request); formUploader.UploadForm(data.HttpPostForm); } catch (WebException ex) { switch (ex.Status) { case WebExceptionStatus.Timeout: result = CURLcode.CURLE_OPERATION_TIMEOUTED; break; default: result = CURLcode.CURLE_COULDNT_CONNECT; // for now just this break; } return(false); } } break; case Curl_HttpReq.PUT: /* Let's PUT the data to the server! */ //INFILE & INFILESIZE has to be set NativeStream nativeStream = data.Infile as NativeStream; if (nativeStream == null) { return(false); } FileStream fs = nativeStream.RawStream as FileStream; if (fs == null) { return(false); } try { uploader = new HttpBitsUploader(request); uploader.UploadFile(fs); } catch (WebException ex) { switch (ex.Status) { case WebExceptionStatus.Timeout: result = CURLcode.CURLE_OPERATION_TIMEOUTED; break; default: result = CURLcode.CURLE_COULDNT_CONNECT; // for now just this break; } return(false); } break; case Curl_HttpReq.POST: /* this is the simple POST, using x-www-form-urlencoded style */ if (String.IsNullOrEmpty(request.ContentType)) // if Content-type isn't set set the default { request.ContentType = "application/x-www-form-urlencoded"; } if (data.Postfields != null) { try { uploader = new HttpBitsUploader(request); uploader.UploadData(data.Postfields); } catch (WebException ex) { switch (ex.Status) { case WebExceptionStatus.Timeout: result = CURLcode.CURLE_OPERATION_TIMEOUTED; break; default: result = CURLcode.CURLE_COULDNT_CONNECT; // for now just this break; } return(false); } } break; } try { // if we got this far, we will turn off AutoRedirect (assuming it was on), since // we are ready to handle manually following certain responses. this is needed // to harvest cookies that are set on any intermediate response (i.e. anything // other than the last one followed), since the .NET HTTP class will use, but // NOT return, cookies set on anything but the last request. request.AllowAutoRedirect = false; response = (HttpWebResponse)request.GetResponse(); } catch (WebException ex) { switch (ex.Status) { case WebExceptionStatus.Timeout: result = CURLcode.CURLE_OPERATION_TIMEOUTED; break; case WebExceptionStatus.ConnectFailure: result = CURLcode.CURLE_COULDNT_CONNECT; break; case WebExceptionStatus.TrustFailure: result = CURLcode.CURLE_SSL_CACERT; break; case WebExceptionStatus.ProtocolError: //Response from server was complete, but indicated protocol error as 404, 401 etc. break; default: result = CURLcode.CURLE_COULDNT_CONNECT; // for now just this break; } //TODO: other errorCodes response = (HttpWebResponse)ex.Response; //return false; //error = true; } if (response == null)// just to make sure I have the response object { return(false); } if (data.FollowLocation) { // see if we need to follow a redirect. switch (response.StatusCode) { case HttpStatusCode.MovedPermanently: case HttpStatusCode.Found: case HttpStatusCode.SeeOther: case HttpStatusCode.RedirectKeepVerb: if (redirectAttempts++ >= data.MaxRedirects) { result = CURLcode.CURLE_TOO_MANY_REDIRECTS; return(false); } string location = response.Headers["Location"]; if (!string.IsNullOrWhiteSpace(location)) { try { keepVerb = response.StatusCode == HttpStatusCode.RedirectKeepVerb; data.Cookies.Add(response.Cookies); response.Close(); uri = new Uri(uri, location); continue; } catch (Exception) { // closest error code though could be confusing as it's not the user- // submitted URL that's the problem result = CURLcode.CURLE_URL_MALFORMAT; return(false); } } break; } } //Save cookies data.Cookies.Add(response.Cookies); // break out of the for loop as we aren't following a redirect break; } byte[] headers = null; byte[] content = null; int headersLength = 0; if (data.IncludeHeader) { //It's necessary to put HTTP header into the result //first we need to create it since there isn't anywhere headers = Encoding.ASCII.GetBytes(response.GetHttpHeaderAsString()); headersLength = headers.Length; } if (data.FunctionWriteHeader != null)// TODO: probably invoke before { response.InvokeHeaderFunction(curl, data.FunctionWriteHeader); } Stream writeStream = null; if (data.WriteFunction != null) { writeStream = new WriteFunctionStream(curl, data.WriteFunction); } else if (data.OutFile != null) { var outStream = data.OutFile as PhpStream; if (outStream == null) { return(false); } Stream fs = outStream.RawStream as Stream; if (fs == null) { return(false); } writeStream = fs; } else if (data.ReturnTransfer == false) // Output to standart output { writeStream = ScriptContext.CurrentContext.OutputStream; } if (writeStream != null) { if (headers != null) //there is http header to copy to the result { writeStream.Write(headers, 0, headersLength); } HttpBitsDownloader reader = new HttpBitsDownloader(response); try { reader.ReadToStream(writeStream, out terminatedCorrectly); } catch (WebException ex) { switch (ex.Status) { case WebExceptionStatus.Timeout: result = CURLcode.CURLE_OPERATION_TIMEOUTED; break; default: result = CURLcode.CURLE_COULDNT_CONNECT; // for now just this break; } } if (!terminatedCorrectly) { result = CURLcode.CURLE_PARTIAL_FILE; } return(true); } else { // Read the response HttpBitsDownloader reader = new HttpBitsDownloader(response); try { content = reader.ReadToEnd(headersLength, out terminatedCorrectly); } catch (WebException ex) { switch (ex.Status) { case WebExceptionStatus.Timeout: result = CURLcode.CURLE_OPERATION_TIMEOUTED; break; default: result = CURLcode.CURLE_COULDNT_CONNECT; // for now just this break; } } if (!terminatedCorrectly) { result = CURLcode.CURLE_PARTIAL_FILE; } if (headers != null) //there is http header to copy to the result { if (content != null) { Buffer.BlockCopy(headers, 0, content, 0, headersLength); } else { content = headers; } } if (content == null) { return(PhpBytes.Empty); } else { return(new PhpBytes(content)); } } }
public SpeedData(Controller controller, string taskName, string dataModuleName, string dataName) { this.rapidData = controller.Rapid.GetRapidData(taskName, dataModuleName, dataName); this.data = (UserDefined)rapidData.Value; }