public static string GetSystemPath(string strSysFolder, string strSysSubFolder = "")
        {
            string strPath = "";

            RscStore store = new RscStore();

            strPath = strPath + "A:\\System";
            if (!store.FolderExists(strPath))
            {
                store.CreateFolder(strPath);
            }
            strPath = strPath + "\\";

            strPath = strPath + strSysFolder;
            if (!store.FolderExists(strPath))
            {
                store.CreateFolder(strPath);
            }
            //strPath = strPath + "\\";

            if (strSysSubFolder.Length > 0)
            {
                strPath = strPath + "\\";

                strPath = strPath + strSysSubFolder;
                if (!store.FolderExists(strPath))
                {
                    store.CreateFolder(strPath);
                }
                //strPath = strPath + "\\";
            }

            return(strPath);
        }
Пример #2
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (m_AppArgs.Waiting)
            {
                RscStore store = new RscStore();

                RscPageArgsRet appOutput = m_AppArgs.GetOutput();
                if (appOutput != null)
                {
                    switch (appOutput.ID)
                    {
                    case "CleanUp":

                        m_AppArgs.Vipe();

                        //Tools called...

                        m_AppArgs.Clear();

                        if (store.FolderExists(csSecretsFolder + "\\" + m_sUserIDlast))
                        {
                            MessageBox.Show("Unable to delete files!");
                        }
                        else
                        {
                            m_btnCleanUp.Visibility = Rsc.Collapsed;
                        }

                        break;

                    case "LogOut":

                        m_AppArgs.Vipe();

                        //Tools called...

                        m_AppArgs.Clear();

                        if (store.FolderExists(csSecretsFolder + "\\" + m_sUserIDlast))
                        {
                            MessageBox.Show("Unable to delete files!");
                        }

                        /*
                         * else
                         * {
                         */
                        m_btnCleanUp.Visibility = Rsc.Collapsed;
                        m_btnLogOut.Visibility  = Rsc.Collapsed;

                        /*
                         * }
                         */

                        break;
                    }
                }
            }
        }
        public static void CleanUpShellTileData( )
        {
            string sStFldr    = RscKnownFolders.GetTempPath("ShellTiles", "");
            string sStCntFldr = RscKnownFolders.GetTempPath("ShellTiles", "Content");
            string sScFldr    = "A:\\Shared\\ShellContent";

            RscStore store = new RscStore();

            string[] fles = store.GetFileNames(sStFldr, "*.txt");

            foreach (string fle in fles)
            {
                string sGd = RscStore.FileNameOfPath(fle);

                ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("IcoGd=" + sGd));
                if (TileToFind != null)
                {
                    continue;
                }

                store.DeleteFile(sStFldr + "\\" + sGd + ".txt");
                store.DeleteFile(sStCntFldr + "\\" + sGd + ".txt");

                if (store.FolderExists(sScFldr))
                {
                    store.DeleteFile(sScFldr + "\\" + sGd + ".jpg");
                    store.DeleteFile(sScFldr + "\\" + sGd + ".png");
                }
            }
        }
Пример #4
0
        public static string LoadUserAgentID(string sDomain, string sDefaultRetVal)
        {
            RscStore store = new RscStore();

            string sFolder = "A:\\Internet\\UserAgents";

            if (!store.FolderExists(sFolder))
            {
                return(sDefaultRetVal);
            }

            List <string> asDomainLst = SplitDomain(sDomain);

            foreach (string sDn in asDomainLst)
            {
                string sPath;

                sPath = sFolder + "\\" + sDn + ".txt";
                if (store.FileExists(sPath))
                {
                    string sUaID = store.ReadTextFile(sPath, "");
                    if (sUaID.Length > 0)
                    {
                        return(sUaID);
                    }
                }
            }

            return(sDefaultRetVal);
        }
        public static string GetMediaPath(string strSysFolder, string strSysSubFolder = "", bool bCreate = true)
        {
            string strPath = "";

            RscStore store = new RscStore();

            strPath = strPath + "A:\\Media";
            if (!store.FolderExists(strPath))
            {
                if (bCreate)
                {
                    store.CreateFolder(strPath);
                }
            }
            strPath = strPath + "\\";

            strPath = strPath + strSysFolder;
            if (!store.FolderExists(strPath))
            {
                if (bCreate)
                {
                    store.CreateFolder(strPath);
                }
            }
            //strPath = strPath + "\\";

            if (strSysSubFolder.Length > 0)
            {
                strPath = strPath + "\\";

                strPath = strPath + strSysSubFolder;
                if (!store.FolderExists(strPath))
                {
                    if (bCreate)
                    {
                        store.CreateFolder(strPath);
                    }
                }
                //strPath = strPath + "\\";
            }

            return(strPath);
        }
