Example #1
0
        private void LoadDatabaseInfo()
        {
            try
            {
                if (Session == null || Session.AppServerInfo == null)
                {
                    return;
                }
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)RequestCode.WSGetDBInfo;
                webRequest.Session = Session;
                webRequest.ListData.Add(Session.UserID.ToString());
                Service11012Client client = new Service11012Client(
                    WebHelper.CreateBasicHttpBinding(Session)
                    , WebHelper.CreateEndpointAddress(Session.AppServerInfo, "Service11012"));
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    WriteLog("LoadDBInfo", string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    return;
                }
                if (webReturn.ListData == null ||
                    webReturn.ListData.Count < 6)
                {
                    WriteLog("LoadDBInfo", string.Format("Fail.\tDatabase param count invalid"));
                    return;
                }

                DatabaseInfo dbInfo = Session.DatabaseInfo;
                if (dbInfo == null)
                {
                    dbInfo = new DatabaseInfo();
                }
                int    intValue;
                string strValue;
                if (webReturn.ListData.Count > 0)
                {
                    strValue = webReturn.ListData[0];
                    if (int.TryParse(strValue, out intValue))
                    {
                        dbInfo.TypeID = intValue;
                    }
                }
                if (webReturn.ListData.Count > 1)
                {
                    strValue    = webReturn.ListData[1];
                    dbInfo.Host = strValue;
                }
                if (webReturn.ListData.Count > 2)
                {
                    strValue = webReturn.ListData[2];
                    if (int.TryParse(strValue, out intValue))
                    {
                        dbInfo.Port = intValue;
                    }
                }
                if (webReturn.ListData.Count > 3)
                {
                    strValue      = webReturn.ListData[3];
                    dbInfo.DBName = strValue;
                }
                if (webReturn.ListData.Count > 4)
                {
                    strValue         = webReturn.ListData[4];
                    dbInfo.LoginName = strValue;
                }
                if (webReturn.ListData.Count > 5)
                {
                    strValue        = webReturn.ListData[5];
                    dbInfo.Password = strValue;
                }
                Session.DatabaseInfo = dbInfo;
                Session.DBType       = dbInfo.TypeID;
                IsDBSetted           = true;

                WriteLog("LoadDBInfo", string.Format("LoadDatabaseInfo end.\t{0}", dbInfo));
            }
            catch (Exception ex)
            {
                WriteLog("LoadDBInfo", string.Format("LoadDatabaseInfo fail.\t{0}", ex.Message));
            }
        }
