Пример #1
1
        public static void Main(string[] args)
        {
            // Datos de conexión
            String Url = "http://localhost:8069";
            String Dbname = "test_db";
            String Login = "******";
            String Password = "******";

            // Login
            OpenERPConnect connection = new OpenERPConnect(Url, Dbname, Login, Password);
            connection.Login();
            Console.WriteLine(connection.UserId);

            Object[] domain = new Object[3]; // Albaranes de salida ya asignados y sin incidencias
            domain[0] = new Object[3] {"picking_type_id.code", "=", "outgoing"};
            domain[1] = new Object[3] {"state", "=", "assigned"};
            domain[2] = new Object[3] {"with_incidences", "=", false};
            long[] picking_ids = connection.Search("stock.picking", domain);
            Console.WriteLine("Albaranes encontrados: {0}", picking_ids.Length);

            //Los recorremos y les escribimos a todos la misma incidencia
            foreach(long picking_id in picking_ids)
            {
                XmlRpcStruct vals = new XmlRpcStruct();
                vals.Add("with_incidences", true); //Lo marcamos como bajo incidencia
                connection.Write("stock.picking", new long[] {picking_id}, vals);

                //Escribimos el motivo de la incidencia
                connection.MessagePost("stock.picking", new long[] {picking_id}, "Stock Incorrecto");
            }

            Console.ReadLine();
        }
Пример #2
0
        public Table(XmlRpcStruct rpcStruct)
        {
            HeaderRow = new List<string>();
            DataRows = new List<DataRow>();

            foreach (string key in rpcStruct.Keys)
            {
                if (key.StartsWith("Name"))
                    Name = rpcStruct[key] as string;

                else if(!key.StartsWith("Type"))
                {
                    if (HeaderRow.Count == 0)
                        foreach (string s in (rpcStruct[key] as XmlRpcStruct).Keys)
                            AddColumn(s);

                    DataRows.Add(new DataRow(HeaderRow.Count));

                    var dataStruct = rpcStruct[key] as XmlRpcStruct;

                    foreach (string s in dataStruct.Keys)
                    {
                        var row = 0;

                        Int32.TryParse(key, out row);

                        SetCellValue(s, row, dataStruct[s] as string);
                    }
                }
            }
        }
Пример #3
0
        public XmlRpcStruct RunKeyword(string keywordName, string[] arguments)
        {
            var result = new XmlRpcStruct();

            Keyword keyword;
            if(!keywordManager.TryGetKeyword(keywordName, out keyword))
            {
                throw new XmlRpcFaultException(1, string.Format("Keyword \"{0}\" not found", keywordName));
            }

            try
            {
                var keywordResult = keyword.Execute(arguments);
                if(keywordResult != null)
                {
                    result.Add(KeywordResultValue, keywordResult.ToString());
                }
                result.Add(KeywordResultStatus, KeywordResultPass);
            }
            catch(Exception e)
            {
                result.Clear();

                result.Add(KeywordResultStatus, KeywordResultFail);
                result.Add(KeywordResultError, BuildRecursiveErrorMessage(e));
                result.Add(KeywordResultTraceback, e.StackTrace);
            }

            return result;
        }
 public void OrderingEnumerator()
 {
   var xps = new XmlRpcStruct();
   xps.Add("1", "a");
   xps.Add("3", "c");
   xps.Add("2", "b");
   IDictionaryEnumerator enumerator = xps.GetEnumerator();
   enumerator.MoveNext();
   Assert.AreEqual("1", enumerator.Key);
   Assert.AreEqual("a", enumerator.Value);
   Assert.IsInstanceOfType(typeof(DictionaryEntry), enumerator.Current);
   DictionaryEntry de = (DictionaryEntry)enumerator.Current;
   Assert.AreEqual("1", de.Key);
   Assert.AreEqual("a", de.Value);
   enumerator.MoveNext();
   Assert.AreEqual("3", enumerator.Key);
   Assert.AreEqual("c", enumerator.Value);
   Assert.IsInstanceOfType(typeof(DictionaryEntry), enumerator.Current);
   de = (DictionaryEntry)enumerator.Current;
   Assert.AreEqual("3", de.Key);
   Assert.AreEqual("c", de.Value);
   enumerator.MoveNext();
   Assert.AreEqual("2", enumerator.Key);
   Assert.AreEqual("b", enumerator.Value);
   Assert.IsInstanceOfType(typeof(DictionaryEntry), enumerator.Current);
   de = (DictionaryEntry)enumerator.Current;
   Assert.AreEqual("2", de.Key);
   Assert.AreEqual("b", de.Value);
 }
        public Subtitle GetSubtitleByHash(string fileName, string languageCode)
        {
            Subtitle retValue = new Subtitle();
            XmlRpcStruct searchParams = new XmlRpcStruct();
            List<SubtitleSearchItem> subtitles = null;
            var fileInfo = new FileInfo(fileName);
            searchParams.Add(SEARCH_PARAM_LANGUAGE_ID, languageCode);
            searchParams.Add(SEARCH_PARAM_MOVIE_HASH, GetMovieHash(fileName));
            searchParams.Add(SEARCH_PARAM_MOVIE_SIZE, fileInfo.Length);

            XmlRpcStruct response = RpcProxy.SearchSubtitles(AuthToken, new object[1] { new XmlRpcStruct[1] { searchParams } });
            if ((string)response[RESPONSE_STATUS_FIELD] == RESPONSE_RESULT_OK)
            {
                subtitles = SearchReponse2List(response);
            }
            //Take one with best rating
            if (subtitles.Count > 0)
            {
                var subtitle = subtitles.OrderByDescending(item => item.SubRating).FirstOrDefault();
                var subtitleStream = DownloadSubtitles(subtitle.IDSubtitleFile);

                retValue = new Subtitle(subtitleStream, subtitle.SubFormat);
            }
            return retValue;
        }
 public void DoubleAdd()
 {
     XmlRpcStruct xps = new XmlRpcStruct();
       xps.Add("foo", "123456");
       xps.Add("foo", "abcdef");
       Assert.Fail("Test should throw ArgumentException");
 }