Пример #6
0
        public PerDay()
        {
            InitializeComponent();

            bool bLoaded = false;

            try
            {
                RscStore store = new RscStore();

                if (store.FolderExists("A:\\Documents\\PerDay"))
                {
                    bool   bTmp;
                    string sTx = store.ReadTextFile("A:\\Documents\\PerDay\\Default.txt", "", out bTmp);
                    if (sTx.Length > 0)
                    {
                        string [] aTx = sTx.Split('|');
                        if (aTx.Length == 5)
                        {
                            dtin_y.Text = aTx[0];
                            dtin_m.Text = aTx[1];
                            dtin_d.Text = aTx[2];

                            amo.Text = aTx[3];

                            unt.Text = aTx[4];

                            Calc();

                            bLoaded = true;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            if (!bLoaded)
            {
                DateTime dt = DateTime.Now;

                dtin_y.Text = dt.Year.ToString();
                dtin_m.Text = dt.Month.ToString();
                dtin_d.Text = dt.Day.ToString();

                amo.Text = "";

                unt.Text = "";
            }

            btnCalc.Click += new System.Windows.RoutedEventHandler(btnCalc_Click);
        }
Пример #7
0
        //
        // //

        protected void DoAck(TreeLbItem ti)
        {
            if (MessageBoxResult.OK != MessageBox.Show("Do you really want to acknowledge message?\n\n(press Back to Cancel)"))
            {
                return;
            }

            if (m_sUserIDlast.Length == 0)
            {
                return;
            }

            string sPath = AppLogic.csSecretsFolder + "\\" + m_sUserIDlast;

            RscStore store = new RscStore();

            sPath += "\\Threads";
            if (!store.FolderExists(sPath))
            {
                return;
            }

            MyThread2 th = new MyThread2();

            th = store.ReadXmlDataFile(sPath + "\\" + ti.sID + "\\" + ti.sHistoryID + ".xml", th);
            if (th.ID.Length == 0)
            {
                return;                 //FAIL!!!
            }
            th.DateAcked = DateTime.Now;

            store.WriteXmlDataFile(sPath + "\\" + ti.sID + "\\" + ti.sHistoryID + ".xml", th, true);

            ti.BtnCustom1Visibility = Rsc.Collapsed;
            ti.DetailsOfTitle       = TreeLbItemThread.DecorateSnippet(th);
            ti.ClearCustomBackColor();

            int iCount_NonAckAll = 0;

            iCount_NonAckAll = store.ReadXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll);
            iCount_NonAckAll = Math.Max(0, iCount_NonAckAll - 1);
            store.WriteXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll, true);

            int iCountAll = 0;

            iCountAll = store.ReadXmlDataFile(sPath + "\\" + "Count" + ".xml", iCountAll);
            UpdateSumItem(iCount_NonAckAll, iCountAll);

            m_AppFrame.StatusText = "";             //To refresh mem info...
        }
Пример #8
0
        private void m_btnDownloadFile_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (m_sLastFile.Length == 0)
            {
                return;
            }

            if (m_bLastFileIsFolder)
            {
                return;
            }

            if (m_lLastFileSize < 0)
            {
                return;
            }

            if (m_ftpc.WorkingDirectory.Length == 0)
            {
                return;
            }

            string sPath = m_ftpc.WorkingDirectory;

            sPath += m_sLastFile;

            RscStore store = new RscStore();

            string sLocalPath = "A:\\FTP";

            if (!store.FolderExists(sLocalPath))
            {
                store.CreateFolder(sLocalPath);
            }
            sLocalPath += "\\" + m_sLastFile;
            if (store.FileExists(sLocalPath))
            {
                store.DeleteFile(sLocalPath);
            }
            System.IO.Stream stream = store.CreateFile(sLocalPath);

            RscFtpClientCommand cmd = RscFtpClientCommand.DownloadBin(sPath, m_lLastFileSize, "", null, stream);

            _SendAutoPASV(cmd);
        }
Пример #9
0
        public static bool MarkedOpenExternal(string sDomain)
        {
            RscStore store = new RscStore();

            string sFolder = "A:\\Internet\\UserAgents";

            if (!store.FolderExists(sFolder))
            {
                return(false);
            }

            if (!store.FileExists(sFolder + "\\" + sDomain + "_OpenExternal" + ".txt"))
            {
                return(false);
            }

            return(true);
        }
Пример #10
0
        public static string[] GetKeys(HKEY hk, string sPath, string sFilter = "")
        {
            string strFullPath = GetFullPath(hk, sPath);

            RscStore store = new RscStore();

            if (!store.FolderExists(strFullPath))
            {
                return new String[] {}
            }
            ;

            if (sFilter.Length == 0)
            {
                sFilter = "*.*";
            }

            return(store.GetFolderNames(strFullPath, sFilter));
        }
        private void ListFiles()
        {
            ActionPanel.Visibility = Rsc.Collapsed;

            //problems with txFilter_TextChanged!!

            /*
             * if( txFilter.Text.Length == 0 )
             *      txFilter.Text = "*.*";
             */

            RscFileItemDesc itCurrent;

            m_folders.Clear();
            m_files.Clear();

            itCurrent             = new RscFileItemDesc(m_AppFrame.Theme);
            itCurrent.bFolder     = true;
            itCurrent.bWalked     = false;
            itCurrent.strParent   = "";
            itCurrent.strFileName = m_txtRootFldr.Text;
            itCurrent.Parent      = m_folders;

            RscStore store = new RscStore();

            if (!store.FolderExists(itCurrent.Path))
            {
                itCurrent.bWalked   = true;
                itCurrent.LastError = "Not exist!";
            }

            m_folders.Add(itCurrent);

            m_AppFrame.SetStatusText("Listing files...");
            m_AppFrame.StartTimer("list files", LayoutRoot, 1, 0, true);
        }
        private string GetImagePath(string sIndiciesToItem, bool bThumbnail, out Picture pic, bool bForceCreateFolderPath = false)
        {
            RscStore store = new RscStore();

            //string sFolder = RscFs.GetRscMediaFolderPath("Zune");
            string sFolder = RscKnownFolders.GetMediaPath("Media Library", "", false);

            // //
            //

            PictureAlbum pa = m_media.RootPictureAlbum;

            pic = null;
            string [] asInd = sIndiciesToItem.Split('|');
            int       iCnt  = asInd.Length;

            for (int i = 0; i < iCnt; i++)
            {
                if (i == iCnt - 1)
                {
                    sFolder += "\\" + pa.Name;
                    if (!store.FolderExists(sFolder))
                    {
                        if (!bForceCreateFolderPath)
                        {
                            return("");
                        }
                        store.CreateFolder(sFolder);
                    }

                    pic = pa.Pictures[Int32.Parse(asInd[i])];
                }
                else
                {
                    sFolder += "\\" + pa.Name;
                    if (!store.FolderExists(sFolder))
                    {
                        if (!bForceCreateFolderPath)
                        {
                            return("");
                        }
                        store.CreateFolder(sFolder);
                    }

                    pa = pa.Albums[Int32.Parse(asInd[i])];
                }
            }

            if (bThumbnail)
            {
                sFolder += "\\" + "tn";
                if (!store.FolderExists(sFolder))
                {
                    if (!bForceCreateFolderPath)
                    {
                        return("");
                    }
                    store.CreateFolder(sFolder);
                }
            }

            //
            // //

            string sPreExt = "";

            if (bThumbnail)
            {
                sPreExt = ".tn";
            }

            string sFName = pic.Name;
            string sFExt  = "";
            int    iPos   = sFName.LastIndexOf('.');

            if (iPos >= 0)
            {
                sFExt  = sFName.Substring(iPos);
                sFName = sFName.Substring(0, iPos);
            }

            string sPath = sFolder + "\\" + sFName + sPreExt + sFExt;

            //ROLLBACK...

            /*
             * iCnt = 0;
             * for(;;)
             * {
             *      if( !store.FileExists(sPath) ) break;
             *      iCnt++;
             *      sPath = sFolder + "\\" + sFName + "_" + iCnt.ToString() + sPreExt + sFExt;
             * }
             */

            if (!bForceCreateFolderPath)
            {
                if (!store.FileExists(sPath))
                {
                    return("");
                }
            }

            return(sPath);
        }
Пример #13
0
        public static ImageSource FaviconForDomain(string sDomain, out bool bFound, out string sPathOut, ImageSource isDefault, bool bSmall = true)
        {
            bFound   = false;
            sPathOut = "";

            // //
            //

            RscStore store = new RscStore();

            string sFolder = "A:\\Internet\\Favicons";

            if (!store.FolderExists(sFolder))
            {
                return(isDefault);
            }

            List <string> asDomainLst = SplitDomain(sDomain);

            string strImgPath = "";

            foreach (string sDn in asDomainLst)
            {
                //MessageBox.Show( sDn );

                string sPath;

                if (bSmall)
                {
                    sPath = sFolder + "\\" + sDn + ".ico.sm.jpg";
                    if (store.FileExists(sPath))
                    {
                        strImgPath = sPath;
                        break;
                    }
                }

                sPath = sFolder + "\\" + sDn + ".ico.jpg";
                if (store.FileExists(sPath))
                {
                    strImgPath = sPath;
                    break;
                }
            }

            if (strImgPath.Length == 0)
            {
                return(isDefault);
            }

            //
            // //
            //

            try
            {
                System.IO.Stream stream = store.GetReaderStream(strImgPath);

                BitmapImage bmp = new BitmapImage();
                bmp.SetSource(stream);
                stream.Close();

                bFound   = true;
                sPathOut = strImgPath;

                return(bmp);
            }
            catch (Exception /*e*/)
            {
                return(isDefault);
            }

            //
            // //
        }
        private void LoadContent( )
        {
            string sPath = m_sPath_TEMP;

            m_sPath_TEMP = "";
            string sContent = m_sContent_TEMP;

            m_sContent_TEMP = "";

            // //
            //

            string sExt = RscStore.ExtensionOfPath(sPath);

            sExt = sExt.ToUpper();
            switch (sExt)
            {
            case ".VCF":

                RscTextTags_VCF tags = new RscTextTags_VCF();
                m_tags = tags;

                tags.Parse(sContent, "\r\n", ":", ";");

                if (tags.PhotoPresent && tags.PhotoIsBase64 && tags.PhotoIs("JPEG"))
                {
                    string sBase64 = tags.PhotoData;

                    //RscFs.WriteTextFile( "vcf.photo.txt", sBase64, true );

                    byte [] ayImage = Convert.FromBase64String(sBase64);

                    if (ayImage != null)
                    {
                        if (ayImage.Length > 0)
                        {
                            /*
                             * RscStore store = new RscStore();
                             * if( store.FileExists("vcf.photo.jpg") ) store.DeleteFile("vcf.photo.jpg");
                             * System.IO.Stream stream = store.CreateFile("vcf.photo.jpg");
                             * stream.Write( ayImage, 0, ayImage.Length );
                             * stream.Close();
                             */

                            System.IO.MemoryStream ms = new System.IO.MemoryStream(ayImage.Length);
                            ms.Write(ayImage, 0, ayImage.Length);
                            ms.Seek(0, System.IO.SeekOrigin.Begin);

                            BitmapImage bmp = new BitmapImage();
                            bmp.SetSource(ms);

                            ms.Close();

                            Img.Source     = bmp;
                            Img.Visibility = Rsc.Visible;
                        }
                        else
                        {
                            Img.Visibility = Rsc.Collapsed;
                        }
                    }
                    else
                    {
                        Img.Visibility = Rsc.Collapsed;
                    }
                }
                else
                {
                    //MessageBox.Show( "No photo present!" );
                    Img.Visibility = Rsc.Collapsed;
                }

                btnCall.Content    = "Call " + tags.PhoneNumber(0);
                BtnGrid.Visibility = Rsc.ConditionalVisibility(tags.PhoneNumber(0).Length > 0);

                RscStore store = new RscStore();

                bool bExists = false;
                if (store.FolderExists("A:\\Desktop"))
                {
                    if (store.FolderExists("A:\\Desktop\\Contacts"))
                    {
                        bExists = store.FileExists("A:\\Desktop\\Contacts\\" + tags.Name + ".txt");
                    }
                }

                if (bExists)
                {
                    btnEx.Content        = "Remove from Desktop";
                    BtnGridEx.Background = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    btnEx.Content        = "Add to Desktop";
                    BtnGridEx.Background = new SolidColorBrush(Colors.Green);
                }
                BtnGridEx.Visibility = Rsc.ConditionalVisibility(tags.PhoneNumber(0).Length > 0);

                break;

            default:
                Img.Visibility     = Rsc.Collapsed;
                BtnGrid.Visibility = Rsc.Collapsed;
                m_tags             = null;
                break;
            }

            //
            // //

            if (m_tags == null)
            {
                m_aLines.FontSize = 18;

                m_aLines.Text = sContent;
            }
            else
            {
                m_aLines.FontSize = 22;

                m_aLines.Text = m_tags.ToString();
            }
        }
Пример #15
0
        private void m_ftpc_ServerDataReceivedSYNC(object sender, Ressive.FTP.RscFtpCommandEventArgs e)
        {
            if (!e.ServerData.ParseOk)
            {
                _Log("20", "<DATA ERROR> " + e.ClientCommand.ToString( ), false);
            }
            else
            {
                switch (e.ClientCommand.Command)
                {
                case "LIST":
                {
                    prsBarData.Visibility = Rsc.Collapsed;

                    int iCount;
                    RscFtpServerDataItemFileInfo fi;

                    iCount = e.ServerData.Count;

                    if (iCount == 0)
                    {
                        _Log("20", e.ClientCommand.Command + " returned 0 item.", false, true);
                    }
                    else
                    {
                        for (int i = 0; i < iCount; i++)
                        {
                            fi = (RscFtpServerDataItemFileInfo)e.ServerData.GetItem(i);

                            _Log("20", fi.GetItemTitle( ), false, true, fi);
                        }
                    }

                    break;
                }

                case "RETR":
                {
                    prsBarData.Visibility = Rsc.Collapsed;

                    _Log("20", e.ClientCommand.Command + " returned " +
                         e.ClientCommand.DataSize.ToString() + " bytes.", false, true);

                    if (e.ClientCommand.HasMemStream)
                    {
                        string sPath = e.ClientCommand.Arg1;
                        int    iPos  = sPath.LastIndexOf(m_ftpc.BackSlashInPath);
                        string sFn   = sPath;
                        if (iPos >= 0)
                        {
                            sFn = sPath.Substring(iPos + m_ftpc.BackSlashInPath.Length);
                        }

                        _Log("20", e.ClientCommand.Command + " saving local file '" +
                             sFn + "'.", false, true);

                        RscStore store = new RscStore();

                        string sLocalPath = "A:\\FTP";
                        if (!store.FolderExists(sLocalPath))
                        {
                            store.CreateFolder(sLocalPath);
                        }
                        sLocalPath += "\\" + sFn;
                        if (store.FileExists(sLocalPath))
                        {
                            store.DeleteFile(sLocalPath);
                        }

                        System.IO.Stream stream = store.CreateFile(sLocalPath);
                        e.ServerData.MemStream.WriteTo(stream);
                        e.ServerData.MemStream.Close();
                        stream.Close();
                    }

                    break;
                }
                }
            }
        }
Пример #16
0
        private void OnOK()
        {
            if (m_AppInput != null)
            {
                string strRes = txStr.Text;

                //NoEmpty...
                if (m_AppInput.GetFlag(1).Length > 0)
                {
                    strRes = strRes.Trim();

                    if (strRes.Length == 0)
                    {
                        MessageBox.Show("Value must not be empty!");
                        return;
                    }
                }

                //FileName...
                if (m_AppInput.GetFlag(1).Length > 0)
                {
                    strRes = strRes.Trim();

                    //string strChk = "\\/:*?\"<>|";
                    //string strChk = "/:*?\"<>|";
                    string strChk = "/*?\"<>|";
                    foreach (char cChk in strChk)
                    {
                        if (strRes.IndexOf(cChk) >= 0)
                        {
                            MessageBox.Show("Value must not contain characters of '" + strChk + "'!");
                            return;
                        }
                    }
                }

                //Folder exits...
                {
                    RscStore store = new RscStore();

                    strRes = strRes.Trim();

                    if (!store.FolderExists(strRes))
                    {
                        MessageBox.Show("Folder does not exist!");
                        return;
                    }
                }

                string sPath = "Software\\Ressive.Hu\\" + csClsName + "\\History";
                sPath += "\\" + m_AppInput.CallerAppTitle;
                sPath += "\\" + m_AppInput.ID;
                RscRegistry.WriteString(HKEY.HKEY_CURRENT_USER, sPath, "LastOk", txStr.Text);

                m_RegHistory.Add(txStr.Text);
                m_RegHistory.Flush();

                RscPageArgsRet appOutput = m_AppInput.CreateOutPut();
                appOutput.SetFlag(0, "Ok");
                appOutput.SetData(0, txStr.Text);
                appOutput.SetOutput();
            }

            this.NavigationService.GoBack();
        }
Пример #17
0
        public override string GetInfo(bool bForSysTile, string sIcoId, out Brush brBk, out Brush brFore,
                                       out double dFontSize, out string sErr,
                                       out string sNotiTitle, out string sNotiContent, out string sNotiSound,
                                       bool bCalledByAgent, object oAgentParam, out string sInfoToChngChk)
        {
            brBk      = null;
            brFore    = null;
            dFontSize = 0;
            sErr      = "";

            sNotiTitle   = "";
            sNotiContent = "";
            sNotiSound   = "";

            sInfoToChngChk = "";

            string sCnt = "";

            try
            {
                switch (sIcoId)
                {
                case csTileID:
                {
                    int iCount_NEW       = 0;
                    int iCount_NonAckAll = 0;
                    int iCountAll        = 0;

                    RscStore store = new RscStore();

                    string sUserIDlast = store.ReadTextFile(AppLogic.csSecretsFolder + "\\" + "UserIDlast.txt", "");

                    if (sUserIDlast.Length > 0)
                    {
                        string sPath = AppLogic.csSecretsFolder + "\\" + sUserIDlast;

                        sPath += "\\Threads";
                        if (store.FolderExists(sPath))
                        {
                            iCount_NEW       = store.ReadXmlDataFile(sPath + "\\" + "Count_NEW" + ".xml", iCount_NEW);
                            iCount_NonAckAll = store.ReadXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll);
                            iCountAll        = store.ReadXmlDataFile(sPath + "\\" + "Count" + ".xml", iCountAll);
                        }
                    }

                    int iNewNow = 0;
                    if (bForSysTile)
                    {
                        /*
                         * try
                         * {
                         *      AppLogic al = new AppLogic();
                         *      iNew = al.ReadThreadData( );
                         * }
                         * catch( Exception )
                         * {
                         *      iNew = -1;
                         * }
                         */

                        if (bCalledByAgent)
                        {
                            iNewNow = 0;
                            if (!Int32.TryParse(oAgentParam.ToString(), out iNewNow))
                            {
                                iNewNow = -400;
                            }
                        }
                    }
                    else
                    {
                    }

                    string sTile;
                    if (iNewNow < 0)
                    {
                        if (iNewNow == AppLogic.ciAuthFail)
                        {
                            sTile = "NO CONN!";
                        }
                        else
                        {
                            sTile = "ERR: " + iNewNow.ToString();                                     //"ERROR!";
                        }
                    }
                    else
                    {
                        sTile = "new: " + iCount_NEW.ToString();
                    }
                    sCnt += sTile;

                    string sCont = "non-ack: " + iCount_NonAckAll.ToString() + " / " + iCountAll.ToString();

                    sCnt += "\n" + "non-ack: " + iCount_NonAckAll.ToString();
                    sCnt += "\n" + "all: " + iCountAll.ToString();

                    sInfoToChngChk = sCnt;

                    DateTime dNow = DateTime.Now;
                    sCnt += "\n\n" + "at: " + RscUtils.pad60(dNow.Hour) +
                            ":" + RscUtils.pad60(dNow.Minute);

                    if (iNewNow < 0 || iNewNow > 0 || iCount_NEW > 0)
                    {
                        brBk = new SolidColorBrush(Colors.Red);

                        sNotiTitle   = sTile;
                        sNotiContent = sCont;

                        //sNotiSound = /*"/Lib_Rsc;component/" +*/ "Media/BociBociTarka.wav";
                        sNotiSound = /*"/Lib_Rsc;component/" +*/ "Media/Ding.wav";
                    }
                    else
                    {
                        if (iCount_NonAckAll > 0)
                        {
                            brBk = new SolidColorBrush(Colors.Orange);
                        }
                        else
                        {
                            brBk = new SolidColorBrush(Colors.Green);
                        }
                    }
                    brFore = new SolidColorBrush(Colors.White);

                    dFontSize = 11;

                    break;
                }

                default:
                {
                    sCnt = "???";
                    break;
                }
                }
            }
            catch (Exception e)
            {
                //Do not generate too many err files...
                RscStore.AddSysEvent(e, "Tile_Info_Title_Createion_Error");

                sErr = e.Message + "\r\n" + e.StackTrace;
                sCnt = "ERR!";
            }

            return(sCnt);
        }