Example #2
0
        private void LoadLanguageInfos()
        {
            try
            {
                if (CurrentApp.Session == null || CurrentApp.Session.LangTypeInfo == null)
                {
                    return;
                }
                mListLanguageInfos.Clear();
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)RequestCode.WSGetLangList;
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add(string.Format("31{0}0", ConstValue.SPLITER_CHAR));
                webRequest.ListData.Add(string.Format("3101{0}0", ConstValue.SPLITER_CHAR));
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add(string.Empty);
                Service11012Client client = new Service11012Client(
                    WebHelper.CreateBasicHttpBinding(CurrentApp.Session)
                    , WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11012"));
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowException(string.Format("{0}\t{1}", webReturn.Code, webReturn.Message));
                }
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    OperationReturn optReturn = XMLHelper.DeserializeObject <LanguageInfo>(webReturn.ListData[i]);
                    if (!optReturn.Result)
                    {
                        ShowException(string.Format("{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    LanguageInfo langInfo = optReturn.Data as LanguageInfo;
                    if (langInfo == null)
                    {
                        ShowException(string.Format("LanguageInfo is null"));
                        return;
                    }
                    ScoreLangauge scoreLanguage = new ScoreLangauge();
                    scoreLanguage.LangID  = langInfo.LangID;
                    scoreLanguage.Display = langInfo.Display;

                    string name = langInfo.Name;
                    if (name.StartsWith("OBJ301"))
                    {
                        scoreLanguage.Code     = name;
                        scoreLanguage.Category = langInfo.Page;
                        mListLanguageInfos.Add(scoreLanguage);
                    }
                    if (name.StartsWith("PRO301"))
                    {
                        scoreLanguage.Code     = name;
                        scoreLanguage.Category = langInfo.Page;
                        mListLanguageInfos.Add(scoreLanguage);
                    }
                    if (name.StartsWith("PROD301"))
                    {
                        scoreLanguage.Code     = name;
                        scoreLanguage.Category = langInfo.Page;
                        mListLanguageInfos.Add(scoreLanguage);
                    }
                    if (name.StartsWith("3101GRP301"))
                    {
                        scoreLanguage.Code     = name;
                        scoreLanguage.Category = langInfo.Page;
                        mListLanguageInfos.Add(scoreLanguage);
                    }
                    if (name.StartsWith("3101Designer"))
                    {
                        scoreLanguage.Category = langInfo.Page;
                        scoreLanguage.Code     = name.Substring(12);
                        mListLanguageInfos.Add(scoreLanguage);
                    }
                    if (name.StartsWith("3101ToolBar"))
                    {
                        scoreLanguage.Category = langInfo.Page;
                        scoreLanguage.Code     = name.Substring(11);
                        mListLanguageInfos.Add(scoreLanguage);
                    }
                    if (name.StartsWith("3101ScoreViewer"))
                    {
                        scoreLanguage.Category = langInfo.Page;
                        scoreLanguage.Code     = name.Substring(15);
                        mListLanguageInfos.Add(scoreLanguage);
                    }
                    if (name.StartsWith("3101PropertyViewer"))
                    {
                        scoreLanguage.Category = langInfo.Page;
                        scoreLanguage.Code     = name.Substring(18);
                        mListLanguageInfos.Add(scoreLanguage);
                    }
                    if (name.StartsWith("3101ObjectViewer"))
                    {
                        scoreLanguage.Category = langInfo.Page;
                        scoreLanguage.Code     = name.Substring(16);
                        mListLanguageInfos.Add(scoreLanguage);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Example #3
0
 private void InitControlOrgs(TreeObjectItem parentItem, string parentID)
 {
     try
     {
         WebRequest webRequest = new WebRequest();
         webRequest.Session = SessionInfo;
         webRequest.Code    = (int)RequestCode.WSGetUserObjList;
         webRequest.ListData.Add(SessionInfo.UserID.ToString());
         webRequest.ListData.Add("0");
         webRequest.ListData.Add(ConstValue.RESOURCE_ORG.ToString());
         webRequest.ListData.Add(parentID);
         Service11012Client client = new Service11012Client(
             WebHelper.CreateBasicHttpBinding(SessionInfo),
             WebHelper.CreateEndpointAddress(
                 SessionInfo.AppServerInfo,
                 "Service11012"));
         WebReturn webReturn = client.DoOperation(webRequest);
         client.Close();
         if (!webReturn.Result)
         {
             return;
         }
         if (webReturn.ListData == null)
         {
             return;
         }
         for (int i = 0; i < webReturn.ListData.Count; i++)
         {
             string   strInfo = webReturn.ListData[i];
             string[] arrInfo = strInfo.Split(new[] { ConstValue.SPLITER_CHAR },
                                              StringSplitOptions.RemoveEmptyEntries);
             if (arrInfo.Length < 2)
             {
                 continue;
             }
             string         strID   = arrInfo[0];
             string         strName = arrInfo[1];
             TreeObjectItem item    = new TreeObjectItem();
             item.ObjType = ConstValue.RESOURCE_ORG;
             item.ObjID   = Convert.ToInt64(strID);
             item.Name    = strName;
             item.Data    = strInfo;
             if (strID == ConstValue.ORG_ROOT.ToString())
             {
                 item.Icon = "Images/root.ico";
             }
             else
             {
                 item.Icon = "Images/org.ico";
             }
             InitControlOrgs(item, strID);
             InitControlUsers(item, strID);
             InitControlAgents(item, strID);
             Dispatcher.Invoke(new Action(() => parentItem.AddChild(item)));
             mListObjects.Add(item);
         }
     }
     catch (Exception ex)
     {
         TreeObjectEventArgs args = new TreeObjectEventArgs();
         args.Code    = 999;
         args.Message = ex.Message;
         OnTreeObjectEvent(args);
     }
 }
Example #4
0
 private void SaveRecordEncryptConfig()
 {
     try
     {
         if (ListRecordEncryptInfos == null)
         {
             return;
         }
         List <UserParamInfo> listInfos = new List <UserParamInfo>();
         for (int i = 0; i < ListRecordEncryptInfos.Count; i++)
         {
             var item = ListRecordEncryptInfos[i];
             if (!item.IsRemember)
             {
                 continue;
             }
             UserParamInfo up = new UserParamInfo();
             up.UserID   = App.Session.UserID;
             up.ParamID  = S3104Consts.USER_PARAM_GROUP_ENCRYPTINFO * 1000 + 1 + i;
             up.GroupID  = S3104Consts.USER_PARAM_GROUP_ENCRYPTINFO;
             up.SortID   = i;
             up.DataType = DBDataType.NVarchar;
             string strValue = string.Format("{0}{1}{2}{1}{3}",
                                             item.ServerAddress,
                                             ConstValue.SPLITER_CHAR_3,
                                             item.Password,
                                             item.EndTime.ToString("yyyyMMddHHmmss"));
             up.ParamValue = strValue;
             listInfos.Add(up);
         }
         int cout = listInfos.Count;
         if (cout <= 0)
         {
             return;
         }
         OperationReturn optReturn;
         WebRequest      webRequest = new WebRequest();
         webRequest.Code    = (int)RequestCode.WSSaveUserParamList;
         webRequest.Session = App.Session;
         webRequest.ListData.Add(App.Session.UserInfo.UserID.ToString());
         webRequest.ListData.Add(cout.ToString());
         for (int i = 0; i < cout; i++)
         {
             var up = listInfos[i];
             optReturn = XMLHelper.SeriallizeObject(up);
             if (!optReturn.Result)
             {
                 App.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                 return;
             }
             webRequest.ListData.Add(optReturn.Data.ToString());
         }
         //App.MonitorHelper.AddWebRequest(webRequest);
         Service11012Client client = new Service11012Client(WebHelper.CreateBasicHttpBinding(App.Session),
                                                            WebHelper.CreateEndpointAddress(App.Session.AppServerInfo, "Service11012"));
         WebHelper.SetServiceClient(client);
         WebReturn webReturn = client.DoOperation(webRequest);
         //App.MonitorHelper.AddWebReturn(webReturn);
         client.Close();
         if (!webReturn.Result)
         {
             App.ShowExceptionMessage(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
         }
     }
     catch (Exception ex)
     {
         App.WriteLog("SaveEncryptConfig", string.Format("Fail.\t{0}", ex.Message));
     }
 }
Example #5
0
 private void InitMemoUsers()
 {
     try
     {
         List <string> listUserID = new List <string>();
         for (int i = 0; i < mListRecordMemos.Count; i++)
         {
             string strUserID = mListRecordMemos[i].UserID.ToString();
             if (!listUserID.Contains(strUserID))
             {
                 listUserID.Add(strUserID);
             }
         }
         if (listUserID.Count <= 0)
         {
             return;
         }
         WebRequest webRequest = new WebRequest();
         webRequest.Session = CurrentApp.Session;
         webRequest.Code    = (int)RequestCode.WSGetResourceProperty;
         webRequest.ListData.Add("102");
         webRequest.ListData.Add("Account");
         webRequest.ListData.Add(listUserID.Count.ToString());
         for (int i = 0; i < listUserID.Count; i++)
         {
             webRequest.ListData.Add(listUserID[i]);
         }
         Service11012Client client = new Service11012Client(
             WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
             WebHelper.CreateEndpointAddress(
                 CurrentApp.Session.AppServerInfo,
                 "Service11012"));
         WebReturn webReturn = client.DoOperation(webRequest);
         client.Close();
         if (!webReturn.Result)
         {
             ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
             return;
         }
         if (webReturn.ListData == null)
         {
             ShowException(string.Format("Fail.\tListData is null"));
             return;
         }
         mListUsers.Clear();
         for (int i = 0; i < webReturn.ListData.Count; i++)
         {
             string   strInfo = webReturn.ListData[i];
             string[] arrInfo = strInfo.Split(new[] { ConstValue.SPLITER_CHAR },
                                              StringSplitOptions.RemoveEmptyEntries);
             if (arrInfo.Length < 2)
             {
                 continue;
             }
             long   id      = Convert.ToInt64(arrInfo[0]);
             string account = arrInfo[1];
             if (id == CurrentApp.Session.UserID)
             {
                 continue;
             }
             BasicUserItem item = new BasicUserItem();
             item.UserID = id;
             item.Name   = account;
             mListUsers.Add(item);
         }
     }
     catch (Exception ex)
     {
         ShowException(ex.Message);
     }
 }
        private void LoadUserOrgs(ObjectItem parentItem)
        {
            string OrgID = string.Empty;

            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Session = CurrentApp.Session;
                webRequest.Code    = (int)RequestCode.WSGetUserObjList;
                webRequest.ListData.Add(UserItem.ObjID.ToString());
                webRequest.ListData.Add("0");
                webRequest.ListData.Add(ConstValue.RESOURCE_ORG.ToString());
                webRequest.ListData.Add("-1");
                Service11012Client client = new Service11012Client(
                    WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                    WebHelper.CreateEndpointAddress(
                        CurrentApp.Session.AppServerInfo,
                        "Service11012"));
                WebHelper.SetServiceClient(client);
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                }
                if (webReturn.ListData == null)
                {
                    ShowException(string.Format("Fail.\tListData is null"));
                }
                if (webReturn.ListData.Count > 0)
                //for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    string   strInfo = webReturn.ListData[0];
                    string[] arrInfo = strInfo.Split(new[] { ConstValue.SPLITER_CHAR },
                                                     StringSplitOptions.RemoveEmptyEntries);
                    if (arrInfo.Length < 2)
                    {
                        return;
                    }
                    OrgID = arrInfo[0];
                    string strName = arrInfo[1];

                    ObjectItem item = new ObjectItem();
                    item.ObjType = ConstValue.RESOURCE_ORG;
                    item.ObjID   = Convert.ToInt64(OrgID);
                    item.Name    = strName;
                    item.Data    = strInfo;
                    if (OrgID == ConstValue.ORG_ROOT.ToString())
                    {
                        item.Icon = "Images/root.ico";
                    }
                    else
                    {
                        item.Icon = "Images/org.ico";
                    }

                    LoadAvaliableOrgs(item, OrgID);
                    LoadAvaliableUsers(item, OrgID);
                    if (PageParent.InitParameter.Contains("A"))
                    {
                        LoadAvaliableAgents(item, OrgID);
                    }
                    if (PageParent.InitParameter.Contains("E"))
                    {
                        LoadAvaliableExts(item, OrgID);
                    }
                    if (PageParent.InitParameter.Contains("R"))
                    {
                        LoadAvaliableRealExts(item, OrgID);
                    }
                    Dispatcher.Invoke(new Action(() => parentItem.AddChild(item)));
                    mListObjectItems.Add(item);
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Example #7
0
        /// <summary>
        /// 获得当前用户可以管理的用户
        /// </summary>
        /// <returns></returns>
        public static OperationReturn GetCotrlUser()
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = Defines.RET_SUCCESS;
            Service11012Client client = null;

            try
            {
                string     strUserID  = App.Session.UserID.ToString();
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)RequestCode.WSGetUserCtlObjList;
                webRequest.Session = App.Session;
                webRequest.ListData.Add(App.Session.UserInfo.UserID.ToString());
                webRequest.ListData.Add("1");
                webRequest.ListData.Add(ConstValue.RESOURCE_USER.ToString());
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add("3");
                App.MonitorHelper.AddWebRequest(webRequest);
                client = new Service11012Client(WebHelper.CreateBasicHttpBinding(App.Session),
                                                WebHelper.CreateEndpointAddress(App.Session.AppServerInfo, "Service11012"));
                WebHelper.SetServiceClient(client);
                WebReturn webReturn = client.DoOperation(webRequest);
                App.MonitorHelper.AddWebReturn(webReturn);
                client.Close();
                if (!webReturn.Result)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = webReturn.Code;
                    optReturn.Message = webReturn.Message;
                    return(optReturn);
                }
                if (webReturn.ListData == null)
                {
                    optReturn.Result = false;
                    optReturn.Code   = (int)S6106WcfErrorCode.GetUserPermissionFailed;
                    return(optReturn);
                }

                List <string>  lstUserIDs = new List <string>();
                ResourceObject res        = null;
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    optReturn = XMLHelper.DeserializeObject <ResourceObject>(webReturn.ListData[i]);
                    if (optReturn.Result)
                    {
                        res = optReturn.Data as ResourceObject;
                        lstUserIDs.Add(res.ObjID.ToString());
                    }
                }
                optReturn.Data = lstUserIDs;
                return(optReturn);
            }
            catch (Exception ex)
            {
                App.ShowExceptionMessage(ex.Message);
                return(optReturn);
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
        }
Example #8
0
 private void LoadCustomColumnData()
 {
     try
     {
         mListObject_Kpi.Clear();
         WebRequest webRequest = new WebRequest();
         webRequest.Code    = (int)RequestCode.WSGetUserViewColumnList;
         webRequest.Session = CurrentApp.Session;
         webRequest.ListData.Add(CurrentApp.Session.UserInfo.UserID.ToString());
         webRequest.ListData.Add("4602001");
         Service11012Client client = new Service11012Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                            WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11012"));
         WebReturn webReturn = client.DoOperation(webRequest);
         client.Close();
         if (!webReturn.Result)
         {
             ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
             return;
         }
         List <ViewColumnInfo> listColumns = new List <ViewColumnInfo>();
         for (int i = 0; i < webReturn.ListData.Count; i++)
         {
             OperationReturn optReturn = XMLHelper.DeserializeObject <ViewColumnInfo>(webReturn.ListData[i]);
             if (!optReturn.Result)
             {
                 ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                 return;
             }
             ViewColumnInfo columnInfo = optReturn.Data as ViewColumnInfo;
             if (columnInfo != null)
             {
                 columnInfo.Display = columnInfo.ColumnName;
                 listColumns.Add(columnInfo);
             }
         }
         listColumns = listColumns.OrderBy(c => c.SortID).ToList();
         if (listColumns.Where(p => p.SortID == 0).First().ColumnName == "UERName")//按对象分组
         {
             rabObject.IsChecked = true;
         }
         else
         {
             rabKpi.IsChecked = true;
         }
         mListCustomColumns.Clear();
         for (int i = 0; i < listColumns.Count; i++)
         {
             ViewColumnInfoItem item = new ViewColumnInfoItem(listColumns[i]);
             item.Display      = CurrentApp.GetLanguageInfo(string.Format("4601P00{0}", item.LangID.ToString().Substring(1, 3)), item.ColumnName);
             item.StrIsVisible = CurrentApp.GetLanguageInfo(string.Format("4601P0004{0}", listColumns[i].Visibility), listColumns[i].Visibility);
             if (i % 2 != 0)
             {
                 item.Background = Brushes.LightGray;
             }
             else
             {
                 item.Background = Brushes.AntiqueWhite;
             }
             if (item.ColumnName == "UERName" || item.ColumnName == "KPIName")//对象、PM指标列不能修改顺序,在提交应用时再加上去
             {
                 mListObject_Kpi.Add(listColumns[i]);
             }
             else
             {
                 mListCustomColumns.Add(item);
             }
         }
     }
     catch (Exception ex)
     {
         ShowException(ex.Message);
     }
 }
Example #9
0
        private void BrowseIconImage()
        {
            try
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Title       = string.Format("Select a image as Alarm icon");
                dialog.Multiselect = false;
                dialog.Filter      = "Support Image|*.jpg;*.jpeg;*.png;*.bmp;*.gif";
                var result = dialog.ShowDialog();
                if (result != true)
                {
                    return;
                }
                string strFile = dialog.FileName;
                if (!File.Exists(strFile))
                {
                    return;
                }


                #region   背景图片

                FileInfo fileInfo = new FileInfo(strFile);
                string   strExt   = fileInfo.Extension;
                strExt = strExt.TrimStart('.');
                if (fileInfo.Length > 1024 * 1024 * 5)
                {
                    //图片文件超过5M,不允许上传
                    ShowException(string.Format("Image file too big, can not upload."));
                    return;
                }
                int           length  = (int)fileInfo.Length;
                byte[]        buffer  = File.ReadAllBytes(strFile);
                UploadRequest request = new UploadRequest();
                request.Session = CurrentApp.Session;
                request.Code    = (int)RequestCode.WSUploadFile;
                request.ListData.Add(length.ToString());
                request.ListData.Add("4415");
                request.ListData.Add("1");          //先上传到MediaData临时目录
                request.ListData.Add(string.Empty); //自动生成文件名
                request.ListData.Add(strExt);       //扩展名
                request.Content = buffer;
                Service11012Client client = new Service11012Client(
                    WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                    WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11012"));
                WebReturn webReturn = client.UploadOperation(request);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    return;
                }
                string strTemp = webReturn.Data;
                if (string.IsNullOrEmpty(strTemp))
                {
                    ShowException(string.Format("Fail.\tFileName empty!"));
                    return;
                }
                mAlarmIcon = strTemp;

                CurrentApp.WriteLog("UploadIconImage", string.Format("End.\t{0}", mAlarmIcon));

                string strUrl = string.Format("{0}://{1}:{2}/{3}/{4}",
                                              CurrentApp.Session.AppServerInfo.Protocol,
                                              CurrentApp.Session.AppServerInfo.Address,
                                              CurrentApp.Session.AppServerInfo.Port,
                                              ConstValue.TEMP_DIR_MEDIADATA,
                                              mAlarmIcon);
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.UriSource = new Uri(strUrl, UriKind.Absolute);
                bitmap.EndInit();
                ImageIcon.Source = bitmap;

                Image imgTip = new Image();
                imgTip.Source     = new BitmapImage(new Uri(strUrl, UriKind.Absolute));
                imgTip.Stretch    = Stretch.Uniform;
                ImageIcon.ToolTip = imgTip;

                #endregion
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Example #10
0
        private OperationReturn RemoveAlarmInfoList(SessionInfo session, List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                //ListParam
                //0     用户编码
                //1     待删除的告警信息总数
                //2...     待删除告警信息的SerialID
                if (listParams == null || listParams.Count < 2)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Request param is null or count invalid");
                    return(optReturn);
                }
                string strUserID = listParams[0];
                string strCount  = listParams[1];
                int    intCount;
                if (!int.TryParse(strCount, out intCount))
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("AlarmInfo count param invalid");
                    return(optReturn);
                }
                if (listParams.Count < intCount + 2)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("AlarmInfo count invalid");
                    return(optReturn);
                }
                List <long> listAlarmInfoIDs = new List <long>();
                for (int i = 0; i < intCount; i++)
                {
                    string strID = listParams[i + 2];
                    long   id;
                    if (!long.TryParse(strID, out id))
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_PARAM_INVALID;
                        optReturn.Message = string.Format("AlarmInfo serialID invalid");
                        return(optReturn);
                    }
                    listAlarmInfoIDs.Add(id);
                }
                //将SerialID插入到临时表中
                WebRequest webRequest = new WebRequest();
                webRequest.Session = session;
                webRequest.Code    = (int)RequestCode.WSInsertTempData;
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add(intCount.ToString());
                for (int i = 0; i < intCount; i++)
                {
                    string strInfo = listAlarmInfoIDs[i].ToString();
                    webRequest.ListData.Add(strInfo);
                }
                Service11012Client client = new Service11012Client(WebHelper.CreateBasicHttpBinding(session),
                                                                   WebHelper.CreateEndpointAddress(session.AppServerInfo, "Service11012"));
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = webReturn.Code;
                    optReturn.Message = webReturn.Message;
                    return(optReturn);
                }
                string strTempID = webReturn.Data;
                string rentToken = session.RentInfo.Token;
                string strSql;
                switch (session.DBType)
                {
                //MSSQL
                case 2:
                    strSql =
                        string.Format(
                            "DELETE FROM T_25_007 WHERE C001 IN (SELECT C011 FROM T_00_901 WHERE C001 = {0})",
                            strTempID);
                    optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    strSql =
                        string.Format(
                            "DELETE FROM T_25_008 WHERE C002 IN (SELECT C011 FROM T_00_901 WHERE C001 = {0})",
                            strTempID);
                    optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    break;

                //ORCL
                case 3:
                    strSql =
                        string.Format(
                            "DELETE FROM T_25_007 WHERE C001 IN (SELECT C011 FROM T_00_901 WHERE C001 = {0})",
                            strTempID);
                    optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    strSql =
                        string.Format(
                            "DELETE FROM T_25_008 WHERE C002 IN (SELECT C011 FROM T_00_901 WHERE C001 = {0})",
                            strTempID);
                    optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Database type not support");
                    return(optReturn);
                }
            }
            catch (Exception ex)
            {
                optReturn.Result    = false;
                optReturn.Code      = Defines.RET_FAIL;
                optReturn.Message   = ex.Message;
                optReturn.Exception = ex;
            }
            return(optReturn);
        }