Пример #7
0
 private void PrintStruct(CookComputing.XmlRpc.XmlRpcStruct ejabberdStruct)
 {
     foreach (object x in ejabberdStruct.Keys)
     {
         Response.Write(x.ToString() + " :  " + ejabberdStruct[x] + "<br />");
     }
 }
 public void DoubleSet()
 {
     XmlRpcStruct xps = new XmlRpcStruct();
       xps["foo"] = "12345";
       xps["foo"] = "abcdef";
       Assert.AreEqual("abcdef", xps["foo"]);
 }
Пример #9
0
	    /// <summary>
	    /// Run specified Robot Framework keyword from remote server.
	    /// </summary>
	    public XmlRpcStruct run_keyword(string keyword, object[] args)
	    {
			log.Debug(String.Format("XmlRpc Method call - run_keyword {0}",keyword));
			XmlRpcStruct kr = new XmlRpcStruct();
			//check for stop remote server
			if (String.Equals(keyword,CStopRemoteServer,StringComparison.CurrentCultureIgnoreCase))
			{
				//start background thread to raise event
				Thread stopthread = new Thread(delayed_stop_remote_server);
				stopthread.IsBackground = true;
				stopthread.Start();
				log.Debug("Stop remote server thread started");
				//return success
				kr.Add("return",String.Empty);
				kr.Add("status","PASS");
				kr.Add("error",String.Empty);
				kr.Add("traceback",String.Empty);
				kr.Add("output",String.Empty);
			}
			else
			{
				try
				{
					var result = _map.ExecuteKeyword(keyword,args);
					log.Debug(result.ToString());
					kr = XmlRpcResultBuilder.ToXmlRpcResult(result);
				}
				catch (Exception e)
				{
					log.Error(String.Format("Exception in method - run_keyword : {0}",e.Message));
					throw new XmlRpcFaultException(1,e.Message);
				}
			}
			return kr;
		}
 /// <summary>
 /// Converts keyword result to RF XmlRpc Structure
 /// </summary>
 public static XmlRpcStruct ToXmlRpcResult(KeywordResult kwresult)
 {
     var result = new XmlRpcStruct();
     //add status
     result.Add("status",kwresult.status.ToString());
     //add error, traceback, output
     result.Add("error",kwresult.error);
     result.Add("traceback",kwresult.traceback);
     result.Add("output",kwresult.output);
     //add return
     if ([email protected]().Equals(typeof(System.Int64)))
     {
         //64bit int has to be returned as string
         result.Add("return",[email protected]());
     }
     else
     {
         result.Add("return",kwresult.@return);
     }
     //check error type
     if (kwresult.status==KeywordStatus.FAIL)
     {
         if (kwresult.errortype==KeywordErrorTypes.Continuable)
         {
             //continuable error
             result.Add("continuable",true);
         }
         if (kwresult.errortype==KeywordErrorTypes.Fatal)
         {
             //fatal error
             result.Add("fatal",true);
         }
     }
     return result;
 }