Пример #18
0
        public override string GetInfo(bool bForSysTile, string sIcoId, out Brush brBk, out Brush brFore,
                                       out double dFontSize, out string sErr,
                                       out string sNotiTitle, out string sNotiContent, out string sNotiSound,
                                       bool bCalledByAgent, object oAgentParam, out string sInfoToChngChk)
        {
            brBk      = null;
            brFore    = null;
            dFontSize = 0;
            sErr      = "";

            sNotiTitle   = "";
            sNotiContent = "";
            sNotiSound   = "";

            sInfoToChngChk = "";

            string sCnt = "";

            try
            {
                switch (sIcoId)
                {
                case "sysTm":
                {
                    DateTime dNow = DateTime.Now;
                    sCnt += RscUtils.pad60(dNow.Hour) +
                            ":" + RscUtils.pad60(dNow.Minute);

                    if (bForSysTile)
                    {
                        sCnt += "\n\n(as of)";
                    }
                    else
                    {
                        sCnt += "\n:" + RscUtils.pad60(dNow.Second);
                    }

                    break;
                }

                case "sysDtFull":
                {
                    DateTime dNow = DateTime.Now;
                    sCnt += dNow.Year.ToString() +
                            ".\n" + RscUtils.pad60(dNow.Month) + "." +
                            RscUtils.pad60(dNow.Day) + ".";
                    break;
                }

                case "sysDtDay":
                {
                    DateTime dNow = DateTime.Now;
                    sCnt += RscUtils.pad60(dNow.Day) + ". ";
                    switch (dNow.DayOfWeek)
                    {
                    case DayOfWeek.Monday: sCnt += "H"; break;

                    case DayOfWeek.Tuesday: sCnt += "K"; break;

                    case DayOfWeek.Wednesday: sCnt += "Sze"; break;

                    case DayOfWeek.Thursday: sCnt += "Cs"; break;

                    case DayOfWeek.Friday: sCnt += "P"; break;

                    case DayOfWeek.Saturday: sCnt += "Szo"; break;

                    case DayOfWeek.Sunday: sCnt += "V"; break;
                    }

                    sCnt += "\n" + RscUtils.pad60(RscUtils.WeekOfYearHU(dNow)) + ". hét";
                    break;
                }

                case "sysFsFree":
                {
                    string sIsoStoreDrive = "";
                    long   lFree          = RscStore.AvailableFreeSpace(out sIsoStoreDrive);

                    sCnt += RscUtils.toMBstr(lFree, true);

                    if (sIsoStoreDrive.Length > 0)
                    {
                        sCnt = sIsoStoreDrive + "\n" + sCnt;
                    }

                    sNotiTitle   = "Free Space";
                    sNotiContent = sCnt.Replace('\n', ' ');

                    sInfoToChngChk = RscUtils.toMBstr(lFree, true, false, 1);

                    break;
                }

                case "sysBatPow":
                {
                    sCnt += Windows.Phone.Devices.Power.Battery.GetDefault().RemainingChargePercent.ToString() + " %";

                    if (Microsoft.Phone.Info.DeviceStatus.PowerSource == Microsoft.Phone.Info.PowerSource.Battery)
                    {
                        sCnt += "";                                 //"\n\nBATT";
                    }
                    else
                    {
                        sCnt += "\n\nCHRG";
                    }

                    if (Windows.Phone.Devices.Power.Battery.GetDefault().RemainingChargePercent >= 100 &&
                        Microsoft.Phone.Info.DeviceStatus.PowerSource != Microsoft.Phone.Info.PowerSource.Battery)
                    {
                        brBk   = new SolidColorBrush(Colors.Red);
                        brFore = new SolidColorBrush(Colors.White);

                        sNotiTitle   = "Battery Charge";
                        sNotiContent = sCnt.Replace('\n', ' ');

                        //sNotiSound = /*"/Lib_Rsc;component/" +*/ "Media/BociBociTarka.wav";
                        sNotiSound = /*"/Lib_Rsc;component/" +*/ "Media/DingDing.wav";
                    }

                    break;
                }

                case "sysCellNet":
                {
                    dFontSize = 11;

                    string sCmo = DeviceNetworkInformation.CellularMobileOperator;
                    for (int i = 0; i < 1; i++)
                    {
                        int iPos = sCmo.IndexOf(' ');
                        if (iPos < 0)
                        {
                            sCmo += "\n";
                            //if( i == 0 ) sCmo += "\n";
                            break;
                        }

                        sCmo = sCmo.Substring(0, iPos) + "\n" + sCmo.Substring(iPos + 1);
                    }

                    sCnt += sCmo + "\n";

                    if (DeviceNetworkInformation.IsCellularDataEnabled)
                    {
                        sCnt += "d(ata) ON";
                    }
                    else
                    {
                        sCnt += "d(ata) OFF";
                    }
                    sCnt += "\n";

                    if (DeviceNetworkInformation.IsCellularDataRoamingEnabled)
                    {
                        sCnt += "d roam ON";
                    }
                    else
                    {
                        sCnt += "d roam OFF";
                    }

                    break;
                }

                case "sysCnt_Note":
                {
                    int iCount = 0;

                    RscStore store = new RscStore();

                    if (store.FolderExists("A:\\Documents\\Notes"))
                    {
                        string[] fles = store.GetFileNames("A:\\Documents\\Notes", "*.txt");
                        iCount = fles.Length;
                    }

                    brBk   = new SolidColorBrush(Color.FromArgb(255, 252, 244, 178));
                    brFore = new SolidColorBrush(Colors.Black);
                    sCnt  += iCount.ToString() + "\n\nnotes";

                    break;
                }

                case "sysCnt_Anni":
                {
                    int iCntRed    = 0;
                    int iCntOrange = 0;
                    int iCntGreen  = 0;
                    int iCntBlue   = 0;
                    int iCntGray   = 0;

                    RscStore store = new RscStore();

                    if (store.FolderExists("A:\\Documents\\Dates"))
                    {
                        string[] fles = RscSort.OrderBy(store.GetFileNames("A:\\Documents\\Dates", "*.txt"));
                        foreach (string sFle in fles)
                        {
                            bool   bTmp;
                            string sDate = store.ReadTextFile("A:\\Documents\\Dates" + "\\" + sFle, "", out bTmp);

                            if (sDate.Length == 0)
                            {
                                continue;
                            }

                            DateTime dtNow = DateTime.Now;
                            string   sYnow = dtNow.Year.ToString();
                            string   sMnow = dtNow.Month.ToString();

                            int iCyc = 0;
                            for (iCyc = 0; iCyc < 2; iCyc++)
                            {
                                string sY;
                                string sM;
                                string sD;

                                bool bAnniver = (sDate.Substring(2, 1) == ".");
                                if (bAnniver)
                                {
                                    if (sDate.Length == 3)
                                    {
                                        sY = sYnow;
                                        sM = sMnow;
                                        sD = sDate.Substring(0, 2);

                                        //FIX...
                                        //sMnow = (dtNow.Month + 1).ToString();
                                        if (dtNow.Month >= 12)
                                        {
                                            sMnow = "1";
                                            sYnow = (dtNow.Year + 1).ToString();
                                        }
                                        else
                                        {
                                            sMnow = (dtNow.Month + 1).ToString();
                                        }
                                    }
                                    else
                                    {
                                        sY = sYnow;
                                        sM = sDate.Substring(0, 2);
                                        sD = sDate.Substring(3, 2);

                                        sYnow = (dtNow.Year + 1).ToString();
                                    }
                                }
                                else
                                {
                                    sY = sDate.Substring(0, 4);
                                    sM = sDate.Substring(5, 2);
                                    sD = sDate.Substring(8, 2);
                                }

                                int iY = 1901; Int32.TryParse(sY, out iY);                                        //parseInt(sY);
                                int iM = 1; Int32.TryParse(sM, out iM);                                           //parseInt(sM);
                                int iD = 1; Int32.TryParse(sD, out iD);                                           //parseInt(sD);

                                dtNow = DateTime.Now;
                                DateTime dt1 = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day);
                                DateTime dt2 = new DateTime(iY, iM, iD);

                                //var dDiff = dt1.getTime() - dt2.getTime();
                                TimeSpan tsDiff = dt1 - dt2;
                                double   dDiff  = tsDiff.TotalMilliseconds;

                                double dDiffD = Math.Floor(dDiff / (1000 * 3600 * 24));

                                /*
                                 * double dDiffW;
                                 * if( dDiffD < 0 )
                                 * {
                                 *      dDiffW = Math.Round((dDiffD * -1) / 7, 0) * -1;
                                 * }
                                 * else
                                 * {
                                 *      dDiffW = Math.Round(dDiffD / 7, 0);
                                 * }
                                 */

                                if (bAnniver && (dDiffD > 7))
                                {
                                    continue;
                                }

                                /*
                                 * var sWtit = dDiffW.ToString() +
                                 *      "w " + (dDiffD - (dDiffW * 7)).ToString() + "d";
                                 */

                                if (bAnniver)
                                {
                                    if ((dDiffD * dDiffD) < 10)
                                    {
                                        iCntRed++;
                                    }
                                    else
                                    {
                                        if ((dDiffD * dDiffD) < 50)
                                        {
                                            iCntOrange++;
                                        }
                                        else
                                        {
                                            if ((dDiffD * dDiffD) < 197)
                                            {
                                                iCntGreen++;
                                            }
                                            else
                                            {
                                                iCntBlue++;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    iCntGray++;
                                }
                            }
                        }
                    }

                    int    iCnt = 0;
                    string sMsg = "";
                    if (iCntRed > 0)
                    {
                        sMsg   = "+/- 3d";
                        iCnt   = iCntRed;
                        brBk   = new SolidColorBrush(Colors.Red);
                        brFore = new SolidColorBrush(Colors.White);
                    }
                    else if (iCntOrange > 0)
                    {
                        sMsg   = "+/- 1w";
                        iCnt   = iCntOrange;
                        brBk   = new SolidColorBrush(Colors.Orange);
                        brFore = new SolidColorBrush(Colors.White);
                    }
                    else if (iCntGreen > 0)
                    {
                        sMsg   = "2w";
                        iCnt   = iCntGreen;
                        brBk   = new SolidColorBrush(Colors.Green);
                        brFore = new SolidColorBrush(Colors.White);
                    }
                    else if (iCntBlue > 0)
                    {
                        sMsg = "> 2w";
                        iCnt = iCntBlue;
                        brBk = new SolidColorBrush(Colors.Blue);
                    }
                    else                             //if( iCntGray > 0 )
                    {
                        sMsg = "dates";
                        iCnt = /*iCntBlue +*/ iCntGray;

                        //Use default...
                        //brBk = new SolidColorBrush(Colors.Black);
                        //brFore = new SolidColorBrush( Colors.White );
                    }

                    sCnt += iCnt.ToString() + "\n\n" + sMsg;

                    sNotiTitle   = "Anniversary";
                    sNotiContent = sCnt.Replace('\n', ' ');

                    break;
                }

                case "sysCnt_WebDog":
                {
                    RscStore store = new RscStore();

                    if (store.FileExists("A:\\Documents\\WebDogUri.txt"))
                    {
                        DateTimeOffset dtf    = store.GetFileLastWriteTime("A:\\Documents\\WebDogUri.txt");
                        DateTime       dt     = dtf.DateTime;
                        DateTime       dtNow  = DateTime.Now;
                        TimeSpan       tsDiff = dtNow - dt;

                        bool   bTmp;
                        string sUri = store.ReadTextFile("A:\\Documents\\WebDogUri.txt", "", out bTmp);
                        if (sUri.Length > 0)
                        {
                            try
                            {
                                Uri    uri  = new Uri(sUri, UriKind.Absolute);
                                string sDns = uri.DnsSafeHost;

                                if (sDns.Length > 5)
                                {
                                    sDns  = sDns.Substring(0, 5);
                                    sDns += "...";
                                }

                                sCnt += sDns;
                            }
                            catch (Exception)
                            {
                            }
                        }
                        sCnt += "\n";

                        //sCnt = RscUtils.toDurationStr( tsDiff.Duration() );
                        if (Math.Floor(tsDiff.TotalDays) > 0)
                        {
                            brBk   = new SolidColorBrush(Colors.Red);
                            brFore = new SolidColorBrush(Colors.White);

                            sCnt += Math.Floor(tsDiff.TotalDays).ToString() + "\nday(s)";
                        }
                        else if (Math.Floor(tsDiff.TotalHours) > 0)
                        {
                            //Use Default...
                            //brBk = new SolidColorBrush( Colors.Black );
                            //brFore = new SolidColorBrush( Colors.White );

                            sCnt += Math.Floor(tsDiff.TotalHours).ToString() + "\nhour(s)";
                        }
                        else                                 //if( Math.Floor( tsDiff.TotalMinutes ) > 0 )
                        {
                            //Use Default...
                            //brBk = new SolidColorBrush( Colors.Black );
                            //brFore = new SolidColorBrush( Colors.White );

                            sCnt += Math.Floor(tsDiff.TotalMinutes).ToString() + "\nmin(s)";
                        }

                        /*
                         * else //if( Math.Floor( tsDiff.TotalSeconds ) > 0 )
                         * {
                         *      //Use Default...
                         *      //brBk = new SolidColorBrush( Colors.Black );
                         *      //brFore = new SolidColorBrush( Colors.White );
                         *
                         *      sCnt += Math.Floor( tsDiff.TotalSeconds ).ToString() + "\n\nsec(s)";
                         * }
                         */
                    }
                    else
                    {
                        if (bForSysTile)
                        {
                            //Use Default...
                            //brBk = new SolidColorBrush( Colors.Black );
                            //brFore = new SolidColorBrush( Colors.White );
                        }
                        else
                        {
                            brBk   = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                            brFore = new SolidColorBrush(Colors.Black);
                        }
                    }

                    break;
                }

                case "sysCnt_Event":
                {
                    int iCountErr = 0;
                    int iCountInf = 0;

                    RscStore store = new RscStore();

                    if (store.FolderExists("A:\\System\\Events"))
                    {
                        string[] fles = store.GetFileNames("A:\\System\\Events", "*.error");
                        iCountErr = fles.Length;

                        fles      = store.GetFileNames("A:\\System\\Events", "*.info");
                        iCountInf = fles.Length;

                        if (iCountErr > 0)
                        {
                            brBk   = new SolidColorBrush(Colors.Red);
                            brFore = new SolidColorBrush(Colors.White);
                        }
                        else if (iCountInf > 0)
                        {
                            brBk   = new SolidColorBrush(Colors.Blue);
                            brFore = new SolidColorBrush(Colors.White);
                        }
                        else
                        {
                            //Use Default...
                            //brBk = new SolidColorBrush( Colors.Black );
                            //brFore = new SolidColorBrush( Colors.White );
                        }
                    }

                    sCnt += iCountErr.ToString() + " err\n"
                            /*+ "\n"*/
                            + iCountInf.ToString() + " inf";

                    break;
                }

                case "sysCnt_PerDay":
                {
                    sCnt += "";

                    if (bForSysTile)
                    {
                        //Use Default...
                        //brBk = new SolidColorBrush( Colors.Black );
                        //brFore = new SolidColorBrush( Colors.White );
                    }
                    else
                    {
                        brBk   = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                        brFore = new SolidColorBrush(Colors.Black);
                    }

                    RscStore store = new RscStore();

                    if (store.FolderExists("A:\\Documents\\PerDay"))
                    {
                        bool   bTmp;
                        string sTx = store.ReadTextFile("A:\\Documents\\PerDay\\Default.txt", "", out bTmp);
                        if (sTx.Length > 0)
                        {
                            string [] aTx = sTx.Split('|');
                            if (aTx.Length == 5)
                            {
                                int iY = Int32.Parse(aTx[0]);
                                int iM = Int32.Parse(aTx[1]);
                                int iD = Int32.Parse(aTx[2]);

                                DateTime dtNow = DateTime.Now;

                                DateTime d1 = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day);
                                DateTime d2 = new DateTime(iY, iM, iD);

                                TimeSpan ts    = d2 - d1;
                                int      iDays = Math.Max(1, (int)Math.Round(ts.TotalDays, 0));

                                double dAmo = double.Parse(aTx[3]);
                                if (dAmo != 0)
                                {
                                    int iRes = (int)Math.Round(dAmo / iDays, 0);

                                    string sUnit = "";
                                    if (aTx[4].Length > 0)
                                    {
                                        sUnit = " " + aTx[4];
                                    }

                                    sCnt += aTx[3] + sUnit + "\n"
                                            + /*(iY % 1000).ToString()*/ aTx[0] + "." + RscUtils.pad60(iM) + "." + RscUtils.pad60(iD) + "." + "\n"
                                            + "----------" + "\n"
                                            + iRes.ToString() + sUnit + "\n"
                                            + "/ day" + " (" + Math.Max(0, (int)Math.Round(ts.TotalDays, 0)).ToString() + ")";

                                    brBk   = new SolidColorBrush(Colors.Gray);
                                    brFore = new SolidColorBrush(Colors.White);

                                    dFontSize = 11;
                                }
                            }
                        }
                    }

                    break;
                }

                default:
                {
                    sCnt = "???";
                    break;
                }
                }
            }
            catch (Exception e)
            {
                //Do not generate too many err files...
                RscStore.AddSysEvent(e, "Tile_Info_Title_Createion_Error");

                sErr = e.Message + "\r\n" + e.StackTrace;
                sCnt = "ERR!";
            }

            return(sCnt);
        }
Пример #19
0
        private void ShowSavedThreadData(string sPath, int iStartIndex, TreeLbItem tiHead = null)
        {
            RscStore store = new RscStore();

            sPath += "\\Threads";
            if (!store.FolderExists(sPath))
            {
                return;
            }

            int iCountAll = 0;

            iCountAll = store.ReadXmlDataFile(sPath + "\\" + "Count" + ".xml", iCountAll);

            int iCount_NonAckAll = 0;

            iCount_NonAckAll = store.ReadXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll);

            if (iStartIndex == 0)
            {
                m_tiSum = new TreeLbItem(m_aTI, null);
                m_tiSum.DetailsFontSize = cdFontSize;
                UpdateSumItem(iCount_NonAckAll, iCountAll);
                m_aTI.Add(m_tiSum);

                tiHead = new TreeLbItem(m_aTI, null);
                //tiHead.DetailsFontSize = cdFontSize;
                tiHead.DetailsOnly = "...";
                m_aTI.Add(tiHead);
            }

            string sThreadIdOrder = "";

            sThreadIdOrder = store.ReadTextFile(sPath + "\\" + "IdOrder" + ".txt", sThreadIdOrder);
            string [] asThreadIdOrders = sThreadIdOrder.Split('|');

            bool bMoreItems = false;
            int  iThCnt     = asThreadIdOrders.Length;

            for (int iTh = iStartIndex; iTh < iThCnt; iTh++)
            {
                //NOT all...
                if ((iTh - iStartIndex) >= ciMaxAtOnce)
                {
                    bMoreItems = true;
                    break;
                }

                string sID = asThreadIdOrders[iTh];

                if (sID.Length == 0)
                {
                    continue;
                }

                if (!store.FolderExists(sPath + "\\" + sID))
                {
                    continue;
                }

                string sIdOrder = "";
                sIdOrder = store.ReadTextFile(sPath + "\\" + sID + "\\" + "IdOrder" + ".txt", sIdOrder);
                string [] asIdOrders = sIdOrder.Split('|');

                string sHistoryID = asIdOrders[0];

                if (sHistoryID.Length == 0)
                {
                    continue;
                }

                if (!store.FileExists(sPath + "\\" + sID + "\\" + sHistoryID + ".xml"))
                {
                    continue;
                }

                MyThread2 th = new MyThread2();
                th = store.ReadXmlDataFile(sPath + "\\" + sID + "\\" + sHistoryID + ".xml", th);
                if (th.ID.Length == 0)
                {
                    continue;
                }

                TreeLbItem ti = new TreeLbItem(m_aTI, null);
                //
                ti.DetailsFontSize  = cdFontSize;
                ti.DetailsBackColor = m_AppFrame.Theme.ThemeColors.TextDarkBack;
                ti.DetailsForeColor = m_AppFrame.Theme.ThemeColors.TextDarkFore;
                if (!th.Acknowledged)
                {
                    ti.CustomBackColor = Colors.Orange;

                    ti.BtnCustom1Visibility = Rsc.Visible;
                }
                ti.BtnCustom1Image = m_isCheckOn;                 //Off;
                //
                string sTitle = "";
                sTitle += RscUtils.toDateDiff(th.DateSaved);
                if (asIdOrders.Length > 1)
                {
                    sTitle += " ( +" + (asIdOrders.Length - 1).ToString() + " )";
                }
                ti.Title          = sTitle;
                ti.DetailsOfTitle = TreeLbItemThread.DecorateSnippet(th);
                ti.IsLeaf         = (asIdOrders.Length <= 1);
                m_aTI.Add(ti);

                ti.sID        = sID;
                ti.sHistoryID = sHistoryID;

                foreach (string sId in asIdOrders)
                {
                    if (sId.Length == 0)
                    {
                        continue;
                    }
                    if (sId == sHistoryID)
                    {
                        continue;
                    }

                    MyThread2 thSub = new MyThread2();
                    thSub = store.ReadXmlDataFile(sPath + "\\" + sID + "\\" + sId + ".xml", thSub);
                    if (thSub.ID.Length == 0)
                    {
                        continue;
                    }

                    //DO NOT!!!

                    /*
                     * TreeLbItem tiSub = new TreeLbItem( m_aTI, ti );
                     * tiSub.Title = RscUtils.toDateDiff( thSub.DateSaved ) + "retrived...";
                     * tiSub.DetailsOfTitle = thSub.Snippet;
                     * tiSub.IsLeaf = true;
                     * m_aTI.Add( tiSub );
                     */

                    ti.m_a.Add(thSub);
                }
            }

            if (tiHead != null)
            {
                string sTit = "Threads " + (iStartIndex + 1).ToString() + " - ";
                if (bMoreItems)
                {
                    sTit += (iStartIndex + ciMaxAtOnce).ToString();
                }
                else
                {
                    sTit += iThCnt.ToString();
                }

                //tiHead.DetailsFontSize = cdFontSize;
                tiHead.DetailsOnly = sTit;
            }

            if (bMoreItems)
            {
                TreeLbItem ti = new TreeLbItem(m_aTI, null);
                ti.Title           = "Threads " + (iStartIndex + ciMaxAtOnce + 1).ToString() + " - ... (press to list)";
                ti.sID             = csMoreItems;
                ti.sHistoryID      = (iStartIndex + ciMaxAtOnce).ToString();
                ti.CustomBackColor = m_AppFrame.Theme.ThemeColors.TreeDescBack;
                ti.CustomForeColor = m_AppFrame.Theme.ThemeColors.TreeDescFore;
                m_aTI.Add(ti);
            }
        }
        private void SaveImage(bool bThumbnail)
        {
            RscStore store = new RscStore();

            string sFolder = m_sAppFolder;

            if (bThumbnail)
            {
                sFolder += "\\" + "tn";
                if (!store.FolderExists(sFolder))
                {
                    store.CreateFolder(sFolder);
                }
            }

            string sPreExt = "";

            if (bThumbnail)
            {
                sPreExt = ".tn";
            }

            string sFName = m_sPicFileName;
            string sFExt  = "";
            int    iPos   = sFName.LastIndexOf('.');

            if (iPos >= 0)
            {
                sFExt  = sFName.Substring(iPos);
                sFName = sFName.Substring(0, iPos);
            }

            string sPath = sFolder + "\\" + sFName + sPreExt + sFExt;

            /*
             * iCnt = 0;
             * for(;;)
             * {
             *      if( !store.FileExists(sPath) ) break;
             *      iCnt++;
             *      sPath = sFolder + "\\" + sFName + "_" + iCnt.ToString() + sPreExt + sFExt;
             * }
             */

            System.IO.Stream strmSrc;

            if (bThumbnail)
            {
                strmSrc = m_pic.GetThumbnail();
            }
            else
            {
                strmSrc = m_pic.GetImage();
            }

            if (store.FileExists(sPath))
            {
                store.DeleteFile(sPath);
            }

            System.IO.Stream stream = store.CreateFile(sPath);
            // Initialize the buffer for 4KB disk pages.
            byte[] readBuffer = new byte[4096];
            int    bytesRead  = -1;

            // Copy the image/thumbnail to the local folder.
            while ((bytesRead = strmSrc.Read(readBuffer, 0, readBuffer.Length)) > 0)
            {
                stream.Write(readBuffer, 0, bytesRead);
            }
            stream.Close();

            strmSrc.Close();

            if (!bThumbnail)
            {
                store.WriteTextFile(sFolder + "\\" + sFName + sPreExt + sFExt + ".inf", m_sInf, true);
            }
        }
        private void SaveImage(string sIndiciesToItem, bool bThumbnail)
        {
            RscStore store = new RscStore();

            //string sFolder = RscKnownFolders.GetMediaPath("Zune");
            string sFolder = RscKnownFolders.GetMediaPath("Media Library");

            // //
            //

            PictureAlbum pa  = m_media.RootPictureAlbum;
            Picture      pic = null;

            string [] asInd = sIndiciesToItem.Split('|');
            int       iCnt  = asInd.Length;

            for (int i = 0; i < iCnt; i++)
            {
                if (i == iCnt - 1)
                {
                    sFolder += "\\" + pa.Name;
                    if (!store.FolderExists(sFolder))
                    {
                        store.CreateFolder(sFolder);
                    }

                    pic = pa.Pictures[Int32.Parse(asInd[i])];
                }
                else
                {
                    sFolder += "\\" + pa.Name;
                    if (!store.FolderExists(sFolder))
                    {
                        store.CreateFolder(sFolder);
                    }

                    pa = pa.Albums[Int32.Parse(asInd[i])];
                }
            }

            if (bThumbnail)
            {
                sFolder += "\\" + "tn";
                if (!store.FolderExists(sFolder))
                {
                    store.CreateFolder(sFolder);
                }
            }

            //
            // //

            string sPreExt = "";

            if (bThumbnail)
            {
                sPreExt = ".tn";
            }

            string sFName = pic.Name;
            string sFExt  = "";
            int    iPos   = sFName.LastIndexOf('.');

            if (iPos >= 0)
            {
                sFExt  = sFName.Substring(iPos);
                sFName = sFName.Substring(0, iPos);
            }

            string sPath = sFolder + "\\" + sFName + sPreExt + sFExt;

            iCnt = 0;
            for (;;)
            {
                if (!store.FileExists(sPath))
                {
                    break;
                }
                iCnt++;
                sPath = sFolder + "\\" + sFName + "_" + iCnt.ToString() + sPreExt + sFExt;
            }

            System.IO.Stream strmSrc;
            if (bThumbnail)
            {
                strmSrc = pic.GetThumbnail();
            }
            else
            {
                strmSrc = pic.GetImage();
            }

            System.IO.Stream stream = store.CreateFile(sPath);
            // Initialize the buffer for 4KB disk pages.
            byte[] readBuffer = new byte[4096];
            int    bytesRead  = -1;

            // Copy the image/thumbnail to the local folder.
            while ((bytesRead = strmSrc.Read(readBuffer, 0, readBuffer.Length)) > 0)
            {
                stream.Write(readBuffer, 0, bytesRead);
            }
            stream.Close();

            strmSrc.Close();
        }