Example #11
0
        private OperationReturn RemoveResourceObjectData(SessionInfo session, List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                //ListParam
                //0     资源总数
                //1...     资源编码
                if (listParams == null || listParams.Count < 1)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Request param is null or count invalid");
                    return(optReturn);
                }
                string strCount = listParams[0];
                int    intCount;
                if (!int.TryParse(strCount, out intCount))
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Resource id count param invalid");
                    return(optReturn);
                }
                if (listParams.Count < intCount + 1)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Resource id count invalid");
                    return(optReturn);
                }
                if (intCount > 0)
                {
                    WebRequest webRequest = new WebRequest();
                    webRequest.Session = session;
                    webRequest.Code    = (int)RequestCode.WSInsertTempData;
                    webRequest.ListData.Add(string.Empty);
                    webRequest.ListData.Add(intCount.ToString());
                    for (int i = 0; i < intCount; i++)
                    {
                        webRequest.ListData.Add(listParams[i + 1]);
                    }
                    Service11012Client client = new Service11012Client(WebHelper.CreateBasicHttpBinding(session),
                                                                       WebHelper.CreateEndpointAddress(session.AppServerInfo, "Service11012"));
                    WebReturn webReturn = client.DoOperation(webRequest);
                    client.Close();
                    if (!webReturn.Result)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = webReturn.Code;
                        optReturn.Message = webReturn.Message;
                        return(optReturn);
                    }
                    string strID     = webReturn.Data;
                    string rentToken = session.RentInfo.Token;
                    string strSql;
                    switch (session.DBType)
                    {
                    case 2:
                        strSql =
                            string.Format(
                                "DELETE FROM T_11_101_{0} WHERE C001 IN (SELECT C011 FROM T_00_901 WHERE C001 = {1})",
                                rentToken,
                                strID);
                        optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql);
                        if (!optReturn.Result)
                        {
                            return(optReturn);
                        }
                        break;

                    case 3:
                        strSql =
                            string.Format(
                                "DELETE FROM T_11_101_{0} WHERE C001 IN (SELECT C011 FROM T_00_901 WHERE C001 = {1})",
                                rentToken,
                                strID);
                        optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql);
                        if (!optReturn.Result)
                        {
                            return(optReturn);
                        }
                        break;

                    default:
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_PARAM_INVALID;
                        optReturn.Message = string.Format("Database type not support");
                        return(optReturn);
                    }
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Example #12
0
        protected override void InitLanguageInfos()
        {
            base.InitLanguageInfos();
            try
            {
                if (Session == null || Session.LangTypeInfo == null)
                {
                    return;
                }
                //ListLanguageInfos.Clear();
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)RequestCode.WSGetLangList;
                webRequest.Session = Session;
                //ListParams
                //0     LangID
                //1     PreName(语言内容编码的前缀,比如 FO:模块、操作显示语言)
                //2     ModuleID
                //3     SubModuleID
                //4     Page
                //5     Name
                webRequest.ListData.Add(Session.LangTypeInfo.LangID.ToString());
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add("11");
                webRequest.ListData.Add("1102");
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add(string.Empty);
                Service11012Client client = new Service11012Client(WebHelper.CreateBasicHttpBinding(Session), WebHelper.CreateEndpointAddress(Session.AppServerInfo, "Service11012"));
                WebHelper.SetServiceClient(client);
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowExceptionMessage(string.Format("{0}\t{1}", webReturn.Code, webReturn.Message));
                }
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    OperationReturn optReturn = XMLHelper.DeserializeObject <LanguageInfo>(webReturn.ListData[i]);
                    if (!optReturn.Result)
                    {
                        ShowExceptionMessage(string.Format("{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    LanguageInfo langInfo = optReturn.Data as LanguageInfo;
                    if (langInfo == null)
                    {
                        ShowExceptionMessage(string.Format("LanguageInfo is null"));
                        return;
                    }
                    ListLanguageInfos.Add(langInfo);
                }
                //MessageBox.Show(name+"  1:ok");

                //ListParams
                //0     LangID
                //1     PreName(语言内容编码的前缀,比如 FO:模块、操作显示语言)
                //2     ModuleID
                //3     SubModuleID
                //4     Page
                //5     Name
                webRequest         = new WebRequest();
                webRequest.Session = Session;
                webRequest.Code    = (int)RequestCode.WSGetLangList;
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add("FO");
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add(string.Empty);
                client = new Service11012Client(WebHelper.CreateBasicHttpBinding(Session), WebHelper.CreateEndpointAddress(Session.AppServerInfo, "Service11012"));
                WebHelper.SetServiceClient(client);
                webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowExceptionMessage(string.Format("{0}\t{1}", webReturn.Code, webReturn.Message));
                }
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    OperationReturn optReturn = XMLHelper.DeserializeObject <LanguageInfo>(webReturn.ListData[i]);
                    if (!optReturn.Result)
                    {
                        ShowExceptionMessage(string.Format("{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    LanguageInfo langInfo = optReturn.Data as LanguageInfo;
                    if (langInfo == null)
                    {
                        ShowExceptionMessage(string.Format("LanguageInfo is null"));
                        return;
                    }
                    if (ListLanguageInfos.Where(p => p.LangID == langInfo.LangID && p.Name == langInfo.Name).Count() == 0)
                    {
                        ListLanguageInfos.Add(langInfo);
                    }
                }
                //MessageBox.Show(name+"  2:ok");

                webRequest         = new WebRequest();
                webRequest.Session = Session;
                webRequest.Code    = (int)RequestCode.WSGetLangList;
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add("COM");
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add(string.Empty);
                webRequest.ListData.Add(string.Empty);
                client = new Service11012Client(WebHelper.CreateBasicHttpBinding(Session), WebHelper.CreateEndpointAddress(Session.AppServerInfo, "Service11012"));
                WebHelper.SetServiceClient(client);
                webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowExceptionMessage(string.Format("{0}\t{1}", webReturn.Code, webReturn.Message));
                }
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    OperationReturn optReturn = XMLHelper.DeserializeObject <LanguageInfo>(webReturn.ListData[i]);
                    if (!optReturn.Result)
                    {
                        ShowExceptionMessage(string.Format("{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    LanguageInfo langInfo = optReturn.Data as LanguageInfo;
                    if (langInfo == null)
                    {
                        ShowExceptionMessage(string.Format("LanguageInfo is null"));
                        return;
                    }
                    if (ListLanguageInfos.Where(p => p.LangID == langInfo.LangID && p.Name == langInfo.Name).Count() == 0)
                    {
                        ListLanguageInfos.Add(langInfo);
                    }
                } //MessageBox.Show(name+"  3:ok");
            }
            catch (Exception ex)
            {
                //ShowExceptionMessage(ex.Message);
            }
        }
Example #13
0
        private OperationReturn SaveNewDomainInfo(DataSet dataSet, SessionInfo session, BasicDomainInfo DI)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                //如果没有重名,则添加到数据库
                WebRequest webRequest = new WebRequest();
                webRequest.Session = session;
                webRequest.Code    = (int)RequestCode.WSGetSerialID;
                webRequest.ListData.Add("11");
                webRequest.ListData.Add("110");
                webRequest.ListData.Add(DateTime.Now.ToString("yyyyMMddHHmmss"));
                Service11012Client client = new Service11012Client(WebHelper.CreateBasicHttpBinding(session),
                                                                   WebHelper.CreateEndpointAddress(session.AppServerInfo, "Service11012"));
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = webReturn.Code;
                    optReturn.Message = webReturn.Message;
                    return(optReturn);
                }
                string strNewID = webReturn.Data;
                if (string.IsNullOrEmpty(strNewID))
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_STRING_EMPTY;
                    optReturn.Message = string.Format("New Domain ID is empty");
                    return(optReturn);
                }
                int     dex    = dataSet.Tables[0].Rows.Count;
                DataRow NewRow = dataSet.Tables[0].NewRow();
                NewRow["C001"] = strNewID;
                NewRow["C002"] = session.RentInfo.Token;
                NewRow["C003"] = EncryptToDB002(DI.DomainName.Trim());
                NewRow["C004"] = dex.ToString();
                NewRow["C005"] = EncryptToDB002(DI.DomainUserName.Trim());
                NewRow["C006"] = EncryptToDB003(string.Format("{0}@{1}", strNewID, DI.DomainUserPassWord.Trim()).Trim());
                NewRow["C007"] = null;
                NewRow["C008"] = "1";
                NewRow["C009"] = "0";
                NewRow["C010"] = DI.IsActiveLogin ? 1 : 0;
                NewRow["C011"] = session.UserID.ToString();
                NewRow["C012"] = DateTime.Now.ToUniversalTime().ToString("yyyyMMddHHmmss");
                NewRow["C999"] = DI.Description;
                dataSet.Tables[0].Rows.Add(NewRow);
                optReturn.Data = dataSet;
                return(optReturn);
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = 88;
                optReturn.Message = string.Format("SaveNewDomainInfo Fail:{0}", ex.Message);
                return(optReturn);
            }
        }
