コード例 #1
0
        private void FrmPerson_WorkFlow_Load(object sender, EventArgs e)
        {
            FlowLib FL = new FlowLib();

            FL.GetFlowTree("0");
            dgList1.DataSource = FL.DtFlowTree;
        }
コード例 #2
0
ファイル: HashTth.cs プロジェクト: BGCX261/zpoc3-svn-to-git
        public void Generate(FlowLib.Containers.ContentInfo info)
        {
            if (info.ContainsKey(ContentInfo.STORAGEPATH))
            {
                TthThreaded tth = new TthThreaded(info.Get(ContentInfo.STORAGEPATH));
                tth.ThreadPriority = priority;
                tth.ThreadCount = count;
                byte[] bytes = tth.GetTTH_Value();
                info.Set(ContentInfo.TTH, Base32.Encode(bytes));
                //byte[][][] tree = tth.TTH;
                //if (tree != null && tree.Length > 0)
                //{
                //    int startIndex = 0;
                //    //if (tree.Length >= 8)
                //    //    startIndex = 7;
                //    long length = 0;
                //    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                //    for (int i = 0; i < tree[startIndex].Length; i++)
                //    {
                //        // Ignore the rest if more then 65KiB has been writed
                //        //if (length > 66560)
                //        //    break;
                //        length += tree[startIndex][i].Length;
                //        ms.Write(tree[startIndex][i], 0, tree[startIndex][i].Length);
                //    }

                //    info.Set(ContentInfo.TTHL, Base32.Encode(ms.ToArray()));
                //}
            }
        }
コード例 #3
0
        public UPnPProtocol(FlowLib.Connections.UPnP connection)
        {
            this.MessageReceived = new FmdcEventHandler(OnMessageReceived);
            this.MessageToSend = new FmdcEventHandler(OnMessageToSend);
            this.Update = new FmdcEventHandler(OnUpdate);

            Encoding = System.Text.Encoding.ASCII;
            con = connection;
        }
 void hubConnection_ProtocolChange(object sender, FlowLib.Events.FmdcEventArgs e)
 {
     hubConnection = sender as Hub;
     IProtocol prot = e.Data as IProtocol;
     if (prot != null)
     {
         prot.MessageReceived -= Protocol_MessageReceived;
     }
     hubConnection.Protocol.MessageReceived += new FlowLib.Events.FmdcEventHandler(Protocol_MessageReceived);
 }
コード例 #5
0
ファイル: PassiveSearch.cs プロジェクト: musakasim/flowlib
 void hubConnection_Update(object sender, FlowLib.Events.FmdcEventArgs e)
 {
     switch (e.Action)
     {
         case Actions.SearchResult:
             if (e.Data is SearchResultInfo)
             {
                 SearchResultInfo srInfo = (SearchResultInfo)e.Data;
             }
             break;
     }
 }
コード例 #6
0
        private void BindCombox()
        {
            DataTable dt2 = new SqlServerHelper().GetDataTable("Meter_WorkFlowState", "", "ID");

            ControlBindHelper.BindComboBoxData(this.State, dt2, "Value", "ID");

            AddTreeNode("0", null);

            FlowLib FL = new FlowLib();

            FL.GetFlowTree("0");
            ControlBindHelper.BindComboBoxData(this.ParentID, FL.DtFlowTree, "WorkName", "WorkFlowID", true);
        }
        void Protocol_MessageReceived(object sender, FlowLib.Events.FmdcEventArgs e)
        {
            FlowLib.Protocols.HubNmdc.To msg = e.Data as FlowLib.Protocols.HubNmdc.To;
            if (msg != null && !string.IsNullOrEmpty(msg.From))
            {
                User usr = hubConnection.GetUserById(msg.From);
                if (usr != null)
                {
                    // Note that this will always be empty if you dont set it. (As this took me like 1-2 min todo. i havnt added a none static one)
                    usr.UserInfo.Set(UserInfo.IP, "193.0.19.25");   // http://ripe.net

                    System.Text.StringBuilder sb = new System.Text.StringBuilder("\r\n");
                    sb.AppendLine("---------------------------------------------------------------------------------------------------------");
                    sb.AppendFormat("¦ Showing information on: {0}\r\n", usr.DisplayName );
                    sb.AppendLine("---------------------------------------------------------------------------------------------------------");
                    sb.AppendLine("¦ General information:");
                    sb.AppendFormat("¦  User: {0} (Online)\r\n", usr.DisplayName);
                    sb.AppendFormat("¦  Profile: {0}\r\n", usr.UserInfo.Account.ToString());
                    // Note that this will always be empty if you dont set it. (As this took me like 1-2 min todo. i havnt added a none static one)
                    if (usr.UserInfo.ContainsKey(UserInfo.IP))
                    {
                        sb.AppendFormat("¦  IP: {0}\r\n", usr.UserInfo.Get(UserInfo.IP));
                        try{
                            System.Net.IPHostEntry entry = System.Net.Dns.GetHostEntry(usr.UserInfo.Get(UserInfo.IP));
                            sb.AppendFormat("¦  DNS: {0}\r\n", entry.HostName);
                        }catch{}
                    }
                    sb.AppendFormat("¦  Passive: {0}\r\n", (usr.Tag.Mode == FlowLib.Enums.ConnectionTypes.Passive));
                    sb.AppendFormat("¦  Operator: {0}\r\n", usr.IsOperator);
                    sb.AppendFormat("¦  Sharesize: {0} (exact size: {1} B)\r\n", usr.UserInfo.ShareIEEE1541, usr.UserInfo.Share);
                    sb.AppendFormat("¦  Description: {0}\r\n", usr.Description);
                    sb.AppendFormat("¦  Tag: {0}\r\n", usr.Tag.Tag);
                    sb.AppendFormat("¦  Hubs: {0}\r\n", usr.UserInfo.TagInfo.Normal + usr.UserInfo.TagInfo.OP + usr.UserInfo.TagInfo.Regged);
                    sb.AppendFormat("¦  Slots: {0}\r\n", usr.UserInfo.TagInfo.Slots);
                    sb.AppendLine("---------------------------------------------------------------------------------------------------------");

                    // Create mainchat message.
                    MainMessage mm = new MainMessage(hubConnection.Me.ID, sb.ToString());
                    // message will here be converted to right format and then be sent.
                    UpdateBase(this, new FlowLib.Events.FmdcEventArgs(FlowLib.Events.Actions.MainMessage, mm));

                    string str = string.Format("[{1}] IN: {0}", sb.ToString(), System.DateTime.Now.ToLongTimeString());
                    System.Console.WriteLine(str);
                }
            }
        }
コード例 #8
0
        void Connection_Update(object sender, FlowLib.Events.FmdcEventArgs e)
        {
            switch (e.Action)
            {
                case Actions.TransferStarted:
                    Transfer trans = e.Data as Transfer;
                    if (trans != null)
                    {
                        if (trans.Protocol == null)
                        {
                            trans.Protocol = new FlowLib.Protocols.AdcProtocol(trans);
                            trans.Listen();
                            transferManager.AddTransfer(trans);
                        }

                        trans.Protocol.ChangeDownloadItem += new FmdcEventHandler(Protocol_ChangeDownloadItem);
                        trans.Protocol.RequestTransfer += new FmdcEventHandler(Protocol_RequestTransfer);
                        trans.ProtocolChange += new FmdcEventHandler(trans_ProtocolChange);
                        e.Handled = true;
                    }
                    break;
            }
        }
コード例 #9
0
ファイル: PassiveSearch.cs プロジェクト: musakasim/flowlib
 void PassiveSearch_UpdateBase(object sender, FlowLib.Events.FmdcEventArgs e)
 {
 }
コード例 #10
0
 void SendMainChatOrPMToHub_UpdateBase(object sender, FlowLib.Events.FmdcEventArgs e)
 {
 }
コード例 #11
0
ファイル: ActiveSearch.cs プロジェクト: musakasim/flowlib
 void hubConnection_Update(object sender, FlowLib.Events.FmdcEventArgs e)
 {
     Hub hub = sender as Hub;
     if (hub == null)
         return;
     switch (e.Action)
     {
         case Actions.SearchResult:
             if (e.Data is SearchResultInfo)
             {
                 SearchResultInfo srInfo = (SearchResultInfo)e.Data;
                 // This is if we want to enable auto adding of sources to a downloaditem.
                 //FlowLib.Managers.DownloadManager dm = new FlowLib.Managers.DownloadManager();
                 //DownloadItem tmpDownloadItem = new DownloadItem(srInfo.Info);
                 //// Do downloadItem exist?
                 //if (dm.ContainsDownload(tmpDownloadItem))
                 //{
                 //    // Add Source to the existing downloaditem. Note that we first check if it exist.
                 //    dm.AddDownload(tmpDownloadItem, srInfo.Source);
                 //}
             }
             break;
         case Actions.UserOnline:
             bool hasMe = (hub.GetUserById(hub.Me.ID) != null);
             if (!sentRequest && hasMe)
             {
                 // Send Search
                 SearchInfo searchInfo = new SearchInfo();
                 searchInfo.Set(SearchInfo.SEARCH, "Ubuntu");
                 //searchInfo.Set(SearchInfo.SIZE, "1000");
                 //searchInfo.Set(SearchInfo.SIZETYPE, "1");
                 UpdateBase(this, new FlowLib.Events.FmdcEventArgs(Actions.Search, searchInfo));
                 sentRequest = true;
             }
             break;
     }
 }
コード例 #12
0
ファイル: HashTth.cs プロジェクト: BGCX261/zpoc3-svn-to-git
 public bool verifySegment(ref FlowLib.Containers.ContentInfo info, FlowLib.Containers.SegmentInfo seg)
 {
     throw new System.Exception("The method or operation is not implemented.");
 }
コード例 #13
0
ファイル: Detect.cs プロジェクト: BGCX261/zpoc3-svn-to-git
        protected virtual void DoInternalListenAccess_Update(object sender, FlowLib.Events.FmdcEventArgs e)
        {
            switch (e.Action)
            {
                case Actions.TransferStarted:
                    Transfer trans = e.Data as Transfer;
                    if (trans != null)
                    {
                        if (trans.Protocol == null)
                        {
                            trans.Protocol = new FlowLib.Protocols.TransferNmdcProtocol(trans);
                            trans.Listen();
                            transferManager.AddTransfer(trans);
                        }

                        trans.Protocol.RequestTransfer += new FmdcEventHandler(DoInternalListenAccess_RequestTransfer);
                        e.Handled = true;
                    }
                    break;
            }
        }
コード例 #14
0
ファイル: UPnP.cs プロジェクト: musakasim/flowlib
 protected virtual void OnUpdateBase(object sender, FlowLib.Events.FmdcEventArgs e)
 {
     ProtocolUPnP.ActOnOutMessage(e);
 }
コード例 #15
0
 protected void OnMessageReceived(object sender, FlowLib.Events.FmdcEventArgs e)
 {
     IConMessage msg = e.Data as IConMessage;
     if (msg != null)
     {
         HandleReceived(msg);
     }
 }
コード例 #16
0
 protected void OnProtocolChange(object sender, FlowLib.Events.FmdcEventArgs e)
 {
     IProtocol prot = e.Data as IProtocol;
     IConnection con = sender as IConnection;
     if (con != null && con.Protocol != null)
     {
         RemoveProtocol();
         AddProtocol(con.Protocol);
     }
 }