Пример #22
0
        public static int SaveThreadData(bool bCalledByAgent, string sPath, RscJSonItem jsonThreads)
        {
            RscJSonItem json = jsonThreads.GetChildByName("threads");

            if (json == null)
            {
                return(-200);
            }

            RscStore store = new RscStore();

            bool bFirstRun = false;

            sPath += "\\Threads";
            if (!store.FolderExists(sPath))
            {
                bFirstRun = true;

                store.CreateFolderPath(sPath);
                store.WriteTextFile(sPath + "\\" + "Version.txt", ciCurrentVersion.ToString(), true);
            }

            string sThreadIdOrder_OLD = "";

            sThreadIdOrder_OLD  = store.ReadTextFile(sPath + "\\" + "IdOrder" + ".txt", sThreadIdOrder_OLD);
            sThreadIdOrder_OLD += "|";             //ATTENTION!!! 1 of 2
            string sThreadIdOrder_NEW = "";

            int iJustAdded = 0;

            int iThCnt = json.ChildCount;

            for (int iTh = 0; iTh < iThCnt; iTh++)
            {
                RscJSonItem jsonTh = json.GetChild(iTh);

                string sID        = jsonTh.GetPropertyValue("id");
                string sHistoryID = jsonTh.GetPropertyValue("historyId");
                string sSnippet   = jsonTh.GetPropertyValue("snippet");                 //, true );

                if (sID.Length == 0 || sHistoryID.Length == 0 || sSnippet.Length == 0)
                {
                    continue;
                }

                store.CreateFolderPath(sPath + "\\" + sID);

                if (store.FileExists(sPath + "\\" + sID + "\\" + sHistoryID + ".xml"))
                {
                    //Threads arrives in reverse order, so...
                    break;
                }
                else
                {
                    sThreadIdOrder_OLD = sThreadIdOrder_OLD.Replace(sID + "|", "");                       //Removing ID
                    if (sThreadIdOrder_NEW.Length > 0)
                    {
                        sThreadIdOrder_NEW += "|";
                    }
                    sThreadIdOrder_NEW += sID;                     //Adding ID

                    string sIdOrder = "";
                    sIdOrder = store.ReadTextFile(sPath + "\\" + sID + "\\" + "IdOrder" + ".txt", "");

                    iJustAdded++;

                    MyThread2 th = new MyThread2();
                    th.ID        = sID;
                    th.HistoryID = sHistoryID;
                    th.Snippet   = sSnippet;

                    if (bFirstRun)
                    {
                        th.DateAcked = DateTime.Now;
                    }

                    store.WriteXmlDataFile(sPath + "\\" + sID + "\\" + sHistoryID + ".xml", th, true);

                    if (sIdOrder.Length > 0)
                    {
                        sIdOrder = "|" + sIdOrder;
                    }
                    sIdOrder = sHistoryID + sIdOrder;
                    store.WriteTextFile(sPath + "\\" + sID + "\\" + "IdOrder" + ".txt", sIdOrder, true);
                }
            }

            if (sThreadIdOrder_OLD.Length > 0)
            {
                //ATTENTION!!! 2 of 2
                sThreadIdOrder_OLD = sThreadIdOrder_OLD.Substring(0, sThreadIdOrder_OLD.Length - 1);
            }
            if (sThreadIdOrder_NEW.Length > 0 && sThreadIdOrder_OLD.Length > 0)
            {
                sThreadIdOrder_NEW += "|";
            }
            sThreadIdOrder_NEW += sThreadIdOrder_OLD;
            store.WriteTextFile(sPath + "\\" + "IdOrder" + ".txt", sThreadIdOrder_NEW, true);

            int iCountAll = 0;

            iCountAll  = store.ReadXmlDataFile(sPath + "\\" + "Count" + ".xml", iCountAll);
            iCountAll += iJustAdded;
            store.WriteXmlDataFile(sPath + "\\" + "Count" + ".xml", iCountAll, true);

            int iCount_NonAckAll = 0;

            iCount_NonAckAll = store.ReadXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll);
            if (!bFirstRun)
            {
                iCount_NonAckAll += iJustAdded;
            }
            store.WriteXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll, true);

            int iCount_NEW = 0;

            iCount_NEW = store.ReadXmlDataFile(sPath + "\\" + "Count_NEW" + ".xml", iCount_NEW);
            if (bCalledByAgent)
            {
                iCount_NEW += iJustAdded;
            }
            else if (bFirstRun)
            {
                iCount_NEW = 0;
            }
            else
            {
                iCount_NEW = 0;
            }
            store.WriteXmlDataFile(sPath + "\\" + "Count_NEW" + ".xml", iCount_NEW, true);

            return(iJustAdded);
        }