Example #14
0
        private void LoadAvaliableOrgs(OrgUserItem parentItem, string parentId)
        {
            try
            {
                WebRequest webRequest = new WebRequest
                {
                    Session = CurrentApp.Session,
                    Code    = (int)RequestCode.WSGetUserObjList
                };
                webRequest.ListData.Add(CurrentApp.Session.UserID.ToString());
                webRequest.ListData.Add("0");
                webRequest.ListData.Add(ConstValue.RESOURCE_ORG.ToString());
                webRequest.ListData.Add(parentId);
                Service11012Client client = new Service11012Client(
                    WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                    WebHelper.CreateEndpointAddress(
                        CurrentApp.Session.AppServerInfo,
                        "Service11012"));
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    return;
                }
                if (webReturn.ListData == null)
                {
                    ShowException("Fail.\tListData is null");
                    return;
                }
                foreach (string strInfo in webReturn.ListData)
                {
                    string[] arrInfo = strInfo.Split(new[] { ConstValue.SPLITER_CHAR },
                                                     StringSplitOptions.RemoveEmptyEntries);
                    if (arrInfo.Length < 2)
                    {
                        continue;
                    }
                    string      strId   = arrInfo[0];
                    string      strName = arrInfo[1];
                    OrgUserItem item    = new OrgUserItem
                    {
                        ObjType = ConstValue.RESOURCE_ORG,
                        ObjID   = Convert.ToInt64(strId),
                        Name    = strName,
                        Data    = strInfo,
                        Icon    = strId == ConstValue.ORG_ROOT.ToString() ? "Images/rootorg.ico" : "Images/org.ico"
                    };
                    LoadAvaliableOrgs(item, strId);
                    //LoadAvaliableUsers(item, strID);
                    if (S3603App.GroupingWay.Contains("A"))
                    {
                        LoadAvaliableAgent(item, strId);
                    }

                    Dispatcher.Invoke(new Action(() => parentItem.AddChild(item)));
                    _mListOrgUserItems.Add(item);
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }