Пример #1
0
        private void _ic_Notified(CVResult result, object obj)
        {
            if (result == CVResult.ResourceOperationResponded)
            {
                if (obj is ResourcePt)
                {
                    ResourcePt r = obj as ResourcePt;

                    if (r.service == 4)
                    {
                        if (r.success == 0)
                        {
                            string tempPathfile = Kits.GetTempPathfile(r.name);

                            string           pathfile = _dc.GetFtpPathfileWithoutRemoteDirectory(r.pathfile);
                            DownloadDataItem ddi      = new DownloadDataItem()
                            {
                                Source = pathfile,
                                Target = tempPathfile,
                                Id     = r.objectid,
                                Crc    = r.crc
                            };
                            _dc.Add(ddi);
                        }
                        else
                        {
                            Notified?.Invoke(CVResRequestResult.SourceNotFound, r.msg);
                        }
                    }
                }
            }
        }
Пример #2
0
 private void _ic_Notified(CVResult r, object o)
 {
     if (r == CVResult.TableQueryReceived)
     {
         if (o is QueryResultPt)
         {
             QueryResultPt qrp = o as QueryResultPt;
             if (qrp.success == 0)
             {
                 if (qrp.resultFmart == "xml")
                 {
                     _txw = new TableXmlWrapper(qrp);
                     Notified?.Invoke(CVRTableResult.SelectXmlReceived, _txw);
                 }
                 else if (qrp.resultFmart == "json")
                 {
                     _cjp = new CVRJsonParser(qrp.result)
                     {
                         Token = qrp.token,
                         Count = qrp.count
                     };
                     Notified?.Invoke(CVRTableResult.SelectJsonReceived, _cjp);
                 }
             }
             else
             {
                 Notified?.Invoke(CVRTableResult.SelectFailed, qrp.msg);
             }
         }
     }
     else if (r == CVResult.TableUpdateReceived)
     {
         if (o is ExecuteResultPt)
         {
             ExecuteResultPt erp = o as ExecuteResultPt;
             _ui = new UpdateItem
             {
                 Id      = erp.token,
                 Succeed = erp.success == 0,
                 Msg     = erp.msg
             };
             Notified?.Invoke(CVRTableResult.UpdateResultReceived, _ui);
         }
     }
 }
Пример #3
0
        private void _ic_Notified(CVResult result, object obj)
        {
            if (result == CVResult.ResourceOperationResponded)
            {
                if (obj is ResourcePt)
                {
                    ResourcePt r = obj as ResourcePt;

                    if (r.service == 1)
                    {
                        if (r.success == 0)
                        {
                            Notified?.Invoke(CVReSubmitResult.SubmitSucceed, r.pathfile);
                        }
                        else
                        {
                            Notified?.Invoke(CVReSubmitResult.UploadFailed, r.msg);
                        }
                    }
                }
            }
        }
Пример #4
0
 protected void Notify(CVResult result, object obj)
 {
     Notified?.Invoke(result, obj);
 }
Пример #5
0
        private void _ic_Notified(CVResult r, object o)
        {
            if (r == CVResult.TableQueryReceived)
            {
                if (o is QueryResultPt)
                {
                    QueryResultPt qrp = o as QueryResultPt;
                    if (qrp.token == _token)
                    {
                        if (qrp.success == 0)
                        {
                            TableXmlWrapper txw = new TableXmlWrapper(qrp);

                            _curNum    = txw.Count;
                            _curIndex  = 0;
                            _pageCount = txw.Count / _pageSize + (txw.Count % _pageSize == 0 ? 0 : 1);

                            foreach (XmlNode xn in txw.Nodes)
                            {
                                ResXmlNodeParser rxnp     = new ResXmlNodeParser(xn);
                                string           pathfile = rxnp.Pathfile.Remove(0, 1);
                                string           file     = pathfile.Replace(_dc.RemoteDirectory + @"/", "");

                                string source = @"ftp://" + _dc.Ip + @"/" + pathfile;
                                string target = Path.Combine(_dc.LocalDirectory, file).Replace("/", @"\");

                                DateTime tdt = File.Exists(target) ? File.GetLastWriteTime(target) : DateTime.MinValue;
                                if (!Kits.DateTimeEqual(rxnp.Lastwrite, tdt))
                                {
                                    if (UseMemory)
                                    {
                                        DownloadMemoryItem dmi = new DownloadMemoryItem
                                        {
                                            Id     = rxnp.Id,
                                            Source = source,
                                            Target = target,
                                            Crc    = rxnp.Crc,
                                            Tag    = rxnp.Name
                                        };
                                        _dc.Add(dmi);
                                    }
                                    else
                                    {
                                        DownloadDataItem ddi = new DownloadDataItem
                                        {
                                            Id     = rxnp.Id,
                                            Source = source,
                                            Target = target,
                                            Crc    = rxnp.Crc,
                                            Tag    = rxnp.Name
                                        };
                                        _dc.Add(ddi);
                                    }
                                }
                                else
                                {
                                    Notified?.Invoke(CVResDownloadResult.ExistedTarget, target);
                                    if (++_curIndex >= _curNum)
                                    {
                                        if (++_pageNo >= _pageCount)
                                        {
                                            Completed?.Invoke();
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Notified?.Invoke(CVResDownloadResult.RequestResourceFailed, qrp.msg);
                        }
                    }
                }
            }
        }
Пример #6
0
        private void _ic_Notified(CVResult result, object obj)
        {
            if (result == CVResult.LogonSucceeded)
            {
                LoginPt lp = obj as LoginPt;
                _user = UserItem.From(lp);
                if (_user.Role == UserRole.Administrator || _user.Role == UserRole.SystemAdministrator)
                {
                    Status = CVRInfoExStatus.Refused;
                    Notified?.Invoke(CVRInfoExResult.PrivilegeHappened, _user.Role.ToString() + " 权限访问使用");
                    _ic.Shutdown();
                }
                else
                {
                    Status = CVRInfoExStatus.Ready;
                    Notified?.Invoke(CVRInfoExResult.LogonSucceeded, _user);
                }
            }
            else if (result == CVResult.LogonFailed)
            {
                Status = CVRInfoExStatus.Offline;
                LoginPt lp = obj as LoginPt;
                Notified?.Invoke(CVRInfoExResult.LogonFailed, lp.msg);
            }
            else if (result == CVResult.OnlineUsersNotified)
            {
                LogonUserListPt lulp = obj as LogonUserListPt;

                foreach (LoginPt lp in lulp.logonUsers)
                {
                    if (!_users.ContainsKey(lp.id))
                    {
                        Add(lp.id, lp.username, lp.role);
                    }
                }
                Notified?.Invoke(CVRInfoExResult.UserChanged, _users);
            }
            else if (result == CVResult.OnlineUserChanged)
            {
                LogoutPt lp = obj as LogoutPt;
                if (lp.state == 0)
                {
                    //用户上线
                    UserItem ui = Add(lp.id, lp.username, lp.role);
                    if (ui != null)
                    {
                        Notified?.Invoke(CVRInfoExResult.UserChanged, _users);
                    }
                }
                else if (lp.state == 1)
                {
                    //用户
                    _users.Remove(lp.id);
                    Notified?.Invoke(CVRInfoExResult.UserChanged, _users);
                }
            }
            else if (result == CVResult.MessageReceived)
            {
                ChatTextPt ctp = obj as ChatTextPt;
                if (ctp.msg.Contains("\r"))
                {
                    TeamworkItem ti = TeamworkItem.FromMsg(ctp.msg);
                    ti.Item = MessageItem.From(ctp);
                    Notified?.Invoke(CVRInfoExResult.TeamworkReceived, ti);
                }
                else
                {
                    MessageItem mi = MessageItem.From(ctp);
                    Notified?.Invoke(CVRInfoExResult.MessageReceived, mi);
                }
            }
            else if (result == CVResult.MessageNotified)
            {
                MessagePt mp = obj as MessagePt;
                Status = mp.msgtype == "101001" ? CVRInfoExStatus.Timeout: CVRInfoExStatus.Unknown;
                Notified?.Invoke(CVRInfoExResult.MessageNotified, mp.msg);
            }
        }
Пример #7
0
 private void _parser_Info(CVResult result, object obj)
 {
     Notified?.Invoke(result, obj);
 }
Пример #8
0
 internal void Notify(CVResult r, object o)
 {
     Notified?.Invoke(r, o);
 }