コード例 #17
0
ファイル: ConnectToHub.cs プロジェクト: musakasim/flowlib
 void OnConnectionStatusChange(object sender, FlowLib.Events.FmdcEventArgs e)
 {
     switch (e.Action)
     {
         case TcpConnection.Connected:
             _isConnected = true;
             break;
     }
 }
コード例 #18
0
ファイル: UiHub.cs プロジェクト: musakasim/flowlib
        public void Hub_Update(object sender, FlowLib.Events.FmdcEventArgs e)
        {
            Hub hub = (Hub)sender;
            this.hub = hub;
            string str = string.Empty;

            switch (e.Action)
            {
                case Actions.TransferStarted:
                    if (e.Data is ITransfer)
                    {
                        ITransfer trans = (ITransfer)e.Data;
                        transferManager.StartTransfer(trans);
                    }
                    break;
                case Actions.TransferRequest:
                    if (e.Data is TransferRequest)
                    {
                        TransferRequest req = (TransferRequest)e.Data;
                        transferManager.AddTransferReq(req);
                    }
                    break;
                #region MainMessage
                case Actions.MainMessage:
                    if (e.Data is MainMessage)
                    {
                        MainMessage mainchat = (MainMessage)e.Data;
                        if (mainchat.From == null)
                            str = mainchat.Content;
                        else
                        {
                            User u = hub.GetUserById(mainchat.From);
                            if (u == null)
                                str = "<" + mainchat.From + "> " + mainchat.Content;
                            else
                                str = "<" + u.DisplayName + "> " + mainchat.Content;
                        }
                        // Test : Start
                        user = hub.GetUserById("DC++0.699");
                        //User user = hub.GetUserById("DCDM++0.0495");
                        if (user != null && hub.Share != null)
                        {
                            ContentInfo ci = new ContentInfo(ContentInfo.FILELIST, FlowLib.Utils.FileLists.BaseFilelist.UNKNOWN);
                            ci.Set(ContentInfo.STORAGEPATH, @"C:\Private\FMDC\PiP\FlowLibDemo\ConsoleDemo\bin\Debug\FileLists\" + user.ID + ".xml.bz2");
                            DownloadItem di = new DownloadItem(ci);
                            downloadManager.AddDownload(di, new Source(null, user.ID));
                            downloadManager.DownloadCompleted += new FmdcEventHandler(DownloadManager_DownloadCompleted);
                            this.Hub_Update(null, new FmdcEventArgs(Actions.TransferRequest, new TransferRequest(user.ID, hub, user.UserInfo)));
                            //TransferManager.AddTransferReq(user.ID, hub, user.UserInfo);
                            hub.Send(new FlowLib.Protocols.HubNmdc.ConnectToMe(user.ID, hub.Share.Port, hub));
                        }
                        // Test : End
                    }
                    else
                        str = e.Data.ToString();
                    Console.WriteLine(str);
                    break;
                #endregion
                #region PrivateMessage
                case Actions.PrivateMessage:
                    PrivateMessage to = (PrivateMessage)e.Data;
                    Console.WriteLine("*** PM From: " + to.From + ", To: " + to.To + " " + to.Content);
                    break;
                #endregion
                #region RegMode
                case Actions.RegMode:
                    break;
                #endregion
                #region Status
                case Actions.StatusChange:
                    HubStatus status = (HubStatus)e.Data;
                    switch (status.Code)
                    {
                        case HubStatus.Codes.Disconnected:
                            Console.WriteLine("*** Hub Disconnected");
                            if (status.Exception != null)
                            {
            #if DEBUG
                                if (status.Exception is System.Net.Sockets.SocketException)
                                {
                                    System.Net.Sockets.SocketException se = (System.Net.Sockets.SocketException)status.Exception;
                                    StringBuilder sb = new StringBuilder();
                                    sb.Append("\r\n");
                                    sb.Append("\tErrorCode: " + se.ErrorCode + "\r\n");
                                    sb.Append("\tMessage: " + se.Message + "\r\n");
                                    sb.Append("\tStackTrace: " + se.StackTrace);
                                    Console.WriteLine(sb.ToString());
                                }
            #else
                                Console.WriteLine(" : " + status.Exception.Message);
                                    //richTextBox1.AppendText(status.Exception.StackTrace);
            #endif
                            }
                            Console.WriteLine("\r\n");
                            break;
                        case HubStatus.Codes.Connected:
                            Console.WriteLine("*** Hub Connected");
                            break;
                        case HubStatus.Codes.Connecting:
                            Console.WriteLine("*** Hub Connecting");
                            break;
                    }
                    break;
                #endregion
                default:
                        Console.WriteLine(e.Data);
                        break;
            }
        }
コード例 #19
0
ファイル: DcBot.cs プロジェクト: oscarmike67/seriebot
 void DcBot_UpdateBase(object sender, FlowLib.Events.FmdcEventArgs e)
 {
 }
コード例 #20
0
        public void ActOnOutMessage(FlowLib.Events.FmdcEventArgs e)
        {
            string key = null;
            UPnPDevice device = null;
            switch (e.Action)
            {
                case Actions.UPnPDeviceDescription:
                    key = e.Data as string;
                    if (key != null)
                    {
                        try
                        {
                            if (con.RootDevices.ContainsKey(key))
                            {
                                device = con.RootDevices[key];
                                System.Net.HttpWebRequest httpRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(device.Information.DescriptionURL);
                                WebResponse webResponse = httpRequest.GetResponse();
                                System.IO.StreamReader sr = new System.IO.StreamReader(webResponse.GetResponseStream());
                                string ret = sr.ReadToEnd();
                                sr.Close();

                                FmdcEventArgs e2 = new FmdcEventArgs(Actions.UPnPDeviceDescription, ret);
                                Update(con, e2);
                                if (!e2.Handled)
                                {
                                    ParseDescription(ref device, ret);
                                    Update(con, new FmdcEventArgs(Actions.UPnPDeviceUpdated, device));
                                }
                            }
                        }
                        catch (System.Exception)
                        {
                            // TODO: Make exception handling
                        }
                    }
                    break;
                case Actions.UPnPFunctionCall:
                    UPnPFunction func = e.Data as UPnPFunction;
                    if (func != null)
                    {
                        try
                        {
                            #region Create Envelope
                            System.Text.StringBuilder sb = new System.Text.StringBuilder();
                            sb.Append("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">");
                            sb.Append("<s:Body>");
                            sb.Append("<u:" + func.Name + " xmlns:u=\"" + func.Service.Information.serviceType + "\">");
                            foreach (KeyValuePair<string, string> argument in func.Arguments)
                            {
                                sb.AppendFormat("<{0}>{1}</{0}>", argument.Key, argument.Value);
                            }
                            sb.Append("</u:" + func.Name + ">");
                            sb.Append("</s:Body>");
                            sb.Append("</s:Envelope>");
                            #endregion
                            #region Create Request
                            byte[] body = System.Text.Encoding.UTF8.GetBytes(sb.ToString());
                            string url = null;
                            // Is ControlURL relative or absolute?
                            if (func.Service.Information.ControlURL.StartsWith("/"))
                            {
                                url = "http://" + func.Service.Device.Information.URLBase + func.Service.Information.ControlURL;
                            }
                            else
                            {
                                url = func.Service.Information.ControlURL;
                            }

                            WebRequest wr = WebRequest.Create(url);//+ controlUrl);
                            wr.Headers.Clear();
                            wr.Method = "POST";
                            wr.ContentType = "text/xml; charset=\"utf-8\"";
                            wr.Headers.Add("SOAPAction", "\"" + func.Service.Information.serviceType +
                            "#" + func.Name + "\"");
                            wr.ContentLength = body.Length;
                            #endregion
                            #region Call Service function
                            // TODO: Add error handling in this (If server returns code 500 or something)
                            System.IO.Stream stream = wr.GetRequestStream();
                            stream.Write(body, 0, body.Length);
                            stream.Flush();
                            stream.Close();
                            WebResponse wres = wr.GetResponse();
                            System.IO.StreamReader sr = new
                            System.IO.StreamReader(wres.GetResponseStream());
                            string xml = sr.ReadToEnd();
                            sr.Close();
                            #endregion
                            #region Parse returning data
                            XmlDocument document = new XmlDocument();
                            document.LoadXml(xml);
                            SortedList<string, string> tmpList = new SortedList<string, string>(func.Arguments);
                            foreach (KeyValuePair<string, string> argument in func.Arguments)
                            {
                                XmlNodeList nodes = document.GetElementsByTagName(argument.Key);
                                if (nodes.Count == 1)
                                {
                                    tmpList[argument.Key] = nodes[0].InnerText;
                                }
                            }
                            func.Arguments = tmpList;
                            #endregion
                            #region Return data
                            e.Data = func;
                            e.Handled = true;
                            #endregion
                        }
                        catch (System.Net.WebException webEx)
                        {
                            HttpWebResponse resp = webEx.Response as HttpWebResponse;
                            if (resp != null)
                            {

                                func.ErrorCode = (int)resp.StatusCode;
                            }
                            e.Data = func;
                        }
                        catch
                        {
                            // TODO: Add more specific error handling here
                        }
                    }
                    break;
            }
        }
コード例 #21
0
 void Protocol_MessageToSend(object sender, FlowLib.Events.FmdcEventArgs e)
 {
     StrMessage msg = e.Data as StrMessage;
     if (msg != null)
         System.Console.WriteLine(string.Format("OUT: {0}", msg.Raw));
 }
コード例 #22
0
ファイル: UPnPProtocol.cs プロジェクト: musakasim/flowlib
 /// <summary>
 /// Creates a UPnP protocol to use on the specified connection.
 /// Specied searchTarget is used to find upnp-devices.
 /// </summary>
 /// <param name="connection">Connection to use</param>
 /// <param name="searchTarget">
 /// Can be one of the below:
 /// ssdp:all			=	Search for all devices and services.
 /// upnp:rootdevice		=	Search for root devices only.
 /// uuid:device-UUID	=	Search for a particular device. Device UUID specified by UPnP vendor.
 /// urn:schemas-upnp-org:device:deviceType:v	=	Search for any device of this type. Device type and version defined by UPnP Forum working committee.
 /// urn:schemas-upnp-org:service:serviceType:v	=	Search for any service of this type. Service type and version defined by UPnP Forum working committee.
 /// urn:domain-name:device:deviceType:v			=	Search for any device of this type. Domain name, device type and version defined by UPnP vendor. Period characters in the domain name must be replaced with hyphens in accordance with RFC 2141.
 /// urn:domain-name:service:serviceType:v		=	Search for any service of this type. Domain name, service type and version defined by UPnP vendor. Period characters in the domain name must be replaced with hyphens in accordance with RFC 2141.
 /// 
 /// See UPnP Architecture spec for more info (http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0.pdf)
 /// </param>
 public UPnPProtocol(FlowLib.Connections.UPnP connection, string searchTarget)
     : this(connection)
 {
     searchStringToUse = searchTarget;
 }
コード例 #23
0
ファイル: HashTth.cs プロジェクト: BGCX261/zpoc3-svn-to-git
 public bool VerifyData(ref FlowLib.Containers.ContentInfo info, string str)
 {
     throw new System.Exception("The method or operation is not implemented.");
 }
コード例 #24
0
ファイル: Downloading.cs プロジェクト: musakasim/flowlib
 void Downloading_In_PassiveMode_UpdateBase(object sender, FlowLib.Events.FmdcEventArgs e)
 {
 }