Пример #23
0
        public static bool VersionUpgrade(string sUserIDlast, bool bChkOnly)
        {
            RscStore store = new RscStore();

            string sFolder = AppLogic.csSecretsFolder + "\\" + sUserIDlast + "\\" + "Threads";

            int iOldVer = 0;

            if (!store.FolderExists(sFolder))
            {
                if (bChkOnly)
                {
                    return(true);                           //NOTHING stored yet...
                }
                store.CreateFolderPath(sFolder);
            }

            string sVersion = store.ReadTextFile(sFolder + "\\" + "Version.txt", "0");

            if (sVersion == ciCurrentVersion.ToString())
            {
                return(true);
            }

            if (bChkOnly)
            {
                return(false);
            }

            if (!Int32.TryParse(sVersion, out iOldVer))
            {
                iOldVer = 0;
            }

            // //
            //

            int iVer = iOldVer;

            for (;;)
            {
                if (iVer >= ciCurrentVersion)
                {
                    break;
                }

                switch (iVer)
                {
                case 0:
                case 100:
                case 101:
                {
                    string [] asIDs = store.GetFolderNames(sFolder, "*.*");

                    int iSubCntr = 0;

                    for (int i = 0; i < asIDs.Length; i++)
                    {
                        string sIdOrder = "";
                        sIdOrder = store.ReadTextFile(sFolder + "\\" + asIDs[i] + "\\" + "IdOrder" + ".txt", sIdOrder);
                        string [] asIdOrders = sIdOrder.Split('|');

                        iSubCntr += asIdOrders.Length;

                        string sId = asIdOrders[asIdOrders.Length - 1];

                        MyThread2 th = new MyThread2();
                        th = store.ReadXmlDataFile(sFolder + "\\" + asIDs[i] + "\\" + sId + ".xml", th);
                        if (th.ID.Length == 0)
                        {
                            return(false);                                    //FAIL!!!
                        }
                        string sTmp = "";

                        sTmp += th.DateSaved.Year.ToString();
                        sTmp += RscUtils.pad60(th.DateSaved.Month);
                        sTmp += RscUtils.pad60(th.DateSaved.Day);
                        sTmp += "_";
                        sTmp += RscUtils.pad60(th.DateSaved.Hour);
                        sTmp += RscUtils.pad60(th.DateSaved.Minute);
                        sTmp += RscUtils.pad60(th.DateSaved.Second);
                        sTmp += "_";
                        int iMs = th.DateSaved.Millisecond;
                        if (iMs < 10)
                        {
                            sTmp += "00";
                        }
                        else
                        {
                            if (iMs < 100)
                            {
                                sTmp += "0";
                            }
                        }
                        sTmp += iMs.ToString();

                        asIDs[i] = sTmp + "|" + asIDs[i];
                    }

                    asIDs = RscSort.OrderBy(asIDs, true);

                    /*
                     * StringBuilder sb = new StringBuilder();
                     */

                    string sRes = "";

                    foreach (string sID in asIDs)
                    {
                        /*
                         * sb.AppendLine( sID );
                         */

                        if (sRes.Length > 0)
                        {
                            sRes += "|";
                        }
                        sRes += sID.Substring(20);
                    }

                    /*
                     * sb.Append( "\r\n" );
                     * sb.Append( "Cntr: " + asIDs.Length.ToString() + "\r\n" );
                     * sb.Append( "Sub-Cntr: " + iSubCntr.ToString() + "\r\n" );
                     * store.WriteTextFile( "A:\\GMail.txt", sb.ToString(), true );
                     */

                    store.WriteTextFile(sFolder + "\\" + "IdOrder" + ".txt", sRes, true);

                    iVer = 102;

                    break;
                }

                //Denie endless loop...
                default:
                    iVer = ciCurrentVersion;
                    break;
                }

                store.WriteTextFile(sFolder + "\\" + "Version.txt", iVer.ToString(), true);
            }

            //
            // //

            return(true);
        }