Пример #11
0
        public object Retrieve(string serviceName, XmlRpcStruct args)
        {
            Console.WriteLine("Service \"{0}\"", serviceName);
            ProvidersManager providers = new ProvidersManager();
            Extractable service = null;
            try {
                service = providers.FindService(serviceName);
            }
            catch (InvalidNameException) {
                string msg = "The name of the service should be in the format NameSpace.ServiceName";
                throw new XmlRpcFaultException(32602, msg);
            }
            catch (ServiceNotFoundException) {
                string msg = String.Format("The service \"{0}\" does not exist on this server.", serviceName);
                throw new XmlRpcFaultException(32602, msg);
            }

            Console.WriteLine("Arguments (as strings):");
            StringDict arguments = new StringDict();
            foreach (DictionaryEntry keyval in args) {
                arguments.Add((string)keyval.Key, keyval.Value.ToString());
                Console.WriteLine("{0}=>{1}", keyval.Key, keyval.Value);
            }

            service.Extract(arguments);

            Console.WriteLine("Result: {0}", service.ToString());
            return service;
        }
Пример #12
0
        public void CreateTicket(TicketInfo ticket)
        {
            if (string.IsNullOrEmpty(ticket.Summary)) throw new ArgumentNullException("ticket.Summary");

            if (string.IsNullOrEmpty(ticket.Description)) throw new ArgumentNullException("ticket.Description");

            if (string.IsNullOrEmpty(ticket.Type)) throw new ArgumentNullException("ticket.Type");

            if (string.IsNullOrEmpty(ticket.Priority)) throw new ArgumentNullException("ticket.Priority");

            if (string.IsNullOrEmpty(ticket.Component)) throw new ArgumentNullException("ticket.Component");

            XmlRpcStruct tempAttributes = new XmlRpcStruct();

            foreach (object key in ticket.Attributes.Keys)
            {

                if ((((string)key) != TicketAttributes.Description) && (((string)key) != TicketAttributes.Summary))
                {

                    tempAttributes.Add(key, ticket.Attributes[key]);

                }

            }

            int id = _ticket.Create(ticket.Summary, ticket.Description, ticket.Attributes);

            ticket.TicketId = id;
        }
Пример #13
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="output">The output from the server.</param>
        public GetSubLanguagesOutput( XmlRpcStruct output ) : base( output )
        {
            XmlRpcStruct[ ] data = output.GetXmlRpcStructArray( "data" );
            Languages = new SubtitleLanguage[ data.Length ];

            for ( int Index = 0; Index < data.Length; Index++ )
                Languages[ Index ] = new SubtitleLanguage( data[ Index ] );
        }
Пример #14
0
 public Result(XmlRpcStruct xmlRpcStruct)
 {
     status = (string)xmlRpcStruct["status"];
     retrn = (string)xmlRpcStruct["retrn"];
     xml = (string)xmlRpcStruct["xml"];
     error = (string)xmlRpcStruct["error"];
     traceback = (string)xmlRpcStruct["traceback"];
 }
Пример #15
0
        public Rank(XmlRpcStruct rank)
        {
            IDataAccess data = DataAccessFactory.GetDataAccess();

            this.id = Convert.ToInt32(rank["ID"]);
            this.total = Convert.ToInt32(rank["TOTAL"]);
            this.rank = Convert.ToInt32(rank["RANK"]);
        }
Пример #16
0
 public static XmlRpcStruct dictionaryToXmlRpcStruct(IDictionary<string, object> idic)
 {
     XmlRpcStruct s = new XmlRpcStruct();
     foreach (string key in idic.Keys) {
         s.Add(key, idic[key]);
     }
     return s;
 }
Пример #17
0
 public Security(XmlRpcStruct security, XmlRpcStruct quote)
     : this(security)
 {
     if (quote == null)
         this.latestQuote = null;
     else
         this.latestQuote = new Quote(quote);
 }
Пример #18
0
        public Exchange(XmlRpcStruct exchange)
        {
            IDataAccess data = DataAccessFactory.GetDataAccess();

            this.symbol = (string)exchange["SYMBOL"];
            this.name = (string)exchange["NAME"];
            this.location = (string)exchange["LOCATION"];
        }
Пример #19
0
 public frmUpdateOrder(string oId,XmlRpcStruct[] orderStatuses,string status,bool isAdmin)
 {
     InitializeComponent();
     OrderId = oId;     
     OrderStatuses = orderStatuses;
     Status = status;
     IsAdmin = isAdmin;
 }
Пример #20
0
 public PointsTransaction(XmlRpcStruct pointsTransaction)
 {
     userId = Convert.ToInt32(pointsTransaction["USER"]);
     timestamp = Convert.ToDateTime(pointsTransaction["TIMESTAMP"]);
     type = (PointsType)Enum.Parse(typeof(PointsType), (string)pointsTransaction["TYPE"]);
     delta = Convert.ToInt32(pointsTransaction["DELTA"]);
     comments = (string)pointsTransaction["COMMENTS"];
 }
Пример #21
0
        public Index(XmlRpcStruct index)
        {
            IDataAccess data = DataAccessFactory.GetDataAccess();

            this.isin = (string)index["ISIN"];
            this.symbol = (string)index["SYMBOL"];
            this.name = (string)index["NAME"];
            this.exchange = data.GetExchangeBySymbol((string)index["EXCHANGE"]);
        }
Пример #22
0
        public XmlRpcStruct toStruct()
        {
            XmlRpcStruct exchange = new XmlRpcStruct();
            exchange.Add("SYMBOl", symbol);
            exchange.Add("NAME", name);
            exchange.Add("LOCATION", location);

            return exchange;
        }
Пример #23
0
 private static List<SearchSubtitleResult> DoSearchRequest(XmlRpcStruct ResponseStruct)
 {
     List<SearchSubtitleResult> SearchResultList = new List<SearchSubtitleResult>();
     if (ResponseStruct["data"] != null && (!ResponseStruct["data"].Equals(false)))
     {
         foreach (XmlRpcStruct SearchResult in ((object[])ResponseStruct["data"]))
         {
             SearchSubtitleResult result = new SearchSubtitleResult();
             result.SubSumCD = (string)SearchResult["SubSumCD"];
             result.MovieYear = (String)SearchResult["MovieYear"];
             result.SubFileName = (String)SearchResult["SubFileName"];
             result.MovieImdbRating = (String)SearchResult["MovieImdbRating"];
             result.UserNickName = (String)SearchResult["UserNickName"];
             result.UserRank = (String)SearchResult["UserRank"];
             result.SubHash = (String)SearchResult["SubHash"];
             result.MovieName = (String)SearchResult["MovieName"];
             result.SubActualCD = (String)SearchResult["SubActualCD"];
             result.MovieNameEng = (String)SearchResult["MovieNameEng"];
             result.SubHearingImpaired = (String)SearchResult["SubHearingImpaired"];
             result.MatchedBy = (String)SearchResult["MatchedBy"];
             result.MovieHash = (String)SearchResult["MovieHash"];
             result.LanguageName = (String)SearchResult["LanguageName"];
             result.IDSubtitleFile = (String)SearchResult["IDSubtitleFile"];
             result.SubLanguageID = (String)SearchResult["SubLanguageID"];
             result.SubAuthorComment = (String)SearchResult["SubAuthorComment"];
             result.IDSubtitle = (String)SearchResult["IDSubtitle"];
             result.UserID = (String)SearchResult["UserID"];
             result.MovieByteSize = (String)SearchResult["MovieByteSize"];
             result.SubSize = (String)SearchResult["SubSize"];
             result.SubDownloadLink = (String)SearchResult["SubDownloadLink"];
             result.SubtitlesLink = (String)SearchResult["SubtitlesLink"];
             result.ISO639 = (String)SearchResult["ISO639"];
             result.MovieReleaseName = (String)SearchResult["MovieReleaseName"];
             result.SubBad = (String)SearchResult["SubBad"];
             result.IDSubMovieFile = (String)SearchResult["IDSubMovieFile"];
             result.SubComments = (String)SearchResult["SubComments"];
             result.MovieTimeMS = (String)SearchResult["MovieTimeMS"];
             result.SubFormat = (String)SearchResult["SubFormat"];
             result.IDMovieImdb = (String)SearchResult["IDMovieImdb"];
             result.SubRating = (String)SearchResult["SubRating"];
             try
             {
                 result.SubDownloadsCnt = Convert.ToInt32((String)SearchResult["SubDownloadsCnt"]);
             }
             catch (Exception)
             {
                 result.SubDownloadsCnt = 0;
             }
             result.IDMovie = (String)SearchResult["IDMovie"];
             result.SubAddDate = (String)SearchResult["SubAddDate"];
             result.ZipDownloadLink = (String)SearchResult["ZipDownloadLink"];
             SearchResultList.Add(result);
         }
     }
     return SearchResultList;
 }
Пример #24
0
        public XmlRpcStruct toStruct()
        {
            XmlRpcStruct security = new XmlRpcStruct();
            security.Add("ISIN", isin);
            security.Add("SYMBOL", symbol);
            security.Add("NAME", name);
            security.Add("EXCHANGE", exchange.Name);

            return security;
        }
 private XmlRpcStruct CreateSearchStructure(List<string> languages, string hashString, long videoSize)
 {
     var searchStructure = new XmlRpcStruct();
     var preferredLanguages = this.GetSubtitleString(languages);
     searchStructure.Add("sublanguageid", preferredLanguages);
     searchStructure.Add("moviehash", hashString);
     searchStructure.Add("moviebytesize", videoSize.ToString());
     searchStructure.Add("imdbid", "");
     return searchStructure;
 }
Пример #26
0
 public Transaction(XmlRpcStruct transaction)
 {
     id = Convert.ToInt32(transaction["ID"]);
     userId = Convert.ToInt32(transaction["USER"]);
     timestamp = (DateTime) (transaction["TIME"]);
     isin = (string) (transaction["ISIN"]);
     type = (string) (transaction["TYPE"]);
     amount = Convert.ToInt32(transaction["AMOUNT"]);
     price = Convert.ToDouble(transaction["PRICE"]);
 }
Пример #27
0
        public XmlRpcStruct toStruct()
        {
            XmlRpcStruct pointsTransaction = new XmlRpcStruct();
            pointsTransaction.Add("USER", userId);
            pointsTransaction.Add("TIMESTAMP", timestamp);
            pointsTransaction.Add("TYPE", type.ToString());
            pointsTransaction.Add("DELTA", delta);
            pointsTransaction.Add("COMMENTS", comments);

            return pointsTransaction;
        }
    private XmlRpcStruct[] ConvertDictionaryToStruct(Dictionary<int, string> dict)
    {
        XmlRpcStruct[] convertionResult = new XmlRpcStruct[dict.Count()];
        for (int i = 0; i < dict.Count; i++)
        {
            convertionResult[i] = new XmlRpcStruct();
            convertionResult[i].Add("NetworkPriority", dict.Keys.ElementAt(i));
            convertionResult[i].Add("IpAddress", dict.Values.ElementAt(i));
        }

        return convertionResult;
    }
Пример #29
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="output">The output from the request.</param>
 public SubtitleData( XmlRpcStruct output )
 {
     this.SubFileName = output.GetString( "SubFileName" );
     this.AddDate = DateTime.Parse( output.GetString( "SubAddDate" ) );
     this.IDSubtitleFile = output.GetULong( "IDSubtitleFile" );
     this.DownloadsCount = output.GetUInt( "SubDownloadsCnt" );
     this.SubDownloadLink = output.GetString( "SubDownloadLink" );
     this.SubFileSize = output.GetUInt( "SubSize" );
     this.LanguageName = output.GetString( "LanguageName" );
     this.SubFileHash = output.GetString( "SubHash" );
     this.ISO639 = output.GetString( "ISO639" );
 }
Пример #30
0
        public Security(XmlRpcStruct security)
        {
            IDataAccess data = DataAccessFactory.GetDataAccess();

            this.isin = (string)security["ISIN"];
            this.symbol = (string)security["SYMBOL"];
            this.name = (string)security["NAME"];
            this.exchange = data.GetExchangeBySymbol((string)security["EXCHANGE"]);
            this.visible = (Convert.ToInt32(security["VISIBLE"]) == 1) ? true : false;
            this.suspended = (Convert.ToInt32(security["SUSPENDED"]) == 1) ? true : false;
            this.latestQuote = null;
        }
Пример #31
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="output">The struct containing the data.</param>
 public MovieData( XmlRpcStruct output )
 {
     this.MovieHash = ( string ) output[ "MovieHash" ];
     this.MovieImbdID = ( string ) output[ "MovieImdbID" ];
     this.MovieName = ( string ) output[ "MovieName" ];
     this.MovieYear = ushort.Parse( ( string ) output[ "MovieYear" ] );
     this.Type = ( string ) output[ "MovieKind" ];
     this.SeriesSeason = ushort.Parse( ( string ) output[ "SeriesSeason" ] );
     this.SeriesEpisode = ushort.Parse( ( string ) output[ "SeriesEpisode" ] );
     this.SeenCount = ulong.Parse( ( string ) output[ "SeenCount" ] );
     this.SubCount = uint.Parse( ( string ) output[ "SubCount" ] );
 }
Пример #32
0
        public void OrderingKeys2()
        {
            var xps = new XmlRpcStruct();

            xps.Add("member_1", "a");
            xps.Add("member_4", "c");

            IEnumerator enumerator = xps.Keys.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("member_1", enumerator.Current);
            enumerator.MoveNext();
            Assert.AreEqual("member_4", enumerator.Current);
        }
Пример #33
0
        public void OrderingValues()
        {
            var xps = new XmlRpcStruct();

            xps.Add("1", "a");
            xps.Add("3", "c");
            xps.Add("2", "b");

            IEnumerator enumerator = xps.Values.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("a", enumerator.Current);
            enumerator.MoveNext();
            Assert.AreEqual("c", enumerator.Current);
            enumerator.MoveNext();
            Assert.AreEqual("b", enumerator.Current);
        }
Пример #34
0
    protected void Send_Click(object sender, EventArgs e)
    {
        send_message_chat message = new send_message_chat();

        message.from = "weavver.com";
        message.to   = ConfigurationManager.AppSettings["admin_address"];
        message.body = "User at " + Request.UserHostAddress + " says asdf asdf asfd";

        Weavver.Vendors.ProcessOne.ejabberdRPC rpc = new Weavver.Vendors.ProcessOne.ejabberdRPC();
        rpc.SendMessageChat(message);

        status s = new status();

        CookComputing.XmlRpc.XmlRpcStruct statResponse = rpc.Status(s);

        PrintStruct(statResponse);
    }
Пример #35
0
        /// <summary>
        /// Create a drupal file structure
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        private XmlRpcStruct buildFileStruct(string filePath, string serverPath)
        {
            // Encode file to base64
            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            byte[] filebytes = new byte[fs.Length];
            fs.Read(filebytes, 0, Convert.ToInt32(fs.Length));
            string encodedFile = Convert.ToBase64String(filebytes, Base64FormattingOptions.InsertLineBreaks);

            System.IO.FileInfo fi = new System.IO.FileInfo(filePath);

            CookComputing.XmlRpc.XmlRpcStruct fileStruct = new CookComputing.XmlRpc.XmlRpcStruct();
            fileStruct.Add("file", encodedFile);
            fileStruct.Add("filename", fi.Name);
            fileStruct.Add("filepath", serverPath + fi.Name);
            fileStruct.Add("filesize", fi.Length.ToString());
            fileStruct.Add("timestamp", GetUnixTimestamp());
            fileStruct.Add("uid", this.UserID);//Form Login

            return(fileStruct);
        }
Пример #36
0
        protected object MapHashtable(
            IEnumerator <Node> iter,
            MappingStack mappingStack,
            MappingAction mappingAction,
            out Type mappedType)
        {
            mappedType = null;
            var retObj = new XmlRpcStruct();

            mappingStack.Push("struct mapped to XmlRpcStruct");
            try {
                while (iter.MoveNext() && iter.Current is StructMember)
                {
                    var rpcName = ((StructMember)iter.Current).Value;
                    if (retObj.ContainsKey(rpcName) && !IgnoreDuplicateMembers)
                    {
                        throw new XmlRpcInvalidXmlRpcException(
                                  mappingStack.MappingType + " contains struct value with duplicate member " + rpcName + " "
                                  + StackDump(mappingStack));
                    }

                    iter.MoveNext();

                    var value = OnStack(
                        string.Format("member {0}", rpcName),
                        mappingStack,
                        () => MapValueNode(iter, null, mappingStack, mappingAction));

                    if (!retObj.ContainsKey(rpcName))
                    {
                        retObj[rpcName] = value;
                    }
                }
            }
            finally {
                mappingStack.Pop();
            }

            return(retObj);
        }
Пример #37
0
        protected virtual void OnConnectButtonClicked(object sender, System.EventArgs e)
        {
            llum.Core core = llum.Core.getCore();

            string[] user_info = { userEntry.Text, passwordEntry.Text };


            try
            {
                string ret;
                CookComputing.XmlRpc.XmlRpcStruct new_ret = core.xmlrpc.client.login(user_info, "Golem", user_info);
                if (Convert.ToInt32(new_ret["status"]) == 0)
                {
                    ret = Convert.ToString(new_ret["return"]);
                }
                else
                {
                    ret = "false";
                }

                if (ret.Contains("true"))
                {
                    core.mw.statusText = Mono.Unix.Catalog.GetString("Connected to LDAP as: ") + userEntry.Text;
                    //core.function_list=core.xmlrpc.client.get_students_function_list(user_info,"Golem");
                    //Console.WriteLine(core.xmlrpc.client.get_students_function_list(user_info,"Golem"));
                    string[] tmp = ret.Split(' ');                   // tmp[1] contains group type [ students, teachers, admin, others ]
                    CookComputing.XmlRpc.XmlRpcStruct function_response;
                    core.user_info = user_info;
                    switch (tmp[1])
                    {
                    case "admin":
                        //function_response=core.xmlrpc.client.get_admin_function_list(user_info,"Golem");
                        //Console.WriteLine(function_response["return"]);
                        //foreach(string str in (string[])function_response["return"])
                        //	Console.WriteLine(str);

                        //core.function_list=()function_response["return"];
                        core.set_function_list("admin");
                        core.user_group = "admin";
                        break;

                    case "promoted-teacher":
                        //core.function_list=core.xmlrpc.client.get_teachers_function_list(user_info,"Golem");
                        core.set_function_list("admin");
                        core.user_group = "promoted-teacher";
                        break;

                    case "students":
                        //function_response=core.xmlrpc.client.get_students_function_list(user_info,"Golem");
                        //core.function_list=function_response["return"];
                        core.set_function_list("students");
                        core.user_group = "students";
                        break;

                    case "teachers":
                        //core.function_list=core.xmlrpc.client.get_teachers_function_list(user_info,"Golem");
                        core.set_function_list("teachers");
                        core.user_group = "teachers";
                        break;

                    case "others":
                        //core.function_list=core.xmlrpc.client.get_others_function_list(user_info,"Golem");
                        core.set_function_list("others");
                        core.user_group = "others";
                        break;

                    default:

                        break;
                    }

                    /*
                     * Console.WriteLine("[LoginWidget] Available functions:");
                     * foreach(string str in core.function_list)
                     * {
                     *      Console.WriteLine("\t*Function " + str);
                     * }
                     * Console.WriteLine();
                     */
                }
                else
                {
                    core.mw.statusText = "<span foreground='red'>" + Mono.Unix.Catalog.GetString("User and/or password are incorrect.") + "\n" + "RET: " + ret + "</span>";
                }
            }
            catch (Exception excp)
            {
                Console.WriteLine(core.server);
                Console.WriteLine(excp);
                core.mw.statusText = "<span foreground='red'>" + Mono.Unix.Catalog.GetString("There was an error trying to connect to the n4d(XMLRPC) server") + "</span>";
            }
        }
Пример #38
0
 //#endif
 void Serialize(
     XmlWriter xtw,
     Object o,
     MappingActions mappingActions,
     List <object> nestedObjs)
 {
     if (nestedObjs.Contains(o))
     {
         throw new XmlRpcUnsupportedTypeException(nestedObjs[0].GetType(),
                                                  "Cannot serialize recursive data structure");
     }
     nestedObjs.Add(o);
     try
     {
         xtw.WriteStartElement("", "value", "");
         XmlRpcType xType = XmlRpcTypeInfo.GetXmlRpcType(o);
         if (xType == XmlRpcType.tArray)
         {
             xtw.WriteStartElement("", "array", "");
             xtw.WriteStartElement("", "data", "");
             Array a = (Array)o;
             foreach (Object aobj in a)
             {
                 //if (aobj == null)
                 //  throw new XmlRpcMappingSerializeException(String.Format(
                 //    "Items in array cannot be null ({0}[]).",
                 //o.GetType().GetElementType()));
                 Serialize(xtw, aobj, mappingActions, nestedObjs);
             }
             WriteFullEndElement(xtw);
             WriteFullEndElement(xtw);
         }
         else if (xType == XmlRpcType.tMultiDimArray)
         {
             Array mda     = (Array)o;
             int[] indices = new int[mda.Rank];
             BuildArrayXml(xtw, mda, 0, indices, mappingActions, nestedObjs);
         }
         else if (xType == XmlRpcType.tBase64)
         {
             byte[] buf = (byte[])o;
             xtw.WriteStartElement("", "base64", "");
             xtw.WriteBase64(buf, 0, buf.Length);
             WriteFullEndElement(xtw);
         }
         else if (xType == XmlRpcType.tBoolean)
         {
             bool boolVal = (bool)o;
             if (boolVal)
             {
                 WriteFullElementString(xtw, "boolean", "1");
             }
             else
             {
                 WriteFullElementString(xtw, "boolean", "0");
             }
         }
         else if (xType == XmlRpcType.tDateTime)
         {
             DateTime dt  = (DateTime)o;
             string   sdt = dt.ToString(DateTimeFormat, DateTimeFormatInfo.InvariantInfo);
             WriteFullElementString(xtw, "dateTime.iso8601", sdt);
         }
         else if (xType == XmlRpcType.tDouble)
         {
             double doubleVal = (double)o;
             WriteFullElementString(xtw, "double", doubleVal.ToString(null,
                                                                      CultureInfo.InvariantCulture));
         }
         else if (xType == XmlRpcType.tHashtable)
         {
             xtw.WriteStartElement("", "struct", "");
             XmlRpcStruct xrs = o as XmlRpcStruct;
             foreach (object obj in xrs.Keys)
             {
                 string skey = obj as string;
                 xtw.WriteStartElement("", "member", "");
                 WriteFullElementString(xtw, "name", skey);
                 Serialize(xtw, xrs[skey], mappingActions, nestedObjs);
                 WriteFullEndElement(xtw);
             }
             WriteFullEndElement(xtw);
         }
         else if (xType == XmlRpcType.tInt32)
         {
             o = SerializeInt32(xtw, o, mappingActions);
         }
         else if (xType == XmlRpcType.tInt64)
         {
             o = SerializeInt64(xtw, o, mappingActions);
         }
         else if (xType == XmlRpcType.tString)
         {
             SerializeString(xtw, o);
         }
         else if (xType == XmlRpcType.tStruct)
         {
             MappingActions structActions
                 = GetMappingActions(o.GetType(), mappingActions);
             xtw.WriteStartElement("", "struct", "");
             MemberInfo[] mis = o.GetType().GetMembers();
             foreach (MemberInfo mi in mis)
             {
                 if (Attribute.IsDefined(mi, typeof(NonSerializedAttribute)))
                 {
                     continue;
                 }
                 if (mi.MemberType == MemberTypes.Field)
                 {
                     FieldInfo fi      = (FieldInfo)mi;
                     string    member  = fi.Name;
                     Attribute attrchk = Attribute.GetCustomAttribute(fi,
                                                                      typeof(XmlRpcMemberAttribute));
                     if (attrchk != null && attrchk is XmlRpcMemberAttribute)
                     {
                         string mmbr = ((XmlRpcMemberAttribute)attrchk).Member;
                         if (mmbr != "")
                         {
                             member = mmbr;
                         }
                     }
                     MappingActions memberActions = MemberMappingActions(o.GetType(),
                                                                         fi.Name, structActions);
                     if (fi.GetValue(o) == null)
                     {
                         if (memberActions.NullMappingAction == NullMappingAction.Ignore)
                         {
                             continue;
                         }
                         else if (memberActions.NullMappingAction == NullMappingAction.Error)
                         {
                             throw new XmlRpcMappingSerializeException(@"Member """ + member +
                                                                       @""" of struct """ + o.GetType().Name + @""" cannot be null.");
                         }
                     }
                     xtw.WriteStartElement("", "member", "");
                     WriteFullElementString(xtw, "name", member);
                     Serialize(xtw, fi.GetValue(o), memberActions, nestedObjs);
                     WriteFullEndElement(xtw);
                 }
                 else if (mi.MemberType == MemberTypes.Property)
                 {
                     PropertyInfo pi      = (PropertyInfo)mi;
                     string       member  = pi.Name;
                     Attribute    attrchk = Attribute.GetCustomAttribute(pi,
                                                                         typeof(XmlRpcMemberAttribute));
                     if (attrchk != null && attrchk is XmlRpcMemberAttribute)
                     {
                         string mmbr = ((XmlRpcMemberAttribute)attrchk).Member;
                         if (mmbr != "")
                         {
                             member = mmbr;
                         }
                     }
                     MappingActions memberActions = MemberMappingActions(o.GetType(),
                                                                         pi.Name, structActions);
                     if (pi.GetValue(o, null) == null)
                     {
                         if (memberActions.NullMappingAction == NullMappingAction.Ignore)
                         {
                             continue;
                         }
                         else if (memberActions.NullMappingAction == NullMappingAction.Error)
                         {
                             throw new XmlRpcMappingSerializeException(@"Member """ + member +
                                                                       @""" of struct """ + o.GetType().Name + @""" cannot be null.");
                         }
                     }
                     xtw.WriteStartElement("", "member", "");
                     WriteFullElementString(xtw, "name", member);
                     Serialize(xtw, pi.GetValue(o, null), memberActions, nestedObjs);
                     WriteFullEndElement(xtw);
                 }
             }
             WriteFullEndElement(xtw);
         }
         else if (xType == XmlRpcType.tVoid)
         {
             WriteFullElementString(xtw, "string", "");
         }
         else if (xType == XmlRpcType.tNil)
         {
             xtw.WriteStartElement("nil");
             WriteFullEndElement(xtw);
         }
         else
         {
             throw new XmlRpcUnsupportedTypeException(o.GetType());
         }
         WriteFullEndElement(xtw);
     }
     catch (System.NullReferenceException)
     {
         throw new XmlRpcNullReferenceException("Attempt to serialize data "
                                                + "containing null reference");
     }
     finally
     {
         nestedObjs.RemoveAt(nestedObjs.Count - 1);
     }
 }
Пример #39
0
        public void SetInvalidKey()
        {
            XmlRpcStruct xps = new XmlRpcStruct();

            xps[1] = "abcdef";
        }
Пример #40
0
        public void AddInvalidKey()
        {
            XmlRpcStruct xps = new XmlRpcStruct();

            xps.Add(1, "abcdef");
        }